/* Life OS: donker, licht gevend, elk domein een eigen kleur */
@font-face { font-family: "Unbounded"; src: url("fonts/unbounded-latin-wght-normal.woff2") format("woff2"); font-weight: 200 900; font-display: swap; }
@font-face { font-family: "Manrope"; src: url("fonts/manrope-latin-wght-normal.woff2") format("woff2"); font-weight: 200 800; font-display: swap; }

:root {
  color-scheme: dark;
  --void: #04050b;
  --panel: var(--panel-mix);
  --panel-solid: #10131f;
  --line: rgb(var(--tint) / calc(0.09 * var(--tint-k)));
  --line-strong: rgb(var(--tint) / calc(0.18 * var(--tint-k)));
  --text: #eef0ff;
  --text-2: #a3a8c3;
  --text-3: #8d92b2;
  --grid: rgb(var(--tint) / calc(0.07 * var(--tint-k)));

  /* Domeinkleuren: één kleur per onderwerp, overal hetzelfde */
  --sleep: #8f7dff;
  --sleep-deep: #5a45ff;
  --sleep-light: #c3b9ff;
  --hrv: #34e3d0;
  --heart: #ff5c7a;
  --energy: #ffb648;
  --stress: #ff5fd2;
  --run: #6dffb0;
  --steps: #5ab4ff;

  --good: #4ee38a;
  --warning: #ffc24b;
  --serious: #ff8a5c;
  --critical: #ff5465;
  --accent: #8f7dff;

  --well: 4 5 11; --well-k: 1;
  --tint: 160 175 255; --tint-k: 1;
  --input-bg: rgba(4, 5, 11, 0.6);
  --panel-mix: rgba(18, 22, 38, 0.58);
  --nav-bg: rgba(12, 14, 26, 0.88);
  --backdrop: rgba(2, 3, 8, 0.65);
  --shadow-l: 0 30px 80px rgba(0, 0, 0, 0.6);
  --shadow-m: 0 12px 40px rgba(0, 0, 0, .5);
  --bg-glow-1: rgba(90, 69, 255, 0.20);
  --bg-glow-2: rgba(52, 227, 208, 0.10);
  --hi: #fff;
  --err-text: #ffd4d9;

  --z1: #6f7591; --z2: #5ab4ff; --z3: #2fbf6e; --z4: #ffbf5a; --z5: #ff5465;
  --radius-l: 26px;
  --radius-m: 18px;
  --nav-w: 104px;
  --display: "Unbounded", "Manrope", system-ui, sans-serif;
  font-family: "Manrope", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--void); color: var(--text); }
body {
  font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased; min-height: 100vh;
  background:
    radial-gradient(1100px 700px at 78% -10%, var(--bg-glow-1), transparent 60%),
    radial-gradient(900px 600px at -10% 110%, var(--bg-glow-2), transparent 60%),
    var(--void);
  background-attachment: fixed;
}
body::before {
  /* fijne scanlijnen, nauwelijks zichtbaar */
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background: repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.012) 0 1px, transparent 1px 3px);
}
button, input { font: inherit; color: inherit; }
a { color: var(--sleep-light); }
:focus-visible { outline: 2px solid var(--hrv); outline-offset: 2px; border-radius: 8px; }
svg.i { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.nav svg, .ghost svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.muted { color: var(--text-2); }
.small { font-size: 13px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- Login ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; position: relative; z-index: 1; }
.auth-card { width: 100%; max-width: 400px; background: var(--panel); backdrop-filter: blur(18px); border: 1px solid var(--line-strong); border-radius: var(--radius-l); padding: 32px; display: grid; gap: 16px; }
.auth-card h1 { font-family: var(--display); font-weight: 500; font-size: 22px; margin: 8px 0 0; letter-spacing: -0.01em; }
.auth-card p { margin: 0; }
.auth-card label { display: grid; gap: 6px; font-size: 13px; color: var(--text-2); }
.auth-card input { padding: 13px 14px; border: 1px solid var(--line-strong); border-radius: 14px; background: var(--input-bg); font-size: 16px; }
.auth-card input:focus { outline: 2px solid var(--sleep); outline-offset: 1px; }
.auth-card button, .btn {
  background: linear-gradient(135deg, var(--sleep-deep), var(--sleep)); color: #fff; border: 0; border-radius: 14px;
  padding: 12px 18px; font-weight: 700; cursor: pointer; box-shadow: 0 0 24px rgba(143, 125, 255, 0.35);
}
.btn.secondary { background: rgb(var(--tint) / calc(0.08 * var(--tint-k))); color: var(--text); box-shadow: none; border: 1px solid var(--line-strong); }
.btn:disabled { opacity: .55; cursor: default; }
.error { color: var(--critical); font-size: 14px; }
.brand { display: flex; align-items: center; gap: 12px; font-family: var(--display); font-weight: 500; font-size: 17px; letter-spacing: 0.01em; }
.brand img { border-radius: 10px; box-shadow: 0 0 18px rgba(90, 69, 255, 0.5); }

/* ---------- Layout ---------- */
.app { min-height: 100vh; position: relative; z-index: 1; }
.nav {
  position: fixed; top: 16px; bottom: 16px; left: 16px; width: calc(var(--nav-w) - 16px); z-index: 10;
  background: var(--panel); backdrop-filter: blur(20px); border: 1px solid var(--line); border-radius: var(--radius-l);
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 16px 8px;
}
.nav .brand span { display: none; }
.nav .brand { margin-bottom: 14px; }
.nav a {
  width: 100%; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 2px; border-radius: 16px;
  color: var(--text-3); text-decoration: none; font-size: 10.5px; font-weight: 600; position: relative; transition: color .2s;
}
.nav a:hover { color: var(--text); }
.nav a.active { color: var(--text); background: rgba(143, 125, 255, 0.12); }
.nav a.active::before { content: ""; position: absolute; left: -9px; top: 22%; bottom: 22%; width: 3px; border-radius: 3px; background: var(--sleep); box-shadow: 0 0 12px var(--sleep); }
.nav a.active svg { filter: drop-shadow(0 0 6px rgba(143, 125, 255, 0.8)); }

.main { margin-left: calc(var(--nav-w) + 16px); padding: 28px 36px 64px; max-width: 1360px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 26px; }
.topbar h1 { font-family: var(--display); font-weight: 400; font-size: 30px; margin: 0; letter-spacing: -0.02em; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.ghost { background: var(--panel); border: 1px solid var(--line-strong); border-radius: 14px; padding: 9px; cursor: pointer; color: var(--text-2); display: inline-flex; }
.ghost:hover { color: var(--text); }
.ghost.spinning svg { animation: spin 1s linear infinite; color: var(--hrv); }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 860px) {
  .nav {
    top: auto; left: 12px; right: 12px; bottom: calc(10px + env(safe-area-inset-bottom)); width: auto; height: 66px;
    flex-direction: row; justify-content: space-around; padding: 6px; border-radius: 24px;
  }
  .nav .brand { display: none; }
  .nav a { padding: 6px 2px; font-size: 10px; border-radius: 16px; }
  .nav a.active::before { left: 30%; right: 30%; top: auto; bottom: -7px; width: auto; height: 3px; }
  .main { margin-left: 0; padding: calc(16px + env(safe-area-inset-top)) 16px calc(100px + env(safe-area-inset-bottom)); }
  .topbar h1 { font-size: 23px; }
  /* Bijgewerkt-tijd onder de titel, knop rechts */
  .topbar { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 12px; row-gap: 3px; align-items: center; }
  .topbar-actions { display: contents; }
  #sync-status { grid-column: 1; grid-row: 2; font-size: 12px; color: var(--text-3); }
  #sync-btn { grid-column: 2; grid-row: 1 / span 2; }
}

/* ---------- Herstel-hero (rings) ---------- */
.hero { display: grid; grid-template-columns: minmax(280px, 400px) 1fr; gap: 28px; align-items: center; margin-bottom: 28px; }
.rings { position: relative; aspect-ratio: 1; width: 100%; max-width: 400px; margin: 0 auto; }
.rings svg { width: 100%; height: 100%; overflow: visible; }
.rings .track { fill: none; stroke: rgb(var(--tint) / calc(0.07 * var(--tint-k))); }
.rings .arc { fill: none; stroke-linecap: round; transition: stroke-dashoffset 1.4s cubic-bezier(.2, .8, .2, 1); }
.rings .center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; pointer-events: none; }
.rings .score { font-family: var(--display); font-weight: 300; font-size: clamp(54px, 7vw, 78px); line-height: 1; letter-spacing: -0.04em; text-shadow: 0 0 30px rgba(143, 125, 255, 0.45); }
.rings .score-label { color: var(--text-2); font-size: 13px; margin-top: 8px; }
.hero-side h2 { font-family: var(--display); font-weight: 400; font-size: 22px; line-height: 1.3; margin: 0 0 8px; letter-spacing: -0.01em; max-width: 26ch; }
.hero-side > p { color: var(--text-2); margin: 0 0 20px; max-width: 60ch; }
.ring-legend { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.ring-legend .rl { display: grid; grid-template-columns: 10px 1fr auto; align-items: center; gap: 10px; padding: 12px 14px; border-radius: var(--radius-m); background: var(--panel); border: 1px solid var(--line); }
.ring-legend .dot { width: 10px; height: 10px; border-radius: 50%; box-shadow: 0 0 10px currentColor; background: currentColor; }
.ring-legend .name { font-size: 13.5px; color: var(--text-2); }
.ring-legend .val { font-family: var(--display); font-weight: 400; font-size: 15px; }
@media (max-width: 860px) {
  .hero { grid-template-columns: 1fr; gap: 18px; }
  .rings { max-width: 300px; }
  .hero-side h2 { font-size: 18px; text-align: center; margin-inline: auto; }
  .hero-side > p { text-align: center; }
}
@media (prefers-reduced-motion: reduce) { .rings .arc { transition: none; } }

/* ---------- Componenten ---------- */
.section { margin: 34px 0 14px; display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.section h2 { font-family: var(--display); font-weight: 400; font-size: 17px; margin: 0; letter-spacing: -0.005em; }
.section a { color: var(--sleep-light); text-decoration: none; font-weight: 600; font-size: 13px; }
.grid { display: grid; gap: 14px; }
.tiles { grid-template-columns: repeat(auto-fill, minmax(178px, 1fr)); }
.cards-2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 480px), 1fr)); }
.card { background: var(--panel); backdrop-filter: blur(14px); border: 1px solid var(--line); border-radius: var(--radius-l); padding: 20px 22px; min-width: 0; position: relative; }
.card h3 { font-size: 14.5px; margin: 0 0 2px; font-weight: 700; }
.card .sub { font-size: 12.5px; color: var(--text-2); margin: 0 0 12px; }

.tile { display: flex; flex-direction: column; gap: 2px; padding: 18px 18px 14px; overflow: hidden; }
.tile::after { /* zachte gloed in de domeinkleur */
  content: ""; position: absolute; width: 160px; height: 160px; right: -70px; top: -80px; border-radius: 50%;
  background: var(--c, transparent); opacity: .13; filter: blur(30px); pointer-events: none;
}
.tile .label { font-size: 13px; color: var(--text-2); font-weight: 600; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tile .label::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--c, var(--text-3)); box-shadow: 0 0 10px var(--c, transparent); }
.tile .value { font-family: var(--display); font-size: 27px; font-weight: 400; letter-spacing: -0.03em; line-height: 1.2; margin-top: 6px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tile .value small { font-family: "Manrope", sans-serif; font-size: 13px; font-weight: 600; color: var(--text-2); margin-left: 5px; letter-spacing: 0; }
.tile .delta { font-size: 12.5px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.tile .when { font-size: 12px; color: var(--text-3); }
.tile canvas { margin-top: 10px; }
/* Vaste hoogte op de houder, zodat Chart.js het canvas zelf op maat maakt en lijnen niet worden uitgerekt */
.spark-box { position: relative; height: 38px; margin-top: 10px; }
.tile .spark-box canvas { margin-top: 0; }

.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 700; padding: 2px 9px; border-radius: 99px; background: rgb(var(--tint) / calc(0.08 * var(--tint-k))); color: var(--text-2); }
.badge.good { color: var(--good); background: rgba(78, 227, 138, 0.1); }
.badge.warning { color: var(--warning); background: rgba(255, 194, 75, 0.1); }
.badge.serious { color: var(--serious); background: rgba(255, 138, 92, 0.1); }
.badge.critical { color: var(--critical); background: rgba(255, 84, 101, 0.1); }

.signals { display: grid; gap: 14px; }
.signal { display: flex; gap: 14px; align-items: flex-start; }
.signal .icon { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; flex: none; font-weight: 800; font-size: 14px; color: #04050b; }
.signal .icon.good { background: var(--good); box-shadow: 0 0 14px rgba(78, 227, 138, 0.5); }
.signal .icon.warning { background: var(--warning); box-shadow: 0 0 14px rgba(255, 194, 75, 0.5); }
.signal .icon.serious { background: var(--serious); box-shadow: 0 0 14px rgba(255, 138, 92, 0.5); }
.signal .icon.info { background: var(--hrv); box-shadow: 0 0 14px rgba(52, 227, 208, 0.45); }
.signal p { margin: 0; }
.signal .t { font-weight: 700; }

.chart-box { position: relative; height: 240px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12.5px; color: var(--text-2); margin: 0 0 10px; }
.legend span { display: inline-flex; align-items: center; gap: 7px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.legend i.line { height: 3px; border-radius: 2px; width: 16px; }
.legend i.dash { height: 0; width: 16px; border-top: 2px dashed currentColor; background: none !important; }
.legend i.band { background: rgba(52, 227, 208, 0.16); }

.seg { display: inline-flex; background: rgb(var(--tint) / calc(0.06 * var(--tint-k))); border: 1px solid var(--line); border-radius: 14px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; padding: 6px 12px; border-radius: 11px; font-size: 13px; cursor: pointer; color: var(--text-2); font-weight: 600; }
.seg button.on { background: rgba(143, 125, 255, 0.18); color: var(--text); box-shadow: inset 0 0 0 1px rgba(143, 125, 255, 0.35); }

table.list { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
table.list th { text-align: left; font-weight: 600; font-size: 12.5px; color: var(--text-3); padding: 8px 10px; border-bottom: 1px solid var(--line-strong); }
table.list td { padding: 10px; border-bottom: 1px solid var(--line); }
table.list tr:last-child td { border-bottom: 0; }
table.list tbody tr:hover td { background: rgb(var(--tint) / calc(0.04 * var(--tint-k))); }
table.list .num { text-align: right; }
.table-wrap { overflow-x: auto; margin: 0 -8px; }

.progress { height: 6px; background: rgb(var(--tint) / calc(0.08 * var(--tint-k))); border-radius: 99px; overflow: hidden; margin: 6px 0 10px; }
.progress > div { height: 100%; background: linear-gradient(90deg, var(--sleep-deep), var(--hrv)); border-radius: 99px; box-shadow: 0 0 12px var(--hrv); transition: width .4s; }
pre.code { background: rgb(var(--well) / calc(0.7 * var(--well-k))); border: 1px solid var(--line); border-radius: 14px; padding: 14px; font-size: 12px; overflow: auto; max-height: 420px; margin: 12px 0 0; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.empty { padding: 32px; text-align: center; color: var(--text-2); }
.loading { padding: 60px; text-align: center; color: var(--text-3); }

.prose h4 { font-family: var(--display); font-weight: 400; font-size: 16px; margin: 22px 0 8px; color: var(--sleep-light); }
.prose h4:first-of-type { margin-top: 4px; }
.prose p, .prose li { margin: 0 0 8px; max-width: 72ch; }
.prose ul, .prose ol { padding-left: 22px; margin: 0 0 8px; }
.prose li::marker { color: var(--sleep); }
.prose summary { cursor: pointer; font-weight: 700; }

@media (max-width: 860px) {
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .tile { padding: 14px 14px 10px; }
  .tile .value { font-size: 22px; }
  .tile .label { font-size: 12.5px; }
  .ring-legend { gap: 8px; }
  .ring-legend .rl { padding: 10px 12px; gap: 8px; }
  .ring-legend .name { font-size: 12.5px; }
  .ring-legend .val { font-size: 13px; white-space: nowrap; }
  .hero-side > p { font-size: 13.5px; }
  .card { padding: 18px 16px; border-radius: 22px; }
}

.paste { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 12px; }
.paste summary { cursor: pointer; font-weight: 600; font-size: 14px; color: var(--sleep-light); }
.paste textarea { width: 100%; margin-top: 8px; background: var(--input-bg); border: 1px solid var(--line-strong); border-radius: 14px; padding: 12px; color: var(--text); font: 13.5px/1.5 "Manrope", sans-serif; resize: vertical; }
.paste textarea:focus { outline: 2px solid var(--sleep); outline-offset: 1px; }
.linkbtn { background: none; border: 0; color: var(--text-3); font-size: 12.5px; cursor: pointer; padding: 4px 0; }
.linkbtn:hover { color: var(--critical); }

/* Tip bovenaan een pagina */
.tip { display: flex; gap: 16px; align-items: flex-start; padding: 18px 20px; margin-bottom: 18px; border-radius: var(--radius-l); border: 1px solid var(--line); position: relative; overflow: hidden;
  background: linear-gradient(120deg, color-mix(in srgb, var(--c) 16%, transparent), var(--panel-mix) 55%); backdrop-filter: blur(14px); }
.tip-icon { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; flex: none; color: var(--c); background: color-mix(in srgb, var(--c) 16%, transparent); box-shadow: 0 0 18px color-mix(in srgb, var(--c) 35%, transparent); }
.tip-icon svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.tip-title { margin: 0 0 3px; font-weight: 700; font-size: 15px; }
.tip-text { margin: 0; color: var(--text-2); font-size: 14px; max-width: 80ch; }

/* Slaapritme */
.rhythm-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin: 4px 0 16px; }
.rv { display: flex; flex-direction: column; gap: 2px; padding: 14px 16px; border-radius: var(--radius-m); background: rgb(var(--well) / calc(0.35 * var(--well-k))); border: 1px solid var(--line); }
.rl-label { font-size: 12.5px; color: var(--text-2); font-weight: 600; }
.rl-value { font-family: var(--display); font-size: 26px; font-weight: 400; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.rl-value small { font-family: "Manrope", sans-serif; font-size: 13px; color: var(--text-2); font-weight: 600; margin-left: 5px; letter-spacing: 0; }
.rl-diff { font-size: 12.5px; color: var(--text-2); }
.chart-box.short { height: 220px; }
@media (max-width: 860px) {
  .rhythm-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .rl-value { font-size: 21px; }
  .tip { padding: 14px 16px; gap: 12px; }
  .tip-text { font-size: 13.5px; }
}

/* Verbanden */
.corr-intro { margin: 0 0 16px; font-size: 14px; max-width: 80ch; }
.corr { display: flex; flex-direction: column; }
/* Gekleurde rand die met de hoeken van de kaart meebuigt: een inset-schaduw volgt de afronding */
.card.corr { box-shadow: inset 3px 0 0 var(--c); background: linear-gradient(90deg, color-mix(in srgb, var(--c) 7%, transparent), transparent 45%), var(--panel); }
.corr-meta { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.corr-cat { font-size: 12.5px; font-weight: 700; color: var(--c); }
.corr-title { font-size: 16px !important; line-height: 1.4; font-weight: 600 !important; margin: 0 0 6px !important; max-width: 60ch; }
.corr-chart { height: 170px; margin-top: auto; }
.corr-chart.pair { height: 110px; }
.corr-none { margin-top: 14px; }
.corr-none summary { cursor: pointer; font-weight: 600; }
.corr-none ul { margin: 6px 0 0; padding-left: 20px; color: var(--text-2); font-size: 14px; }
@media (max-width: 860px) { .nav a { font-size: 9.5px; } .nav a span { max-width: 52px; } }

/* Klikbare tegels */
.clickable { cursor: pointer; transition: border-color .2s, transform .2s; }
.card.clickable:hover, .rl.clickable:hover { border-color: color-mix(in srgb, var(--c, var(--sleep)) 45%, transparent); }
.rl.clickable:hover { border-color: currentColor; }
.card.clickable:active { transform: scale(0.985); }

/* Uitleg-popup */
dialog.info {
  width: min(640px, calc(100vw - 32px)); max-height: calc(100vh - 48px); overflow: auto; padding: 24px 26px 28px;
  background: var(--panel-solid); color: var(--text); border: 1px solid var(--line-strong); border-radius: var(--radius-l);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.02), var(--shadow-l), 0 0 60px color-mix(in srgb, var(--c) 18%, transparent);
}
dialog.info::backdrop { background: var(--backdrop); backdrop-filter: blur(6px); }
dialog.info[open] { animation: pop .22s cubic-bezier(.2, .8, .2, 1); }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.98); } }
.info-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.info-head h2 { font-family: var(--display); font-weight: 400; font-size: 21px; margin: 0; display: flex; align-items: center; gap: 12px; }
.info-head .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--c); box-shadow: 0 0 14px var(--c); }
/* Tegels groeien mee: zoveel naast elkaar als past, een losse laatste tegel vult de rij */
.info-stats { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 18px; }
.info-stats > div { flex: 1 1 128px; min-width: 0; display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; border-radius: var(--radius-m); background: rgb(var(--well) / calc(0.45 * var(--well-k))); border: 1px solid var(--line); }
.info-stats span { font-size: 12px; color: var(--text-2); font-weight: 600; }
.info-stats strong { font-family: var(--display); font-weight: 400; font-size: 18px; letter-spacing: -0.02em; }
.info-stats em { font-style: normal; font-size: 12px; color: var(--text-3); }
.info-chart { height: 190px; margin-bottom: 8px; }
dialog.info h3 { font-size: 14.5px; margin: 18px 0 6px; color: var(--c); }
dialog.info p { margin: 0; color: var(--text-2); max-width: 70ch; }
dialog.info ul { margin: 0; padding-left: 20px; color: var(--text-2); }
dialog.info li { margin-bottom: 6px; }
dialog.info li::marker { color: var(--c); }
@media (max-width: 860px) {
  dialog.info { width: 100vw; max-width: 100vw; max-height: 88vh; margin: auto 0 0; border-radius: 26px 26px 0 0; padding: 20px 18px calc(28px + env(safe-area-inset-bottom)); }
  dialog.info[open] { animation: sheet .28s cubic-bezier(.2, .8, .2, 1); }
  @keyframes sheet { from { transform: translateY(40px); opacity: 0; } }
}
@media (prefers-reduced-motion: reduce) { dialog.info[open] { animation: none; } }

/* Plan voor vandaag (Vandaag) */
.plan-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 10px; }
.plan { display: flex; flex-direction: column; gap: 2px; padding: 14px 16px; border-radius: var(--radius-m); background: var(--panel); border: 1px solid var(--line); position: relative; overflow: hidden; }
.plan::after { content: ""; position: absolute; width: 120px; height: 120px; right: -50px; top: -60px; border-radius: 50%; background: var(--c); opacity: .14; filter: blur(26px); pointer-events: none; }
.plan:hover { border-color: color-mix(in srgb, var(--c) 45%, transparent); }
.plan-label { font-size: 12.5px; color: var(--text-2); font-weight: 600; }
.plan-value { font-family: var(--display); font-size: 22px; font-weight: 400; letter-spacing: -0.02em; }
.plan-text { font-size: 13px; color: var(--text); font-weight: 600; }
.plan-sub { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.te-scale { margin: 12px 0 6px; }
.te-bar { position: relative; height: 8px; border-radius: 99px; background: rgb(var(--tint) / calc(0.08 * var(--tint-k))); }
.te-tick { position: absolute; top: 1px; bottom: 1px; width: 1px; margin-left: -0.5px; background: rgb(var(--tint) / calc(0.22 * var(--tint-k))); }
.te-nums { position: relative; height: 16px; margin-top: 5px; font-size: 11px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.te-nums span { position: absolute; top: 0; transform: translateX(-50%); }
.te-nums span:first-child { transform: none; }
.te-nums span:last-child { transform: translateX(-100%); }
.te-ends { display: flex; justify-content: space-between; font-size: 11px; color: var(--text-3); margin-top: 1px; }
.te-target { position: absolute; top: 0; bottom: 0; border-radius: 99px; background: var(--c); box-shadow: 0 0 10px var(--c); }
.te-done { position: absolute; top: 50%; width: 12px; height: 12px; margin: -6px 0 0 -6px; border-radius: 50%; background: var(--hi); box-shadow: 0 0 0 3px var(--panel-solid), 0 0 10px var(--hi); }

/* Vannacht (Slaap) */
.tonight { display: flex; align-items: center; gap: 14px; padding: 14px 16px; margin: 4px 0 12px; border-radius: var(--radius-m); border: 1px solid color-mix(in srgb, var(--sleep) 35%, transparent); background: linear-gradient(110deg, color-mix(in srgb, var(--sleep) 18%, transparent), transparent 70%); }
.tonight > div { display: flex; flex-direction: column; gap: 2px; }
.tonight-main { font-size: 15px; }
.tonight-main strong { font-family: var(--display); font-weight: 400; font-size: 20px; color: var(--sleep-light); }

/* Weekrapport */
.week { margin-bottom: 4px; }
.week-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.week-head > div { text-align: center; }
.week-head .ghost { width: 38px; height: 38px; justify-content: center; align-items: center; font-size: 20px; line-height: 1; padding: 0; }
.week-head .ghost:disabled { opacity: .3; cursor: default; }
.week-verdict { padding: 12px 14px; border-radius: var(--radius-m); background: rgb(var(--well) / calc(0.35 * var(--well-k))); border: 1px solid var(--line); margin-bottom: 10px; }
.week-table td:first-child { color: var(--text-2); }
.week-table .up-good { color: var(--good); }
.week-table .up-bad { color: var(--critical); }
.week-nights { margin: 10px 0 0; }
.week-ai { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }

/* Menubalk: extra pagina's op mobiel in een paneel */
.nav-more { display: none; }
.more-sheet { display: none; }
@media (max-width: 860px) {
  .nav a.nav-extra { display: none; }
  .nav-more { display: flex; flex-direction: column; align-items: center; gap: 3px; flex: 1; padding: 6px 2px; border: 0; background: none; border-radius: 16px; color: var(--text-3); font-size: 10.5px; font-weight: 600; cursor: pointer; position: relative; }
  .nav-more.active { color: var(--text); background: rgba(143, 125, 255, 0.12); }
  .nav-more.active::before { content: ""; position: absolute; left: 30%; right: 30%; bottom: -7px; height: 3px; border-radius: 3px; background: var(--sleep); box-shadow: 0 0 12px var(--sleep); }
  .nav a { font-size: 10.5px; }
  .nav a span { max-width: none; }
  .more-sheet[open] { display: grid; gap: 8px; width: 100vw; max-width: 100vw; margin: auto 0 0; padding: 10px 14px calc(24px + env(safe-area-inset-bottom)); border: 1px solid var(--line-strong); border-bottom: 0; border-radius: 26px 26px 0 0; background: var(--panel-solid); color: var(--text); animation: sheet .26s cubic-bezier(.2, .8, .2, 1); }
  .more-sheet::backdrop { background: var(--backdrop); backdrop-filter: blur(4px); }
  .sheet-grip { width: 40px; height: 4px; border-radius: 4px; background: var(--line-strong); justify-self: center; margin-bottom: 6px; }
  .more-sheet a { display: flex; align-items: center; gap: 14px; padding: 14px; border-radius: var(--radius-m); background: rgb(var(--tint) / calc(0.05 * var(--tint-k))); border: 1px solid var(--line); color: var(--text); text-decoration: none; }
  .more-sheet a.active { border-color: color-mix(in srgb, var(--c) 50%, transparent); }
  .more-sheet svg { width: 24px; height: 24px; fill: none; stroke: var(--c); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; flex: none; filter: drop-shadow(0 0 6px var(--c)); }
  .more-sheet span { display: flex; flex-direction: column; }
  .more-sheet strong { font-size: 15px; }
  .more-sheet em { font-style: normal; font-size: 12.5px; color: var(--text-2); }
  .plan-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .plan { padding: 12px; }
  .plan-value { font-size: 18px; }
}
@media (max-width: 860px) and (prefers-reduced-motion: reduce) { .more-sheet[open] { animation: none; } }

.week-table td.num { white-space: nowrap; }
@media (max-width: 860px) { .week-table { font-size: 13px; } .week-table td, .week-table th { padding: 8px 6px; } }
.week .table-wrap, .week-verdict, .week-nights, .week-ai { max-width: 820px; }

/* Menubalk mobiel: vijf gelijke vakken */
@media (max-width: 860px) {
  .nav { justify-content: stretch; gap: 2px; padding: 6px; }
  .nav a, .nav-more { flex: 1 1 0; width: auto; min-width: 0; padding: 7px 0; gap: 4px; font-size: 10.5px; }
  .nav a span, .nav-more span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
}
@media (max-width: 860px) { .nav { background: var(--nav-bg); backdrop-filter: blur(24px) saturate(140%); } }

/* Vannacht in drie stappen */
.tonight { flex-direction: column; align-items: stretch; gap: 10px; }
.tonight-top { display: flex; flex-direction: column; gap: 2px; }
.steps { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; position: relative; }
.step { display: flex; flex-direction: column; gap: 1px; padding: 10px 12px; border-radius: 14px; background: rgb(var(--well) / calc(0.4 * var(--well-k))); border: 1px solid var(--line); }
.step strong { font-family: var(--display); font-weight: 400; font-size: 20px; color: var(--sleep-light); letter-spacing: -0.02em; }
.step:first-child { border-color: color-mix(in srgb, var(--sleep) 45%, transparent); }
.step:first-child strong { color: var(--hi); text-shadow: 0 0 14px var(--sleep); }
@media (max-width: 860px) { .step { padding: 8px 10px; } .step strong { font-size: 17px; } }

/* Achtergrond vast terwijl een popup open is */
html.modal-open, html.modal-open body { overflow: hidden; }
html.modal-open body { position: fixed; left: 0; right: 0; width: 100%; }
dialog.info, .more-sheet { overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.tonight > .steps { display: grid; flex-direction: row; gap: 12px; }
@media (max-width: 380px) { .tonight > .steps { gap: 6px; } .step { padding: 8px; } .step .rl-diff { font-size: 11px; } }

/* Jouw slaapbehoefte */
.need-card { margin-bottom: 14px; }
.need-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.need-value { font-family: var(--display); font-weight: 300; font-size: 34px; letter-spacing: -0.03em; white-space: nowrap; text-shadow: 0 0 22px color-mix(in srgb, var(--sleep) 60%, transparent); }
.need-card code { font-size: 12px; background: rgb(var(--tint) / calc(0.08 * var(--tint-k))); padding: 1px 5px; border-radius: 5px; }
@media (max-width: 860px) { .need-value { font-size: 26px; } }

/* ---------- Ronde 7: rust, feedback, leesbaarheid ---------- */

/* Compacte uitleg van de ringen */
.ring-key { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; color: var(--text-2); margin: 4px 0 16px; }
.ring-key span { display: inline-flex; align-items: center; gap: 7px; }
.ring-key i { width: 9px; height: 9px; border-radius: 50%; background: var(--c); box-shadow: 0 0 8px var(--c); }
.ring-key .muted { color: var(--text-3); }
.hero-side h2 { margin-bottom: 12px; }
@media (max-width: 860px) { .ring-key { justify-content: center; } }

/* Melding onderin */
.toast { position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; z-index: 50;
  max-width: min(92vw, 460px); padding: 11px 18px; border-radius: 14px; font-size: 14px; font-weight: 600; text-align: center;
  background: var(--panel-solid); color: var(--text); border: 1px solid var(--line-strong); box-shadow: var(--shadow-m); transition: opacity .2s, transform .2s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.ok { border-color: color-mix(in srgb, var(--good) 50%, transparent); }
.toast.error { border-color: color-mix(in srgb, var(--critical) 60%, transparent); color: var(--err-text); }
.toast.warn { border-color: color-mix(in srgb, var(--warning) 50%, transparent); }
.toast.busy::before { content: ""; display: inline-block; width: 10px; height: 10px; margin-right: 9px; border-radius: 50%; border: 2px solid var(--hrv); border-right-color: transparent; vertical-align: -1px; animation: spin .8s linear infinite; }
@media (max-width: 860px) { .toast { bottom: calc(92px + env(safe-area-inset-bottom)); } }

/* Label bij verouderde data */
.title-wrap { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; min-width: 0; }
.stale { font-size: 12px; font-weight: 700; color: var(--warning); background: rgba(255, 194, 75, 0.1); padding: 3px 10px; border-radius: 99px; }

/* Omlaag trekken om te vernieuwen */
.ptr { position: fixed; top: 0; left: 50%; z-index: 40; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center;
  transform: translate(-50%, -50px); opacity: 0; background: var(--panel-solid); border: 1px solid var(--line-strong); color: var(--text-2); pointer-events: none; }
.ptr svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.ptr.ready { color: var(--hrv); box-shadow: 0 0 16px rgba(52, 227, 208, .4); }

/* Tabs op Slaap */
.seg.tabs { display: flex; width: fit-content; margin-bottom: 18px; }
.seg.tabs button { padding: 9px 20px; font-size: 14px; }
@media (max-width: 860px) { .seg.tabs { width: 100%; } .seg.tabs button { flex: 1; } }

/* Schakelaar voor de herinnering */
.remind-row { margin: -2px 0 14px; min-height: 24px; display: flex; flex-direction: column; gap: 4px; }
.switch { display: inline-flex; align-items: center; gap: 12px; cursor: pointer; font-size: 14px; color: var(--text); width: fit-content; position: relative; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { position: relative; width: 44px; height: 26px; border-radius: 99px; background: rgb(var(--tint) / calc(0.16 * var(--tint-k))); transition: background .2s; flex: none; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .2s; }
.switch input:checked + .track { background: var(--sleep); box-shadow: 0 0 12px rgba(143, 125, 255, .5); }
.switch input:checked + .track::after { transform: translateX(18px); }
.switch input:focus-visible + .track { outline: 2px solid var(--hrv); outline-offset: 2px; }
.switch input:disabled + .track { opacity: .4; }

/* Verschil op Verbanden */
.pair { display: grid; grid-template-columns: auto 1fr; gap: 26px; align-items: center; margin-top: auto; padding: 10px 8px 0 0; }
.pair-diff { display: flex; flex-direction: column; line-height: 1.1; min-width: 70px; }
.pair-diff strong { font-family: var(--display); font-weight: 400; font-size: 34px; letter-spacing: -0.03em; }
.pair-diff span { font-size: 13px; font-weight: 600; color: var(--text-2); }
.pair-diff em { font-style: normal; font-size: 12px; color: var(--text-3); }
.pair-diff.up-good strong { color: var(--good); text-shadow: 0 0 18px rgba(78, 227, 138, .35); }
.pair-diff.up-bad strong { color: var(--serious); text-shadow: 0 0 18px rgba(255, 138, 92, .3); }
.pair-scale { position: relative; height: 84px; margin: 0 40px; }
.pair-line { position: absolute; left: -24px; right: -24px; top: 41px; height: 2px; border-radius: 2px; background: var(--line-strong); }
.pair-dot { position: absolute; top: 35px; width: 14px; height: 14px; margin-left: -7px; border-radius: 50%; background: var(--c); box-shadow: 0 0 0 3px var(--panel-solid), 0 0 14px var(--c); }
.pair-dot.b { background: var(--panel-solid); border: 2px solid var(--c); box-shadow: 0 0 0 3px var(--panel-solid); }
.pair-dot span { position: absolute; left: 50%; transform: translateX(-50%); white-space: nowrap; font-size: 12px; color: var(--text-2); text-align: center; display: flex; flex-direction: column; }
.pair-dot.a span { bottom: 20px; }
.pair-dot.b span { top: 20px; flex-direction: column-reverse; }
.pair-dot b { font-size: 13px; color: var(--text); }

/* Grotere tikvlakken */
.ghost { min-width: 40px; min-height: 40px; justify-content: center; align-items: center; }
.seg button { padding: 8px 13px; min-height: 34px; }
.linkbtn { padding: 8px 4px; }

/* Instellingen */
.settings { display: grid; gap: 16px; margin-bottom: 4px; }
.settings h3 { margin: 0; }
.settings .sub { margin: -10px 0 0; }
.set-row { border: 0; padding: 0; margin: 0; display: grid; gap: 8px; }
.set-row legend, .set-field > span { font-size: 13px; font-weight: 700; color: var(--text-2); margin-bottom: 6px; padding: 0; }
.radio { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 12px; border-radius: 14px; border: 1px solid var(--line); background: rgb(var(--well) / calc(0.3 * var(--well-k))); cursor: pointer; }
.radio:has(input:checked) { border-color: color-mix(in srgb, var(--sleep) 50%, transparent); background: rgba(143, 125, 255, 0.08); }
.radio input { accent-color: var(--sleep); width: 18px; height: 18px; margin: 0; }
.radio span { font-size: 14px; color: var(--text-2); }
.radio strong { color: var(--text); }
.settings select, .settings textarea { background: var(--input-bg); border: 1px solid var(--line-strong); border-radius: 12px; padding: 9px 12px; color: var(--text); font: 14px "Manrope", sans-serif; }
.settings select:focus, .settings textarea:focus { outline: 2px solid var(--sleep); outline-offset: 1px; }
.settings select:disabled { opacity: .45; }
.radio select { margin-left: auto; }
.set-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.set-field { display: flex; flex-direction: column; gap: 4px; }
.set-pair .set-note { grid-column: 1 / -1; margin: -4px 0 0; font-size: 12px; color: var(--text-3); }
.set-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-top: 14px; }
.set-field em { font-style: normal; font-size: 12px; color: var(--text-3); }
.set-field textarea { resize: vertical; min-height: 64px; }
@media (max-width: 860px) { .set-grid { grid-template-columns: 1fr; } .radio select { margin-left: 28px; } }
.radio { display: grid; grid-template-columns: 18px 1fr auto; align-items: center; column-gap: 10px; row-gap: 8px; }
.radio select { margin-left: 0; }
@media (max-width: 860px) { .radio { grid-template-columns: 18px 1fr; } .radio select { grid-column: 2; justify-self: start; margin-left: 0; } }

/* Waarschuwingen bovenaan */
.alerts { display: grid; gap: 10px; }
.alerts:not(:empty) { margin-bottom: 18px; }
.alert { display: flex; gap: 14px; align-items: flex-start; padding: 14px 16px; border-radius: var(--radius-m); border: 1px solid; }
.alert .icon { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; flex: none; font-weight: 800; color: #04050b; }
.alert .t { margin: 0 0 2px; font-weight: 700; }
.alert .x { margin: 0; font-size: 13.5px; color: var(--text-2); }
.alert a { color: var(--text); font-weight: 600; }
.alert.critical { border-color: rgba(255, 84, 101, .45); background: rgba(255, 84, 101, .08); }
.alert.critical .icon { background: var(--critical); box-shadow: 0 0 14px rgba(255, 84, 101, .5); }
.alert.warning { border-color: rgba(255, 194, 75, .4); background: rgba(255, 194, 75, .07); }
.alert.warning .icon { background: var(--warning); }

/* Account */
.account { display: grid; gap: 14px; }
.account h3, .account .sub { margin: 0; }
.pw-form { display: grid; gap: 12px; padding-top: 4px; }
.pw-form input, .settings input[type=date], .settings input[type=time] { background: var(--input-bg); border: 1px solid var(--line-strong); border-radius: 12px; padding: 10px 12px; color: var(--text); font: 15px "Manrope", sans-serif; }
.pw-form input:focus, .settings input[type=date]:focus, .settings input[type=time]:focus { outline: 2px solid var(--sleep); outline-offset: 1px; }
.account-actions { padding-top: 12px; border-top: 1px solid var(--line); }

/* Vroege waarschuwing */
.ew { --c: var(--warning); display: flex; gap: 16px; padding: 20px 22px; margin-bottom: 22px; border-radius: var(--radius-l); border: 1px solid color-mix(in srgb, var(--c) 45%, transparent);
  background: linear-gradient(120deg, color-mix(in srgb, var(--c) 16%, transparent), var(--panel-mix) 60%); box-shadow: 0 0 40px color-mix(in srgb, var(--c) 12%, transparent); }
.ew.ill { --c: var(--critical); }
.ew-icon { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; flex: none; color: var(--c); background: color-mix(in srgb, var(--c) 16%, transparent); box-shadow: 0 0 18px color-mix(in srgb, var(--c) 35%, transparent); }
.ew-icon svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.ew-body h2 { font-family: var(--display); font-weight: 400; font-size: 20px; margin: 2px 0 6px; }
.ew-body p { margin: 0 0 10px; color: var(--text-2); max-width: 72ch; }
.ew-body ul { margin: 0 0 8px; padding-left: 20px; color: var(--text); font-size: 14px; }
.ew-body li { margin-bottom: 4px; }
.ew-body li::marker { color: var(--c); }
.ew-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 12px; }
.ew-chip { font-size: 13px; padding: 6px 11px; border-radius: 10px; background: rgb(var(--well) / calc(0.45 * var(--well-k))); border: 1px solid var(--line); color: var(--text-2); }
.ew-chip b { color: var(--c); font-weight: 700; }
.ew-chip em { font-style: normal; color: var(--text-3); margin-left: 4px; }
.ew-note { font-size: 12px !important; color: var(--text-3) !important; margin: 4px 0 0 !important; }
@media (max-width: 860px) { .ew { flex-direction: column; gap: 10px; padding: 16px; } .ew-body h2 { font-size: 18px; } }
.toast { width: max-content; }

/* ---------- Licht thema ---------- */
html[data-theme="light"] {
  color-scheme: light;
  --z1: #b4b9cc; --z2: #1f7fd6; --z3: #17924d; --z4: #eca42a; --z5: #cf2b42;
  --void: #eef0f7;
  --panel: rgba(255, 255, 255, 0.82);
  --panel-solid: #ffffff;
  --line: rgba(28, 36, 96, 0.09);
  --line-strong: rgba(28, 36, 96, 0.17);
  --text: #15172c;
  --text-2: #4a4f6e;
  --text-3: #63688a;
  --grid: rgba(28, 36, 96, 0.08);

  --sleep: #6a52e8;
  --sleep-deep: #4a33d6;
  --sleep-light: #5038d8;
  --hrv: #0b9e8f;
  --heart: #e0365a;
  --energy: #c97a00;
  --stress: #c93aa6;
  --run: #1c9a5a;
  --steps: #1f7fd6;

  --good: #17924d;
  --warning: #9a6a00;
  --serious: #c4501c;
  --critical: #cf2b42;
  --accent: #6a52e8;

  --well: 230 233 244; --well-k: 1.6;
  --tint: 60 70 150; --tint-k: 1.1;
  --input-bg: #ffffff;
  --panel-mix: rgba(255, 255, 255, 0.85);
  --nav-bg: rgba(255, 255, 255, 0.9);
  --backdrop: rgba(30, 34, 64, 0.32);
  --shadow-l: 0 24px 60px rgba(22, 26, 60, 0.18);
  --shadow-m: 0 10px 30px rgba(22, 26, 60, 0.14);
  --bg-glow-1: rgba(106, 82, 232, 0.10);
  --bg-glow-2: rgba(11, 158, 143, 0.07);
  --hi: #15172c;
  --err-text: #cf2b42;
}
html[data-theme="light"] .card, html[data-theme="light"] .nav, html[data-theme="light"] .auth-card { box-shadow: 0 1px 2px rgba(22, 26, 60, 0.04), 0 6px 20px rgba(22, 26, 60, 0.05); }
html[data-theme="light"] body::before { display: none; }
html[data-theme="light"] * { text-shadow: none !important; }
html[data-theme="light"] :is(.btn, .brand img, .nav a.active::before, .ring-legend .dot, .tile .label::before, .signal .icon, .progress > div, .tip-icon, .corr::before, .info-head .dot, .te-target, .nav-more.active::before, .ring-key i, .ptr.ready, .switch input:checked + .track, .alert .icon, .ew-icon, .ew) { box-shadow: none; }
html[data-theme="light"] :is(.pair-dot, .te-done) { box-shadow: 0 0 0 3px var(--panel-solid); }
html[data-theme="light"] :is(.nav a.active svg, .more-sheet svg, .rings .arc) { filter: none; }
html[data-theme="light"] .rings .track { stroke: rgba(28, 36, 96, 0.08); }
html[data-theme="light"] .tile::after { opacity: .07; }
html[data-theme="light"] .plan::after { opacity: .07; }
html[data-theme="light"] :is(.signal .icon, .alert .icon) { color: #fff; }
html[data-theme="light"] .badge.warning, html[data-theme="light"] .stale { background: rgba(201, 138, 0, 0.12); }
.theme-card { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 22px; }
.theme-card .sub { margin: 0; }

/* ---------- Hartslagzones, runs en hartslag door de dag ---------- */
.zbar { display: flex; gap: 2px; width: 84px; height: 8px; border-radius: 4px; overflow: hidden; vertical-align: middle; }
.zbar i { display: block; min-width: 2px; }
.zrows { display: grid; gap: 8px; margin: 14px 0 12px; }
.zrow { display: grid; grid-template-columns: 58px 92px 1fr 40px; align-items: center; gap: 10px; font-size: 13px; }
.zname { font-weight: 700; }
.zbpm { color: var(--text-2); font-variant-numeric: tabular-nums; }
.ztrack { height: 10px; border-radius: 5px; background: rgb(var(--tint) / calc(0.08 * var(--tint-k))); overflow: hidden; }
.ztrack i { display: block; height: 100%; border-radius: 5px; }
.zpct { text-align: right; font-variant-numeric: tabular-nums; color: var(--text-2); }
.zsum { margin: 0; font-size: 13.5px; color: var(--text-2); }
.zsum strong { color: var(--text); }
.zdot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; }
.hot { color: var(--serious); font-weight: 700; }
table.list tr.clickable { cursor: pointer; }
table.list tr.clickable:focus-visible { outline: 2px solid var(--hrv); outline-offset: -2px; }
.run-when { margin: -6px 0 14px; }
.run-note { padding: 10px 12px; border-radius: 12px; border: 1px solid color-mix(in srgb, var(--serious) 45%, transparent); background: color-mix(in srgb, var(--serious) 9%, transparent); font-size: 13.5px; margin: 0 0 14px; }
.run-drift { font-size: 13.5px; color: var(--text-2); margin: 0 0 14px; }
.run-drift strong { color: var(--text); margin-right: 4px; }
table.laps td, table.laps th { padding-top: 6px; padding-bottom: 6px; }
.hr-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.hr-head .sub { margin: 0; }
.hr-card .legend { margin-top: 6px; }
@media (max-width: 560px) {
  .zrow { grid-template-columns: 52px 80px 1fr 34px; gap: 8px; font-size: 12.5px; }
}
.rhythm + .hr-card { margin-top: 18px; }
.nodata { padding: 12px 14px; border-radius: var(--radius-m); border: 1px dashed var(--line-strong); color: var(--text-2); font-size: 13.5px; margin: 0 0 16px; }

/* ---------- Meekleuren met de dag ---------- */
/* Ochtend: licht met een warme gloed van de opkomende zon */
html[data-phase="ochtend"] {
  --void: #f4eff0;
  --bg-glow-1: rgba(255, 158, 84, 0.20);
  --bg-glow-2: rgba(240, 110, 150, 0.10);
  --panel: rgba(255, 253, 251, 0.84);
  --panel-mix: rgba(255, 253, 251, 0.86);
  --tint: 110 70 60; --tint-k: 1;
  --well: 240 232 230; --well-k: 1.6;
}
/* Nacht: vanaf je avondroutine. Donker, warm, minder blauw en gedempte kleuren */
html[data-phase="nacht"] {
  --z1: #6e6459; --z2: #5a8fc7; --z3: #3f9a6a; --z4: #d6a24c; --z5: #d4505d;
  --void: #0b0705;
  --panel-solid: #17110e;
  --panel-mix: rgba(30, 22, 17, 0.62);
  --nav-bg: rgba(24, 17, 13, 0.92);
  --tint: 255 196 150; --tint-k: 0.85;
  --well: 8 5 3;
  --input-bg: rgba(8, 5, 3, 0.6);
  --text: #efe4d8;
  --text-2: #b3a597;
  --text-3: #918576;
  --bg-glow-1: rgba(255, 120, 50, 0.10);
  --bg-glow-2: rgba(170, 70, 110, 0.07);
  --hi: #efe4d8;

  --sleep: #8672d8;
  --sleep-deep: #5f4cc0;
  --sleep-light: #b9acef;
  --hrv: #2a9e8f;
  --heart: #d9546d;
  --energy: #c58a36;
  --stress: #c060a6;
  --run: #4caf7c;
  --steps: #5a8fc7;
  --good: #4fae74;
  --warning: #d1a345;
  --serious: #d47c55;
  --critical: #d4505d;
  --accent: #8672d8;
}
html[data-phase="nacht"] body::before { opacity: .5; }
html[data-phase="nacht"] * { text-shadow: none !important; }
html[data-phase="nacht"] :is(.nav a.active svg, .more-sheet svg, .rings .arc) { filter: none; }

/* Vloeiende overgang, alleen tijdens het wisselen */
html.theme-fade, html.theme-fade body, html.theme-fade :is(.card, .tile, .nav, .tip, .panel, .topbar, .seg, .btn, .info, h1, h2, h3, p, span, strong) {
  transition: background-color 1.4s ease, color 1.4s ease, border-color 1.4s ease, box-shadow 1.4s ease;
}
@media (prefers-reduced-motion: reduce) {
  html.theme-fade, html.theme-fade * { transition: none !important; }
}
.theme-card .seg button { white-space: nowrap; }
@media (max-width: 560px) {
  .theme-card .seg { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; width: 100%; padding: 6px; }
  .theme-card .seg button { padding: 11px 8px; font-size: 14px; }
}

/* ---------- Ruimte rond tekst ---------- */
.grid { gap: 16px; }
.card h3 { margin-bottom: 4px; }
.card .sub { line-height: 1.5; margin-bottom: 14px; }
.tip-text { line-height: 1.55; }
.tile { gap: 4px; padding: 20px 20px 16px; }
.tile .delta, .tile .when { line-height: 1.45; }
.plan { gap: 4px; padding: 16px 18px; }
.plan-sub { line-height: 1.45; }
.rv { gap: 4px; padding: 16px 18px; }
.rl-diff { line-height: 1.45; }
.tonight { padding: 16px 18px; gap: 14px; }
.tonight-top { gap: 4px; line-height: 1.45; }
.steps { gap: 10px; }
.step { gap: 3px; padding: 12px 14px; }
.rhythm-grid { gap: 14px; margin-bottom: 18px; }
table.list td { padding: 12px 10px; }
table.list.runs td { white-space: nowrap; }
.zsum, .run-drift, .run-note { line-height: 1.55; }
.info-stats { gap: 12px; }
.info-stats > div { padding: 14px 16px; gap: 3px; }

@media (max-width: 860px) {
  .main { padding-left: 18px; padding-right: 18px; }
  .card { padding: 20px 18px; }
  .tiles { gap: 12px; }
  .tile { padding: 16px 16px 12px; }
  .grid { gap: 14px; }
  .plan-grid { grid-template-columns: 1fr; gap: 12px; }
  .rhythm-grid { gap: 10px; }
  .rv { padding: 14px; }
  /* Vannacht: stappen onder elkaar, tijd rechts */
  .tonight > .steps { grid-template-columns: 1fr; gap: 8px; }
  .step { display: grid; grid-template-columns: 1fr auto; grid-template-areas: "l v" "s v"; align-items: center; column-gap: 14px; padding: 12px 16px; }
  .step .rl-label { grid-area: l; }
  .step strong { grid-area: v; font-size: 22px; }
  .step .rl-diff { grid-area: s; }
  table.list .hide-m { display: none; }
  table.list.runs td, table.list.runs th { padding-left: 8px; padding-right: 8px; }
  table.list.runs .zbar { width: 56px; }
}
@media (max-width: 380px) {
  .main { padding-left: 14px; padding-right: 14px; }
  .step { padding: 10px 14px; }
  .tonight > .steps { gap: 6px; }
}
.tile .label { flex-wrap: nowrap; align-items: flex-start; line-height: 1.35; }
.tile .label::before { flex-shrink: 0; margin-top: 4px; }
.nw { white-space: nowrap; }
.info-stats strong .nw { font: inherit; color: inherit; letter-spacing: inherit; display: inline; margin: 0; }
.eff-sum { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 2px 0 14px; }
.eff-sum > div { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border-radius: 12px; background: rgb(var(--well) / calc(0.35 * var(--well-k))); border: 1px solid var(--line); }
.eff-sum span { font-size: 12px; color: var(--text-2); font-weight: 600; }
.eff-sum strong { font-family: "Unbounded", sans-serif; font-size: 17px; font-weight: 600; }
.eff-sum em { font-style: normal; font-size: 11.5px; color: var(--text-3); line-height: 1.35; }
.ew.serious { --c: var(--serious); }
.push-state { margin: 12px 0 0; padding: 10px 12px; border-radius: 12px; font-size: 13.5px; line-height: 1.5; border: 1px solid var(--line); }
.push-state.ok { color: var(--text-2); }
.push-state.bad { border-color: color-mix(in srgb, var(--warning) 45%, transparent); background: color-mix(in srgb, var(--warning) 9%, transparent); }
.push-state code { font-size: 12.5px; }
.week-ready { display: flex; align-items: center; gap: 14px; padding: 14px 18px; margin-bottom: 18px; border-radius: var(--radius-l); border: 1px solid color-mix(in srgb, var(--sleep) 40%, var(--line)); background: color-mix(in srgb, var(--sleep) 10%, var(--panel)); color: var(--text); text-decoration: none; }
.week-ready:hover { border-color: color-mix(in srgb, var(--sleep) 65%, var(--line)); }
.wr-icon { width: 36px; height: 36px; flex: none; display: grid; place-items: center; border-radius: 12px; font-weight: 800; background: color-mix(in srgb, var(--hrv) 16%, transparent); color: var(--hrv); }
.wr-icon.good { background: color-mix(in srgb, var(--good) 16%, transparent); color: var(--good); }
.wr-icon.warning { background: color-mix(in srgb, var(--warning) 18%, transparent); color: var(--warning); }
.wr-body { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.wr-title { font-weight: 700; }
.wr-text { font-size: 13.5px; color: var(--text-2); line-height: 1.45; }
.wr-go { font-size: 24px; color: var(--text-3); }
html[data-theme="light"] .card.corr { box-shadow: inset 3px 0 0 var(--c), 0 1px 2px rgba(22, 26, 60, 0.04), 0 6px 20px rgba(22, 26, 60, 0.05); }
/* Waarde aan het eind van elke ring */
.rings .ring-val { font-family: "Manrope", system-ui, sans-serif; font-size: 3.5px; font-weight: 800; fill: rgba(4, 5, 11, 0.82); letter-spacing: -0.02em; pointer-events: none; animation: ring-val-in .5s ease 1.15s both; }
html[data-theme="light"] .rings .ring-val { fill: #fff; }
@keyframes ring-val-in { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .rings .ring-val { animation: none; } }
.rings .ring-unit { font-size: 2.7px; font-weight: 700; opacity: .8; }
.te-key { display: inline-flex; align-items: center; gap: 6px; }
.te-key i { width: 14px; height: 6px; border-radius: 99px; background: var(--run); }

/* Kaarten met een groeiende rij tegels */
.eff-sum { display: flex; flex-wrap: wrap; }
.eff-sum > div { flex: 1 1 150px; min-width: 0; }

/* Trend bij grafieken */
.th { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 6px 12px; margin-bottom: 4px; }
.th h3 { margin: 0; }
.trend { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 99px; font-size: 12.5px; font-weight: 600; line-height: 1.4; color: var(--text-2); background: rgb(var(--well) / calc(0.45 * var(--well-k))); border: 1px solid var(--line); }
.trend b { font-weight: 700; }
.trend.good { color: var(--good); border-color: color-mix(in srgb, var(--good) 35%, transparent); background: color-mix(in srgb, var(--good) 9%, transparent); }
.trend.bad { color: var(--warning); border-color: color-mix(in srgb, var(--warning) 40%, transparent); background: color-mix(in srgb, var(--warning) 9%, transparent); }
.info-stats .trend-tile.good strong { color: var(--good); }
.info-stats .trend-tile.bad strong { color: var(--warning); }

/* ---------- Trainingsschema ---------- */
.plan-card { margin-bottom: 18px; }
.pl-progress { display: flex; flex-direction: column; gap: 6px; margin: 4px 0 6px; font-size: 13px; color: var(--text-2); }
.pl-bar { height: 8px; border-radius: 99px; background: rgb(var(--tint) / calc(0.08 * var(--tint-k))); overflow: hidden; }
.pl-bar i { display: block; height: 100%; border-radius: 99px; background: var(--run); }
.pl-h { margin: 16px 0 8px; font-size: 13px; font-weight: 700; color: var(--text-2); }
.ps-list { display: flex; flex-direction: column; gap: 8px; }
.ps-row { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; padding: 11px 14px; border-radius: 14px; border: 1px solid var(--line); background: rgb(var(--well) / calc(0.35 * var(--well-k))); }
.ps-row[data-run] { cursor: pointer; }
.ps-row.is-due { border-color: color-mix(in srgb, var(--c) 55%, var(--line)); background: color-mix(in srgb, var(--c) 9%, transparent); }
.ps-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c); }
.ps-main { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.ps-main strong { font-size: 14px; }
.ps-main span { font-size: 12.5px; color: var(--text-2); }
.ps-side { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; text-align: right; }
.ps-state { font-size: 12.5px; color: var(--text-2); font-weight: 600; white-space: nowrap; }
.ps-state.done { color: var(--good); }
.ps-state.missed { color: var(--text-3); text-decoration: line-through; font-weight: 500; }
.ps-state.due { color: var(--text); }
.ps-note { font-size: 11.5px; color: var(--warning); }
.pl-all { margin-top: 16px; }
.pl-all summary { cursor: pointer; font-size: 13.5px; font-weight: 600; color: var(--text-2); }
.pl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; margin-top: 12px; }
.pl-week { display: flex; align-items: center; gap: 5px; padding: 8px 10px; border-radius: 12px; border: 1px solid var(--line); }
.pl-week.is-cur { border-color: var(--run); }
.pl-wn { display: flex; flex-direction: column; font-size: 12px; font-weight: 700; margin-right: auto; white-space: nowrap; }
.pl-wn em { font-style: normal; font-weight: 500; color: var(--text-3); font-size: 11px; }
.pl-pill { min-width: 30px; padding: 2px 6px; border-radius: 99px; font-size: 11.5px; font-weight: 700; text-align: center; color: var(--c); background: color-mix(in srgb, var(--c) 14%, transparent); }
.pl-pill.done { color: #fff; background: var(--c); }
.pl-pill.missed { opacity: .45; text-decoration: line-through; }
.pl-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 10px; font-size: 12px; color: var(--text-2); }
.pl-legend span { display: inline-flex; align-items: center; gap: 6px; }
.pl-legend i { width: 9px; height: 9px; border-radius: 50%; background: var(--c); }
.plan-sched { display: block; margin-top: 6px; font-size: 13px; color: var(--text); line-height: 1.45; }
.plan-sched:empty { display: none; }
@media (min-width: 900px) { .plan-card .ps-list { display: grid; grid-template-columns: repeat(3, 1fr); } }

/* Wachten op de nacht van vandaag */
.hero.waiting .rings .score { animation: wait-pulse 1.6s ease-in-out infinite; }
@keyframes wait-pulse { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .hero.waiting .rings .score { animation: none; } }

/* Stoplicht: gekleurd stipje bij de tekst onder je score */
.rec-light { display: inline-flex; align-items: center; justify-content: center; gap: 6px; margin-top: 8px; color: var(--text-2); font-size: 13px; font-weight: 500; }
.rec-light i { width: 8px; height: 8px; border-radius: 50%; background: var(--c); flex: none; }

/* Periodeknoppen blijven in beeld tijdens het scrollen en worden dan een balk over de volle breedte */
.range-head { position: sticky; top: 0; z-index: 5; pointer-events: none; }
.range-head > * { pointer-events: auto; }
.range-head h2 { transition: opacity .2s ease; }
.range-head.stuck h2 { position: absolute; left: 0; opacity: 0; pointer-events: none; }
.range-head .seg { --ease: cubic-bezier(.2, .8, .2, 1); width: var(--seg-w, auto); margin-left: auto; box-sizing: border-box;
  transition: width .45s var(--ease), margin .45s var(--ease), padding .45s var(--ease), border-radius .45s var(--ease), box-shadow .3s ease, background-color .3s ease; }
.range-head .seg button { flex: 0 1 auto; transition: flex-grow .45s var(--ease); }
.range-head.stuck .seg { width: calc(var(--full-w) + var(--bleed-l, 0px) + var(--bleed-r, 0px)); margin-left: calc(-1 * var(--bleed-l, 0px)); margin-right: calc(-1 * var(--bleed-r, 0px));
  padding: calc(env(safe-area-inset-top, 0px) + 8px) 14px 8px; border-radius: 0 0 20px 20px; border-color: transparent;
  background: color-mix(in srgb, var(--panel-solid) 90%, transparent);
  -webkit-backdrop-filter: blur(16px) saturate(1.4); backdrop-filter: blur(16px) saturate(1.4);
  box-shadow: 0 10px 28px rgba(20, 16, 60, .16), inset 0 -1px 0 var(--line); }
.range-head.stuck .seg button { flex-grow: 1; }
@media (min-width: 861px) {
  .range-head { top: 12px; }
  .range-head.stuck .seg { width: var(--seg-w, auto); margin-left: auto; margin-right: 0; padding: 3px; border-radius: 14px; border-color: var(--line);
    box-shadow: 0 10px 28px rgba(20, 16, 60, .16); }
  .range-head.stuck .seg button { flex-grow: 0; }
}
@media (prefers-reduced-motion: reduce) { .range-head h2, .range-head .seg, .range-head .seg button { transition: none; } }
.range-head.instant h2, .range-head.instant .seg, .range-head.instant .seg button { transition: none !important; }

/* Geen inzoomen met twee vingers of dubbeltikken: de app gedraagt zich als een gewone app */
html { touch-action: pan-x pan-y; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
