/* Shared day/night control. The existing light design stays the default. */
:root { color-scheme: light; }
.topbar-actions { display: flex; align-items: center; gap: 20px; }
.theme-toggle {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  flex-shrink: 0; min-width: 85px; min-height: 36px; padding: 8px 11px;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--white); color: var(--ink); font-size:0.9375rem; font-weight: 550;
}
.theme-toggle .icon { width: 16px; height: 16px; }
.theme-toggle:hover { background: var(--green-soft); }
.breadcrumb > .breadcrumb-label { color: var(--muted); }

/* All dark colors are screen-only. Printed documents retain their paper design. */
@media screen {
  html[data-theme="dark"] {
    color-scheme: dark;
    --ink: #e4ece7;
    --muted: #a3b4a8;
    --petrol: #142d25;
    --petrol-dark: #10251e;
    --green: #acd39b;
    --green-soft: #263e2d;
    --paper: #111c18;
    --line: #34483b;
    --white: #1a2a22;
    --amber: #e2c27f;
    --shadow: 0 2px 12px #00000015;
    --surface-raised: #21352a;
    --field: #14241c;
    --accent-ink: #19311e;
    background: var(--paper); color: var(--ink);
  }
  html[data-theme="dark"] body { background: var(--paper); }
  html[data-theme="dark"] :is(button, a, input, select, textarea, summary):focus-visible {
    outline-color: #b4d69f;
  }
  html[data-theme="dark"] :is(.topbar, .panel, .stat-card, .category-tile, .auth-card, .example-box) {
    background: var(--white); border-color: var(--line);
  }
  html[data-theme="dark"] .auth-card { box-shadow: 0 8px 40px #00000012; }
  html[data-theme="dark"] :is(.auth-brand, .skip-link) { color: var(--ink); }
  html[data-theme="dark"] .skip-link { background: var(--white); border-color: var(--green); }
  html[data-theme="dark"] .auth-brand > span { color: var(--muted); border-color: var(--line); }
  html[data-theme="dark"] :is(.auth-intro > p, .auth-benefit, .auth-switch, .auth-illustration,
    .app-footer, .category-tile > p, .category-tile-upcoming h3, .tile-progress, .tile-upcoming-note,
    .recent-item > time, .recent-item > .icon, .bottom-note, .question-reference,
    .help-content, .checkbox-field label, .answer-details > summary, .aside-card p,
    .aside-tip > p, .export-note, .table-category, .table-note, .table-date,
    .history-card > header time, .history-note > p) { color: var(--muted); }
  html[data-theme="dark"] .category-tile-active {
    border-color: #709067; background: linear-gradient(135deg, #1a2a22 50%, #243a2a);
  }
  html[data-theme="dark"] :is(.history-number, .question-number, .category-code,
    .category-tile-upcoming .category-code, .user-avatar, .round-check, .recent-icon,
    .export-icon, .empty-icon, .table-edit, .tile-progress a) {
    color: #b8d7a0; background: var(--green-soft); border-color: #42573e;
  }
  html[data-theme="dark"] :is(.badge-green, .stat-icon-green) { color: #c0dda9; background: #2c432e; }
  html[data-theme="dark"] .badge-neutral { color: #bdcabc; background: #303d33; }
  html[data-theme="dark"] :is(.badge-amber, .stat-icon-amber) { color: #e7ca91; background: #433a25; }
  html[data-theme="dark"] .stat-icon-blue { color: #b3d3e1; background: #263e48; }
  html[data-theme="dark"] :is(.button-primary, .setup-steps .is-active b) {
    background: #acd39b; color: var(--accent-ink); border-color: #acd39b;
  }
  html[data-theme="dark"] .button-primary:hover { background: #c1dfb3; }
  html[data-theme="dark"] .button-secondary {
    background: var(--surface-raised); color: var(--ink); border-color: #4c6350;
  }
  html[data-theme="dark"] .button-secondary:hover { background: #2d4533; border-color: #8ba87b; }
  html[data-theme="dark"] .button-light { background: #cadfae; color: var(--accent-ink); }
  html[data-theme="dark"] .button-light:hover { background: #dbecc7; }
  html[data-theme="dark"] .icon-button:hover { background: var(--green-soft); }
  html[data-theme="dark"] .progress-track { background: #344a35; }
  html[data-theme="dark"] .progress-track > span { background: #b1ce94; }
  html[data-theme="dark"] :is(.recent-item, .tile-upcoming-note, .auth-switch,
    .answer-footer, .answer-details, .document-links > a, .history-card > header,
    .data-table td, .data-table th, .form-footer) { border-color: var(--line); }
  html[data-theme="dark"] .recent-item:hover { background: var(--surface-raised); }
  html[data-theme="dark"] .filter-group { background: #22342a; }
  html[data-theme="dark"] .filter-button { color: var(--muted); }
  html[data-theme="dark"] .filter-button.is-active { color: var(--ink); background: #354b38; }
  html[data-theme="dark"] .filter-button:hover { color: var(--ink); }
  html[data-theme="dark"] .question-card:target { border-color: #9cbd85; box-shadow: 0 0 0 3px #455e38; }
  html[data-theme="dark"] :is(.question-help, .history-value, .aside-card, .auth-illustration) {
    background: var(--surface-raised); border-color: #3c513f;
  }
  html[data-theme="dark"] :is(.question-help > summary, .example-box strong, .help-symbol,
    .aside-card > strong, .history-note > strong, .illustration-label) { color: #bfdaa9; }
  html[data-theme="dark"] :is(.example-box, .help-symbol) { border-color: #749763; }
  html[data-theme="dark"] :is(.field > label, .standard-form p > label) { color: #d3dfce; }
  html[data-theme="dark"] :is(.field, .standard-form) :is(input:not([type="checkbox"]):not([type="radio"]), select, textarea) {
    color: var(--ink); background: var(--field); border-color: #52694f; box-shadow: none;
  }
  html[data-theme="dark"] :is(input, textarea)::placeholder { color: #a0b09e; opacity: 1; }
  html[data-theme="dark"] .field input[type="file"] { background: var(--field) !important; }
  html[data-theme="dark"] .field input[type="file"]::file-selector-button {
    background: #304a33; color: #d3e7c3; border-color: #5d7951;
  }
  html[data-theme="dark"] :is(.field, .standard-form) :is(input, select, textarea):focus { border-color: #b4d69f; }
  html[data-theme="dark"] :is(.module-options input, .checkbox-field input) { accent-color: #acd39b; }
  html[data-theme="dark"] .errorlist { color: #ffb8a9; }
  html[data-theme="dark"] :is(.message, .setup-steps .is-done b) {
    background: #273e2a; color: #c7e0b4; border-color: #526d43;
  }
  html[data-theme="dark"] :is(.form-errors, .standard-form > .errorlist, .message-error) {
    background: #422b27; color: #ffb8a9; border-color: #825348;
  }
  html[data-theme="dark"] :is(.version-notice, .message-warning) {
    background: #403725; color: #ead09a; border-color: #7f6a3d;
  }
  html[data-theme="dark"] .data-table th { color: #bdcbb3; background: #213328; }
  html[data-theme="dark"] .aside-divider { background: var(--line); }
  html[data-theme="dark"] .setup-steps { color: var(--muted); }
  html[data-theme="dark"] .setup-steps b { background: var(--white); border-color: var(--line); }
  html[data-theme="dark"] .setup-steps i { background: var(--line); }
  html[data-theme="dark"] :is(.setup-steps .is-active, .setup-steps .is-done) { color: #c7dfa9; }
  html[data-theme="dark"] .illustration-line > span { background: #678459; }
  html[data-theme="dark"] .illustration-line > i { background: #435c39; }
  html[data-theme="dark"] .illustration-leaf { color: #91b177; }
}

@media (max-width: 900px) {
  .topbar-actions { gap: 12px; }
  .auth-slogan { display: none; }
}
@media (max-width: 690px) {
  .topbar-account .year-label { display: none; }
  .theme-toggle { min-width: 76px; min-height: 34px; padding: 6px 8px; font-size:0.875rem; }
  .theme-toggle .icon { width: 15px; height: 15px; }
}

/* The adjacent size selector shares the day/night control's visual language. */
.text-size-control {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  flex-shrink: 0; min-height: 42px; max-width: 100%; padding: 7px 10px;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--white); color: var(--ink); font-size: .875rem; font-weight: 550;
}
.text-size-symbol { font-size: 1.0625rem; line-height: 1; letter-spacing: -.04em; }
.text-size-control select {
  min-width: 0; max-width: 100%; border: 0; border-radius: 4px; padding: 3px 4px;
  background: var(--white); color: var(--ink); font: inherit; cursor: pointer;
}
.text-size-control:hover { background: var(--green-soft); }
.text-size-control select:focus-visible { outline-offset: 2px; }
@media screen {
  .theme-toggle { min-height: 42px; font-size: .875rem; }
  html[data-theme="dark"] .text-size-control { background: var(--white); border-color: var(--line); }
}
@media print { .text-size-control { display: none !important; } }
@media (max-width: 440px) {
  .breadcrumb > :is(.breadcrumb-label, .breadcrumb-separator) { display: none; }
  .auth-brand > span { display: none; }
}
@media print {
  :root { color-scheme: light; }
  .theme-toggle { display: none !important; }
}
