:root {
    --bg-main: #050505;
    --card-bg: rgba(20, 20, 20, 0.72);
    --card-border: rgba(80, 80, 80, 0.4);
    --text-primary: #fff;
    --text-secondary: #999;
    --bg-text-color: #fff;
    --accent-color: #ffffff;
    --header-bg: #0d0d0d;
    --task-color: #ffd700;
    --task-bg: rgba(255, 215, 0, 0.05);
    --task-border: rgba(255, 215, 0, 0.2);
    --note-color: #7ecfcf;
    --note-bg: rgba(100, 210, 210, 0.05);
    --note-border: rgba(100, 210, 210, 0.3);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    scrollbar-width: thin;
    scrollbar-color: rgba(100, 100, 100, 0.4) transparent;
    transition: background-color 0.5s ease, color 0.5s ease, border-color 0.5s ease, backdrop-filter 0.5s ease, box-shadow 0.5s ease;
}

/* Chrome/Safari Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(80, 80, 80, 0.4);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(100, 100, 100, 0.6);
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-primary);
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    line-height: 1.4;
    -webkit-text-size-adjust: none;
    text-size-adjust: none;
    overscroll-behavior: none;
    /* Prevent Safari rubber-band shift */
}

.container {
    max-width: 1024px;
    height: 100%;
    margin: 0 auto;
    padding: 10px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding: 8px 12px;
    background: var(--bar-bg);
    border: 1px solid var(--card-border);
    border-radius: 8px;
    flex-shrink: 0;
}

/* Global Timer Styles (PC & Mobile) */
.timer-container {
    display: flex !important;
    flex-direction: column !important;
    align-items: flex-end !important;
    /* Default for PC */
    overflow: visible !important;
}

.timer-main-row {
    display: flex !important;
    align-items: baseline !important;
    gap: 6px !important;
    justify-content: flex-end !important;
}

.timer-status-inline {
    font-size: 0.9rem !important;
    font-weight: 700 !important;
    color: var(--text-primary) !important;
}

#countdown-timer.timer-main {
    font-size: 1.6rem !important;
    font-weight: 800 !important;
    line-height: 1 !important;
    color: var(--text-primary) !important;
}

.timer-secondary-row {
    display: flex !important;
    gap: 4px !important;
    align-items: baseline !important;
    justify-content: flex-end !important;
    margin-top: 2px !important;
}

.timer-secondary-row span,
.timer-secondary-row #real-time {
    font-size: 0.72rem !important;
    color: #555 !important;
    font-weight: 500 !important;
    line-height: 1.1 !important;
    font-family: inherit !important;
}

/* Settings Button */
.settings-btn {
    background: var(--btn-bg);
    border: 1px solid var(--card-border);
    color: var(--text-secondary);
    font-size: 1.1rem;
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    border-radius: 6px;
    line-height: 1;
}

.settings-btn:hover {
    color: var(--text-primary);
    border-color: var(--text-secondary);
    background: var(--card-border);
}

.settings-pc {
    display: inline-flex;
    margin-left: 4px;
}

.settings-mobile {
    display: none;
}

/* Custom Settings Sections */
.settings-section-notes {
    background: rgba(255, 255, 255, 0.05) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    color: #ccc !important;
}

.settings-section-sync {
    background: rgba(255, 255, 255, 0.04) !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
}

.settings-accent-text {
    color: #eee !important;
}

.btn-settings-alt {
    background: rgba(255, 255, 255, 0.08) !important;
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
    color: #fff !important;
}

.btn-settings-alt:hover {
    background: rgba(255, 255, 255, 0.15) !important;
}

/* Settings notes rows */
.stn-row:hover {
    background: rgba(255, 255, 255, 0.08) !important;
}

/* Sync proposal note rows */
#sync-proposal-list>div:last-child {
    border-bottom: none !important;
}

/* Settings Form Styles */
.form-group {
    margin-bottom: 15px;
    text-align: left;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    margin-bottom: 6px;
    color: var(--text-secondary);
}

.form-input {
    width: 100%;
    padding: 10px;
    background: var(--lesson-bg);
    border: 1px solid var(--card-border);
    border-radius: 6px;
    color: var(--text-primary);
    outline: none;
    transition: all 0.2s;
}

.form-input:focus {
    border-color: var(--text-secondary);
    background: var(--lesson-number-bg);
}


.top-bar-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: var(--bar-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--card-border);
    padding: 8px 16px;
    border-radius: 8px;
    margin-bottom: 25px;
    flex-shrink: 0;
    position: relative;
    transition: all 0.4s ease-in-out;
}

.top-bar-container.container-shutter-mode {
    padding-top: 0;
    padding-bottom: 8px;
    margin-bottom: 25px;
    gap: 0;
}

.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    transition: all 0.4s ease-in-out;
    max-height: 200px;
    opacity: 1;
    overflow: hidden;
}

.week-nav {
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    padding-top: 8px;
    border-top: 1px solid #333;
}

.add-task-top-btn {
    position: absolute;
    left: 0;
    background: #ffd700;
    color: #000;
    border-color: #ffd700;
}

.nav-controls {
    display: flex;
    gap: 10px;
}

.week-btn {
    background: var(--btn-bg);
    color: var(--text-primary);
    border: 1px solid var(--card-border);
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.2s;
}

.week-btn:hover {
    background: var(--card-border);
}

.header-left {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 15px;
    min-width: 0;
    flex: 1;
}

.title-row {
    display: flex;
    align-items: baseline;
    gap: 12px;
    flex-shrink: 0;
}

.title {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
    white-space: nowrap;
}

#hero-quote {
    max-width: 500px;
    word-break: break-word;
    margin-top: 4px;
    font-size: 0.68rem;
    /* Smaller for PC as requested */
    color: #555;
}

.week-info {
    font-size: 0.9rem;
    color: var(--text-secondary);
    border: 1px solid var(--card-border);
    padding: 2px 8px;
    border-radius: 4px;
    text-transform: uppercase;
}

.status-right {
    display: flex;
    align-items: center;
    gap: 20px;
}


/* Hide unused */
.status-panel,
.progress-bar-container {
    display: none;
}

/* Grid */
.schedule-grid {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(2, minmax(0, 1fr));
    gap: 10px;
    will-change: transform, opacity;
}

.top-bar {
    transition: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.1);
    max-height: 200px;
    opacity: 1;
    overflow: hidden;
}

.header-collapsed {
    max-height: 0 !important;
    opacity: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    pointer-events: none;
    transform: translateY(-20px);
    transition: all 0.4s ease-in-out;
}

.week-nav {
    transition: all 0.4s ease-in-out;
    transform: translateY(0);
}

.nav-shutter-mode {
    transform: translateY(0);
    /* Simply stays in place */
}

.collapse-wrapper-top {
    display: flex;
    justify-content: center;
    position: absolute;
    bottom: -14px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 20;
}

.collapse-toggle-top {
    background: var(--bar-bg);
    border: 1px solid var(--card-border);
    border-top: none;
    color: var(--text-primary);
    width: 46px;
    /* Slightly wider as requested */
    height: 16px;
    border-radius: 0 0 12px 12px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.3s ease;
    backdrop-filter: blur(8px);
}

.collapse-toggle-top:hover {
    background: #222;
}

.collapse-toggle-top span {
    font-size: 0.75rem;
    line-height: 1;
}

/* Cards */
.day-card {
    background: var(--card-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--card-border);
    border-radius: 8px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}

.day-card.today {
    background: var(--card-today-bg);
    border-color: var(--accent-color);
}

.day-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--card-border);
    flex-shrink: 0;
    /* Prevent squashing */
    position: relative;
    z-index: 10;
    background: var(--header-bg);
    /* Opaque to hide manual scroll overlap */
    margin: -10px -10px 8px -10px;
    padding: 10px 10px 6px 10px;
    border-radius: 8px 8px 0 0;
}

.day-title-col {
    display: flex;
    flex-direction: column;
}

.day-name {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.day-date {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.day-global-note-count {
    font-size: 0.75rem;
    color: #7ecfcf;
    background: rgba(100, 210, 210, 0.1);
    padding: 1px 6px;
    border-radius: 10px;
    margin-left: 6px;
    border: 1px solid rgba(100, 210, 210, 0.2);
    font-weight: 600;
}

.day-badge {
    font-size: 0.8rem;
    color: #666;
    background: #222;
    padding: 3px 8px;
    border-radius: 4px;
}

.day-card.today .day-badge {
    background: #fff;
    color: #000;
}

/* Lessons */
.lesson-list {
    list-style: none;
    overflow-y: auto;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
    scrollbar-width: none;
}
.lesson-list::-webkit-scrollbar {
    display: none;
}

.lesson-item {
    background: var(--lesson-bg);
    border: 1px solid var(--card-border);
    border-radius: 6px;
    padding: 8px 10px;
    display: flex;
    align-items: flex-start;
    gap: 8px;
    min-height: 50px;
    flex-shrink: 0;
    /* Prevent items from overlapping when card is small */
}

.lesson-number {
    width: 24px;
    height: 24px;
    background: var(--lesson-number-bg);
    color: var(--text-secondary);
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 4px;
    font-weight: 700;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.lesson-content {
    flex-grow: 1;
    min-width: 0;
}

.lesson-subject {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
    word-break: break-word;
    /* Allows long text/names to break on PC too */
}

.lesson-details-compact {
    font-size: 0.8rem;
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    gap: 0;
    margin-top: 1px;
}

.lesson-teacher {
    color: var(--text-secondary);
    font-size: 0.8rem;
    line-height: 1.1;
}

.lesson-room {
    color: var(--text-secondary);
    opacity: 0.6;
    font-size: 0.72rem;
    line-height: 1.1;
    font-weight: 500;
}

.oscillator-text {
    transition: opacity 0.5s ease;
    will-change: opacity;
    display: inline-block; /* Ensure stable layout box */
}

.lesson-time-col {
    text-align: right;
    font-size: 0.85rem;
    color: var(--text-secondary);
    flex-shrink: 0;
}

/* Active */
.lesson-item.active-lesson {
    background: var(--lesson-number-bg);
    border-color: var(--text-primary);
}

.lesson-item.active-lesson .lesson-number {
    background: var(--text-primary);
    color: var(--bg-main);
}

.lesson-item.active-lesson .lesson-subject {
    color: var(--text-primary);
}

/* Inline Lesson Tasks */
.lesson-task-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px dashed #333;
}

.lesson-task-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--task-color);
    cursor: pointer;
    padding: 4px 6px;
    background: var(--task-bg);
    border-radius: 4px;
    border: 1px solid var(--task-border);
    transition: all 0.2s;
    white-space: pre-wrap;
    word-break: break-word;
}

.lesson-task-item:hover {
    filter: brightness(1.2);
}

.lesson-task-item.completed {
    color: #666;
    text-decoration: line-through;
    border-color: transparent;
    background: transparent;
}

.lesson-task-item.hidden-task {
    color: #555;
    border-style: dotted;
    background: transparent;
    opacity: 0.7;
}

.lesson-task-item.global-note-item {
    color: var(--note-color);
    border-color: var(--note-border);
    background: var(--note-bg);
    cursor: default;
}

.lesson-task-item.global-note-item:hover {
    filter: brightness(1.2);
}

.task-check-icon {
    font-size: 1rem;
    line-height: 1;
}

.task-text-content {
    flex-grow: 1;
    word-break: break-word;
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.2s;
}

.modal-overlay.active {
    display: flex;
    opacity: 1;
}

.modal-box {
    background: var(--modal-bg);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    width: 95%;
    max-width: 420px;
    padding: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    transform: translateY(20px);
    transition: transform 0.2s;
    max-height: 90vh;
    overflow-y: auto;
}

@media (max-width: 600px) {
    .modal-box {
        padding: 15px;
        width: 98%;
    }

    .modal-title {
        font-size: 1.1rem;
    }

    .btn {
        padding: 12px 8px;
        /* Bigger touch target */
    }
}


.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    color: #aaa;
    margin-bottom: 6px;
}

.form-input,
input[type="text"],
input[type="password"],
select,
textarea {
    width: 100%;
    background: #2a2a2a;
    border: 1px solid #3a3a3a;
    color: #e0e0e0;
    padding: 10px;
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.95rem;
    transition: border-color 0.2s, background 0.2s;
}

.form-input:focus,
input:focus,
select:focus {
    outline: none;
    border-color: #555;
    background: #333;
}

.modal-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.btn {
    flex: 1;
    padding: 10px;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    font-size: 0.95rem;
}

.btn-cancel {
    background: #222;
    color: #aaa;
}

.btn-cancel:hover {
    background: #333;
    color: #fff;
}

.btn-primary {
    background: #ffd700;
    color: #000;
}

.btn-primary:hover {
    background: #e6c200;
}

/* Action Menu Grid */
.action-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: #222;
    border: 1px solid #333;
    padding: 15px 10px;
    border-radius: 8px;
    color: #fff;
    cursor: pointer;
    transition: all 0.2s;
}

.action-btn:hover {
    background: #333;
    border-color: #555;
    transform: translateY(-2px);
}

.action-icon {
    font-size: 1.5rem;
}

.action-label {
    font-size: 0.85rem;
    font-weight: 500;
}

.action-btn.complete:hover {
    background: #1a331a;
    border-color: #2e5c2e;
    color: #4CAF50;
}

.action-btn.hide:hover {
    background: #331a1a;
    border-color: #5c2e2e;
    color: #f44336;
}

.action-btn.edit:hover {
    background: #1a2a33;
    border-color: #2e4a5c;
    color: #2196F3;
}

.action-btn.move:hover {
    background: #332b1a;
    border-color: #5c4e2e;
    color: #FFC107;
}

.action-btn.delete {
    color: #ff5252;
    border-color: #551111;
}

.action-btn.delete:hover {
    background: #440000;
    border-color: #aa1111;
    color: #ff8888;
}

/* Holidays */
.holiday-item {
    justify-content: center;
    text-align: center;
    background: transparent !important;
    border: 2px dashed #444 !important;
    color: #888;
    min-height: 100px;
}

.holiday-item .lesson-subject {
    color: #aaa;
    font-size: 1.2rem;
}

body.theme-womens-body {
    background: radial-gradient(circle at center, #3d1b24 0%, #050505 100%);
}

body.theme-spring-body,
body.theme-victory-body {
    background: radial-gradient(circle at center, #330000 0%, #050505 100%);
}

body.theme-newyear-body {
    background: radial-gradient(circle at center, #001f3f 0%, #050505 100%);
}

body.theme-china-body {
    background: radial-gradient(circle at center, #3d0000 0%, #050505 100%);
}

body.theme-education-body {
    background: radial-gradient(circle at center, #001222 0%, #050505 100%);
}

body.theme-student-body {
    background: radial-gradient(circle at center, #1e3c72 0%, #050505 100%);
}

body.theme-knowledge-body {
    background: radial-gradient(circle at center, #4b3621 0%, #050505 100%);
}

body.theme-teacher-body {
    background: radial-gradient(circle at center, #5c0000 0%, #050505 100%);
}

body.theme-love-body {
    background: radial-gradient(circle at center, #4b0082 0%, #050505 100%);
}

body.theme-green-body {
    background: radial-gradient(circle at center, #002200 0%, #050505 100%);
}

body.theme-fun-body {
    background: radial-gradient(circle at center, #3d2000 0%, #050505 100%);
}

body.theme-earth-body {
    background: radial-gradient(circle at center, #003311 0%, #050505 100%);
}

body.theme-stars-body {
    background: radial-gradient(circle at center, #000022 0%, #050505 100%);
}

body.theme-yoga-body {
    background: radial-gradient(circle at center, #220033 0%, #050505 100%);
}

body.theme-japan-body {
    background: radial-gradient(circle at center, #331144 0%, #050505 100%);
}

body.theme-youth-body {
    background: radial-gradient(circle at center, #001133 0%, #050505 100%);
}

body.theme-halloween-body {
    background: radial-gradient(circle at center, #221100 0%, #050505 100%);
}

body.theme-fire-body {
    background: radial-gradient(circle at center, #330c00 0%, #050505 100%);
}

body.theme-christmas-body {
    background: radial-gradient(circle at center, #002200 0%, #050505 100%);
}

/* Mobile */
.schedule-wrapper {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    /* fill remaining space in .container */
    min-height: 0;
    /* prevent overflow */
    gap: 0;
}

.mobile-nav {
    display: none;
    margin-top: 10px;
    padding: 10px;
    background: var(--bar-bg);
    border: 1px solid var(--card-border);
    border-radius: 8px;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    transition: all 0.5s ease;
}

.nav-btn {
    background: var(--lesson-number-bg);
    color: var(--text-primary);
    border: 1px solid var(--card-border);
    width: 40px;
    height: 40px;
    border-radius: 6px;
    font-size: 1.2rem;
    transition: background 0.5s ease, color 0.5s ease, border-color 0.5s ease;
}

.nav-label {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text-primary);
    transition: color 0.5s ease;
}

/* --- Animated Text Background --- */
.animated-bg {
    position: fixed;
    top: -50%;
    left: -50%;
    width: 200vw;
    height: 200vh;
    z-index: -2;
    overflow: hidden;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    justify-content: space-evenly;
    transform: rotate(-15deg);
    /* Angle of diagonal scroll */
    user-select: none;
    opacity: 0.15;
    /* Subtle background opacity */
}

.bg-text-line {
    white-space: nowrap;
    font-size: 2.2rem;
    /* Reduced for tighter density */
    font-weight: 900;
    text-transform: uppercase;
    color: var(--bg-text-color);
    /* We animate transformX continuously */
    will-change: transform;
}

/* 
  To create a seamless loop, the text string must be very long (repeated many times).
  We translate it from 0 to -50%. Because the first half and second half are identical,
  the jump back to 0 is invisible.
*/
.scroll-left {
    animation: scroll-diagonal-left 40s linear infinite;
}

.scroll-right {
    animation: scroll-diagonal-right 50s linear infinite;
}

@keyframes scroll-diagonal-left {
    0% {
        transform: translateX(0);
    }

    100% {
        transform: translateX(-50%);
    }
}

@keyframes scroll-diagonal-right {
    0% {
        transform: translateX(-50%);
    }

    100% {
        transform: translateX(0%);
    }
}

@keyframes autoScrollVertical {
    0%,
    15% {
        transform: translateY(0);
    }

    45%,
    60% {
        transform: translateY(calc(-1 * var(--scroll-dist, 0px)));
    }

    90%,
    100% {
        transform: translateY(0);
    }
}

.auto-animate-scroll {
    animation: autoScrollVertical var(--scroll-speed, 8s) ease-in-out infinite;
}

/* --- Mobile Specific Overrides --- */
@media (max-width: 768px) {
    .container {
        padding: 5px;
        padding-top: env(safe-area-inset-top, 15px);
        /* fixes Safari notch overlap */
        height: 100dvh;
        max-height: 100dvh;
        overflow: hidden;
        display: flex;
        flex-direction: column;
        padding-bottom: env(safe-area-inset-bottom, 20px);
    }

    body {
        overflow: hidden !important;
        /* Strictly forbid body scroll */
        height: 100dvh;
        width: 100vw;
        position: fixed;
        /* Extra layer of scroll prevention */
    }

    /* Force Top Bar to stack */
    .top-bar {
        display: flex;
        flex-direction: column !important;
        align-items: center !important;
        gap: 8px;
        height: auto;
        padding: 8px 10px;
    }

    .header-left {
        width: 100%;
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center !important;
        margin-bottom: 8px;
    }

    .title-row {
        justify-content: center;
        width: 100%;
    }

    .schedule-wrapper {
        margin: 0;
        display: flex;
        flex-direction: column;
        flex: 1;
        min-height: 0;
        overflow: hidden;
    }

    .status-right {
        width: 100%;
        justify-content: center;
        gap: 15px;
    }


    /* Grid - show one card at a time */
    .schedule-grid {
        display: flex;
        flex-direction: column;
        flex: 1;
        min-height: 0;
        overflow: hidden;
    }

    .day-card {
        display: none;
        height: 100%;
    }

    @keyframes slideInRight {
        from {
            transform: translateX(30px);
            opacity: 0;
        }

        to {
            transform: translateX(0);
            opacity: 1;
        }
    }

    @keyframes slideInLeft {
        from {
            transform: translateX(-30px);
            opacity: 0;
        }

        to {
            transform: translateX(0);
            opacity: 1;
        }
    }

    @keyframes fadeInScale {
        from {
            transform: scale(0.98);
            opacity: 0;
        }

        to {
            transform: scale(1);
            opacity: 1;
        }
    }

    .anim-slide-right {
        animation: slideInRight 0.3s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
    }

    .anim-slide-left {
        animation: slideInLeft 0.3s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
    }

    .anim-fade-scale {
        animation: fadeInScale 0.4s ease-out forwards;
    }

    .day-card.mobile-active {
        display: flex;
        flex-direction: column;
        flex: 1;
        min-height: 0;
        height: 100%;
        max-height: 100%;
    }

    .mobile-nav {
        display: flex;
        order: -1;
        /* Move above the schedule grid */
        margin-top: 0;
        margin-bottom: 8px;
        border-radius: 8px;
        flex-shrink: 0;
    }

    /* Week Nav Mobile */
    .week-nav {
        flex-direction: column;
        gap: 8px;
        align-items: stretch;
    }

    .add-task-top-btn {
        position: static;
        width: 100%;
        padding: 10px;
        font-size: 0.95rem;
    }

    .nav-controls {
        width: 100%;
        gap: 4px;
        justify-content: space-between;
    }

    .nav-controls .week-btn {
        flex: 1;
        padding: 8px 4px;
        font-size: 0.78rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* ── Compact lesson cards: 2-row layout ── */
    .lesson-item {
        display: flex;
        flex-direction: row;
        align-items: flex-start;
        gap: 8px;
        padding: 10px 10px;
        height: auto;
        min-height: min-content;
        flex-wrap: nowrap;
        flex-shrink: 0;
        /* Important: prevents overlap when list is constrained */
    }

    .lesson-number {
        width: 22px;
        height: 22px;
        font-size: 0.78rem;
        flex-shrink: 0;
        margin: 2px 0 0;
    }

    /* All text info — stacked: main row + teacher row */
    .lesson-content {
        flex: 1;
        min-width: 0;
        display: flex;
        flex-direction: column;
        gap: 2px;
    }

    /* Main row: subject + room */
    .lesson-subject {
        font-size: 0.88rem;
        font-weight: 700;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 100%;
    }

    /* Fixed mobile lesson layout */
    .lesson-details-compact {
        display: flex;
        flex-direction: column;
        gap: 0;
    }

    .lesson-details-compact .lesson-teacher {
        color: var(--text-secondary);
        font-size: 0.78rem;
        line-height: 1.1;
    }

    .lesson-details-compact .lesson-room {
        color: var(--text-secondary);
        opacity: 0.6;
        font-size: 0.7rem;
        line-height: 1.1;
    }

    .lesson-time-col {
        font-size: 0.78rem;
        color: #888;
        flex-shrink: 0;
        text-align: right;
        padding-top: 2px;
    }

    .lesson-time {
        white-space: nowrap;
        font-size: 0.78rem;
    }

    /* Compact task list under lessons */
    .lesson-list {
        display: flex;
        flex-direction: column;
        position: relative;
    }

    .lesson-task-list {
        width: 100%;
    }

    .lesson-task-item {
        font-size: 0.8rem;
        padding: 4px 6px;
    }


    /* --- ANIMATED BACKGROUND on mobile --- */
    .animated-bg {
        opacity: 0.07;
    }

    .bg-text-line {
        font-size: 1.4rem;
    }

    /* HEADER-LEFT: wrap on narrow screens */
    .header-left {
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center !important;
        text-align: center !important;
    }

    .header {
        padding: 8px 10px !important;
        gap: 8px !important;
        flex-direction: row !important;
        flex-wrap: wrap !important;
        /* Allow wrapping if too wide */
        justify-content: space-between !important;
        align-items: center !important;
        min-height: auto !important;
    }

    .header-left {
        justify-content: flex-start !important;
        width: 100% !important;
        /* Title takes full width on very small screens to give room to widgets? No, let's keep it flexible. */
        margin-bottom: 4px !important;
        flex: none !important;
    }

    .status-right {
        display: flex !important;
        flex: 1 !important;
        width: 100% !important;
        justify-content: center !important;
        /* Center the timer */
        align-items: center !important;
    }

    /* Mobile Alignment Overrides */
    .timer-container {
        align-items: center !important;
    }

    .timer-main-row,
    .timer-secondary-row {
        justify-content: center !important;
    }

    #hero-quote {
        font-size: 0.72rem !important;
        max-width: 100% !important;
        width: 100% !important;
        order: 1;
        white-space: normal !important;
        text-align: center !important;
        color: var(--text-secondary) !important;
        line-height: 1.3;
        padding: 0 10px;
        margin: 4px 0 0 0 !important;
    }

    /* --- GLASSMORPHISM on mobile (force re-apply for Safari) --- */
    .top-bar-container {
        background: var(--bar-bg) !important;
        -webkit-backdrop-filter: blur(12px) !important;
        backdrop-filter: blur(12px) !important;
        padding: 6px 10px !important;
    }

    .day-card {
        background: var(--card-bg) !important;
        -webkit-backdrop-filter: blur(15px) !important;
        backdrop-filter: blur(15px) !important;
    }

    /* Larger toggle for mobile */
    .collapse-wrapper-top {
        bottom: -20px !important;
        width: 100% !important;
        left: 0 !important;
        transform: none !important;
        pointer-events: none;
        display: flex;
        justify-content: center;
    }

    .collapse-toggle-top {
        width: 70px !important;
        height: 22px !important;
        border-radius: 0 0 12px 12px !important;
        pointer-events: auto;
        position: relative;
    }

    .collapse-toggle-top span {
        font-size: 1rem !important;
    }

    /* Mobile Admin Support */
    .lesson-admin-row {
        flex-direction: column !important;
        gap: 10px !important;
        padding: 12px !important;
        background: rgba(255, 255, 255, 0.05) !important;
    }

    .lesson-admin-row input,
    .lesson-admin-row select {
        width: 100% !important;
        height: 40px !important;
    }

    .form-group[style*="flex"] {
        flex-direction: column !important;
        align-items: stretch !important;
    }

    /* Settings button positioning on mobile */
    .settings-pc {
        display: none !important;
    }

    .settings-mobile {
        display: flex !important;
        position: absolute;
        right: 0;
        top: 50%;
        transform: translateY(-50%);
        z-index: 10;
    }

    .settings-mobile:hover {
        transform: translateY(-50%);
    }

    .title-row {
        position: relative;
        width: 100%;
        display: flex;
        justify-content: center;
        align-items: center;
    }


}