:root {
    --bg-primary: #ffffff;
    --bg-secondary: #f8f8f8;
    --bg-tertiary: #e8e8e8;
    --bg-hover: #d8d8d8;
    --text-primary: #333333;
    --text-secondary: #666666;
    --text-tertiary: #999999;
    --border-color: #e0e0e0;
    --border-color-dark: #d0d0d0;
    --accent-color: #0066cc;
    --accent-hover: #0052a3;
    --card-bg: #f8f8f8;
}
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg-primary: #1a1a1a;
        --bg-secondary: #2a2a2a;
        --bg-tertiary: #3a3a3a;
        --bg-hover: #4a4a4a;
        --text-primary: #e0e0e0;
        --text-secondary: #b0b0b0;
        --text-tertiary: #808080;
        --border-color: #3a3a3a;
        --border-color-dark: #4a4a4a;
        --accent-color: #4d9fff;
        --accent-hover: #3d8fef;
        --card-bg: #2a2a2a;
    }
}
:root[data-theme="dark"] {
    --bg-primary: #1a1a1a;
    --bg-secondary: #2a2a2a;
    --bg-tertiary: #3a3a3a;
    --bg-hover: #4a4a4a;
    --text-primary: #e0e0e0;
    --text-secondary: #b0b0b0;
    --text-tertiary: #808080;
    --border-color: #3a3a3a;
    --border-color-dark: #4a4a4a;
    --accent-color: #4d9fff;
    --accent-hover: #3d8fef;
    --card-bg: #2a2a2a;
}

*, *::before, *::after { box-sizing: border-box; }
sup.coeff-sup { font-size: 0.6em; font-weight: 700; }
html { color-scheme: light dark; height: 100%; }
body {
    margin: 0;
    height: 100%;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.5;
    user-select: none; -webkit-user-select: none;
}
button, input, select { font-family: inherit; }
h1, h2, h3 { margin: 0; }

input, textarea { user-select: text; -webkit-user-select: text; }
.profile-block .id, .screen[data-screen="dev-menu"] {
    user-select: text; -webkit-user-select: text;
}

#app { min-height: 100%; display: flex; flex-direction: column; }

.icon { width: 1.1em; height: 1.1em; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: -.15em; }
.icon text { fill: currentColor; stroke: none; }

.viewport { flex: 1; position: relative; overflow: hidden; }
.screen {
    position: absolute; inset: 0;
    display: flex; flex-direction: column;
    background: var(--bg-primary);
    opacity: 0; pointer-events: none;
    transform: translateX(16px);
    transition: opacity .22s ease, transform .22s ease;
    overflow-y: auto;
}
.screen.is-current { opacity: 1; pointer-events: auto; transform: translateX(0); }
@media (prefers-reduced-motion: reduce) { .screen { transition: none; } }

.screen-head {
    position: sticky; top: 0; z-index: 5;
    display: flex; align-items: center; gap: 10px;
    padding: 16px 20px;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
}
.back-btn {
    all: unset; box-sizing: border-box;
    width: 32px; height: 32px; border-radius: 6px;
    display: flex; align-items: center; justify-content: center;
    background: var(--bg-tertiary); color: var(--text-primary); flex-shrink: 0;
}
.back-btn:hover { background: var(--bg-hover); }
.back-btn:focus-visible { outline: 2px solid var(--accent-color); outline-offset: 2px; }
.screen-title { font-size: 20px; font-weight: 600; flex: 1; min-width: 0; color: var(--text-primary); }
.screen-action {
    all: unset; box-sizing: border-box;
    font-weight: 600; font-size: 14px; color: #fff;
    background: var(--accent-color); padding: 8px 14px; border-radius: 6px; flex-shrink: 0;
}
.screen-action:hover { background: var(--accent-hover); }
.screen-action:focus-visible { outline: 2px solid var(--text-primary); outline-offset: 2px; }
.icon-btn {
    all: unset; box-sizing: border-box;
    width: 34px; height: 34px; border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    background: var(--bg-tertiary); color: var(--text-primary); flex-shrink: 0;
}
.icon-btn:hover { background: var(--bg-hover); }
.icon-btn:focus-visible { outline: 2px solid var(--accent-color); outline-offset: 2px; }
.icon-btn.is-active { background: #ff9800; color: #fff; }
.icon-btn:active { background: var(--bg-hover); transform: scale(.92); }
.icon-btn.is-loading { pointer-events: none; }
.icon-btn.is-loading .icon { animation: spin 0.8s linear infinite; }
.head-actions { display: flex; gap: 8px; flex-shrink: 0; }

.screen-body { padding: 18px 20px 20px; display: flex; flex-direction: column; gap: 18px; flex: 1; max-width: 640px; width: 100%; margin: 0 auto; }
.screen-body.flush { padding-left: 0; padding-right: 0; }
.screen-body.tight { gap: 14px; }

.tabbar {
    display: flex; gap: 6px;
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
    background: var(--bg-secondary); border-top: 1px solid var(--border-color);
}
.tab-btn {
    all: unset; box-sizing: border-box; flex: 1;
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    padding: 6px 0; border-radius: 8px;
    color: var(--text-secondary); font-size: 11px; font-weight: 600;
    max-width: 120px; margin: 0 auto;
}
.tab-btn .icon { width: 19px; height: 19px; }
.tab-btn.is-active { background: var(--accent-color); color: #fff; }
.tab-btn:focus-visible { outline: 2px solid var(--accent-color); outline-offset: -2px; }

.sidebar-brand, .sidebar-foot { display: none; }

body.is-standalone-nav .sidebar { display: none; }

@media (min-width: 900px) {
    body { zoom: 90%; }

    #app { flex-direction: row; }
    .sidebar {
        order: -1; display: flex; flex-direction: column;
        width: 232px; flex-shrink: 0;
        background: var(--bg-secondary); border-right: 1px solid var(--border-color);
    }

    .sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 20px 18px 16px; }
    .brand-mark { width: 30px; height: 30px; border-radius: 8px; flex-shrink: 0; object-fit: cover; display: block; }
    .brand-name { font-size: 15px; font-weight: 700; letter-spacing: -.01em; color: var(--text-primary); }

    .tabbar { flex-direction: column; gap: 2px; padding: 8px 12px; background: transparent; border-top: none; }
    .tab-btn { flex-direction: row; justify-content: flex-start; gap: 12px; padding: 9px 12px; max-width: none; margin: 0; font-size: 14px; }
    .tab-btn .icon { width: 18px; height: 18px; }

    .sidebar-foot {
        display: flex; align-items: center; gap: 10px; margin-top: auto; cursor: pointer;
        padding: 14px 16px; border-top: 1px solid var(--border-color);
    }
    .sidebar-foot:hover { background: var(--bg-hover); }
    .sidebar-foot .avatar-circle { width: 34px; height: 34px; font-size: 13px; }
    .sidebar-foot .who { min-width: 0; }
    .sidebar-foot .who .n { font-size: 13px; font-weight: 600; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .sidebar-foot .who .c { font-size: 11.5px; color: var(--text-tertiary); }
}

.notes-desktop { display: none; }
.notes-desktop-globalavg { display: none; }
.notes-desktop-statsbtn { display: none; }
.notes-desktop-simbtn { display: none; }
.app-title-desktop { display: none; }

@media (min-width: 900px) {
    .screen[data-screen="notes"] .screen-body { max-width: none; }
    .screen[data-screen="notes"] .avg-header,
    .screen[data-screen="notes"] #subjectList,
    .screen[data-screen="notes"] #addSubjectBtn { display: none; }
    .app-title-mobile { display: none; }
    .app-title-desktop { display: block; }

    .screen[data-screen="notes"] .trimester-tabs { justify-content: flex-start; padding: 18px 20px 14px; align-items: center; }
    .notes-desktop-globalavg { display: flex; align-items: baseline; gap: 5px; margin-left: auto; font-variant-numeric: tabular-nums; }
    .notes-desktop-globalavg .n { font-size: 32px; font-weight: 700; color: var(--accent-color); line-height: 1; }
    .notes-desktop-globalavg .u { font-size: 11.5px; color: var(--text-tertiary); }
    .notes-desktop-statsbtn { display: flex; margin-left: 12px; }
    .notes-desktop-simbtn { display: flex; margin-left: 8px; }

    .notes-desktop { display: flex; flex: 1; min-height: 0; }

    .notes-desktop-list { width: 320px; flex-shrink: 0; overflow-y: auto; border-right: 1px solid var(--border-color); display: flex; flex-direction: column; }
    .notes-desktop-row {
        all: unset; box-sizing: border-box; display: flex; width: 100%; align-items: center; justify-content: space-between; gap: 10px;
        padding: 13px 20px; border-bottom: 1px solid var(--border-color); cursor: pointer;
    }
    .notes-desktop-row:hover { background: var(--bg-secondary); }
    .notes-desktop-row.is-active { background: var(--bg-tertiary); box-shadow: inset 3px 0 0 var(--accent-color); }
    .notes-desktop-row.is-lift-ready { background: var(--bg-hover); }
    .notes-desktop-row.is-dragging { position: relative; z-index: 80; background: var(--bg-hover); cursor: grabbing; box-shadow: 0 14px 28px rgba(0, 0, 0, .28); }
    .notes-desktop-row .name { font-size: 14px; font-weight: 600; color: var(--text-primary); }
    .notes-desktop-row .coeff { font-size: 11.5px; color: var(--text-tertiary); font-weight: 400; margin-left: 4px; }
    .notes-desktop-row .avg { font-weight: 700; color: var(--accent-color); font-size: 15px; font-variant-numeric: tabular-nums; flex-shrink: 0; white-space: nowrap; }
    .notes-desktop-addrow {
        all: unset; box-sizing: border-box; display: flex; align-items: center; justify-content: center; gap: 6px;
        width: 100%; padding: 13px 20px; color: var(--text-secondary); font-weight: 500; font-size: 13px; cursor: pointer; margin-top: auto;
    }
    .notes-desktop-addrow:hover { background: var(--bg-secondary); color: var(--text-primary); }

    .notes-desktop-detail { flex: 1; min-width: 0; overflow-y: auto; padding: 24px 32px 40px; }
    .notes-desktop-empty { height: 100%; display: flex; align-items: center; justify-content: center; color: var(--text-tertiary); font-size: 14px; text-align: center; padding: 40px; }
    .notes-desktop-detail-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 4px; }
    .notes-desktop-detail-head h2 { font-size: 19px; font-weight: 700; margin: 0; }
    .notes-desktop-detail-head .avg { font-size: 26px; font-weight: 700; color: var(--accent-color); font-variant-numeric: tabular-nums; }
    .notes-desktop-sub { font-size: 12.5px; color: var(--text-tertiary); }
    .notes-desktop-eval-row { margin-top: 6px; }
    .notes-desktop-eval-row .eval-badge-full { max-width: none; overflow: visible; text-overflow: clip; white-space: normal; }

    .notes-desktop-table { width: 100%; border-collapse: collapse; border: 1px solid var(--border-color); border-radius: 8px; overflow: hidden; margin-top: 20px; }
    .notes-desktop-table th {
        text-align: left; font-size: 11px; letter-spacing: .04em; text-transform: uppercase; color: var(--text-tertiary);
        font-weight: 700; padding: 10px 16px; background: var(--bg-secondary); border-bottom: 1px solid var(--border-color);
        border-right: 1px solid var(--border-color);
    }
    .notes-desktop-table th:last-child { border-right: none; }
    .notes-desktop-table th.num, .notes-desktop-table td.num { text-align: right; }
    .notes-desktop-table td { padding: 12px 16px; font-size: 13.5px; border-bottom: 1px solid var(--border-color); border-right: 1px solid var(--border-color); }
    .notes-desktop-table td:last-child { border-right: none; }
    .notes-desktop-table tr:last-child td { border-bottom: none; }
    .notes-desktop-table tr { cursor: pointer; }
    .notes-desktop-table tr:hover td { background: var(--bg-secondary); }
    .notes-desktop-table .d { color: var(--text-tertiary); font-size: 12px; }
    .notes-desktop-table .v { font-weight: 700; color: var(--accent-color); font-variant-numeric: tabular-nums; }
    .notes-desktop-table .v sub { color: var(--text-tertiary); font-weight: 400; font-size: 11px; }
    .notes-desktop-table .v sup.coeff-sup { color: var(--text-tertiary); font-weight: 700; font-size: 9px; }

    .notes-desktop-table-actions { display: flex; align-items: center; justify-content: space-between; margin-top: 14px; }

    .notes-desktop-addgrade {
        all: unset; box-sizing: border-box; display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
        padding: 7px 12px; border: 1px solid var(--border-color); border-radius: 6px;
        font-size: 12.5px; font-weight: 600; color: var(--text-secondary);
    }
    .notes-desktop-addgrade:hover { background: var(--bg-secondary); color: var(--text-primary); border-color: var(--border-color-dark); }
    .notes-desktop-addgrade .icon { width: 14px; height: 14px; }

    .notes-desktop-editbtn {
        all: unset; box-sizing: border-box; cursor: pointer;
        padding: 7px 14px; border-radius: 6px; background: var(--bg-tertiary); color: var(--text-primary);
        font-size: 12.5px; font-weight: 600;
    }
    .notes-desktop-editbtn:hover { background: var(--bg-hover); }

    .screen[data-screen="notes-stats"] .screen-body { max-width: none; }
    .screen[data-screen="notes-stats"] #notesStatsSwipe {
        display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px;
    }
}

.trimester-tabs { display: flex; gap: 5px; justify-content: center; padding: 16px 0 4px; }
.tab-pill {
    all: unset; box-sizing: border-box;
    padding: 8px 16px; background: var(--bg-tertiary); border-radius: 6px;
    font-size: 13px; font-weight: 500; color: var(--text-secondary);
}
.tab-pill.active { background: var(--accent-color); color: #fff; }
.avg-header { position: relative; text-align: center; padding: 6px 0 2px; }
.avg-header .average { font-size: 44px; font-weight: bold; color: var(--accent-color); }
.avg-header .avg-caption { font-size: 12px; color: var(--text-tertiary); margin-top: 2px; }
.avg-header .avg-caption .eval-badge-full { display: inline-block; margin: 4px 0 0 6px; max-width: 100%; overflow: visible; text-overflow: clip; white-space: normal; vertical-align: middle; }
.stats-btn {
    all: unset; box-sizing: border-box;
    position: absolute; right: 20px; bottom: 4px;
    width: 34px; height: 34px; border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    background: var(--bg-tertiary); color: var(--accent-color);
}
.stats-btn:hover { background: var(--bg-hover); }
#statsBtn { right: 62px; }
#simBtn.is-active, .notes-desktop-simbtn.is-active { background: #ffcc00; color: #1a1a1a; }

.stats-swipe { display: flex; flex-direction: column; gap: 18px; }
.stats-card { padding: 4px 20px 8px; }
.stats-card h3 { font-size: 15px; font-weight: 600; color: var(--text-primary); margin-bottom: 2px; }
.stats-card .stats-sub { font-size: 12px; color: var(--text-tertiary); margin-bottom: 14px; }
.stats-empty { padding: 40px 0; text-align: center; color: var(--text-tertiary); font-size: 13px; }
.stats-dots { display: none; }

.chart-value-label { font-size: 12px; fill: var(--text-tertiary); }
.chart-axis-label { font-size: 11px; fill: var(--text-tertiary); }

.chart-hover-wrap { position: relative; }
.chart-line-svg { cursor: crosshair; touch-action: pan-y; }
.chart-tooltip {
    position: absolute; top: 0; z-index: 2; pointer-events: none; opacity: 0; transition: opacity .1s ease;
    background: var(--bg-tertiary); color: var(--text-primary); border: 1px solid var(--border-color-dark);
    border-radius: 6px; padding: 4px 8px; font-size: 11px; white-space: nowrap; box-shadow: 0 2px 8px rgba(0, 0, 0, .18);
}
.chart-tooltip strong { color: var(--accent-color); }

.subject-list { display: flex; flex-direction: column; border-top: 1px solid var(--border-color-dark); }
.subject-item { border-bottom: 1px solid var(--border-color-dark); }
.subject-header {
    all: unset; box-sizing: border-box; display: flex; width: 100%;
    justify-content: space-between; align-items: center; gap: 10px; padding: 15px 20px;
    background: var(--bg-tertiary); user-select: none;
    -webkit-user-select: none; cursor: grab;
    touch-action: none;
}
.subject-header:hover { background: var(--bg-hover); }
.subject-header:focus-visible { outline: 2px solid var(--accent-color); outline-offset: -2px; }
.subject-header .name, .notes-desktop-row .name { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 6px; min-width: 0; flex: 1 1 auto; }
.subject-header .name-text, .notes-desktop-row .name-text { font-weight: 600; color: var(--text-primary); font-size: 16px; flex-shrink: 0; white-space: nowrap; }
.notes-desktop-row .name-text { font-size: inherit; font-weight: inherit; }
.subject-header .coeff-note { color: var(--text-tertiary); font-size: 12px; font-weight: 400; margin-left: 4px; }
.eval-badge { display: inline-block; flex-shrink: 0; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 2px 8px; border-radius: 10px; background: #f39c12; color: #fff; font-size: 11px; font-weight: 600; }
.subject-header .avg { font-weight: bold; color: var(--accent-color); font-size: 18px; flex-shrink: 0; white-space: nowrap; }
.subject-item.is-dragging { position: relative; z-index: 80; box-shadow: 0 14px 28px rgba(0,0,0,.28); }
.subject-item.is-dragging .subject-header { background: var(--bg-hover); cursor: grabbing; }
.subject-item.is-lift-ready .subject-header { background: var(--bg-hover); }

.subject-row.add-row {
    all: unset; box-sizing: border-box; display: flex; align-items: center;
    justify-content: center; gap: 6px; width: 100%; padding: 15px 20px;
    background: var(--bg-primary); color: var(--text-secondary); font-weight: 500; font-size: 14px;
}
.subject-row.add-row:hover { background: var(--bg-secondary); color: var(--text-primary); }
.subject-row.add-row:focus-visible { outline: 2px solid var(--accent-color); outline-offset: -2px; }

.section-label { font-size: 11px; letter-spacing: .04em; text-transform: uppercase; color: var(--text-tertiary); font-weight: 700; padding: 0 20px; }
.grades-container { padding: 12px 15px 45px 15px; position: relative; background: var(--bg-primary); }
.grades-grid { display: flex; flex-wrap: wrap; gap: 6px; }
.grade-chip {
    all: unset; box-sizing: border-box; padding: 6px 8px; background: var(--bg-primary);
    border: 1px solid var(--border-color-dark); border-radius: 4px; font-size: 13px; text-align: center;
    flex: 0 0 auto; min-width: 65px;
}
.grade-chip:hover { border-color: var(--accent-color); background: var(--bg-tertiary); }
.grade-chip.is-new { border: 3px solid var(--accent-color); font-weight: bold; box-shadow: 0 0 8px rgba(0,102,204,.3); }
.grade-chip .val {
    color: var(--accent-color); font-weight: 600; display: flex; align-items: center; justify-content: center;
    flex-wrap: nowrap; white-space: nowrap; font-size: 12px;
}
.grade-chip .val sub { color: var(--text-secondary); font-size: 9px; font-weight: normal; }
.grade-chip .val sup.coeff-sup { color: var(--text-secondary); font-weight: 700; font-size: 7px; }
.comp-dots { display: inline-flex; flex-wrap: nowrap; gap: 3px; margin-left: 4px; }
.grade-chip.competence-only .comp-dots { margin-left: 0; }
.comp-dot {
    flex: none; display: inline-block; box-sizing: border-box;
    width: 10px; height: 10px; border-radius: 50%; background: var(--text-tertiary);
}
.comp-dot-letter {
    width: 13px; height: 13px; display: inline-flex; align-items: center; justify-content: center;
    background: var(--bg-tertiary); border: 1px solid var(--border-color-dark); color: var(--text-secondary);
    font-size: 8px; font-weight: 700; line-height: 1;
}
#competenceLevelDot.is-letter { display: inline-flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; font-size: 13px; }
.grade-chip.competence-only { padding: 10px 8px; }
.grade-chip.competence-only .val { font-size: 11px; }

.btn-add-grade {
    all: unset; box-sizing: border-box; position: absolute; bottom: 10px; right: 10px;
    width: 32px; height: 32px; padding: 0; font-size: 20px; font-weight: 300;
    border: 1px solid var(--border-color-dark); border-radius: 6px;
    background: var(--bg-secondary); color: var(--text-secondary);
    display: flex; align-items: center; justify-content: center;
}
.btn-add-grade:hover { background: var(--bg-hover); }

.grade-list { display: flex; flex-direction: column; margin: 0 20px; border: 1px solid var(--border-color); border-radius: 8px; overflow: hidden; }
.grade-list-row {
    all: unset; box-sizing: border-box; display: flex; justify-content: space-between; align-items: center;
    padding: 12px 14px; background: var(--bg-primary); border-bottom: 1px solid var(--border-color); width: 100%;
}
.grade-list-row:last-child { border-bottom: none; }
.grade-list-row:hover { background: var(--bg-secondary); }
.grade-list-row .meta { display: flex; flex-direction: column; gap: 2px; text-align: left; }
.grade-list-row .meta .t { font-size: 14px; color: var(--text-primary); }
.grade-list-row .meta .d { font-size: 12px; color: var(--text-tertiary); }
.grade-list-row .v { font-weight: 600; color: var(--accent-color); font-size: 15px; }
.grade-list-row .v sub { color: var(--text-secondary); font-size: 10px; font-weight: normal; }
.grade-list-row .v sup.coeff-sup { color: var(--text-secondary); font-weight: 700; font-size: 8px; }

.big-btn { all: unset; box-sizing: border-box; display: block; margin: 0 20px; padding: 15px; border-radius: 8px; font-size: 16px; font-weight: 600; text-align: center; color: #fff; cursor: pointer; }
.big-btn:focus-visible { outline: 2px solid var(--text-primary); outline-offset: 2px; }
.big-btn:disabled { opacity: .45; cursor: not-allowed; pointer-events: none; }
.big-btn.blue { background: #0066cc; } .big-btn.blue:hover { background: #0052a3; }
.big-btn.green { background: #4caf50; } .big-btn.green:hover { background: #45a049; }
.big-btn.red { background: #c62828; } .big-btn.red:hover { background: #b71c1c; }
.big-btn.neutral { background: var(--bg-tertiary); color: var(--text-primary); } .big-btn.neutral:hover { background: var(--bg-hover); }

.form-group { padding: 0 20px; display: flex; flex-direction: column; gap: 8px; }
.form-group label { color: var(--text-secondary); font-size: 14px; font-weight: 500; }
.form-group input, .form-group select, .form-group textarea { width: 100%; padding: 12px; border: 2px solid var(--border-color); border-radius: 6px; font-size: 16px; background: var(--bg-secondary); color: var(--text-primary); font-family: inherit; }
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { outline: none; border-color: var(--accent-color); }
.form-group textarea { resize: vertical; }
.form-row { display: flex; gap: 10px; padding: 0 20px; }
.form-row .form-group { padding: 0; flex: 1; }
.form-group .ddn-input { width: 56px; flex: none; padding: 12px 4px; text-align: center; }
.form-group .ddn-input-year { width: 84px; }

.acct-list { display: flex; flex-direction: column; margin: 0 20px; border: 1px solid var(--border-color); border-radius: 8px; overflow: hidden; }
.acct-row {
    all: unset; box-sizing: border-box; display: flex; align-items: center; gap: 12px;
    padding: 14px 16px; background: var(--bg-primary); border-bottom: 1px solid var(--border-color); width: 100%;
}
.acct-row:last-child { border-bottom: none; }
.acct-row:hover { background: var(--bg-secondary); }
.acct-row.highlighted { box-shadow: inset 0 0 0 2px var(--accent-color); }
.acct-row .ic { font-size: 18px; width: 22px; text-align: center; flex-shrink: 0; }
.acct-row .lbl { flex: 1; text-align: left; font-size: 14px; color: var(--text-primary); }
.acct-row .sub { font-size: 11px; color: var(--text-tertiary); margin-top: 2px; }
.acct-row .sub input { width: 100%; box-sizing: border-box; padding: 4px 6px; margin-top: 2px; font-size: 13px; border: 1px solid var(--border-color-dark); border-radius: 4px; background: var(--bg-secondary); color: var(--text-primary); font-family: inherit; }
.acct-row .sub input:focus { outline: none; border-color: var(--accent-color); }
.acct-row .chev { color: var(--text-tertiary); }
.acct-row.sub-row { padding-left: 50px; background: var(--bg-secondary); }
.acct-row.sub-row .lbl { font-size: 13px; color: var(--text-secondary); }
body.is-offline .screen.offline-lockable input,
body.is-offline .screen.offline-lockable select,
body.is-offline .screen.offline-lockable textarea,
body.is-offline .screen.offline-lockable .big-btn,
body.is-offline .screen.offline-lockable .row-manage-btn,
body.is-offline .screen.offline-lockable .link-line,
body.is-offline .screen.offline-lockable .font-opt,
body.is-offline .screen[data-screen="compte"] .acct-row:not([data-go="appearance"]) {
    opacity: .45;
    pointer-events: none;
}
.offline-lock-banner {
    display: none;
    margin: 0 20px 12px;
    padding: 10px 14px;
    border-radius: 8px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-size: 12px;
    text-align: center;
}
body.is-offline .screen.offline-lockable .offline-lock-banner { display: block; }
.status-pill { font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 10px; background: #e8f5e9; color: #2e7d32; }
.row-manage-btn {
    all: unset; box-sizing: border-box; flex-shrink: 0;
    font-size: 12px; font-weight: 600; color: var(--accent-color);
    background: color-mix(in srgb, var(--accent-color) 12%, transparent);
    padding: 5px 10px; border-radius: 6px; cursor: pointer;
}
.row-manage-btn:hover { background: color-mix(in srgb, var(--accent-color) 20%, transparent); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .status-pill { background: rgba(76,175,80,.18); color: #81c784; } }
:root[data-theme="dark"] .status-pill { background: rgba(76,175,80,.18); color: #81c784; }

.toggle-switch { position: relative; width: 50px; height: 26px; flex-shrink: 0; }
.toggle-switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle-slider { position: absolute; inset: 0; background: var(--bg-tertiary); border-radius: 26px; transition: .3s; cursor: pointer; }
.toggle-slider::before { content: ''; position: absolute; height: 20px; width: 20px; left: 3px; bottom: 3px; background: #fff; border-radius: 50%; transition: .3s; box-shadow: 0 2px 4px rgba(0,0,0,.2); }
.toggle-switch input:checked + .toggle-slider { background: var(--accent-color); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(24px); }
.toggle-switch input:disabled + .toggle-slider { opacity: .4; cursor: not-allowed; }

.profile-block { display: flex; align-items: center; gap: 12px; padding: 0 20px; }
.avatar-circle { width: 48px; height: 48px; border-radius: 50%; background: var(--accent-color); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 16px; flex-shrink: 0; overflow: hidden; }
.avatar-circle img { width: 100%; height: 100%; object-fit: cover; }
.profile-block .name { font-weight: 600; font-size: 15px; color: var(--text-primary); }
.profile-block .id { font-size: 12px; color: var(--text-tertiary); }

.avatar-edit-block { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 6px 0 4px; }
.avatar-edit-wrap { position: relative; width: 84px; height: 84px; }
.avatar-edit-wrap .avatar-circle { width: 84px; height: 84px; font-size: 26px; }
.avatar-edit-btn {
    all: unset; box-sizing: border-box; position: absolute; bottom: -2px; right: -2px;
    width: 30px; height: 30px; border-radius: 50%; background: var(--accent-color); color: #fff;
    display: flex; align-items: center; justify-content: center; border: 3px solid var(--bg-primary);
}
.avatar-edit-btn:hover { background: var(--accent-hover); }
.avatar-edit-btn:focus-visible { outline: 2px solid var(--text-primary); outline-offset: 2px; }
.avatar-edit-btn .icon { width: 14px; height: 14px; }

.sync-card { margin: 0 20px; border-radius: 8px; border: 1px solid var(--border-color); padding: 14px 16px; }
.info-box { margin: 0 20px; background: #e3f2fd; color: #1976d2; border-radius: 6px; padding: 10px 12px; font-size: 12px; line-height: 1.5; }
.info-box.warning { background: #fff3cd; color: #856404; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .info-box { background: rgba(77,159,255,.14); color: #8fc4ff; } }
:root[data-theme="dark"] .info-box { background: rgba(77,159,255,.14); color: #8fc4ff; }

.week-nav { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 0 20px 14px; }
.week-arrow { all: unset; box-sizing: border-box; display: flex; align-items: center; justify-content: center; width: 34px; height: 34px; flex-shrink: 0; border-radius: 8px; background: var(--bg-tertiary); color: var(--text-primary); cursor: pointer; }
.week-arrow:hover { background: var(--bg-hover); }
.week-arrow.next .icon { transform: rotate(180deg); }
.week-label { font-size: 14px; font-weight: 600; text-align: center; flex: 1; }
.day-tabs { display: flex; flex-direction: row; gap: 4px; padding: 0 20px 12px; }
.day-pill { all: unset; box-sizing: border-box; flex: 1; min-width: 0; padding: 8px 2px; background: var(--bg-tertiary); border-radius: 8px; font-size: 10px; font-weight: 500; color: var(--text-secondary); text-align: center; line-height: 1.4; }
.day-pill .dname { display: block; }
.day-pill .ddate { display: block; font-size: 10px; opacity: .8; }
.day-pill.active { background: var(--accent-color); color: #fff; }
.edt-cancel { display: inline-block; text-decoration: none; font-size: 10px; font-weight: 700; background: #ffebee; color: #c62828; padding: 2px 6px; border-radius: 8px; margin-left: 6px; }
.edt-modified { display: inline-block; text-decoration: none; font-size: 10px; font-weight: 700; background: #fff3e0; color: #e65100; padding: 2px 6px; border-radius: 8px; margin-left: 6px; }

.edt-grid { display: flex; padding: 0 20px 20px; }
.edt-grid-hours { width: 34px; flex-shrink: 0; position: relative; }
.edt-hour-label { position: absolute; right: 8px; transform: translateY(-50%); font-size: 10px; color: var(--text-tertiary); font-variant-numeric: tabular-nums; }
.edt-grid-track {
    flex: 1; position: relative; border-left: 1px solid var(--border-color); margin-left: 6px;
    background-image: repeating-linear-gradient(to bottom, var(--border-color) 0, var(--border-color) 1px, transparent 1px, transparent var(--edt-hour-h));
}

.edt-course-block {
    position: absolute; box-sizing: border-box; overflow: hidden; cursor: pointer;
    border-left: 3px solid var(--accent-color); background: var(--bg-secondary); border-radius: 4px;
    padding: 3px 7px; display: flex; flex-direction: column; gap: 1px;
}
.edt-course-block:hover { background: var(--bg-tertiary); }
.edt-course-block .t { font-size: 10px; color: var(--text-tertiary); font-variant-numeric: tabular-nums; white-space: nowrap; }
.edt-course-block .n { font-size: 12px; font-weight: 600; color: var(--text-primary); white-space: nowrap; text-overflow: ellipsis; overflow: hidden; }
.edt-course-block .n.cancelled { text-decoration: line-through; color: var(--text-tertiary); }
.edt-course-block .r { font-size: 10px; color: var(--text-tertiary); white-space: nowrap; text-overflow: ellipsis; overflow: hidden; }

.edt-week { display: none; }

@media (min-width: 900px) {
    .screen[data-screen="edt-schedule"] .screen-body { max-width: none; }
    .screen[data-screen="edt-schedule"] .day-tabs,
    .screen[data-screen="edt-schedule"] #edtList { display: none; }

    .edt-week { display: grid; grid-template-columns: 40px repeat(6, 1fr); flex: 1; min-height: 0; align-content: start; }

    .edt-week-corner { grid-column: 1; grid-row: 1; position: sticky; top: 0; z-index: 2; background: var(--bg-primary); border-bottom: 1px solid var(--border-color); }
    .edt-week-daylabel {
        grid-row: 1; position: sticky; top: 0; z-index: 1; padding: 10px 8px; text-align: center; font-size: 12px; font-weight: 600;
        color: var(--text-secondary); background: var(--bg-primary); border-bottom: 1px solid var(--border-color); border-left: 1px solid var(--border-color);
    }
    .edt-week-daylabel .d { display: block; font-size: 10.5px; font-weight: 400; color: var(--text-tertiary); margin-top: 1px; }
    .edt-week-daylabel.is-today { background: var(--accent-color); color: #fff; }
    .edt-week-daylabel.is-today .d { color: rgba(255, 255, 255, .8); }

    .edt-week .edt-grid-hours { width: auto; }
    .edt-week-track {
        grid-row: 2; position: relative; border-left: 1px solid var(--border-color);
        background-image: repeating-linear-gradient(to bottom, var(--border-color) 0, var(--border-color) 1px, transparent 1px, transparent var(--edt-hour-h));
    }

    .screen[data-screen="subject-stats"] .screen-body { max-width: none; }
    .screen[data-screen="subject-stats"] #subjectStatsSwipe {
        display: grid; grid-template-columns: 1fr 1fr; gap: 24px;
    }
}

.font-options { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; padding: 0 20px; }
.font-opt { all: unset; box-sizing: border-box; padding: 10px 14px; background: var(--bg-secondary); border: 2px solid var(--border-color); border-radius: 8px; font-size: 13px; color: var(--text-primary); text-align: center; }
.font-opt.selected { border-color: var(--accent-color); background: var(--accent-color); color: #fff; }
.color-row { display: flex; gap: 14px; padding: 0 20px; flex-wrap: wrap; }
.color-opt { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.color-opt input[type=color] { width: 44px; height: 44px; border-radius: 50%; border: 3px solid var(--border-color-dark); padding: 0; background: none; }
.color-opt span { font-size: 10px; color: var(--text-tertiary); }

.version-line { text-align: center; color: var(--text-tertiary); font-size: 12px; padding: 4px 0; }
.privacy-line { text-align: center; color: var(--accent-color); font-size: 12px; padding: 0 0 4px; }

.auth-brand { display: flex; align-items: center; gap: 10px; }
.auth-brand-logo { width: 28px; height: 28px; border-radius: 7px; flex-shrink: 0; }
.auth-brand-name { font-size: 17px; font-weight: 700; color: var(--text-primary); }

.center-copy { text-align: center; padding: 14px 20px 0; }
.center-copy h2 { font-size: 20px; font-weight: 700; color: var(--text-primary); }
.center-copy p { color: var(--text-secondary); font-size: 14px; margin-top: 6px; }
.link-line { all: unset; box-sizing: border-box; display: block; text-align: center; color: var(--accent-color); font-size: 13px; font-weight: 500; cursor: pointer; padding: 4px; }
.link-line:hover { text-decoration: underline; }

.loading-spinner { width: 40px; height: 40px; margin: 0 auto; border: 3px solid var(--border-color); border-top-color: var(--accent-color); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .loading-spinner { animation: none; } }

.toast-container { position: fixed; top: max(12px, env(safe-area-inset-top)); right: 12px; z-index: 999; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.toast { background: var(--bg-tertiary); color: var(--text-primary); padding: 10px 16px; border-radius: 8px; font-size: 13px; font-weight: 500; box-shadow: 0 4px 14px rgba(0,0,0,.18); opacity: 0; transform: translateY(-8px); transition: opacity .2s, transform .2s; }
.toast.is-visible { opacity: 1; transform: translateY(0); }

.confirm-overlay { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 20px; background: rgba(0,0,0,0); transition: background .2s; }
.confirm-overlay.is-visible { background: rgba(0,0,0,.5); }
.confirm-modal { width: 100%; max-width: 320px; background: var(--bg-secondary); border: 1px solid var(--border-color); border-radius: 12px; padding: 20px; box-shadow: 0 10px 32px rgba(0,0,0,.28); opacity: 0; transform: translateY(8px) scale(.98); transition: opacity .2s, transform .2s; }
.confirm-overlay.is-visible .confirm-modal { opacity: 1; transform: translateY(0) scale(1); }
.confirm-message { margin: 0 0 18px; font-size: 14px; font-weight: 500; color: var(--text-primary); text-align: center; line-height: 1.4; }
.confirm-actions { display: flex; flex-direction: column; gap: 8px; }
.confirm-actions .big-btn { margin: 0; }

.btn-spinner { display: inline-block; width: 15px; height: 15px; margin-right: 8px; vertical-align: -3px; border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: spin 0.7s linear infinite; }
@media (prefers-reduced-motion: reduce) { .btn-spinner { animation: none; } }

.simulation-frame { display: none; position: fixed; inset: 0; z-index: 998; pointer-events: none; border: 10px solid transparent; border-image: repeating-linear-gradient(45deg, #ffcc00 0 20px, #1a1a1a 20px 40px) 30; }
body.simulation-mode .simulation-frame { display: block; }
