/* Neon-Nest design system: Apple-like (SF font, grouped insets, glass bars, sheets) in three looks.
   <html data-theme="auto|light|neon">: auto follows the device (light or dark), neon is the warm
   night-city dark look with neon accents. Pages use only these tokens and components. */

:root {
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", "Segoe UI", system-ui, sans-serif;
  --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Helvetica Neue", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
  --r-s: 8px; --r-m: 12px; --r-l: 16px; --r-xl: 22px;
  --gap: 16px;
  --tabbar-h: 50px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --ease: cubic-bezier(.2, .8, .2, 1);
  /* Einstellungen (docs/plan-0.4-optionen.md §3): text size (85–130 %, never below 13 px, OPT-11), the diary's own size,
     one hit size for buttons and the scene (44 or 56 px, OPT-10). Set by ui.js from js/optionen.js. */
  --ui-scale: 1; --tb-scale: 1; --hit: 44px;
  --fs-10: max(13px, calc(10px * var(--ui-scale))); --fs-11: max(13px, calc(11px * var(--ui-scale))); --fs-12: max(13px, calc(12px * var(--ui-scale)));
  --fs-12_5: max(13px, calc(12.5px * var(--ui-scale))); --fs-13: max(13px, calc(13px * var(--ui-scale))); --fs-14: max(13px, calc(14px * var(--ui-scale)));
  --fs-15: max(13px, calc(15px * var(--ui-scale))); --fs-16: max(13px, calc(16px * var(--ui-scale))); --fs-17: max(13px, calc(17px * var(--ui-scale)));
  --fs-18: max(13px, calc(18px * var(--ui-scale))); --fs-19: max(13px, calc(19px * var(--ui-scale))); --fs-20: max(13px, calc(20px * var(--ui-scale)));
  --fs-22: max(13px, calc(22px * var(--ui-scale))); --fs-25: max(13px, calc(25px * var(--ui-scale))); --fs-28: max(13px, calc(28px * var(--ui-scale)));
  --fs-34: max(13px, calc(34px * var(--ui-scale))); --fs-52: max(13px, calc(52px * var(--ui-scale)));
}

/* ---- light (iOS system colours) */
:root, [data-theme="light"] {
  color-scheme: light;
  --bg: #f2f2f7;            /* systemGroupedBackground */
  --bg-elev: #ffffff;       /* secondarySystemGroupedBackground */
  --bg-elev2: #f2f2f7;
  --fill: rgba(120, 120, 128, .12);
  --fill-2: rgba(120, 120, 128, .2);
  --label: #000000;
  --label-2: rgba(60, 60, 67, .6);
  --label-3: rgba(60, 60, 67, .3);
  --sep: rgba(60, 60, 67, .29);
  --accent: #007aff;
  --accent-ink: #ffffff;
  --pink: #ff2d55; --amber: #ff9500; --cyan: #32ade6; --green: #34c759; --red: #ff3b30; --purple: #af52de;
  --glass: rgba(249, 249, 249, .78);
  --glass-line: rgba(0, 0, 0, .12);
  --shadow: 0 8px 30px rgba(0, 0, 0, .12);
  --glow: none;
  --card-shadow: 0 1px 2px rgba(0, 0, 0, .06);
  --scene-frame: #0d0b14;
}

/* ---- dark (iOS dark mode) */
[data-theme="dark"] {
  color-scheme: dark;
  --bg: #000000;
  --bg-elev: #1c1c1e;
  --bg-elev2: #2c2c2e;
  --fill: rgba(120, 120, 128, .24);
  --fill-2: rgba(120, 120, 128, .36);
  --label: #ffffff;
  --label-2: rgba(235, 235, 245, .6);
  --label-3: rgba(235, 235, 245, .3);
  --sep: rgba(84, 84, 88, .65);
  --accent: #0a84ff;
  --accent-ink: #ffffff;
  --pink: #ff375f; --amber: #ff9f0a; --cyan: #64d2ff; --green: #30d158; --red: #ff453a; --purple: #bf5af2;
  --glass: rgba(29, 29, 31, .72);
  --glass-line: rgba(255, 255, 255, .1);
  --shadow: 0 8px 30px rgba(0, 0, 0, .5);
  --glow: none;
  --card-shadow: none;
  --scene-frame: #000000;
}
@media (prefers-color-scheme: dark) {
  [data-theme="auto"] {
    color-scheme: dark;
    --bg: #000000; --bg-elev: #1c1c1e; --bg-elev2: #2c2c2e;
    --fill: rgba(120, 120, 128, .24); --fill-2: rgba(120, 120, 128, .36);
    --label: #ffffff; --label-2: rgba(235, 235, 245, .6); --label-3: rgba(235, 235, 245, .3);
    --sep: rgba(84, 84, 88, .65); --accent: #0a84ff; --accent-ink: #ffffff;
    --pink: #ff375f; --amber: #ff9f0a; --cyan: #64d2ff; --green: #30d158; --red: #ff453a; --purple: #bf5af2;
    --glass: rgba(29, 29, 31, .72); --glass-line: rgba(255, 255, 255, .1);
    --shadow: 0 8px 30px rgba(0, 0, 0, .5); --scene-frame: #000000;
  }
}

/* ---- neon (the night city: warm dark, neon accents with a soft glow) */
[data-theme="neon"] {
  color-scheme: dark;
  --bg: #0d0b14;
  --bg-elev: #1a1624;
  --bg-elev2: #241f33;
  --fill: rgba(167, 159, 180, .16);
  --fill-2: rgba(167, 159, 180, .26);
  --label: #f1e8da;
  --label-2: rgba(241, 232, 218, .62);
  --label-3: rgba(241, 232, 218, .32);
  --sep: rgba(167, 159, 180, .22);
  --accent: #ff6fae;
  --accent-ink: #1a0d14;
  --pink: #ff6fae; --amber: #ffb65c; --cyan: #6fe3e8; --green: #8fe0a0; --red: #ff6a5c; --purple: #c49bff;
  --glass: rgba(22, 19, 31, .72);
  --glass-line: rgba(255, 111, 174, .18);
  --shadow: 0 10px 34px rgba(0, 0, 0, .55);
  --glow: 0 0 18px rgba(255, 111, 174, .35);
  --card-shadow: 0 0 0 .5px rgba(255, 111, 174, .12), 0 6px 18px rgba(0, 0, 0, .35);
  --scene-frame: #0d0b14;
}

/* ---- base */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--label);
  font: var(--fs-17)/1.35 var(--font); letter-spacing: -.01em;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
a { color: var(--accent); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 60%, transparent); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ---- typography */
.ui-large-title { font: 700 var(--fs-34)/1.15 var(--font-display); letter-spacing: .01em; margin: 8px 0 4px; }
.ui-title { font: 600 var(--fs-22)/1.2 var(--font-display); margin: 0; }
.ui-headline { font-weight: 600; }
.ui-sub { font-size: var(--fs-15); color: var(--label-2); }
.ui-foot { font-size: var(--fs-13); color: var(--label-2); }
.ui-section-head { font-size: var(--fs-13); text-transform: uppercase; letter-spacing: .02em; color: var(--label-2); margin: 22px 16px 6px; }

/* ---- page frame */
.ui-page { max-width: 760px; margin: 0 auto; padding: calc(8px + var(--safe-t)) var(--gap) calc(var(--tabbar-h) + var(--safe-b) + 24px); }
.ui-navbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 8px; min-height: 44px;
  padding: calc(4px + var(--safe-t)) var(--gap) 4px; background: var(--glass);
  -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  border-bottom: .5px solid var(--glass-line);
}
.ui-navbar .ui-nav-title { flex: 1; text-align: center; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ui-navbar .ui-nav-side { min-width: 72px; display: flex; gap: 4px; }
.ui-navbar .ui-nav-side.end { justify-content: flex-end; }
.ui-back { display: inline-flex; align-items: center; gap: 2px; color: var(--accent); background: none; border: 0; padding: 6px 0; font-size: var(--fs-17); cursor: pointer; }
.ui-back::before { content: ""; width: 11px; height: 11px; border-left: 2.5px solid currentColor; border-bottom: 2.5px solid currentColor; transform: rotate(45deg); margin-right: 4px; }

/* ---- grouped inset list (Settings style) */
.ui-group { background: var(--bg-elev); border-radius: var(--r-m); overflow: hidden; margin: 0 0 8px; }
.ui-row { display: flex; align-items: center; gap: 12px; min-height: var(--hit); padding: 10px 16px; position: relative; }
.ui-row + .ui-row::before { content: ""; position: absolute; top: 0; left: 16px; right: 0; border-top: .5px solid var(--sep); }
.ui-row .ui-row-main { flex: 1; min-width: 0; }
.ui-row .ui-row-detail { color: var(--label-2); text-align: right; }
.ui-row.ui-chevron::after { content: ""; width: 8px; height: 8px; border-right: 2px solid var(--label-3); border-top: 2px solid var(--label-3); transform: rotate(45deg); margin-left: 4px; }
.ui-icon-tile { width: 30px; height: 30px; border-radius: 7px; display: inline-grid; place-items: center; color: #fff; flex: none; font-size: var(--fs-17); }

/* ---- cards */
.ui-card { background: var(--bg-elev); border-radius: var(--r-l); padding: 16px; margin: 0 0 12px; box-shadow: var(--card-shadow); }
.ui-card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }

/* ---- buttons */
.ui-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: var(--hit); padding: 0 18px;
  border-radius: var(--r-m); border: 0; cursor: pointer; font-weight: 600; font-size: var(--fs-17);
  background: var(--fill); color: var(--accent); transition: transform .12s var(--ease), opacity .12s;
}
.ui-btn:active { transform: scale(.97); opacity: .85; }
.ui-btn:disabled { opacity: .4; cursor: default; transform: none; }
.ui-btn.filled { background: var(--accent); color: var(--accent-ink); box-shadow: var(--glow); }
.ui-btn.tinted { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent); }
.ui-btn.destructive { background: color-mix(in srgb, var(--red) 16%, transparent); color: var(--red); }
.ui-btn.plain { background: none; padding: 0 8px; }
.ui-btn.small { min-height: 32px; padding: 0 12px; font-size: var(--fs-15); border-radius: 999px; }
.ui-btn.block { width: 100%; }

/* ---- segmented control */
.ui-segmented { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--fill); border-radius: 9px; padding: 2px; gap: 2px; }
.ui-segmented button { border: 0; background: none; min-height: var(--hit); border-radius: 7px; font-size: var(--fs-14); font-weight: 500; cursor: pointer; color: var(--label); }
.ui-segmented button[aria-pressed="true"], .ui-segmented button[aria-selected="true"] { background: var(--bg-elev); box-shadow: 0 1px 4px rgba(0, 0, 0, .2); font-weight: 600; }
[data-theme="neon"] .ui-segmented button[aria-pressed="true"], [data-theme="neon"] .ui-segmented button[aria-selected="true"] { background: var(--bg-elev2); color: var(--pink); }

/* ---- switch */
.ui-switch { appearance: none; -webkit-appearance: none; width: 51px; height: 31px; border-radius: 999px; background: var(--fill-2); position: relative; cursor: pointer; transition: background .2s; flex: none; margin: 0; }
.ui-switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, .25); transition: transform .2s var(--ease); }
.ui-switch:checked { background: var(--green); }
.ui-switch:checked::after { transform: translateX(20px); }

/* ---- inputs */
.ui-input { width: 100%; min-height: var(--hit); padding: 10px 14px; border-radius: var(--r-m); border: 0; background: var(--fill); color: var(--label); }
.ui-input::placeholder { color: var(--label-3); }
input[type="range"].ui-range { width: 100%; accent-color: var(--accent); }

/* ---- pills / badges */
.ui-pill { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 999px; font-size: var(--fs-13); font-weight: 600; background: var(--fill); color: var(--label-2); }
.ui-pill.ok { background: color-mix(in srgb, var(--green) 18%, transparent); color: var(--green); }
.ui-pill.warn { background: color-mix(in srgb, var(--amber) 18%, transparent); color: var(--amber); }
.ui-pill.bad { background: color-mix(in srgb, var(--red) 18%, transparent); color: var(--red); }
.ui-pill.accent { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent); }
/* in the light look the tinted text needs more contrast */
[data-theme="light"] .ui-pill.ok { color: #1e7a34; } [data-theme="light"] .ui-pill.warn { color: #9a5800; } [data-theme="light"] .ui-pill.bad { color: #c4231a; }
@media (prefers-color-scheme: light) { [data-theme="auto"] .ui-pill.ok { color: #1e7a34; } [data-theme="auto"] .ui-pill.warn { color: #9a5800; } [data-theme="auto"] .ui-pill.bad { color: #c4231a; } }
/* 44 px touch targets for the small controls */
.ui-btn.small, .ui-switch { position: relative; }
.ui-btn.small::before, .ui-switch::before { content: ""; position: absolute; inset: calc((var(--hit) - 30px) / -2) -4px; }

/* ---- tab bar (bottom, glass) */
.ui-tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; display: flex; justify-content: space-around;
  padding: 6px 4px calc(4px + var(--safe-b)); background: var(--glass);
  -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  border-top: .5px solid var(--glass-line);
}
.ui-tabbar a, .ui-tabbar button {
  flex: 1; max-width: 120px; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 2px 0;
  font-size: var(--fs-10); font-weight: 500; color: var(--label-3); background: none; border: 0; cursor: pointer; text-decoration: none;
}
.ui-tabbar svg { width: 26px; height: 26px; }
.ui-tabbar [aria-current="page"] { color: var(--accent); }
[data-theme="neon"] .ui-tabbar [aria-current="page"] svg { filter: drop-shadow(0 0 6px rgba(255, 111, 174, .6)); }

/* ---- sheet (bottom sheet with grabber) */
.ui-sheet-backdrop { position: fixed; inset: 0; z-index: 60; background: rgba(0, 0, 0, .4); opacity: 0; transition: opacity .25s; }
.ui-sheet-backdrop.open { opacity: 1; }
.ui-sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 61; max-height: 88vh; overflow: auto; overscroll-behavior: contain;
  background: var(--bg); border-radius: 14px 14px 0 0; padding: 8px var(--gap) calc(20px + var(--safe-b));
  transform: translateY(100%); transition: transform .32s var(--ease); box-shadow: var(--shadow);
}
.ui-sheet.open { transform: none; }
/* the shared close button: a 32 px circle inside a hit area of at least 44 px (56 with larger targets, OPT-10) */
.ui-sheet-close { position: absolute; top: calc(26px - var(--hit) / 2); right: calc(28px - var(--hit) / 2); width: var(--hit); height: var(--hit); border-radius: 50%; border: 0; background: none; color: var(--label-2); font-size: var(--fs-14); cursor: pointer; display: grid; place-items: center; z-index: 1; }
.ui-sheet-close::before { content: ""; position: absolute; left: 50%; top: 50%; width: 32px; height: 32px; margin: -16px 0 0 -16px; border-radius: 50%; background: var(--fill); z-index: -1; }
.ui-sheet-close:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ui-sheet::before { content: ""; display: block; width: 36px; height: 5px; border-radius: 3px; background: var(--label-3); margin: 0 auto 10px; }
@media (min-width: 700px) { .ui-sheet { left: 50%; right: auto; width: 560px; transform: translate(-50%, 100%); } .ui-sheet.open { transform: translate(-50%, 0); } }

/* ---- toast */
.ui-toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + var(--safe-b) + 16px); transform: translateX(-50%); z-index: 70;
  max-width: min(92vw, 520px); padding: 12px 18px; border-radius: 999px; background: var(--glass); color: var(--label);
  -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px); box-shadow: var(--shadow); font-size: var(--fs-15); text-align: center;
}

/* ---- "Was ist neu?" (js/neuigkeiten.js; viewer, Werkstatt and Steuerpult) */
.neu .ui-row.neu-punkt { flex-direction: column; align-items: stretch; gap: 2px; }
.neu .ui-section-head { margin-top: 4px; }
.neu-alt { margin-top: 14px; }
.neu-alt summary { cursor: pointer; font-weight: 600; color: var(--label-2); padding: 10px 4px; min-height: 44px; box-sizing: border-box; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---- Einstellungen (docs/plan-0.4-optionen.md): effects of the device settings on all pages */
html[data-bewegung="reduziert"] *, html[data-bewegung="reduziert"] *::before, html[data-bewegung="reduziert"] *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
/* high contrast: secondary texts in full colour, visible edges */
html[data-kontrast="hoch"] { --label-2: var(--label); --sep: color-mix(in srgb, var(--label) 55%, transparent); --label-3: color-mix(in srgb, var(--label) 70%, transparent); --fill: color-mix(in srgb, var(--label) 16%, transparent); }
html[data-kontrast="hoch"] .ui-group, html[data-kontrast="hoch"] .ui-card, html[data-kontrast="hoch"] .ui-btn, html[data-kontrast="hoch"] .ui-input, html[data-kontrast="hoch"] .ui-pill { box-shadow: inset 0 0 0 1.5px var(--sep); }
html[data-kontrast="hoch"] :focus-visible { outline: 3px solid var(--label); }
/* colour-blind friendly status colours (Okabe–Ito: blue/orange/vermilion) plus a sign; the city's sprites stay as they are */
html[data-farben="sicher"] { --green: #3b8fd9; --red: #e0661c; --amber: #e6a700; }
html[data-farben="sicher"][data-theme="light"] { --green: #0b6db7; --red: #b84a00; --amber: #8a6400; }
html[data-farben="sicher"] .ui-pill.ok::before { content: "✓ "; }
html[data-farben="sicher"] .ui-pill.warn::before { content: "! "; }
html[data-farben="sicher"] .ui-pill.bad::before { content: "✕ "; }
html[data-tipp="gross"] .ui-switch { transform: scale(1.12); }

/* the gear and the settings sheet */
.opt { padding-bottom: 8px; }
.opt .opt-intro { margin: 4px 0 12px; }
.opt-bereich { margin: 0 0 10px; border-radius: var(--r-m); background: var(--bg-elev); box-shadow: var(--card-shadow); }
.opt-bereich > summary { display: flex; align-items: center; gap: 8px; min-height: var(--hit); padding: 8px 16px; cursor: pointer; font-weight: 600; list-style: none; border-radius: var(--r-m); }
.opt-bereich > summary::-webkit-details-marker { display: none; }
.opt-bereich > summary::after { content: ""; width: 8px; height: 8px; border-right: 2px solid var(--label-3); border-bottom: 2px solid var(--label-3); transform: rotate(45deg); margin-left: auto; transition: transform .2s; }
.opt-bereich[open] > summary::after { transform: rotate(-135deg); }
.opt-bereich .ui-group { margin: 0; background: none; border-top: .5px solid var(--sep); border-radius: 0; }
.opt-bereich .opt-note { margin: 0; padding: 0 16px 8px; }
.opt-row { flex-wrap: wrap; }
.opt-row.col { flex-direction: column; align-items: stretch; gap: 6px; }
.opt-row .opt-t { font-weight: 500; }
.opt-row label.ui-row-main { cursor: pointer; }
.opt-head { display: flex; align-items: baseline; gap: 8px; }
.opt-head label { flex: 1; font-weight: 500; }
.opt-head output { color: var(--label-2); font-variant-numeric: tabular-nums; }
.opt-row .ui-segmented { width: 100%; }
.opt-row select.ui-input { appearance: auto; -webkit-appearance: menulist; }
.opt-row.bald, .opt-row.aus { opacity: .5; }
.opt-confirm { display: flex; flex-wrap: wrap; gap: 8px; width: 100%; padding-top: 6px; }
.opt-reset { margin: 6px 8px 10px; }
.opt-foot { margin: 14px 4px 0; }
.opt-hilfe dl { margin: 0; }
.opt-hilfe dt { font-weight: 600; margin-top: 10px; }
.opt-hilfe dd { margin: 2px 0 0; color: var(--label-2); }
.opt-hilfe kbd { font: inherit; font-weight: 600; padding: 1px 6px; border-radius: 6px; background: var(--fill); }

.push-options { padding-top: 8px; padding-bottom: 12px; }
.push-options > button { margin: 8px 16px 0; }
.push-options .ui-input { width: auto; max-width: 54%; }
.push-options .opt-note { overflow-wrap: anywhere; }
