/* Colour themes. The choice (System / Light / Dark / Warm) is set by the switcher at the top of the menu
   and stored per browser; <html data-theme="light|dark|warm"> carries the resolved theme.
   Light is the TypeUI "Clean" palette in index.html :root. Each theme redefines the same tokens,
   plus the few places that use fixed light colours (status pills, notes, birthday banner, tooltips). */

:root { --surface-alt: #f8f7f5; --placeholder: #9ca3af; --tip-bg: #111827; --tip-ink: #ffffff; --accent-press: #1e40af; color-scheme: light; }

/* ---------- Dark ---------- */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1117; --surface: #171a22; --surface-2: #1f232d; --surface-alt: #1f232d;
  --ink: #e6e8ec; --ink-soft: #b4bac5; --ink-mute: #8c93a0;
  --line: #2a2f3b; --line-strong: #3a404d;
  --primary: #60a5fa; --secondary: #a78bfa;
  --accent: #3b82f6; --accent-hover: #2563eb; --accent-soft: #1a2640; --accent-press: #1d4ed8;
  --ok: #4ade80; --warning: #fbbf24; --danger: #f87171; --danger-soft: #3a1d20;
  --focus: 0 0 0 3px rgba(96,165,250,0.4);
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.4);
  --placeholder: #6b7280; --tip-bg: #2b3242; --tip-ink: #f3f4f6;
}
:root[data-theme="dark"] h1 em, :root[data-theme="dark"] .nav-item.active,
:root[data-theme="dark"] .sidebar-foot a.help-link, :root[data-theme="dark"] .tk-kpi-hot .stat-value,
:root[data-theme="dark"] .tk-kpi-hot .stat-label { color: #7cb4fb !important; }
:root[data-theme="dark"] .tk-s-new { background: #262b4f; color: #c7d2fe; }
:root[data-theme="dark"] .tk-s-in_progress { background: #0c2d44; color: #7dd3fc; }
:root[data-theme="dark"] .tk-s-awaiting_clarification { background: #3a2c0b; color: #fcd34d; }
:root[data-theme="dark"] .tk-s-awaiting_further_clarification { background: #4a3507; color: #fde68a; border-color: #b45309; }
:root[data-theme="dark"] .tk-s-resolved { background: #123321; color: #86efac; }
:root[data-theme="dark"] .tk-p-high { background: #3f2410; color: #fdba74; }
:root[data-theme="dark"] .tk-row-turn:hover { background: #22304d; }
:root[data-theme="dark"] .tk-kpi-hot { border-color: #1e3a8a; }
:root[data-theme="dark"] .tk-kpi-late { border-color: #7f1d1d; }
:root[data-theme="dark"] .rm-due { background: #3a1a2c; border-color: #be185d; }
:root[data-theme="dark"] .rm-due .rm-when { color: #f9a8d4; }
:root[data-theme="dark"] .rm-overdue { border-color: #7f1d1d; }
:root[data-theme="dark"] .tk-warn { background: #33290c; border-color: #854d0e; color: #fcd34d; }
:root[data-theme="dark"] .tk-close-note, :root[data-theme="dark"] .tk-resolved-note { background: #12301f; }
:root[data-theme="dark"] .dash-zone-tasks { border-color: #1e3a8a; border-top-color: var(--accent); box-shadow: 0 4px 16px rgba(0,0,0,0.35); }
:root[data-theme="dark"] .pu-pill.submitted { background: #0f3a2b; color: #6ee7b7; }
:root[data-theme="dark"] .pu-pill.draft { background: #3a2c0b; color: #fcd34d; }
:root[data-theme="dark"] .pu-pill.missing { background: #3a1d20; color: #fca5a5; }
:root[data-theme="dark"] .room-type-tag.conf { background: #0f3a2b; color: #6ee7b7; }
:root[data-theme="dark"] .room-type-tag.ide { background: #2a2050; color: #c4b5fd; }
:root[data-theme="dark"] .slot.booked-own { background: #2a2050; color: #c4b5fd; border-color: #6d28d9; }
:root[data-theme="dark"] .btn-release { color: #fbbf24; border-color: #b45309; }
:root[data-theme="dark"] .btn-release:hover { background: #33290c; }
:root[data-theme="dark"] .btn-extend { color: #34d399; border-color: #047857; }
:root[data-theme="dark"] .btn-extend:hover { background: #0f3a2b; }
:root[data-theme="dark"] mark { color: #111827; }
:root[data-theme="dark"] .bday-wish { border-color: #831843;
  background: linear-gradient(90deg, rgba(23,26,34,0.94) 0%, rgba(23,26,34,0.8) 45%, rgba(23,26,34,0.1) 80%), url('/img/birthday.jpg') center 40% / cover no-repeat; }
:root[data-theme="dark"] .bday-dear, :root[data-theme="dark"] .bday-flash-cta { color: #f9a8d4; }
:root[data-theme="dark"] .bday-script { color: #f472b6; text-shadow: none; }
:root[data-theme="dark"] .bday-close { background: rgba(23,26,34,0.85); }
:root[data-theme="dark"] .bday-flash { background: linear-gradient(90deg, #3a1a2c, #261f40); border-color: #9d174d; color: #fbcfe8; }

/* ---------- Warm (soft cream, easy on the eyes) ---------- */
:root[data-theme="warm"] {
  --bg: #f6f0e4; --surface: #fffaf0; --surface-2: #f0e6d4; --surface-alt: #f0e6d4;
  --ink: #2b2118; --ink-soft: #5b4a3a; --ink-mute: #7a6754;
  --line: #e4d6bf; --line-strong: #d3c0a2;
  --primary: #d97706; --secondary: #a16207;
  --accent: #b45309; --accent-hover: #92400e; --accent-soft: #fbecd4; --accent-press: #78350f;
  --ok: #3f7d20; --warning: #b45309; --danger: #b91c1c; --danger-soft: #fbe5df;
  --focus: 0 0 0 3px rgba(217,119,6,0.35);
  --shadow-sm: 0 1px 2px rgba(60,40,20,0.08);
  --placeholder: #a8957d; --tip-bg: #3a2c1f; --tip-ink: #fffaf0;
}
:root[data-theme="warm"] .tk-row-turn:hover { background: #f6dfba; }
:root[data-theme="warm"] .tk-kpi-hot { border-color: #f0c98e; }
:root[data-theme="warm"] .dash-zone-tasks { border-color: #f0c98e; box-shadow: 0 4px 16px rgba(180,83,9,0.08); }

/* Places that used fixed colours: now follow the theme tokens */
input::placeholder, textarea::placeholder { color: var(--placeholder); }
.btn-primary:active { background: var(--accent-press); }
.toast, #slotTip, .install-banner, .rp-tooltip { background: var(--tip-bg); color: var(--tip-ink); }

/* ---------- Theme switcher (top of the menu) ---------- */
.side-head { position: relative; }
.theme-btn { position: absolute; top: 0; right: 0; width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line-strong); background: var(--surface);
  color: var(--ink-soft); cursor: pointer; font-size: calc(16px * var(--fs, 1)); line-height: 1; display: inline-flex; align-items: center; justify-content: center; }
.theme-btn:hover { background: var(--surface-2); color: var(--ink); }
.theme-menu { position: absolute; top: 40px; right: 0; z-index: 60; min-width: 190px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg);
  box-shadow: 0 12px 32px rgba(0,0,0,0.18); padding: 6px; }
.theme-menu[hidden] { display: none; }
.theme-menu-title { font-family: var(--mono); font-size: calc(11px * var(--fs, 1)); text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-mute); padding: 6px 10px 4px; }
.theme-opt { display: flex; width: 100%; align-items: center; gap: 10px; padding: 8px 10px; min-height: 38px; border: none; background: transparent; color: var(--ink);
  font: calc(14px * var(--fs, 1)) var(--sans); border-radius: var(--radius); cursor: pointer; text-align: left; }
.theme-opt:hover { background: var(--surface-2); }
.theme-opt[aria-checked="true"] { background: var(--accent-soft); color: var(--accent); font-weight: 500; }
:root[data-theme="dark"] .theme-opt[aria-checked="true"] { color: #7cb4fb; }
.theme-swatch { width: 18px; height: 18px; border-radius: 50%; border: 1px solid rgba(0,0,0,0.15); flex-shrink: 0; }
.theme-swatch.system { background: linear-gradient(135deg, #ffffff 50%, #171a22 50%); }
.theme-swatch.light { background: #ffffff; }
.theme-swatch.dark { background: #171a22; }
.theme-swatch.warm { background: #f6dfba; }
.theme-check { margin-left: auto; }
@media (min-width: 901px) { .brand-sub { padding-right: 38px; } }
@media (max-width: 900px) {
  /* Phones: the button sits in the top bar, between the logo and the menu button */
  .theme-btn { position: static; flex-shrink: 0; margin-left: auto; }
  .side-head { gap: 8px; }
  .theme-menu { position: fixed; top: 60px; right: 12px; } /* the folded top bar clips anything hanging below it */
}

/* ---------- ◐ Settings page: theme, font, text size (2026-11-20) ---------- */
.set-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; align-items: start; max-width: 1100px; }
.set-h { font-family: var(--serif); font-size: calc(16px * var(--fs, 1)); font-weight: 600; margin: 0 0 12px; }
.set-themes, .set-fonts { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.set-sizes { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.set-theme, .set-font, .set-size { position: relative; display: flex; align-items: center; gap: 10px; text-align: left; padding: 10px 12px; min-height: 44px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-lg); background: var(--surface); color: var(--ink); cursor: pointer; font-size: calc(14px * var(--fs, 1)); }
.set-size { flex-direction: column; align-items: center; gap: 2px; text-align: center; padding: 10px 4px; }
.set-size-a { font-weight: 600; line-height: 1.1; font-family: var(--sans); }
.set-theme:hover, .set-font:hover, .set-size:hover { border-color: var(--accent); }
.set-theme:focus-visible, .set-font:focus-visible, .set-size:focus-visible { outline: none; box-shadow: var(--focus); }
.set-theme.on, .set-font.on, .set-size.on { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.set-theme > span:not(.theme-swatch):not(.set-check) { display: flex; flex-direction: column; }
.set-note { display: block; font-size: calc(12px * var(--fs, 1)); color: var(--ink-mute); font-weight: 400; }
.set-check { position: absolute; top: 6px; right: 8px; color: var(--accent); font-weight: 700; font-size: calc(13px * var(--fs, 1)); }
.set-help { margin: 10px 0 0; font-size: calc(12.5px * var(--fs, 1)); color: var(--ink-mute); }
.set-preview p { margin: 0 0 8px; }
.set-prev-title { font-family: var(--serif); font-size: calc(18px * var(--fs, 1)); font-weight: 600; margin: 0 0 6px; }
@media (max-width: 520px) { .set-sizes { grid-template-columns: repeat(3, minmax(0, 1fr)); } .set-grid { grid-template-columns: 1fr; } }
