/* Shared appearance controls, scalable type and a full dark palette. */
:root {
  --surface: #fff;
  --surface-raised: #f7f9fa;
  --font-scale: 1;
  color-scheme: light;
}
html[data-theme="dark"] {
  --ink: #edf3fa;
  --muted: #b7c5d7;
  --forest: #101e32;
  --green: #67d9e8;
  --line: #35455d;
  --bg: #0f172a;
  --surface: #172235;
  --surface-raised: #1e293b;
  --surface-muted: #233248;
  --green-soft: #18364a;
  --green-border: #3f7088;
  --green-text: #86dfeb;
  --red: #f0a19a;
  --soft-shadow: 0 5px 24px rgb(0 0 0 / 12%);
  color-scheme: dark;
}
.page { min-height: 100svh; display: flex; flex-direction: column; }
.page>main { width: 100%; flex: 1; }
.page>header { flex-wrap: wrap; }
.breadcrumb { color: var(--ink); font-size: .9375rem; }
.header-right { margin-left: auto; flex-wrap: wrap; justify-content: flex-end; }
.appearance-trigger { gap: 7px; flex-shrink: 0; white-space: nowrap; }
.appearance-trigger svg { width: 19px; height: 19px; flex-shrink: 0; }
.auth-appearance { display: none; }
.signed-out .auth-appearance {
  display: inline-flex;
  position: absolute;
  top: 22px;
  right: 24px;
  z-index: 2;
  background: rgb(255 255 255 / 9%);
  border-color: rgb(221 241 245 / 35%);
  color: #eff8fa;
}
.signed-out .auth-appearance:hover { background: rgb(255 255 255 / 16%); border-color: #c4dee4; }
.signed-out .auth-screen { padding-top: 90px; }
.auth-card { overflow-wrap: anywhere; }

.home-hero { min-height: 440px; margin: 0; padding: 48px; isolation: isolate; }
.home-hero .hero-copy { max-width: 59%; position: relative; z-index: 1; }
.home-hero h1 { font-size: clamp(2rem, calc(3vw * var(--font-scale)), 3rem); color: #fff; line-height: 1.22; letter-spacing: -1.3px; }
.home-hero p { font-size: 1rem; max-width: 40ch; margin-top: 19px; }
.home-hero .forklift-art { width: 46%; height: auto; max-height: 360px; right: 3px; bottom: 29px; }
.hero-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 20px; margin-top: 30px; }
.hero-actions .button { gap: 15px; }
.hero-link { color: #edf6f8; font-size: .9375rem; text-decoration: underline; text-underline-offset: 5px; }
.hero-link:hover { color: var(--lime); }

.appearance-dialog {
  width: min(500px, calc(100% - 32px));
  padding: 32px;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
}
.appearance-dialog h2 { padding-right: 27px; font-size: 1.5rem; }
.appearance-dialog h3 { font-size: 1rem; letter-spacing: -.2px; }
.appearance-section { margin-top: 27px; }
.text-size-controls { display: flex; align-items: center; gap: 14px; margin: 14px 0 9px; }
.text-size-controls .button { width: 60px; min-height: 48px; padding: 9px; font-size: 1.125rem; }
#appearance-size { min-width: 65px; text-align: center; font-size: 1rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.appearance-dialog .text-button { font-size: .8125rem; min-height: 38px; }
.theme-options { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 14px; }
.theme-option { display: flex; flex-direction: column; align-items: flex-start; gap: 9px; padding: 12px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface); color: var(--ink); font-size: .8125rem; font-weight: 600; }
.theme-option:hover { border-color: var(--green-border); background: var(--surface-raised); }
.theme-option[aria-pressed="true"] { border-color: #457884; background: var(--green-soft); box-shadow: inset 0 0 0 1px #457884; }
.theme-preview { display: block; position: relative; width: 100%; height: 48px; border: 1px solid rgb(88 110 115 / 35%); border-radius: 6px; overflow: hidden; }
.theme-preview::before { content: ''; position: absolute; inset: 0 auto 0 0; width: 23%; background: #192f38; }
.theme-preview::after { content: ''; position: absolute; left: 35%; right: 12%; top: 12px; height: 6px; border-radius: 2px; background: #8cb5be; box-shadow: 0 12px 0 rgb(116 142 148 / 40%); }
.preview-light { background: #f4f6f7; }
.preview-dark { background: #1b272c; }
.preview-system { background: linear-gradient(120deg, #f4f6f7 50%, #1b272c 50%); }
.appearance-dialog .appearance-hint { font-size: .8125rem; color: var(--muted); margin-top: 25px; padding-top: 18px; border-top: 1px solid var(--line); }

/* Actual surfaces and semantic feedback are recolored; diagrams retain their white canvas. */
[data-theme="dark"] .page>header { background: rgb(23 34 53 / 97%); }
[data-theme="dark"] :is(.panel, .mode-card, .stat-grid .stat, .oral-index, .oral-foundations, .auth-card, dialog, .study-view) { background: var(--surface); color: var(--ink); border-color: var(--line); }
[data-theme="dark"] :is(input, select, textarea, .question-notes textarea) { color: var(--ink); background-color: #111d30; border-color: #465b76; }
[data-theme="dark"] :is(input, textarea)::placeholder { color: #9aaaae; }
[data-theme="dark"] select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' fill='none' stroke='%23bcced2' stroke-width='1.8'%3E%3Cpath d='m3 5 4 4 4-4'/%3E%3C/svg%3E"); }
[data-theme="dark"] :is(.field label, .oral-draft-label, .question-notes label, dialog label, .auth-card label, .oral-reading, .oral-followup h4, .oral-recall-prompt, .oral-self-rate>p) { color: #d1e0e3; }
[data-theme="dark"] :is(.oral-reading h3, .oral-foundations>summary, .oral-full-detail>summary, .question-notes>summary, .timer) { color: var(--ink); }
[data-theme="dark"] :is(#account-email, .question-count, .oral-scope) { color: var(--muted); }
[data-theme="dark"] .course-chip { background: #293b43; color: #c9dfe4; }
[data-theme="dark"] .avatar { background: #2d4149; color: #e3f2f5; }
[data-theme="dark"] .progress-track { background: #2d4048; }
[data-theme="dark"] .progress-track>span { background: #81b4c0; }
[data-theme="dark"] :is(.text-link, .text-button, .source-link, .question-source, .oral-references a:not(.button), .oral-topic small) { color: var(--green-text); }
[data-theme="dark"] :is(.button.secondary, .study-view, .question-map button) { color: #e0ebee; background: var(--surface-raised); border-color: #485c61; }
[data-theme="dark"] :is(.button.secondary:hover, .study-view:hover, .question-map button:hover) { background: #2b3f47; border-color: #7ea8b2; }
[data-theme="dark"] :is(.button.primary, .oral-tabs .button[aria-pressed="true"]) { background: #9ad6e4; color: #172a32; border-color: #9ad6e4; }
[data-theme="dark"] :is(.button.primary:hover, .oral-tabs .button[aria-pressed="true"]:hover) { background: #b3e2ed; border-color: #b3e2ed; }
[data-theme="dark"] :is(.study-view.active, .question-bookmark.is-saved, .oral-topic.current, .question-map button.current) { background: #29424c; color: #d1ebf1; border-color: #7fb2be; }
[data-theme="dark"] :is(.study-view [data-study-count], .note-saved-label) { background: var(--surface-muted); color: #d1e3e7; }
[data-theme="dark"] .study-view.active [data-study-count] { background: #3b5b62; color: #e3f3f7; }
[data-theme="dark"] .question-notes { background: #162328; border-color: var(--line); }
[data-theme="dark"] .question-notes>summary::marker { color: #9ed0db; }
[data-theme="dark"] .answer { background: var(--surface); border-color: #485c60; color: var(--ink); }
[data-theme="dark"] .answer:hover { background: #23363e; border-color: #83b1bb; }
[data-theme="dark"] .answer-letter { background: #2a3940; border-color: #485c60; color: #d5e7eb; }
[data-theme="dark"] .answer.selected { background: #243f4b; border-color: #91bfc9; }
[data-theme="dark"] .answer.correct { background: #203a45; border-color: #6badbc; box-shadow: inset 3px 0 0 #6badbc; }
[data-theme="dark"] .answer.correct .answer-letter { background: #36525e; color: #e0f4f8; border-color: #6badbc; }
[data-theme="dark"] .answer.wrong { background: #472921; border-color: #d78b76; box-shadow: inset 3px 0 0 #d78b76; }
[data-theme="dark"] .answer.wrong .answer-letter { background: #63392e; color: #ffdfd3; border-color: #cb8c77; }
[data-theme="dark"] :is(.explanation, .oral-answer) { background: #20343c; border-color: #567b83; color: #daeaee; }
[data-theme="dark"] :is(.explanation small, .oral-answer .eyebrow, .oral-memory) { color: #bbd3d8; }
[data-theme="dark"] .oral-memory { border-color: #4a666c; }
[data-theme="dark"] :is(.explanation.bad, .study-unavailable, .sync-error) { background: #402a20; color: #f9d0b5; border-color: #875a42; }
[data-theme="dark"] .explanation.bad small { color: #e5baa1; }
[data-theme="dark"] :is(.review-wrong, .failure, .question-personal-status.is-error, .question-note-status.is-error, .auth-card #auth-message) { color: #ffb7a5; }
[data-theme="dark"] :is(.review-correct, .success) { color: #a4d8e4; }
[data-theme="dark"] :is(.rule, .question-map button.answered, .score-circle) { background: #23363e; color: #cee9ef; border-color: var(--line); }
[data-theme="dark"] .rule strong { color: #b6e1eb; }
[data-theme="dark"] .history th { background: #213138; color: #bfd1d5; }
[data-theme="dark"] .history tbody tr:hover { background: #213138; }
[data-theme="dark"] :is(.history th, .history td) { border-color: var(--line); }
[data-theme="dark"] .oral-topic { color: #d2e1e4; }
[data-theme="dark"] .oral-topic>span:first-child { color: #a4cfd9; }
[data-theme="dark"] .oral-topic:hover { background: #283c44; }
[data-theme="dark"] .oral-foundations[open] { background: #1a292f; }
[data-theme="dark"] .oral-reading li::marker { color: #a4cfd9; }
[data-theme="dark"] .oral-answer .eyebrow { color: #b1dee8; }
[data-theme="dark"] :is(.auth-card .platform-brand .brand-wordmark strong, .page>header .header-brand .brand-wordmark strong) { color: #e4eff1; }
[data-theme="dark"] .signed-out { background-color: #0f172a; background-image: radial-gradient(ellipse at 15% 10%, #16364f 0, transparent 50%); }
[data-theme="dark"] .dialog-close { color: var(--ink); }
[data-theme="dark"] .dialog-close:hover { background: var(--surface-raised); }
[data-theme="dark"] .theme-option[aria-pressed="true"] { border-color: #89b5bf; box-shadow: inset 0 0 0 1px #89b5bf; }
[data-theme="dark"] :is(button, a, input, select, textarea, summary):focus-visible { outline-color: #a4d9e5; }

@media (max-width: 1150px) {
  .home-hero { min-height: 420px; padding: 36px; }
  .home-hero .forklift-art { width: 45%; right: -2px; bottom: 40px; }
  .header-right { gap: 8px; }
}
@media (max-width: 850px) {
  .page>header .breadcrumb { display: block; order: 3; flex-basis: 100%; font-size: .8125rem; padding-top: 8px; border-top: 1px solid var(--line); }
  .appearance-trigger-label { display: none; }
  .header-right .appearance-trigger { min-width: 40px; min-height: 40px; padding: 8px; }
}
@media (max-width: 700px) {
  .home-hero { min-height: 0; padding: 30px 26px 6px; flex-direction: column; align-items: flex-start; }
  .home-hero .hero-copy { max-width: 100%; width: 100%; }
  .home-hero h1 { font-size: 2rem; max-width: 100%; }
  .home-hero h1 br { display: none; }
  .home-hero p { max-width: 100%; font-size: .9375rem; }
  .home-hero .forklift-art { position: relative; inset: auto; width: min(100%, 360px); max-height: none; align-self: center; margin: 14px 0 0; }
  .hero-actions { margin-top: 24px; gap: 17px; }
  .hero-actions .button, .hero-link { font-size: .875rem; }
  .page>header { gap: 10px; }
  .page>header .header-right { gap: 6px; }
  .appearance-dialog { padding: 30px 22px 24px; }
  .theme-options { gap: 7px; }
  .theme-option { padding: 9px; font-size: .75rem; }
  .signed-out .auth-appearance { right: 16px; top: 16px; }
  .signed-out .auth-appearance .appearance-trigger-label { display: inline; }
  html { scroll-padding-top: 160px; }
}
@media (max-width: 600px) {
  .sidebar nav a { overflow-wrap: normal; }
  .home-hero { padding-left: 24px; padding-right: 24px; }
  :is([data-text-size="130"], [data-text-size="140"]) .sidebar nav { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 3px; }
  :is([data-text-size="130"], [data-text-size="140"]) .sidebar nav a { flex-direction: row; justify-content: center; align-items: center; gap: 6px; min-height: 48px; padding: 8px 5px; text-align: left; }
  :is([data-text-size="130"], [data-text-size="140"]) .page { padding-bottom: calc(140px + env(safe-area-inset-bottom, 0px)); }
  :is([data-text-size="130"], [data-text-size="140"]) #toast { bottom: calc(140px + env(safe-area-inset-bottom, 0px)); }
}
@media (max-width: 400px) {
  .theme-options { grid-template-columns: minmax(0, 1fr); }
  .theme-option { flex-direction: row; align-items: center; gap: 13px; }
  .theme-preview { width: 64px; flex: 0 0 64px; height: 38px; }
}

/* Restored dashboard summary follows the selected theme. */
[data-theme="dark"] .source-summary { background: var(--surface); color: var(--ink); border-color: var(--line); }

