/* The shared rose palette sits after the original page styles so every view,
   including the admin shell, uses the same theme tokens. */
:root[data-theme="day"] {
  color-scheme: light;
  --ink: #422a38;
  --muted: #765f6d;
  --paper: #fff6fa;
  --sidebar: #fff9fc;
  --surface: #ffffff;
  --surface-2: #fff0f5;
  --surface-raised: #ffffff;
  --surface-soft: #fdeaf1;
  --line: #ead3dd;
  --line-bright: #d9aabb;
  --accent: #a93463;
  --accent-dark: #87264e;
  --accent-soft: #fbe1eb;
  --blue: #a93463;
  --gold: #91652c;
  --green: #28775c;
  --danger: #ad394e;
  --shadow: 0 12px 34px #71334d15;
  background: var(--paper);
  color: var(--ink);
}
:root[data-theme="night"] {
  color-scheme: dark;
  --ink: #f9edf3;
  --muted: #c8aebc;
  --paper: #1b121a;
  --sidebar: #211620;
  --surface: #291b27;
  --surface-2: #33212f;
  --surface-raised: #372534;
  --surface-soft: #3b2535;
  --line: #604050;
  --line-bright: #86536b;
  --accent: #f195b9;
  --accent-dark: #f6b2cc;
  --accent-soft: #512e41;
  --blue: #f195b9;
  --gold: #e2b873;
  --green: #80c5a8;
  --danger: #ff9baa;
  --shadow: 0 12px 34px #08030755;
  background: var(--paper);
  color: var(--ink);
}
html[data-theme] body { color: var(--ink); background-color: var(--paper); }
html[data-theme="day"] body {
  background-image: linear-gradient(#a9346308 1px, transparent 1px),
    linear-gradient(90deg, #a9346307 1px, transparent 1px);
}
html[data-theme="night"] body {
  background-image: linear-gradient(#f195b906 1px, transparent 1px),
    linear-gradient(90deg, #f195b905 1px, transparent 1px);
}
html[data-theme] :is(button, a, input, textarea, select, summary):focus-visible {
  outline-color: var(--accent);
}
html[data-theme] :is(input[type="checkbox"], input[type="radio"], input[type="range"]) { accent-color: var(--accent); }
html[data-theme] ::selection { background: color-mix(in srgb, var(--accent) 26%, transparent); }

/* Shell and navigation */
html[data-theme] .app-shell { background: color-mix(in srgb, var(--surface) 72%, transparent); border-color: var(--line); }
html[data-theme] .sidebar { background: var(--sidebar); border-color: var(--line); color: var(--ink); }
html[data-theme] .sidebar::before { background: var(--surface); border-color: var(--line); box-shadow: var(--shadow); }
html[data-theme] .nav-scrolled .sidebar { background: color-mix(in srgb, var(--sidebar) 96%, transparent); }
html[data-theme] .brand strong,
html[data-theme] .topbar h1,
html[data-theme] .section-heading h2 { color: var(--ink); }
html[data-theme] :is(.brand small, .nav-button span) { color: var(--muted); }
html[data-theme] .nav-button,
html[data-theme] .nav-button::before { color: var(--ink); }
html[data-theme] .nav-button:is(:hover, :focus-visible) { color: var(--accent); background: var(--accent-soft); }
html[data-theme] .nav-button.active,
html[data-theme] .nav-button.active::before,
html[data-theme] .nav-button.active span { color: var(--accent); }
html[data-theme] .topbar {
  border-color: var(--line-bright);
  background: linear-gradient(100deg, color-mix(in srgb, var(--accent) 17%, var(--surface)) 0 35%,
    var(--surface) 35.1% 70%, var(--surface-soft) 70.1%);
}
html[data-theme] .topbar::before { color: color-mix(in srgb, var(--accent) 13%, transparent); }
html[data-theme] .topbar::after { background: repeating-linear-gradient(90deg, transparent 0 calc(17% - 1px), color-mix(in srgb, var(--accent) 13%, transparent) 17%); }
html[data-theme] :is(.topbar .eyebrow, .eyebrow, .text-button, .link-button) { color: var(--accent); }
html[data-theme] :is(.text-button, .link-button):hover { color: var(--accent-dark); }

/* Cards, buttons, forms and segmented controls */
html[data-theme] :is(.focus-card, .progress-card, .panel, .practice-card, .notice,
  .external-tool-card, .tool-workspace, .exam-paper-card, .mock-question,
  .practice-question-card, .exam-result, .schedule-course, .schedule-day,
  .schedule-empty, .mock-empty, .attempt-list article, .practice-setup,
  .practice-ready, .knowledge-card, .mistake-entry, .paper-card) {
  border-color: var(--line); background: var(--surface); color: var(--ink); box-shadow: var(--shadow);
}
html[data-theme] .focus-card { background: linear-gradient(140deg, var(--surface) 0 62%, var(--surface-soft) 62%); }
html[data-theme] .focus-card::after { color: var(--line-bright); }
html[data-theme] :is(.focus-card h2, .progress-card h3, .panel h3, .plan-item strong,
  .metric-row strong, .ring span, .practice-question .term, .mistake-entry h3,
  .exam-paper-card h3, .question-content h3, .practice-question-card h3,
  .mock-overview strong, .review-metrics strong, .exam-runner-head h2,
  .exam-report-ready strong) { color: var(--ink); }
html[data-theme] :is(.focus-card p:not(.eyebrow), .phase span, .phase small,
  .task-timer, .task-timer-reset, .daily-progress-strip, .daily-progress-strip strong,
  .exam-report-ready span) { color: var(--muted); }
html[data-theme] .phase { border-color: var(--line); background: var(--surface-2); }
html[data-theme] .ring { background: conic-gradient(var(--accent) var(--progress), var(--line) 0); }
html[data-theme] .ring::before { background: var(--surface); }
html[data-theme] :is(.plan-grid, .metric-row, .review-metrics, .mock-overview, .tool-card-grid) { border-color: var(--line); background: var(--line); }
html[data-theme] :is(.metric-row div, .review-metrics article, .mock-overview article) { background: var(--surface); color: var(--ink); }
html[data-theme] :is(.primary, .primary-button, .n1-user-submit, #n1UserLogout,
  .daily-splash-enter, .book-open, .epub-loading button) {
  border-color: var(--accent); background: var(--accent); color: #fff;
}
html[data-theme="night"] :is(.primary, .primary-button, .n1-user-submit, #n1UserLogout,
  .daily-splash-enter, .book-open) { color: #291321; }
html[data-theme] :is(.primary, .primary-button, .n1-user-submit, #n1UserLogout,
  .daily-splash-enter, .book-open):hover { border-color: var(--accent-dark); background: var(--accent-dark); }
html[data-theme] :is(.secondary, .secondary-button, .file-button, .tool-quick-links a,
  .timer-controls button, .timer-menu button, .n1-code-send) {
  border-color: var(--line-bright); background: var(--surface-soft); color: var(--accent-dark);
}
html[data-theme] :is(.secondary, .secondary-button, .file-button, .tool-quick-links a,
  .n1-code-send):hover { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-dark); }
html[data-theme] :is(.segmented, .mock-mode-switch, .schedule-switch) { border-color: var(--line); background: var(--surface-soft); }
html[data-theme] :is(.segmented button, .mock-mode-switch button, .schedule-switch button) { color: var(--muted); }
html[data-theme] :is(.segmented button.active, .mock-mode-switch button.active, .schedule-switch button.active) { background: var(--surface); color: var(--accent-dark); }
html[data-theme] :is(.segmented button, .mock-mode-switch button, .schedule-switch button):hover { color: var(--accent-dark); }
html[data-theme] :is(.search, .select-label) { border-color: var(--line); background: var(--surface); }
html[data-theme] :is(input, select, textarea, .status-select) { border-color: var(--line-bright); color: var(--ink); }
html[data-theme] :is(.mistake-form input, .mistake-form select, .mistake-form textarea,
  .profile-form input, .practice-setup select, .n1-user-dialog input,
  .admin-form input, .admin-form textarea, .admin-form select, .search-form input) {
  border-color: var(--line-bright); background: var(--surface); color: var(--ink);
}
html[data-theme] :is(input, textarea)::placeholder { color: var(--muted); }
html[data-theme] :is(.badge, .knowledge-status, .tool-availability, .course-state, .schedule-week,
  .notice code) { border-color: var(--line); background: var(--surface-soft); color: var(--ink); }
html[data-theme] .toast { border-color: var(--line-bright); background: var(--surface-raised); color: var(--ink); box-shadow: var(--shadow); }

/* Home, progress, and timers */
html[data-theme] .daily-sentence--home { background: linear-gradient(125deg, color-mix(in srgb, var(--accent) 9%, transparent), transparent 65%), var(--surface); }
html[data-theme] .daily-sentence__toggle:hover,
html[data-theme] .daily-sentence__context { background: color-mix(in srgb, var(--accent) 8%, var(--surface)); }
html[data-theme] .site-guide {
  --guide-ink: var(--ink); --guide-muted: var(--muted); --guide-surface: var(--surface);
  --guide-panel: var(--surface-2); --guide-line: var(--line); --guide-accent: var(--accent);
}
html[data-theme] .splash-intro,
html[data-theme] .splash-intro[data-playing] { background: var(--paper); color: var(--ink); }
html[data-theme] .splash-intro .splash-intro__title,
html[data-theme] .splash-intro[data-playing] .splash-intro__title { color: var(--ink); }
html[data-theme] .splash-intro .splash-intro__title span { color: var(--accent); }
html[data-theme] .daily-sentence--splash {
  --daily-ink: var(--ink); --daily-muted: var(--muted); --daily-accent: var(--accent); --daily-line: var(--line);
}
html[data-theme] #dashboardView .plan-item { border-color: var(--line); background: var(--surface); }
html[data-theme] #dashboardView .plan-item:hover { background: var(--surface-2); }
html[data-theme] #dashboardView .plan-item.done { border-color: var(--line-bright); background: var(--surface-soft); }
html[data-theme] #dashboardView .plan-item.border-glow-card { --card-bg: var(--surface) !important; }
html[data-theme] #dashboardView .plan-item.border-glow-card:hover { --card-bg: var(--surface-2) !important; }
html[data-theme] #dashboardView .plan-item.border-glow-card.done { --card-bg: var(--surface-soft) !important; }
/* Border Glow writes cyan colors inline when each card mounts. Override every
   layer of the effect so calendar cells and all other glowing cards follow the
   active rose palette in both day and night mode. */
html[data-theme] .border-glow-card {
  --gradient-one: radial-gradient(at 80% 55%, var(--accent) 0px, transparent 50%) !important;
  --gradient-two: radial-gradient(at 69% 34%, color-mix(in srgb, var(--accent) 68%, var(--surface)) 0px, transparent 50%) !important;
  --gradient-three: radial-gradient(at 8% 6%, color-mix(in srgb, var(--accent) 40%, var(--surface)) 0px, transparent 50%) !important;
  --gradient-four: radial-gradient(at 41% 38%, var(--accent) 0px, transparent 50%) !important;
  --gradient-five: radial-gradient(at 86% 85%, color-mix(in srgb, var(--accent) 68%, var(--surface)) 0px, transparent 50%) !important;
  --gradient-six: radial-gradient(at 82% 18%, color-mix(in srgb, var(--accent) 40%, var(--surface)) 0px, transparent 50%) !important;
  --gradient-seven: radial-gradient(at 51% 4%, color-mix(in srgb, var(--accent) 68%, var(--surface)) 0px, transparent 50%) !important;
  --gradient-base: linear-gradient(var(--accent) 0 100%) !important;
  --glow-color: var(--accent) !important;
  --glow-color-60: color-mix(in srgb, var(--accent) 60%, transparent) !important;
  --glow-color-50: color-mix(in srgb, var(--accent) 50%, transparent) !important;
  --glow-color-40: color-mix(in srgb, var(--accent) 40%, transparent) !important;
  --glow-color-30: color-mix(in srgb, var(--accent) 30%, transparent) !important;
  --glow-color-20: color-mix(in srgb, var(--accent) 20%, transparent) !important;
  --glow-color-10: color-mix(in srgb, var(--accent) 10%, transparent) !important;
}
html[data-theme] #dashboardView .task-heading strong { color: var(--ink); }
html[data-theme] :is(.task-timer-state, .task-timer-reset) { color: var(--muted); }
html[data-theme] :is(.task-progress-track, .daily-progress-track) { background: var(--line); }
html[data-theme] #dashboardView .task-timer:hover .task-progress-track { background: var(--accent-soft); border-color: var(--accent); }
html[data-theme] #dashboardView .task-timer:is(:hover, :focus-visible) .task-heading strong { color: var(--accent); }
html[data-theme] .plan-editor,
html[data-theme] .plan-empty { border-color: var(--line); background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
html[data-theme] :is(.plan-editor-head strong, .plan-empty strong) { color: var(--ink); }
html[data-theme] :is(.plan-editor-head p, .plan-editor-empty, .plan-empty p) { color: var(--muted); }
html[data-theme] :is(.plan-editor-row, .plan-add-row) { border-color: var(--line); background: var(--surface-2); }
html[data-theme] .plan-editor-order { color: var(--accent); }
html[data-theme] :is(.plan-editor label, .plan-add-row label) { color: var(--muted); }
html[data-theme] :is(.plan-editor input, .plan-editor select) { border-color: var(--line-bright); background: var(--surface); color: var(--ink); }
html[data-theme] :is(.plan-editor-close, .plan-editor-row-actions button) { border-color: var(--line); background: var(--surface); color: var(--ink); }
html[data-theme] #dashboardView .shredder { color: var(--ink); }
html[data-theme] .shredder__card { border-color: var(--line); background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
html[data-theme] .shredder__item:hover .shredder__card { border-color: var(--accent); background: var(--surface-2); }
html[data-theme] .shredder__drag,
html[data-theme] .shredder__finish { border-color: var(--line-bright); background: var(--surface-soft); color: var(--accent-dark); }
html[data-theme] .shredder__drag:hover,
html[data-theme] .shredder__finish:hover { background: var(--accent-soft); color: var(--accent-dark); }
html[data-theme] .shredder__card .task-heading strong { color: var(--ink); }
html[data-theme] .shredder__card :is(.task-timer-state, .task-timer-reset) { color: var(--muted); }
html[data-theme] .shredder__card .task-progress-track { background: var(--line); }
html[data-theme] .shredder__card .task-progress-fill { background: var(--accent); }
html[data-theme] .shredder__card .task-progress-glint { background: linear-gradient(90deg, transparent, var(--accent), #fff, transparent); box-shadow: 0 0 9px var(--accent); }
html[data-theme] .shredder__slit { background: linear-gradient(var(--surface-2) 0 43%, var(--accent) 46% 54%, var(--surface-2) 57% 100%); box-shadow: inset 0 0 8px #0003, 0 0 12px color-mix(in srgb, var(--accent) 22%, transparent); }
html[data-theme] .shredder__slit span { background: var(--surface); color: var(--muted); }
html[data-theme] .shredder__slit:is(.is-over, .is-feeding) { box-shadow: inset 0 0 8px #0003, 0 0 22px color-mix(in srgb, var(--accent) 58%, transparent); }
html[data-theme] .shredder__fall { background: linear-gradient(color-mix(in srgb, var(--accent) 9%, transparent), transparent 78%); }
html[data-theme] .shredder__all-done { border-color: var(--line); color: var(--ink); background: var(--surface-soft); }
html[data-theme] .shredder__completed { border-color: var(--line); }
html[data-theme] .timer-widget,
html[data-theme] .timer-widget.timer-floating-dock { --timer-color: var(--accent); border-color: var(--line-bright); border-top-color: var(--accent); background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
html[data-theme] .timer-widget .timer-display { color: var(--accent); text-shadow: none; }
html[data-theme] .timer-widget.completed .timer-display { color: var(--danger); }
html[data-theme] .timer-head { border-color: var(--line); background: var(--surface-soft); }
html[data-theme] :is(.timer-menu, .timer-restore) { border-color: var(--line); background: var(--surface); color: var(--ink); }
html[data-theme] .timer-progress { background: var(--line); }

/* Search, dictionary and study center */
html[data-theme="day"] #knowledgeView .toolbar .search.gooey-search {
  --gs-surface: #fce7ef; --gs-bubble: #ad416c; --gs-ink: #543045;
  --gs-muted: #826675; --gs-focus: #a93463;
}
html[data-theme="night"] #knowledgeView .toolbar .search.gooey-search {
  --gs-surface: #3b2535; --gs-bubble: #cb7197; --gs-ink: #f9edf3;
  --gs-muted: #c8aebc; --gs-focus: #f195b9;
}
html[data-theme] :is(.flip-card, .knowledge-flip-card) { --fc-bg: var(--surface); --fc-ink: var(--ink); }
html[data-theme] .flip-card__face { border-color: var(--line); }
html[data-theme] .knowledge-flip-card .flip-card__face--front {
  border-color: var(--line-bright); background: radial-gradient(circle at 88% 8%, color-mix(in srgb, var(--accent) 12%, transparent), transparent 34%), var(--surface); color: var(--ink);
}
html[data-theme] .knowledge-flip-card .flip-card__face--front::before { background: linear-gradient(90deg, var(--accent-dark), var(--accent), transparent 82%); }
html[data-theme] .knowledge-flip-card .flip-card__face--back { background: var(--surface); }
html[data-theme] .knowledge-flip-card .flip-card__face--back > header { border-color: var(--line); color: var(--muted); }
html[data-theme] :is(.knowledge-flip-card .flip-card__face--front > strong, .knowledge-heading strong,
  .mistake-card-answer strong, .mistake-empty strong, .mistake-retest-head h3, .mistake-retest-question) { color: var(--ink); }
html[data-theme] :is(.knowledge-card-topline, .knowledge-card-meaning, .knowledge-card-back-scroll dt,
  .knowledge-flip-hint, .knowledge-flip-card .flip-card__face--front > small, .knowledge-meaning,
  .mistake-card-topline, .mistake-card-answer, .mistake-detail, .mistake-detail p) { color: var(--muted); }
html[data-theme] :is(.knowledge-card-kind, .mistake-card-kind, .mistake-detail summary) { color: var(--accent); }
html[data-theme] .knowledge-card-back-scroll dd { color: var(--ink); }
html[data-theme] :is(.knowledge-body, .answer-box, .example-pair, .mistake-retest-result) { border-color: var(--line); background: var(--surface-2); }
html[data-theme] .knowledge-card summary:hover { background: var(--surface-soft); }
html[data-theme] :is(#knowledgeList, .animated-list-scroll, .animated-react-scroll) { scrollbar-color: var(--line-bright) var(--surface-2); }
html[data-theme] .animated-list-item.is-list-selected { border-color: var(--accent) !important; background: var(--surface-soft) !important; box-shadow: inset 3px 0 var(--accent), var(--shadow) !important; }
html[data-theme] :is(.animated-list-gradient--top, .animated-react-gradient.top) { background: linear-gradient(var(--paper), transparent); }
html[data-theme] :is(.animated-list-gradient--bottom, .animated-react-gradient.bottom) { background: linear-gradient(transparent, var(--paper)); }
html[data-theme] .mistake-toolbar { border-color: var(--line); border-left-color: var(--accent); background: var(--surface-soft); }
html[data-theme] :is(.mistake-entry, .mistake-retest) { border-color: var(--line); border-top-color: var(--accent); background: var(--surface); }
html[data-theme] .mistake-retest-options label { border-color: var(--line); background: var(--surface); color: var(--ink); }
html[data-theme] .mistake-retest-options label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
html[data-theme] .schedule-summary { border-color: var(--line-bright); background: var(--surface-soft); color: var(--ink); }
html[data-theme] .schedule-week { color: var(--accent-dark) !important; }
html[data-theme] .schedule-course:not([class*="tone-"]) { --course: var(--accent); }
html[data-theme] .course-main p { color: var(--muted); }
html[data-theme] .schedule-day.today { border-color: var(--accent); box-shadow: inset 0 2px var(--accent); }
html[data-theme] :is(.practice-ready, .exam-report-ready, .exam-subsection-title, .question-passage,
  .passage-table, .mock-overview article, .question-number) { border-color: var(--line); background: var(--surface-2); color: var(--ink); }
html[data-theme] .exam-runner-head { border-color: var(--line); background: var(--surface); }
html[data-theme] :is(#mockView .eyebrow, .exam-paper-card p, .exam-section-title span, .question-meta) { color: var(--accent); }
html[data-theme] .exam-section-title { border-color: var(--line-bright); }
html[data-theme] .mock-option { border-color: var(--line); background: var(--surface); color: var(--ink); }
html[data-theme] .mock-option:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }

/* Books, tools, and account */
html[data-theme] #booksView .book-card { border-color: var(--line); border-top-color: var(--accent); background: var(--surface); box-shadow: var(--shadow); }
html[data-theme] #booksView .book-info .eyebrow { color: var(--accent); }
html[data-theme] #booksView .book-info h3 { color: var(--ink); }
html[data-theme] #booksView .book-info > p:not(.eyebrow),
html[data-theme] #booksView .book-meta span { color: var(--muted); }
html[data-theme] #booksView .book-meta span { border-color: var(--line); }
html[data-theme] #booksView .book-audio { border-color: var(--line-bright); color: var(--accent-dark); background: var(--surface-soft); }
html[data-theme] #booksView .book-open:focus-visible,
html[data-theme] #booksView .book-audio:focus-visible { outline-color: var(--accent); }
html[data-theme] .n1-bubble-overlay { border-color: var(--line); background: radial-gradient(circle at 82% 18%, color-mix(in srgb, var(--accent) 13%, transparent), transparent 37%), var(--paper); }
html[data-theme] .n1-bubble-overlay.is-side-rail { border-color: var(--line); background: var(--surface); }
html[data-theme] .n1-bubble-pill { border-color: var(--line); background: var(--surface); color: var(--ink); box-shadow: none; }
html[data-theme] .n1-bubble-pill:is(:hover, :focus-visible) { border-color: var(--accent); background: var(--surface-soft); color: var(--ink); }
html[data-theme] :is(.n1-bubble-brand #n1UserButton, .n1-bubble-toggle, .n1-theme-toggle) { border-color: var(--line-bright); background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
html[data-theme] .n1-bubble-toggle span { background: var(--ink); }
html[data-theme] :is(.n1-bubble-brand #n1UserButton, .n1-bubble-toggle, .n1-theme-toggle):hover { border-color: var(--accent); background: var(--surface-soft); color: var(--accent-dark); }
html[data-theme] .n1-theme-switch { --gooey-ink: var(--ink); --gooey-selected: var(--accent-dark); --color-1: var(--accent); --color-2: var(--accent-dark); --color-3: var(--line-bright); --color-4: var(--accent-soft); border-color: var(--line-bright); background: var(--surface-soft); box-shadow: var(--shadow); }
html[data-theme] .gooey-nav-container li::after,
html[data-theme] .gooey-nav-container .effect.filter::after { background: var(--surface); }
html[data-theme] .gooey-nav-container button:focus-visible { outline-color: var(--accent); }
html[data-theme] .n1-user-modal { background: #35182677; }
html[data-theme] .n1-user-dialog { border-color: var(--line); border-top-color: var(--accent); background: var(--surface-raised); color: var(--ink); box-shadow: var(--shadow); }
html[data-theme] :is(.n1-user-dialog h2, .n1-user-dialog #n1UserSigned strong) { color: var(--ink); }
html[data-theme] :is(.n1-user-kicker, .n1-auth-tabs button.active) { color: var(--accent); }
html[data-theme] :is(.n1-user-copy, .n1-user-dialog label, .n1-user-dialog #n1UserSigned p, .n1-bind-note) { color: var(--muted); }
html[data-theme] .n1-auth-tabs button.active { border-color: var(--accent); }

/* Admin */
html[data-theme] .admin-sidebar { border-color: var(--line); background: var(--sidebar); }
html[data-theme] .admin-brand > span { border-color: var(--line-bright); background: var(--accent-soft); color: var(--accent); }
html[data-theme] :is(.admin-brand strong, .workspace-header h1, .dashboard-heading h2,
  .content-heading h2, .management-panel h2, .admin-panel h2, .data-panel h2,
  .login-card h1, .paper-card h2, .content-list strong, .dataset-list strong,
  .schedule-table td strong) { color: var(--ink); }
html[data-theme] :is(.admin-brand small, .metric-grid span, .paper-card ul) { color: var(--muted); }
html[data-theme] .sidebar-nav a { color: var(--ink); }
html[data-theme] .sidebar-nav a span { color: var(--muted); }
html[data-theme] .sidebar-nav a:hover { background: var(--surface-soft); color: var(--accent); }
html[data-theme] .sidebar-nav a.active { background: var(--accent-soft); color: var(--accent-dark); }
html[data-theme] .workspace-header { border-color: var(--line); }
html[data-theme] .n1-admin-header-actions > a { color: var(--accent); }
html[data-theme] :is(.metric-grid article, .management-panel, .admin-panel, .data-panel,
  .paper-card, .login-card) { border-color: var(--line); background: var(--surface); box-shadow: var(--shadow); }
html[data-theme] :is(.sync-note, .dataset-list div, .content-list article, .data-hero article) { border-color: var(--line); background: var(--surface-2); color: var(--ink); }
html[data-theme] .content-tabs a { border-color: var(--line); background: var(--surface-soft); color: var(--ink); }
html[data-theme] .content-tabs a.active { background: var(--accent); color: #fff; }
html[data-theme] .schedule-table th { background: var(--surface-soft); color: var(--ink); }
html[data-theme] :is(.paper-card-head span, .subtle-link, .row-actions a) { color: var(--accent); }

/* Existing motion components keep their behavior and take the shared palette. */
html[data-theme] body .rubber-segment.rubber-segment {
  --rs-track: var(--surface-soft); --rs-line: var(--line); --rs-ink: var(--muted);
  --rs-hover-ink: var(--ink); --rs-thumb: var(--surface); --rs-thumb-held: var(--accent-soft);
  --rs-thumb-ink: var(--accent-dark); --rs-focus: var(--accent);
}
html[data-theme] .dictionary-search-options.squish-switch-root { --ss-track: var(--line-bright); --ss-track-on: var(--accent); --ss-thumb-color: var(--surface); --ss-thumb-on: var(--surface); }
html[data-theme] .n1-back-to-top { background: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 22%, transparent), var(--shadow); }
html[data-theme] .n1-back-to-top:is(:hover, :focus-visible) { background: var(--accent-dark); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 28%, transparent), var(--shadow); }
html[data-theme="night"] .n1-back-to-top { color: #291321; }
html[data-theme] .n1-back-to-top:focus-visible { outline-color: var(--accent); }
html[data-theme] .selection-lookup { border-color: var(--line-bright); background: var(--surface-raised); color: var(--ink); box-shadow: var(--shadow); }
html[data-theme] .selection-lookup__heading { border-color: var(--line); color: var(--accent); }
html[data-theme] .selection-lookup__close { color: var(--muted); }
html[data-theme] .selection-lookup__close:hover { background: var(--surface-soft); color: var(--ink); }
html[data-theme] .selection-lookup__word,
html[data-theme] .selection-lookup__row,
html[data-theme] .selection-lookup__result { border-color: var(--line); }
html[data-theme] :is(.selection-lookup__word, .selection-lookup__result strong) { color: var(--ink); }
html[data-theme] :is(.selection-lookup__message, .selection-lookup__preview) { color: var(--muted); }
html[data-theme] .selection-lookup__result small { color: var(--accent); }
html[data-theme] .selection-lookup__result:is(:hover, :focus-visible) { background: var(--surface-soft); }
html[data-theme] :is(.selection-lookup__add, .selection-lookup__all) { border-color: var(--line-bright); background: var(--surface-soft); color: var(--accent-dark); }
html[data-theme] :is(.selection-lookup__add, .selection-lookup__all):hover { background: var(--accent-soft); color: var(--accent-dark); }
html[data-theme] .selection-lookup button:focus-visible { outline-color: var(--accent); }
html[data-theme] body .topbar .tech-text,
html[data-theme] body .workspace-header .tech-text { --tech-text-color: var(--ink); --tech-text-accent: var(--accent); }

/* Dedicated reading and practice pages are outside the main app shell. */
html[data-theme="day"]:has(.reader-shell) {
  --rd-bg: #fff6fa; --rd-bar: #ffffff; --rd-stage: #f6e9ef;
  --rd-line: #e2c6d2; --rd-ink: #422a38; --rd-muted: #765f6d;
  --rd-accent: #a93463; --rd-active: #fbe1eb;
}
html[data-theme="night"]:has(.reader-shell) {
  --rd-bg: #1b121a; --rd-bar: #291b27; --rd-stage: #1a1119;
  --rd-line: #604050; --rd-ink: #f9edf3; --rd-muted: #c8aebc;
  --rd-accent: #f195b9; --rd-active: #512e41;
}
html[data-theme] .reader-stage { background: radial-gradient(circle at 50% 10%, color-mix(in srgb, var(--rd-accent) 13%, transparent), transparent 45%), var(--rd-stage); }
html[data-theme] .reader-text-layer ::selection { color: transparent; background: #cc669966; }
html[data-theme] body .reader-shell .rubber-segment.rubber-segment {
  --rs-track: var(--rd-active); --rs-line: var(--rd-line); --rs-ink: var(--rd-muted);
  --rs-hover-ink: var(--rd-ink); --rs-thumb: var(--rd-bar); --rs-thumb-held: var(--rd-active);
  --rs-thumb-ink: var(--rd-accent); --rs-focus: var(--rd-accent);
}
html[data-theme] .reader-marks { background: var(--rd-active); border-color: var(--rd-line); }
html[data-theme] .reader-marks .reader-icon-tool { color: var(--rd-ink); }
html[data-theme] .reader-marks .reader-icon-tool:is(:hover, :focus-visible, .is-active) { background: var(--rd-bar); color: var(--rd-accent); box-shadow: inset 0 0 0 1px var(--rd-line); }
html[data-theme] .reader-marks-divider { background: var(--rd-line); }

html[data-theme="day"]:has(.epub-shell) { --epub-desk: #f5e9ef; --epub-paper: #faf8f2; }
html[data-theme="night"]:has(.epub-shell) { --epub-desk: #1b121a; --epub-paper: #261d25; }
html[data-theme] .epub-header,
html[data-theme] .epub-toolbar,
html[data-theme] .epub-footer { border-color: var(--line); background: var(--surface); color: var(--ink); }
html[data-theme] .epub-back { color: var(--accent); }
html[data-theme] :is(.epub-heading small, .epub-footer span) { color: var(--muted); }
html[data-theme] :is(.epub-header, .epub-toolbar, .epub-footer) button {
  border-color: var(--line-bright); color: var(--ink); background: var(--surface-soft);
}
html[data-theme] :is(.epub-header, .epub-toolbar, .epub-footer) button:hover { border-color: var(--accent); background: var(--accent-soft); }
html[data-theme] .epub-main { background: radial-gradient(ellipse at 50% 0%, color-mix(in srgb, var(--accent) 10%, var(--epub-desk)), var(--epub-desk) 70%); }
html[data-theme] .epub-stage { border-color: var(--line-bright); }
html[data-theme] .epub-loading { color: var(--ink); }
html[data-theme] #epub-toc { border-color: var(--line-bright); color: var(--ink); background: var(--surface-raised); }
html[data-theme] .epub-toc-head { border-color: var(--line); }
html[data-theme] .epub-toc-list button:hover { background: var(--surface-soft); }

html[data-theme] .audio-header { border-color: var(--line); background: var(--surface); color: var(--ink); }
html[data-theme] .audio-header a,
html[data-theme] .audio-kicker { color: var(--accent); }
html[data-theme] .audio-panel { border-color: var(--line); border-top-color: var(--accent); background: var(--surface); color: var(--ink); }
html[data-theme] :is(.audio-hero p:last-child, #audio-status, .audio-panel-head span) { color: var(--muted); }
html[data-theme] .audio-transport button,
html[data-theme] .audio-track-list button { border-color: var(--line-bright); background: var(--surface-soft); color: var(--ink); }
html[data-theme] .audio-transport button:hover,
html[data-theme] .audio-track-list button:hover { border-color: var(--accent); background: var(--accent-soft); }
html[data-theme] .audio-track-list button[aria-current="true"] { border-color: var(--accent); background: var(--accent); color: #fff; }
html[data-theme] .audio-disc-heading { border-color: var(--line); color: var(--muted); }

html[data-theme="day"]:has(.retest-topbar) {
  --rt-bg: #fff6fa; --rt-panel: #ffffff; --rt-panel-alt: #fff0f5;
  --rt-line: #ead3dd; --rt-text: #422a38; --rt-muted: #765f6d;
  --rt-accent: #a93463; --rt-accent-ink: #ffffff;
}
html[data-theme="night"]:has(.retest-topbar) {
  --rt-bg: #1b121a; --rt-panel: #291b27; --rt-panel-alt: #33212f;
  --rt-line: #604050; --rt-text: #f9edf3; --rt-muted: #c8aebc;
  --rt-accent: #f195b9; --rt-accent-ink: #291321;
}
html[data-theme]:has(.retest-topbar) body { background: radial-gradient(circle at 85% 0%, color-mix(in srgb, var(--rt-accent) 13%, transparent), transparent 38%), var(--rt-bg); color: var(--rt-text); }
