/* Follow the device preference, including changes while the app is open.
   Keep dark colours screen-only so printing always uses the light palette. */
:root { color-scheme: light; }

@media screen and (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #111915;
    --paper: #19241e;
    --ink: #e3ebdf;
    --muted: #a8b8a1;
    --line: #334333;
    --sage: #26372b;
    --warm: #342f20;
    --forest-dark: #2c5a49;
    --shadow: 0 4px 18px #00000012;
    --theme-green: #b3ce9a;
    --theme-text: #b2bfaa;
    --theme-surface: #202e25;
  }

  ::selection { background: #526f43; color: #f3faed; }
  .skip-link, .sidebar, .progress-card, .card, .task-list,
  .task, .date-tab, .today-chip, .empty-day, dialog {
    background: var(--paper);
  }
  .topbar { background: #141e18; }
  .brand-mark { background: #2e5140; }
  .sidebar-caption, .sidebar-footer, .breadcrumb, .breadcrumb span,
  .page-footer, .page-footer .text-button { color: #9cad94; }
  .breadcrumb strong, .today-chip { color: var(--theme-text); }
  .nav-item { color: var(--theme-text); }
  .nav-item:hover { background: var(--theme-surface); }
  .nav-item.active { background: #2b3d2b; color: #d5e7c4; }
  .nav-dot { background: var(--theme-green); }
  .support-icon { background: #26372b; color: var(--theme-green); }
  .sidebar-bottom small { color: var(--muted); }
  .quiet-link, .text-button, .contact-card a { color: #bed8a6; }
  .sync-status { color: #b1c49f; }
  .status-dot { background: #a4c48a; }
  .sync-status.offline { color: #e1af80; }
  .sync-status.offline .status-dot { background: #e1af80; }

  .phase-card { background: #223326; border-color: #3b5035; }
  .phase-symbol { background: #34492e; color: #c3d8b0; }
  .phase-card .eyebrow, .phase-card p { color: #b8cba9; }
  .phase-card.fast { background: #352a20; border-color: #705335; }
  .phase-card.fast .phase-symbol { background: #55402b; color: #f0c797; }
  .phase-card.fast .eyebrow, .phase-card.fast p { color: #e4c49f; }
  .ring-track { stroke: #30402f; }
  .ring-fill { stroke: #afcc93; }
  .progress-card p, .progress-card h2 span, .small-note,
  .note-status, .field-help { color: var(--theme-text); }

  .date-tab, .date-tab strong { color: var(--theme-text); }
  .date-tab:not(.selected):hover { background: #2c3e2e; }
  .date-tab.selected { background: #b3ce9a; border-color: #b3ce9a; color: #273d23; }
  .date-tab.selected strong { color: #182b17; }
  .day-done { background: #9cbf7e; color: #172b14; }
  .day-heading .eyebrow, .task-kicker, .source-link,
  .skip-button, .earlier summary { color: #b1c49e; }
  .count-pill { background: #263627; border-color: #405438; color: #c3d5b1; }
  .task { border-bottom-color: var(--line); }
  .task-body > p, .food-columns p, .food-intro > p,
  .note-card > p, .settings-card > p, .backup-card p,
  .sources-card p, .help-card ul, .fluid-grid small,
  .reminder p, .next-card p, .contact-card small,
  dialog p { color: var(--theme-text); }
  .task-checkbox { background: #141e18; border-color: #829574; }
  .task-checkbox:checked { background: #adca94; border-color: #adca94; }
  .task-checkbox:checked::after { color: #172b14; }
  .task-checkbox:hover { border-color: #c0d7a8; }
  .completed { background: #1c2b21; }
  .completed .task-title { color: #b7d4a1; }
  .completed .task-body > p, .completion-stamp { color: #aebfa2; }
  .mini-tag { background: #253427; border-color: #405238; color: #bdcda9; }
  .glass { background: #202f25; border-color: #4a6040; color: #c0d0af; }
  .glass.filled { background: #34503a; border-color: #749466; color: #e0f0d2; }
  .glass:hover { border-color: #aac88f; }
  .glass-count { color: var(--theme-text); }
  .fasting-task { box-shadow: inset 3px 0 #d4aa76; }
  .history-note, .help-card > p, .contact-card > p { color: #dfc59c; }
  .food-layout .eyebrow, .notes-grid .eyebrow { color: #b3c69f; }

  .appointment-card { background: #203c31; box-shadow: inset 0 0 0 1px #3e5c49; }
  .appointment-card .eyebrow, .appointment-card p,
  .appointment-date span, .appointment-time span,
  .appointment-discharge { color: #c0d3b4; }
  .reminder > .icon { color: #bad49f; }
  .quick-card .quiet-link { border-top-color: var(--line); }
  .next-card { border-color: #506344; }
  .empty-day > .icon { color: #bcd6a3; }
  .segmented { background: #202e23; }
  .segmented button { color: var(--theme-text); }
  .segmented button.active { background: #3a5134; color: #edf5e6; }
  .allowed, .fluid-grid .icon { color: #bfdca5; }
  .avoid { color: #e2bc95; }
  .alert.warning { background: #332d20; border-color: #665436; color: #e6d0a4; }
  .alert.fasting { background: #372b20; border-color: #715638; color: #efd0a4; }

  textarea, input[type="date"], input[type="time"] {
    background: #131e17;
    border-color: #526447;
    color: var(--ink);
  }
  textarea::placeholder { color: #9eaf93; }
  .primary { background: #b3ce9a; color: #1c2c18; }
  .primary:hover { background: #c4ddad; }
  .secondary { background: #283a29; border-color: #516747; color: #d0e1bd; }
  .secondary:hover { background: #354d32; }
  .data-details span, .data-details strong, .data-details code,
  .settings-card label, .sources-card > a, .backup-card > small {
    color: var(--theme-text);
  }
  .dialog-close { color: #bed4a9; }
  dialog::backdrop { background: #020804b8; }
  #notice { background: #34563a; color: #f0f8e8; box-shadow: 0 8px 25px #0005; }
  #notice.error { background: #6a432d; }

  @media (max-width: 600px) {
    .topbar { background: transparent; }
    .mobile-nav { background: #19241ef5; }
    .mobile-nav .nav-item.active { background: #2b3d2b; color: #d5e7c4; }
  }
}
