:root {
    color-scheme: dark;
    --accent: 159, 220, 190;
    --bg: #252b32;
    --panel: #30373f;
    --panel-2: #282f36;
    --panel-3: #22282e;
    --line: rgba(170, 190, 211, 0.22);
    --line-strong: rgba(181, 203, 225, 0.38);
    --text: #edf3f8;
    --muted: #aeb9c5;
    --blue: #9bc2ed;
    --mint: #a8d9bd;
    --gold: #e6c381;
    --rose: #e3aab4;
    --lilac: #c6b5e9;
    --aqua: #8cd8d2;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
    margin: 0;
    min-width: 320px;
    color: var(--text);
    background:
        radial-gradient(circle at 8% 0%, rgba(var(--accent), 0.055), transparent 32%),
        linear-gradient(150deg, #252b32 0%, #2d333a 58%, #252c31 100%);
}

button, input, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible {
    outline: 2px solid rgba(var(--accent), 0.72);
    outline-offset: 2px;
}

svg {
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.daily-shell {
    width: min(1500px, calc(100% - 32px));
    min-height: 100dvh;
    margin: 0 auto;
    padding: 18px 0 42px;
}

.daily-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 46px;
    margin-bottom: 12px;
}

.icon-button,
.card-tool,
.mode-button,
.nav-button,
.grade-button,
.scope-button,
.filter-chip,
.filter-reveal,
.text-button {
    border: 1px solid var(--line);
    color: var(--muted);
    background: rgba(47, 55, 64, 0.9);
    cursor: pointer;
    transition: color 150ms ease, border-color 160ms ease, background 180ms ease, transform 180ms cubic-bezier(.2,.8,.2,1), box-shadow 180ms ease;
}

.icon-button:hover,
.card-tool:hover,
.mode-button:hover,
.nav-button:hover,
.scope-button:hover,
.filter-chip:hover,
.filter-reveal:hover {
    color: var(--text);
    border-color: var(--line-strong);
    background: rgba(61, 70, 80, 0.96);
    transform: translateY(-1px);
}

.icon-button {
    display: grid;
    width: 46px;
    height: 46px;
    flex: 0 0 46px;
    padding: 0;
    place-items: center;
    border-radius: 7px;
    text-decoration: none;
}

.icon-button svg { width: 22px; height: 22px; }

.home-button {
    color: rgba(192, 205, 217, 0.72);
    border-color: transparent;
    background: transparent;
}

.daily-today {
    position: relative;
    display: flex;
    align-items: baseline;
    gap: 7px;
    min-width: 116px;
    height: 42px;
    padding: 8px 32px 8px 15px;
    color: var(--blue);
    border: 1px solid var(--line);
    border-radius: 7px;
    background: rgba(35, 42, 49, 0.72);
    font-size: 17px;
    font-weight: 750;
    font-variant-numeric: tabular-nums;
}

.daily-today-divider { color: rgba(198, 211, 224, 0.42); }
.daily-today #today-attempted { color: var(--muted); }

.daily-today-pulse {
    position: absolute;
    top: 50%;
    right: 13px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(var(--accent), 0.72);
    box-shadow: 0 0 9px rgba(var(--accent), 0.24);
    transform: translateY(-50%);
}

.daily-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 62px;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(39, 46, 53, 0.9);
    box-shadow: 0 14px 34px rgba(7, 11, 16, 0.12);
}

.mode-segment {
    display: grid;
    grid-template-columns: repeat(5, 62px);
    height: 46px;
    border: 1px solid var(--line);
    border-radius: 7px;
    overflow: hidden;
}

.mode-button {
    display: grid;
    width: 62px;
    height: 44px;
    padding: 0;
    place-items: center;
    border: 0;
    border-right: 1px solid var(--line);
    border-radius: 0;
    background: transparent;
}

.mode-button:last-child { border-right: 0; }
.mode-button svg { width: 23px; height: 23px; }

.mode-button.is-active {
    color: #142333;
    background: rgba(145, 187, 231, 0.9);
    box-shadow: inset 0 0 0 1px rgba(225, 239, 252, 0.14);
}

.mode-button[data-mode="flagged"].is-active {
    color: #2d281b;
    background: rgba(224, 190, 126, 0.9);
}

.scope-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    min-width: 142px;
    height: 46px;
    padding: 0 14px;
    border-radius: 7px;
    color: var(--text);
    font-size: 14px;
    font-weight: 700;
}

.scope-button svg { width: 21px; height: 21px; color: var(--blue); }
.scope-button:not(.is-week) .scope-check { display: none; }
.scope-button:not(.is-week) { color: var(--muted); }
.toolbar-spacer { flex: 1; }

.card-search {
    position: relative;
    display: flex;
    flex-direction: row-reverse;
    align-items: center;
}

.search-panel {
    position: relative;
    width: 0;
    opacity: 0;
    pointer-events: none;
    transition: width 260ms cubic-bezier(.2,.8,.2,1), opacity 170ms ease, margin 260ms cubic-bezier(.2,.8,.2,1);
}

.card-search.is-open .search-panel {
    width: min(360px, 34vw);
    margin-right: 8px;
    opacity: 1;
    pointer-events: auto;
}

.search-panel input {
    width: 100%;
    height: 46px;
    padding: 0 14px;
    color: var(--text);
    border: 1px solid var(--line-strong);
    border-radius: 7px;
    background: #252c32;
}

.search-results {
    position: absolute;
    z-index: 40;
    top: calc(100% + 8px);
    right: 0;
    display: none;
    width: min(520px, calc(100vw - 32px));
    max-height: 390px;
    overflow: auto;
    padding: 6px;
    border: 1px solid var(--line-strong);
    border-radius: 7px;
    background: rgba(34, 41, 48, 0.98);
    box-shadow: 0 22px 54px rgba(0, 0, 0, 0.36);
}

.search-results:not(:empty) { display: grid; gap: 3px; }

.search-result {
    display: grid;
    gap: 4px;
    width: 100%;
    padding: 10px 11px;
    color: var(--text);
    text-align: left;
    border: 0;
    border-radius: 5px;
    background: transparent;
    cursor: pointer;
}

.search-result:hover, .search-result.is-active { background: rgba(140, 174, 207, 0.14); }
.search-result strong { font-size: 13px; line-height: 1.35; }
.search-result span { color: var(--muted); font-size: 11px; }

.filter-panel {
    position: relative;
    min-height: 124px;
    margin-top: 14px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(43, 50, 58, 0.72);
    overflow: hidden;
    cursor: default;
}

.filter-content {
    display: grid;
    gap: 8px;
    transform-origin: center;
    transition: opacity 580ms cubic-bezier(.2,.65,.2,1), transform 700ms cubic-bezier(.16,.8,.22,1), filter 480ms ease;
}

.filter-panel.is-hidden { cursor: pointer; }
.filter-panel.is-hidden .filter-content {
    opacity: 0;
    filter: blur(7px);
    transform: translateY(-8px) scale(0.985);
    pointer-events: none;
}

.filter-row {
    display: flex;
    min-height: 46px;
    align-items: stretch;
    gap: 7px;
    overflow-x: auto;
    scrollbar-width: none;
}

.filter-row::-webkit-scrollbar { display: none; }
.filter-row-secondary { padding-top: 7px; border-top: 1px solid rgba(174, 195, 217, 0.12); }

.filter-chip {
    flex: 0 0 auto;
    min-width: 104px;
    height: 46px;
    padding: 0 16px;
    border-radius: 7px;
    color: #c8d3de;
    font-size: 14px;
    font-weight: 720;
    white-space: nowrap;
}

.filter-chip.is-active {
    color: #132334;
    border-color: rgba(173, 211, 247, 0.7);
    background: rgba(147, 187, 228, 0.92);
}

.filter-row-secondary .filter-chip.is-active {
    color: #18251f;
    border-color: rgba(var(--accent), 0.64);
    background: rgba(var(--accent), 0.8);
}

.filter-reveal {
    position: absolute;
    inset: 0;
    display: grid;
    width: 100%;
    height: 100%;
    place-items: center;
    color: rgba(171, 193, 214, 0.68);
    border: 0;
    border-radius: 0;
    background: rgba(43, 50, 58, 0.96);
    opacity: 0;
    pointer-events: none;
}

.filter-reveal svg { width: 29px; height: 29px; }
.filter-panel.is-hidden .filter-reveal { opacity: 1; pointer-events: auto; }

.quiz-progress {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 14px;
    height: 42px;
    margin: 8px 3px 2px;
}

.progress-track {
    height: 3px;
    overflow: hidden;
    border-radius: 2px;
    background: rgba(178, 196, 214, 0.13);
}

.progress-track span {
    display: block;
    width: 0;
    height: 100%;
    background: linear-gradient(90deg, rgba(144, 187, 231, 0.95), rgba(var(--accent), 0.92));
    transition: width 460ms cubic-bezier(.2,.8,.2,1);
}

#position-label {
    min-width: 68px;
    color: #c3ced9;
    text-align: right;
    font-size: 14px;
    font-variant-numeric: tabular-nums;
}

.quiz-stage { animation: stage-in 420ms cubic-bezier(.2,.8,.2,1) both; }
@keyframes stage-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.card-frame {
    position: relative;
    min-height: 500px;
    padding-top: 0;
}

.quiz-card {
    position: relative;
    display: grid;
    width: 100%;
    min-height: 500px;
    padding: 68px 72px 58px;
    place-items: center;
    color: var(--text);
    text-align: left;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    background:
        linear-gradient(145deg, rgba(255, 255, 255, 0.025), transparent 48%),
        rgba(49, 57, 66, 0.96);
    box-shadow: 0 24px 58px rgba(8, 12, 17, 0.22), inset 0 1px 0 rgba(255,255,255,0.035);
    cursor: pointer;
    overflow: hidden;
    transition: border-color 220ms ease, box-shadow 240ms ease, background 260ms ease;
}

.quiz-card:hover {
    border-color: rgba(var(--accent), 0.48);
    box-shadow: 0 28px 68px rgba(7, 12, 17, 0.28), inset 0 1px 0 rgba(255,255,255,0.045);
}

.quiz-card.is-answer {
    background:
        linear-gradient(145deg, rgba(var(--accent), 0.035), transparent 46%),
        rgba(46, 55, 63, 0.98);
}

.quiz-card.is-switching .card-copy { animation: copy-in 310ms cubic-bezier(.2,.8,.2,1) both; }
@keyframes copy-in { from { opacity: 0; transform: translateY(7px) scale(.995); } to { opacity: 1; transform: none; } }

.side-label {
    position: absolute;
    top: 20px;
    left: 22px;
    color: rgba(190, 203, 216, 0.5);
    font-size: 11px;
    font-weight: 760;
    text-transform: uppercase;
}

.card-copy {
    display: block;
    width: min(1040px, 100%);
    margin: auto;
    color: #eef3f7;
    font-size: 27px;
    font-weight: 470;
    line-height: 1.55;
    letter-spacing: 0;
    overflow-wrap: anywhere;
}

.card-copy.is-answer-copy { font-size: 21px; line-height: 1.58; }
.card-copy p { margin: 0 0 16px; }
.card-copy p:last-child { margin-bottom: 0; }
.card-copy ul, .card-copy ol { display: grid; gap: 8px; margin: 8px 0 16px; padding-left: 25px; }
.card-copy li { padding-left: 3px; }
.card-copy strong { font-weight: 720; }

.answer-sections { display: grid; gap: 17px; width: 100%; }
.answer-section { padding-left: 14px; border-left: 3px solid rgba(155, 194, 237, 0.56); }
.answer-section[data-tone="mint"] { border-left-color: rgba(168, 217, 189, 0.68); }
.answer-section[data-tone="gold"] { border-left-color: rgba(230, 195, 129, 0.68); }
.answer-section[data-tone="rose"] { border-left-color: rgba(227, 170, 180, 0.68); }
.answer-section[data-tone="lilac"] { border-left-color: rgba(198, 181, 233, 0.68); }
.answer-section[data-tone="aqua"] { border-left-color: rgba(140, 216, 210, 0.68); }
.answer-section h3 { margin: 0 0 5px; color: #c4d2df; font-size: 13px; font-weight: 740; }
.answer-section p { margin: 0; }

.term-sky { color: var(--blue); }
.term-mint { color: var(--mint); }
.term-gold { color: var(--gold); }
.term-rose { color: var(--rose); }
.term-lilac { color: var(--lilac); }
.term-aqua { color: var(--aqua); }

.card-meta {
    position: absolute;
    z-index: 5;
    top: 16px;
    left: 18px;
    right: 170px;
    display: flex;
    align-items: center;
    gap: 7px;
    opacity: 0;
    transform: translateY(-5px);
    pointer-events: none;
    transition: opacity 210ms ease, transform 280ms cubic-bezier(.2,.8,.2,1);
}

.card-frame:hover .card-meta,
.card-frame:focus-within .card-meta { opacity: 1; transform: none; }

.meta-pill {
    display: inline-flex;
    align-items: center;
    min-height: 30px;
    padding: 5px 10px;
    color: rgba(226, 235, 243, 0.86);
    border: 1px solid rgba(180, 201, 220, 0.23);
    border-radius: 6px;
    background: rgba(28, 34, 40, 0.67);
    backdrop-filter: blur(10px);
    font-size: 11px;
    font-weight: 720;
}

.meta-pill[hidden],
.mastery-mark[hidden] { display: none; }

.meta-flag { padding: 5px 8px; color: var(--gold); }
.meta-flag svg { width: 16px; height: 16px; }

.card-tools {
    position: absolute;
    z-index: 6;
    top: 14px;
    right: 16px;
    display: flex;
    gap: 7px;
}

.card-tool {
    display: grid;
    width: 42px;
    height: 42px;
    padding: 0;
    place-items: center;
    border-radius: 7px;
    background: rgba(48, 56, 65, 0.9);
}

.card-tool svg { width: 20px; height: 20px; }
.card-tool[hidden] { display: none; }
.card-tool.is-active { color: var(--gold); border-color: rgba(230, 195, 129, 0.56); background: rgba(101, 82, 48, 0.34); }

.mastery-mark {
    position: absolute;
    right: 23px;
    bottom: 20px;
    display: grid;
    width: 29px;
    height: 29px;
    place-items: center;
    color: var(--mint);
    border: 1px solid rgba(168, 217, 189, 0.28);
    border-radius: 50%;
    background: rgba(28, 53, 42, 0.38);
}
.mastery-mark svg { width: 17px; height: 17px; }

.answer-row {
    display: grid;
    grid-template-columns: 58px minmax(96px, 150px) minmax(96px, 150px) 58px;
    justify-content: center;
    gap: 10px;
    margin-top: 14px;
}

.nav-button, .grade-button {
    display: grid;
    height: 54px;
    padding: 0;
    place-items: center;
    border-radius: 7px;
}
.nav-button svg, .grade-button svg { width: 24px; height: 24px; }
.grade-button { color: #d3dce5; }
.grade-button.is-missed:not(:disabled):hover { color: #f4ced3; border-color: rgba(227, 170, 180, 0.6); background: rgba(105, 52, 62, 0.42); }
.grade-button.is-known:not(:disabled):hover { color: #d9f2e3; border-color: rgba(168, 217, 189, 0.6); background: rgba(48, 91, 68, 0.42); }
.grade-button:disabled { opacity: 0.34; cursor: default; transform: none; }
.grade-button.is-recorded { animation: grade-pop 430ms cubic-bezier(.18,.8,.2,1); }
@keyframes grade-pop { 45% { transform: translateY(-3px) scale(1.07); } }

.grade-note {
    min-height: 28px;
    padding-top: 8px;
    color: rgba(182, 197, 210, 0.7);
    text-align: center;
    font-size: 12px;
}

.loading-state, .empty-state {
    display: grid;
    min-height: 520px;
    place-items: center;
    color: var(--muted);
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(43, 50, 58, 0.5);
}
.loading-state[hidden], .empty-state[hidden] { display: none; }
.loading-state span {
    width: 38px;
    height: 38px;
    border: 2px solid rgba(231, 239, 247, 0.14);
    border-top-color: #edf4fa;
    border-right-color: rgba(155, 194, 237, 0.9);
    border-radius: 50%;
    box-shadow: 0 0 17px rgba(155, 194, 237, 0.1);
    animation: spin 720ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

dialog {
    width: auto;
    max-width: none;
    max-height: none;
    padding: 0;
    color: var(--text);
    border: 0;
    background: transparent;
}
dialog::backdrop { background: rgba(7, 11, 15, 0.7); backdrop-filter: blur(7px); }

.dialog-shell {
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    background: #2c333a;
    box-shadow: 0 34px 90px rgba(0, 0, 0, 0.46);
    overflow: hidden;
}

.stats-shell {
    width: calc(100vw - 54px);
    height: calc(100dvh - 54px);
    overflow: auto;
}

.dialog-header {
    position: sticky;
    z-index: 4;
    top: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    min-height: 66px;
    padding: 10px 14px 10px 22px;
    border-bottom: 1px solid var(--line);
    background: rgba(44, 51, 58, 0.96);
    backdrop-filter: blur(14px);
}

.stats-context { color: #c9d5e0; font-size: 14px; font-weight: 750; }
.stats-body { display: grid; gap: 22px; padding: 22px; }
.stats-metrics { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }
.stat-metric { min-height: 122px; padding: 17px; border-left: 3px solid rgba(155, 194, 237, 0.62); background: rgba(35, 42, 49, 0.64); }
.stat-metric:nth-child(2) { border-color: rgba(168, 217, 189, 0.65); }
.stat-metric:nth-child(3) { border-color: rgba(230, 195, 129, 0.65); }
.stat-metric:nth-child(4) { border-color: rgba(198, 181, 233, 0.65); }
.stat-metric:nth-child(5) { border-color: rgba(140, 216, 210, 0.65); }
.stat-metric span { display: block; color: var(--muted); font-size: 12px; font-weight: 690; }
.stat-metric strong { display: block; margin-top: 10px; font-size: 31px; font-weight: 720; font-variant-numeric: tabular-nums; }
.stat-metric small { display: block; margin-top: 3px; color: rgba(177, 191, 204, 0.65); font-size: 11px; }

.stats-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(300px, .7fr); gap: 18px; }
.stats-panel { padding: 17px; border: 1px solid var(--line); border-radius: 7px; background: rgba(35, 42, 49, 0.48); }
.category-stat { display: grid; grid-template-columns: minmax(150px, 1fr) minmax(160px, 2fr) auto; align-items: center; gap: 14px; min-height: 55px; border-bottom: 1px solid rgba(178, 197, 215, 0.1); }
.category-stat:last-child { border-bottom: 0; }
.category-stat strong { font-size: 13px; }
.category-stat span:last-child { min-width: 76px; color: var(--muted); text-align: right; font-size: 12px; font-variant-numeric: tabular-nums; }
.category-bar { height: 7px; overflow: hidden; background: #20262b; }
.category-bar i { display: block; height: 100%; background: linear-gradient(90deg, rgba(146, 187, 230, .9), rgba(168, 217, 189, .88)); }
.weak-list { display: grid; gap: 7px; }
.weak-item { display: grid; gap: 4px; padding: 11px; border-left: 2px solid rgba(227, 170, 180, 0.55); background: rgba(47, 54, 62, 0.62); }
.weak-item strong { font-size: 12px; font-weight: 650; line-height: 1.4; }
.weak-item span { color: var(--muted); font-size: 11px; }
.activity-grid { display: grid; grid-template-columns: repeat(26, 1fr); gap: 4px; }
.activity-cell { aspect-ratio: 1; min-width: 5px; background: rgba(159, 177, 195, 0.1); }
.activity-cell[data-level="1"] { background: rgba(155, 194, 237, 0.28); }
.activity-cell[data-level="2"] { background: rgba(155, 194, 237, 0.48); }
.activity-cell[data-level="3"] { background: rgba(168, 217, 189, 0.66); }
.activity-cell[data-level="4"] { background: rgba(168, 217, 189, 0.9); box-shadow: 0 0 7px rgba(168,217,189,.12); }

.sources-shell { width: min(800px, calc(100vw - 32px)); max-height: calc(100dvh - 48px); overflow: auto; }
.sources-list { display: grid; gap: 7px; padding: 14px; }
.source-entry { display: grid; grid-template-columns: minmax(0,1fr) 34px; align-items: center; gap: 12px; min-height: 64px; padding: 11px 12px; color: var(--text); text-align: left; border: 1px solid var(--line); border-radius: 6px; background: rgba(37, 44, 51, 0.76); }
button.source-entry { cursor: pointer; }
button.source-entry:hover { border-color: rgba(var(--accent), .48); background: rgba(50, 59, 67, .9); }
.source-entry strong { display: block; font-size: 13px; }
.source-entry small { display: block; margin-top: 4px; color: var(--muted); font-size: 11px; }
.source-entry svg { width: 20px; height: 20px; color: var(--blue); }
.source-entry.is-unavailable { opacity: .62; }

.edit-shell { width: min(860px, calc(100vw - 32px)); }
.edit-shell label { display: grid; gap: 7px; padding: 14px 18px 0; color: var(--muted); font-size: 12px; font-weight: 700; }
.edit-shell textarea { width: 100%; min-height: 180px; resize: vertical; padding: 13px; color: var(--text); border: 1px solid var(--line); border-radius: 6px; background: #242b31; font-size: 15px; line-height: 1.5; }
.edit-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 16px 18px 18px; }
.text-button { min-width: 112px; height: 44px; border-radius: 6px; color: #152333; background: rgba(151, 192, 232, .9); font-weight: 740; }
.text-button.is-quiet { color: var(--muted); background: transparent; }

.ui-tooltip {
    position: fixed;
    z-index: 100;
    width: max-content;
    max-width: 300px;
    padding: 8px 10px;
    color: #e9f1f8;
    border: 1px solid rgba(175, 198, 220, .24);
    border-radius: 5px;
    background: rgba(24, 30, 36, .96);
    box-shadow: 0 12px 30px rgba(0,0,0,.32);
    font-size: 11px;
    line-height: 1.45;
    opacity: 0;
    pointer-events: none;
    transform: translateY(4px);
    transition: opacity 120ms ease, transform 150ms ease;
}
.ui-tooltip.is-visible { opacity: 1; transform: none; }

@media (max-width: 900px) {
    .daily-shell { width: min(100% - 20px, 1500px); padding-top: 10px; }
    .daily-toolbar { flex-wrap: wrap; }
    .mode-segment { grid-template-columns: repeat(5, 54px); }
    .mode-button { width: 54px; }
    .toolbar-spacer { display: none; }
    #open-stats { margin-left: auto; }
    .card-copy { font-size: 23px; }
    .card-copy.is-answer-copy { font-size: 19px; }
    .stats-metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .stats-grid { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
    .daily-shell { width: 100%; padding: 6px 8px 28px; }
    .daily-topbar { margin-bottom: 6px; }
    .daily-toolbar { gap: 7px; padding: 7px; }
    .mode-segment { order: 1; width: 100%; grid-template-columns: repeat(5, 1fr); }
    .mode-button { width: auto; }
    .scope-button { order: 2; min-width: 118px; flex: 1; padding-inline: 9px; }
    #open-stats { order: 2; margin-left: 0; }
    .card-search { order: 2; }
    .card-search.is-open { width: 100%; order: 3; }
    .card-search.is-open .search-panel { width: 100%; max-width: none; }
    .filter-panel { min-height: 112px; margin-top: 8px; padding: 7px; }
    .filter-chip { min-width: 90px; height: 43px; padding: 0 12px; font-size: 12px; }
    .filter-row { min-height: 43px; }
    .quiz-progress { height: 34px; }
    .card-frame, .quiz-card { min-height: min(61dvh, 590px); }
    .quiz-card { padding: 72px 18px 45px; }
    .card-copy { font-size: 20px; line-height: 1.48; }
    .card-copy.is-answer-copy { font-size: 17px; line-height: 1.52; }
    .card-meta { top: 55px; left: 12px; right: 12px; overflow-x: auto; }
    .card-tools { top: 10px; right: 10px; }
    .card-tool { width: 38px; height: 38px; }
    .side-label { top: 20px; left: 16px; }
    .answer-row { grid-template-columns: 48px minmax(76px, 1fr) minmax(76px, 1fr) 48px; gap: 7px; }
    .nav-button, .grade-button { height: 50px; }
    .stats-shell { width: calc(100vw - 12px); height: calc(100dvh - 12px); }
    .stats-body { padding: 10px; gap: 12px; }
    .stats-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
    .stat-metric { min-height: 96px; padding: 12px; }
    .stat-metric strong { font-size: 25px; }
    .category-stat { grid-template-columns: minmax(105px, 1fr) minmax(80px, 1fr) auto; gap: 7px; }
    .activity-grid { grid-template-columns: repeat(13, 1fr); }
    .ui-tooltip { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 1ms !important; transition-duration: 1ms !important; }
}
