/* Shared appearance controls, scalable type and a full dark palette. */
:root {
  --surface: #fff;
  --surface-raised: #f7faf8;
  --font-scale: 1;
  color-scheme: light;
}
html[data-theme="dark"] {
  --ink: #edf5ef;
  --muted: #b0c3b7;
  --forest: #0a2119;
  --green: #8ed4a4;
  --line: #334b3d;
  --bg: #101b16;
  --surface: #19281f;
  --surface-raised: #22362a;
  --surface-muted: #243a2c;
  --green-soft: #203e2c;
  --green-border: #4b7959;
  --green-text: #a5e4b4;
  --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 245 225 / 35%);
  color: #f0faef;
}
.signed-out .auth-appearance:hover { background: rgb(255 255 255 / 16%); border-color: #c4e4c7; }
.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: #edf8ed; 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: #45845b; background: var(--green-soft); box-shadow: inset 0 0 0 1px #45845b; }
.theme-preview { display: block; position: relative; width: 100%; height: 48px; border: 1px solid rgb(88 115 95 / 35%); border-radius: 6px; overflow: hidden; }
.theme-preview::before { content: ''; position: absolute; inset: 0 auto 0 0; width: 23%; background: #123f2d; }
.theme-preview::after { content: ''; position: absolute; left: 35%; right: 12%; top: 12px; height: 6px; border-radius: 2px; background: #8cbe8c; box-shadow: 0 12px 0 rgb(116 148 122 / 40%); }
.preview-light { background: #f4f7f5; }
.preview-dark { background: #1b2c22; }
.preview-system { background: linear-gradient(120deg, #f4f7f5 50%, #1b2c22 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(25 40 31 / 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: #132219; border-color: #49644f; }
[data-theme="dark"] :is(input, textarea)::placeholder { color: #9aae9e; }
[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='%23bcd2c2' 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: #d1e3d5; }
[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: #294332; color: #c9e4ce; }
[data-theme="dark"] .avatar { background: #2d4935; color: #e4f5e3; }
[data-theme="dark"] .progress-track { background: #2d4835; }
[data-theme="dark"] .progress-track>span { background: #87c081; }
[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: #e0eee2; background: var(--surface-raised); border-color: #48614f; }
[data-theme="dark"] :is(.button.secondary:hover, .study-view:hover, .question-map button:hover) { background: #2b4733; border-color: #7eb28c; }
[data-theme="dark"] :is(.button.primary, .oral-tabs .button[aria-pressed="true"]) { background: #b6e49a; color: #173222; border-color: #b6e49a; }
[data-theme="dark"] :is(.button.primary:hover, .oral-tabs .button[aria-pressed="true"]:hover) { background: #cbedb3; border-color: #cbedb3; }
[data-theme="dark"] :is(.study-view.active, .question-bookmark.is-saved, .oral-topic.current, .question-map button.current) { background: #294c34; color: #d1f1d5; border-color: #7fbe8d; }
[data-theme="dark"] :is(.study-view [data-study-count], .note-saved-label) { background: var(--surface-muted); color: #d1e7d5; }
[data-theme="dark"] .study-view.active [data-study-count] { background: #3b6244; color: #e3f7e5; }
[data-theme="dark"] .question-notes { background: #16281c; border-color: var(--line); }
[data-theme="dark"] .question-notes>summary::marker { color: #9edbaf; }
[data-theme="dark"] .answer { background: var(--surface); border-color: #48604e; color: var(--ink); }
[data-theme="dark"] .answer:hover { background: #233e2d; border-color: #83bb92; }
[data-theme="dark"] .answer-letter { background: #2a4031; border-color: #48604e; color: #d5ebd9; }
[data-theme="dark"] .answer.selected { background: #244b31; border-color: #91c99b; }
[data-theme="dark"] .answer.correct { background: #20452d; border-color: #6bbc83; box-shadow: inset 3px 0 0 #6bbc83; }
[data-theme="dark"] .answer.correct .answer-letter { background: #365e3d; color: #e0f8e2; border-color: #6bbc83; }
[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: #203c29; border-color: #568364; color: #daeedc; }
[data-theme="dark"] :is(.explanation small, .oral-answer .eyebrow, .oral-memory) { color: #bbd8c1; }
[data-theme="dark"] .oral-memory { border-color: #4a6c53; }
[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: #a4e4b4; }
[data-theme="dark"] :is(.rule, .question-map button.answered, .score-circle) { background: #233e2a; color: #d5efce; border-color: var(--line); }
[data-theme="dark"] .rule strong { color: #c4ebb6; }
[data-theme="dark"] .history th { background: #21382a; color: #bfd5c5; }
[data-theme="dark"] .history tbody tr:hover { background: #21382a; }
[data-theme="dark"] :is(.history th, .history td) { border-color: var(--line); }
[data-theme="dark"] .oral-topic { color: #d2e4d7; }
[data-theme="dark"] .oral-topic>span:first-child { color: #a4d9ad; }
[data-theme="dark"] .oral-topic:hover { background: #28442f; }
[data-theme="dark"] .oral-foundations[open] { background: #1a2f20; }
[data-theme="dark"] .oral-reading li::marker { color: #a4d9ad; }
[data-theme="dark"] .oral-answer .eyebrow { color: #b1e8bf; }
[data-theme="dark"] :is(.auth-card .platform-brand .brand-wordmark strong, .page>header .header-brand .brand-wordmark strong) { color: #e4f1e6; }
[data-theme="dark"] .signed-out { background-color: #0e1e15; background-image: radial-gradient(ellipse at 15% 10%, #1c4229 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: #8bbf89; box-shadow: inset 0 0 0 1px #8bbf89; }
[data-theme="dark"] :is(button, a, input, select, textarea, summary):focus-visible { outline-color: #b8e5a4; }

@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; }
}
