/* 深色模式 (2026-11-06): libenest.com's everyday pages only (<html data-themeable>, see layout.mjs). Their stylesheets read
   colours as var(--lb-*, original) and the --lb-* tokens exist only here, only in dark: light stays exactly as it was.
   Dark is 深色 picked in 外觀 (data-theme="dark", written by the Worker from the lb_theme cookie and by theme.js), or the
   phone in dark mode with nothing picked. Independent sites, listing pages, No.88 and Admin never load this file.
   The two token blocks below must stay identical (theme-css.test.mjs checks them against site-theme.js). */

:root[data-themeable][data-theme="dark"] {
  color-scheme: dark;
  --lb-bg: #000000;
  --lb-surface: #1a1a1a;
  --lb-surface-2: #2c2c2e;
  --lb-elevated: #1c1c1e;
  --lb-strong: #3a3a3c;
  --lb-glass: rgb(28 28 30 / 88%);
  --lb-text: #f5f5f5;
  --lb-text-2: #a8a8a8;
  --lb-text-3: #8e8e8e;
  --lb-line: #262626;
  --lb-line-strong: #6b6b6b;
  --lb-link: #4da3ff;
  --lb-focus: #80b9ff;
  --lb-blue-soft: #0e2847;
  --lb-blue-text: #8cc4ff;
  --lb-red-soft: #3b1515;
  --lb-red-text: #ff7b72;
  --lb-green-soft: #0f2c1b;
  --lb-green-text: #4cd47b;
  --lb-amber-soft: #36290a;
  --lb-amber-text: #ffc95e;
  --lb-purple-soft: #2a1c40;
  --lb-purple-text: #cbb2ff;
  --lb-icon-filter: invert(1) hue-rotate(180deg);
  /* libenest.css's own palette (header, footer, forms, 我的 and the older page styles read these). */
  --paper: #000000;
  --paper-deep: #1a1a1a;
  --ink: #f5f5f5;
  --muted: #a8a8a8;
  --line: #262626;
  --dark: #3a3a3c;
}
@media (prefers-color-scheme: dark) {
  :root[data-themeable]:not([data-theme="light"]) {
    color-scheme: dark;
    --lb-bg: #000000;
    --lb-surface: #1a1a1a;
    --lb-surface-2: #2c2c2e;
    --lb-elevated: #1c1c1e;
    --lb-strong: #3a3a3c;
    --lb-glass: rgb(28 28 30 / 88%);
    --lb-text: #f5f5f5;
    --lb-text-2: #a8a8a8;
    --lb-text-3: #8e8e8e;
    --lb-line: #262626;
    --lb-line-strong: #6b6b6b;
    --lb-link: #4da3ff;
    --lb-focus: #80b9ff;
    --lb-blue-soft: #0e2847;
    --lb-blue-text: #8cc4ff;
    --lb-red-soft: #3b1515;
    --lb-red-text: #ff7b72;
    --lb-green-soft: #0f2c1b;
    --lb-green-text: #4cd47b;
    --lb-amber-soft: #36290a;
    --lb-amber-text: #ffc95e;
    --lb-purple-soft: #2a1c40;
    --lb-purple-text: #cbb2ff;
    --lb-icon-filter: invert(1) hue-rotate(180deg);
    --paper: #000000;
    --paper-deep: #1a1a1a;
    --ink: #f5f5f5;
    --muted: #a8a8a8;
    --line: #262626;
    --dark: #3a3a3c;
  }
}

/* Everything below reads the tokens with the light look as the fallback (so in light it changes nothing). */
/* MapLibre's own controls (zoom, compass, attribution) around the base map, which has its own dark palette (base-style.js). */
@media not (forced-colors: active) {
  :root[data-themeable] .maplibregl-ctrl-group:not(:empty) { background: var(--lb-elevated, #fff); box-shadow: 0 0 0 2px var(--lb-line, rgb(0 0 0 / 10%)); }
  :root[data-themeable] .maplibregl-ctrl-group button + button { border-top: 1px solid var(--lb-line, #ddd); }
  :root[data-themeable] .maplibregl-ctrl button .maplibregl-ctrl-icon { filter: var(--lb-icon-filter, none); }
  :root[data-themeable] .maplibregl-ctrl.maplibregl-ctrl-attrib { background: var(--lb-glass, rgb(255 255 255 / 50%)); }
  :root[data-themeable] .maplibregl-ctrl-attrib a { color: var(--lb-text-2, rgb(0 0 0 / 75%)); }
  :root[data-themeable] .maplibregl-ctrl-attrib-button { filter: var(--lb-icon-filter, none); }
}

/* 外觀: 跟隨手機／淺色／深色, in the ☰ menu (compact) and on 我的. Plain radios, so arrow keys move between them. */
.lb-theme-switch { margin: 0; padding: 0; border: 0; min-width: 0; }
.lb-theme-switch legend { padding: 0; font-size: 13px; color: var(--lb-text-2, #6d7480); }
.lb-theme-options { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 2px; margin-top: 8px; padding: 3px; border-radius: 12px; background: var(--lb-surface, #f2f4f6); }
.lb-theme-options label { position: relative; display: grid; place-items: center; min-height: 40px; padding: 0 6px; border-radius: 9px; color: var(--lb-text-2, #5f6672); font-size: 13px; font-weight: 600; text-align: center; line-height: 1.25; cursor: pointer; }
.lb-theme-options input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.lb-theme-options label:has(input:checked) { background: var(--lb-strong, #fff); color: var(--lb-text, #101113); box-shadow: 0 1px 3px rgb(16 17 19 / 14%); }
.lb-theme-options label:has(input:focus-visible) { outline: 3px solid var(--lb-focus, #80b9ff); outline-offset: 1px; }
@media (prefers-reduced-motion: no-preference) {
  .lb-theme-options label { transition: background .15s, color .15s; }
}
