/* Kleuren: normaal donkerblauw met amber, nachtmodus alleen rood op zwart. */
:root {
  --bg: #0d1321;
  --card: #172036;
  --line: #26314d;
  --text: #f2f4f8;
  --text-soft: #8e9ab5;
  --accent: #ffb547;
  --on-accent: #1a1205;
  --radius: 18px;
  --tabbar-h: 64px;
  color-scheme: dark;
}
:root[data-night="true"] {
  --bg: #000;
  --card: #120000;
  --line: #2a0000;
  --text: #d32f2f;
  --text-soft: #8b1e1e;
  --accent: #b71c1c;
  --on-accent: #000;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  min-height: 100dvh;
}
button, select, input { font: inherit; color: inherit; }
button { cursor: pointer; }
svg { width: 22px; height: 22px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Kopbalk en tabs ---------- */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 12px;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px;
  background: var(--bg);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 20px; flex: 1; }
.brand-mark { color: var(--accent); width: 30px; height: 30px; fill: currentColor; stroke: none; }
.brand-mark circle { stroke: currentColor; }
.icon-btn {
  display: grid; place-items: center;
  width: 44px; height: 44px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--card); color: var(--text);
}
.icon-btn[aria-pressed="true"] { color: var(--accent); border-color: var(--accent); }
.icon-btn[aria-pressed="true"] svg { fill: currentColor; }

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  display: flex; justify-content: space-around;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--card); border-top: 1px solid var(--line);
}
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  border: 0; background: none; color: var(--text-soft); font-size: 12px;
}
.tab.is-active { color: var(--accent); }

main {
  max-width: 1040px; margin: 0 auto;
  padding: 0 16px calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 24px);
}
.view { display: none; }
.view.is-active { display: block; }
.view-title { font-size: 22px; margin: 8px 4px 16px; }

/* ---------- Rekenscherm ---------- */
.calc-grid { display: grid; gap: 8px; }
.label {
  margin: 20px 4px 8px; font-size: 12px; font-weight: 600;
  letter-spacing: .12em; text-transform: uppercase; color: var(--text-soft);
}
.hint { margin: 8px 4px 0; font-size: 13px; color: var(--text-soft); }
.hint.center { text-align: center; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px;
}
.shutter-row { display: flex; gap: 10px; align-items: stretch; }
.step-btn {
  width: 56px; flex: none; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--card); font-size: 26px; line-height: 1;
}
.step-btn:disabled { color: var(--line); cursor: default; }

.field {
  position: relative; flex: 1; display: flex; align-items: center;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  min-height: 64px;
}
.field select {
  appearance: none; -webkit-appearance: none;
  width: 100%; height: 100%; min-height: 62px;
  padding: 0 44px 0 52px; border: 0; background: transparent;
  font-size: 22px; font-weight: 600; cursor: pointer;
}
.field select option { background: var(--card); color: var(--text); font-size: 16px; }
.field-icon { position: absolute; left: 16px; color: var(--accent); pointer-events: none; }
.chevron { position: absolute; right: 14px; color: var(--text-soft); pointer-events: none; }
.field .stops { position: absolute; right: 44px; color: var(--text-soft); font-size: 14px; pointer-events: none; }
.field.filter select { font-size: 19px; padding-right: 120px; }

.filters { display: grid; gap: 10px; }
.filter-row { display: flex; gap: 6px; align-items: center; }
.remove-btn { width: 44px; height: 44px; flex: none; border: 0; background: none; color: var(--text-soft); display: grid; place-items: center; }

.text-btn {
  display: inline-flex; align-items: center; gap: 8px;
  margin-top: 10px; padding: 10px 6px; border: 0; background: none;
  color: var(--accent); font-weight: 600;
}
.text-btn.muted { color: var(--text-soft); font-weight: 500; width: 100%; justify-content: center; }

.result { text-align: center; padding: 26px 20px; margin-top: 20px; }
.result-kicker { margin: 0; font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--text-soft); }
.result-value {
  margin: 8px 0 6px; font-size: clamp(44px, 14vw, 64px); font-weight: 300; line-height: 1.1;
  color: var(--accent); font-variant-numeric: tabular-nums;
}
.result-detail { margin: 0; font-size: 14px; color: var(--text-soft); }

.primary-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; min-height: 56px; margin-top: 16px;
  border: 0; border-radius: 16px; background: var(--accent); color: var(--on-accent);
  font-size: 17px; font-weight: 700;
}
.primary-btn svg { fill: currentColor; stroke: none; }
.primary-btn:disabled { opacity: .4; cursor: default; }
.primary-btn.small { width: auto; min-height: 44px; margin: 0; padding: 0 20px; }

/* ---------- Favorieten en tips ---------- */
.list { display: grid; gap: 10px; }
.fav { display: flex; align-items: center; gap: 8px; padding: 0; overflow: hidden; }
.fav-main { flex: 1; text-align: left; border: 0; background: none; padding: 16px; }
.fav-name { display: block; font-weight: 600; }
.fav-sub { display: block; color: var(--text-soft); font-size: 14px; }
.empty { text-align: center; color: var(--text-soft); padding: 40px 24px; }
.tips h3 { margin: 0 0 6px; font-size: 16px; color: var(--accent); }
.tips p { margin: 0; }
.maker a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.option { display: flex; gap: 14px; align-items: flex-start; cursor: pointer; }
.option input { accent-color: var(--accent); width: 20px; height: 20px; margin: 2px 0 0; flex: none; }
.option:has(input:checked) { border-color: var(--accent); }
.option-title { display: block; font-weight: 600; }
.option-sub { display: block; color: var(--text-soft); font-size: 14px; margin-top: 2px; }
#open-settings.is-active { color: var(--accent); border-color: var(--accent); }
.maker { text-align: center; color: var(--text-soft); font-size: 13px; margin-top: 20px; }

/* ---------- Timer ---------- */
.timer {
  position: fixed; inset: 0; z-index: 10;
  display: flex; flex-direction: column; align-items: center;
  padding: calc(env(safe-area-inset-top) + 10px) 16px calc(env(safe-area-inset-bottom) + 20px);
  background: var(--bg);
}
.timer[hidden] { display: none; }
.timer-head { display: flex; align-items: center; width: 100%; max-width: 560px; }
.timer-head h1 { flex: 1; text-align: center; font-size: 18px; margin: 0; }
.spacer { width: 44px; }
.timer-summary { color: var(--text-soft); margin: 8px 0 0; }
.ring-wrap {
  position: relative; flex: 1; width: 100%; max-width: 440px;
  display: grid; place-items: center; min-height: 0;
}
.ring { width: min(100%, 52dvh); height: auto; aspect-ratio: 1; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 8; }
.ring-track { stroke: var(--line); }
.ring-bar { stroke: var(--accent); stroke-linecap: round; transition: stroke-dashoffset .1s linear; }
.ring-center { position: absolute; text-align: center; }
.timer-state { margin: 0; font-size: 13px; letter-spacing: .2em; text-transform: uppercase; color: var(--text-soft); }
.timer-state.done { color: var(--accent); }
.timer-clock { margin: 4px 0 0; font-size: clamp(52px, 16vw, 84px); font-weight: 300; font-variant-numeric: tabular-nums; }
.timer .primary-btn { max-width: 560px; }
/* Alarm: scherm knippert, zodat je het ook ziet als het geluid zacht staat. */
.timer.alarm { animation: alarm-flash 1.5s steps(1) infinite; }
.timer.alarm .timer-clock, .timer.alarm .timer-state { color: var(--accent); }
@keyframes alarm-flash {
  0%, 30% { background: color-mix(in srgb, var(--accent) 35%, var(--bg)); }
  15%, 45%, 100% { background: var(--bg); }
}
@media (prefers-reduced-motion: reduce) {
  .timer.alarm { animation: none; background: color-mix(in srgb, var(--accent) 25%, var(--bg)); }
}
.timer .hint { max-width: 560px; }

/* ---------- Dialoog en melding ---------- */
dialog {
  width: min(92vw, 420px); border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--card); color: var(--text); padding: 20px;
}
dialog::backdrop { background: rgb(0 0 0 / .6); }
dialog h2 { margin: 0 0 12px; font-size: 18px; }
.dialog-field { display: grid; gap: 6px; color: var(--text-soft); font-size: 14px; }
.dialog-field input {
  padding: 12px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--bg); color: var(--text); font-size: 16px;
}
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.dialog-actions .text-btn { margin: 0; }
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 20;
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 16px);
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 16px; font-size: 14px; max-width: calc(100vw - 32px);
}

/* ---------- Tablet en desktop ---------- */
@media (min-width: 820px) {
  .topbar { padding-left: 32px; padding-right: 32px; }
  .tabs {
    position: static; height: auto; padding: 4px; gap: 4px; flex: none;
    border: 1px solid var(--line); border-radius: 999px;
  }
  .tab { flex-direction: row; gap: 8px; padding: 8px 16px; border-radius: 999px; font-size: 14px; }
  .tab.is-active { background: color-mix(in srgb, var(--accent) 16%, transparent); }
  main { padding: 8px 32px 40px; }
  .calc-grid { grid-template-columns: 1fr 1fr; gap: 32px; align-items: start; }
  .calc-grid > .col:last-child { position: sticky; top: 90px; }
  .tips { grid-template-columns: 1fr 1fr; }
  .toast { bottom: 24px; }
}
@media (min-width: 820px) and (max-width: 1000px) {
  .brand span { display: none; }
}
