:root {
  --bg: #0a0c11;
  --panel: #12161f;
  --line: #232a38;
  --ink: #e8ecf3;
  --dim: #93a0b4;
  --accent: #ffb020;
  --good: #4ec98a;
  --warn: #ffb020;
  --bad: #ff6b6b;
  --safe: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior: none;
}

#scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

/* ---------- laden ---------- */
.load {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  background: var(--bg);
  transition: opacity .4s ease;
}
.load.done { opacity: 0; pointer-events: none; }
.load-inner { width: min(300px, 78vw); text-align: center; }
.load-title { font-size: 13px; letter-spacing: .14em; text-transform: uppercase; color: var(--dim); }
.load-bar { height: 3px; background: var(--line); border-radius: 2px; margin: 14px 0 8px; overflow: hidden; }
.load-bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .25s ease; }
.load-pct { font-variant-numeric: tabular-nums; font-size: 22px; font-weight: 600; }
.load-note { font-size: 11px; color: var(--dim); margin-top: 6px; }

/* ---------- kop en tabbladen ---------- */
.top {
  position: fixed;
  top: 0; left: 0; right: 0;
  /* Boven het laadscherm (z-index 50), zodat je altijd bij de tabbladen kunt. */
  z-index: 55;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 14px 10px;
  background: linear-gradient(180deg, rgba(10,12,17,.94), rgba(10,12,17,.6) 70%, rgba(10,12,17,0));
}
.brand { display: flex; align-items: center; gap: 7px; font-size: 15px; letter-spacing: .02em; }
.brand .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.brand .sep, .brand .sub { color: var(--dim); font-weight: 400; }

.tabs {
  display: flex;
  gap: 3px;
  background: rgba(255,255,255,.05);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px;
}
.tabs button {
  border: 0;
  background: none;
  color: var(--dim);
  font-size: 12.5px;
  padding: 6px 12px;
  border-radius: 999px;
  font-family: inherit;
}
.tabs button.on { background: var(--accent); color: #17140c; font-weight: 600; }

.ghost {
  background: rgba(255,255,255,.05);
  border: 1px solid var(--line);
  color: var(--ink);
  border-radius: 999px;
  padding: 7px 13px;
  font-size: 12.5px;
  font-family: inherit;
}
.primary {
  background: var(--accent);
  border: 0;
  color: #17140c;
  font-weight: 600;
  border-radius: 999px;
  padding: 11px 20px;
  font-size: 14px;
  font-family: inherit;
}
.primary:disabled { opacity: .5; }

/* ---------- gids ---------- */
.guide {
  position: fixed;
  right: 10px;
  bottom: calc(96px + var(--safe));
  z-index: 25;
  width: 96px;
  pointer-events: none;
  transform-origin: 50% 100%;
  animation: breathe 4.6s ease-in-out infinite;
}
@keyframes breathe {
  0%, 100% { transform: translateY(0) scale(1); }
  50%      { transform: translateY(-4px) scale(1.012); }
}
.guide img {
  width: 100%;
  display: block;
  border-radius: 12px;
  filter: drop-shadow(0 6px 16px rgba(0,0,0,.55));
  transition: filter .3s ease;
}
/* Tijdens het praten licht ze op en beweegt ze mee. */
.guide.speaking img {
  animation: talk .46s ease-in-out infinite;
  filter: drop-shadow(0 0 14px rgba(255,176,32,.5)) drop-shadow(0 6px 16px rgba(0,0,0,.55));
}
@keyframes talk {
  0%, 100% { transform: scale(1) rotate(0deg); }
  50%      { transform: scale(1.035) rotate(-.7deg); }
}

.mute {
  position: absolute;
  right: -4px;
  bottom: -12px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  font-size: 14px;
  line-height: 1;
  padding: 0;
  pointer-events: auto;
}

.bubble {
  position: absolute;
  right: 108px;
  bottom: 6px;
  width: max(150px, 40vw);
  min-height: 3.2em;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 9px 11px;
  font-size: 12.5px;
  line-height: 1.4;
  color: var(--ink);
  opacity: 0;
  transform: translateX(6px);
  transition: opacity .25s ease, transform .25s ease;
}
.bubble.on { opacity: 1; transform: none; }
.bubble::before {
  content: "";
  position: absolute;
  right: -7px;
  bottom: 16px;
  width: 0;
  height: 0;
  border-top: 7px solid transparent;
  border-bottom: 7px solid transparent;
  border-left: 7px solid var(--panel);
}

/* ---------- aanwijsstreep ---------- */
.pointer {
  position: fixed;
  inset: 0;
  z-index: 15;
  pointer-events: none;
  opacity: 0;
  transition: opacity .3s ease;
}
.pointer.on { opacity: 1; }
.pointer path {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.5;
  stroke-dasharray: 5 5;
  animation: dash 1.1s linear infinite;
}
.pointer circle { fill: var(--accent); }
@keyframes dash { to { stroke-dashoffset: -20; } }

/* ---------- zones ---------- */
.zones {
  position: fixed;
  left: 0; right: 0;
  bottom: 0;
  z-index: 30;
  display: flex;
  gap: 8px;
  padding: 12px 12px calc(12px + var(--safe));
  overflow-x: auto;
  scrollbar-width: none;
  background: linear-gradient(0deg, rgba(10,12,17,.96) 55%, rgba(10,12,17,0));
}
.zones::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 7px;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--ink);
  border-radius: 999px;
  padding: 9px 14px;
  font-size: 13px;
  white-space: nowrap;
  font-family: inherit;
}
.chip .sw { width: 9px; height: 9px; border-radius: 50%; }
.chip.on { border-color: currentColor; background: rgba(255,255,255,.09); }

/* ---------- infoblad ---------- */
.sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 40;
  max-height: 68vh;
  overflow-y: auto;
  background: var(--panel);
  border-top: 1px solid var(--line);
  border-radius: 18px 18px 0 0;
  padding: 18px 16px calc(96px + var(--safe));
  transform: translateY(102%);
  transition: transform .32s cubic-bezier(.22,.7,.3,1);
  box-shadow: 0 -18px 40px rgba(0,0,0,.5);
}
.sheet.on { transform: none; }
.sheet-close {
  position: absolute;
  top: 10px; right: 12px;
  background: none; border: 0;
  color: var(--dim);
  font-size: 24px;
  line-height: 1;
  padding: 4px 8px;
}
.sheet h2 { margin: 0 0 4px; font-size: 19px; }
.metric {
  display: inline-block;
  font-size: 12px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--accent);
  border: 1px solid rgba(255,176,32,.35);
  background: rgba(255,176,32,.08);
  border-radius: 6px;
  padding: 4px 8px;
  margin-bottom: 10px;
}
.why { color: var(--ink); margin: 0 0 14px; }
.block { border-top: 1px solid var(--line); padding-top: 11px; margin-top: 11px; }
.tag {
  display: block;
  font-size: 11px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--dim);
  margin-bottom: 4px;
}
.block p { margin: 0; font-size: 14px; }
.block p code {
  font-size: 12.5px;
  background: rgba(255,255,255,.07);
  padding: 1px 5px;
  border-radius: 4px;
}

/* ==================== NULMETING ==================== */
.intake[hidden] { display: none; }
.intake {
  position: fixed;
  inset: 0;
  z-index: 20;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: calc(58px + env(safe-area-inset-top, 0px)) 14px calc(96px + var(--safe));
}

.in-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 14px;
}
.in-card h2 { margin: 0 0 10px; font-size: 15px; letter-spacing: .04em; text-transform: uppercase; color: var(--dim); }

.in-derived { display: flex; flex-direction: column; gap: 6px; }
.in-derived-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  padding: 7px 10px;
  border-radius: 8px;
  background: rgba(255,255,255,.035);
  border-left: 3px solid var(--line);
}
.in-derived-row .k { font-size: 13px; color: var(--dim); }
.in-derived-row .v { font-variant-numeric: tabular-nums; font-weight: 600; font-size: 15px; }
.in-derived-row.good { border-left-color: var(--good); }
.in-derived-row.warn { border-left-color: var(--warn); }
.in-derived-row.bad  { border-left-color: var(--bad); }
.in-derived-row.bad .v { color: var(--bad); }
.in-derived-row.warn .v { color: var(--warn); }
.in-derived-row.good .v { color: var(--good); }

.in-flags { margin-top: 10px; display: flex; flex-direction: column; gap: 7px; }
.in-flag {
  font-size: 12.5px;
  line-height: 1.4;
  color: #ffd9a8;
  background: rgba(255,107,107,.12);
  border: 1px solid rgba(255,107,107,.35);
  border-radius: 8px;
  padding: 8px 10px;
}

.in-status { color: var(--bad); font-size: 13px; margin-bottom: 10px; }
.in-disc {
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--dim);
  background: rgba(255,176,32,.07);
  border: 1px solid rgba(255,176,32,.25);
  border-radius: 10px;
  padding: 10px 12px;
  margin: 0 0 14px;
}

.in-sec {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  margin-bottom: 12px;
  overflow: hidden;
}
.in-sechead {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: none;
  border: 0;
  color: var(--ink);
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  padding: 14px;
  text-align: left;
}
.in-sechead.static { display: block; }
.chev { width: 8px; height: 8px; border-right: 2px solid var(--dim); border-bottom: 2px solid var(--dim); transform: rotate(45deg); transition: transform .2s; }
.in-sec.open .chev { transform: rotate(-135deg); }
.in-secbody { display: none; padding: 0 14px 14px; }
.in-sec.open .in-secbody { display: block; }
.in-intro { font-size: 13px; color: var(--dim); margin: 0 0 12px; }

.in-item { padding: 12px 0; border-top: 1px solid var(--line); }
.in-item:first-of-type { border-top: 0; }
.in-label { display: block; font-size: 14px; margin-bottom: 7px; line-height: 1.35; }
.in-unit { color: var(--dim); font-size: 12.5px; }
.in-loinc {
  font-size: 10.5px;
  color: var(--dim);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1px 5px;
  margin-left: 4px;
  font-family: ui-monospace, monospace;
}
.in-input {
  width: 100%;
  background: #0d1017;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--ink);
  font-size: 16px;          /* 16px voorkomt inzoomen op iOS */
  font-family: inherit;
  padding: 10px 11px;
}
.in-input:focus { outline: 2px solid rgba(255,176,32,.5); outline-offset: 1px; }
textarea.in-input { resize: vertical; }
input[type="range"].in-input { padding: 0; }
.in-scaleval { display: inline-block; margin-top: 6px; font-size: 13px; color: var(--accent); }
.in-why {
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--dim);
  margin-top: 7px;
}
.in-why-tag {
  display: inline-block;
  font-size: 10px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--accent);
  border: 1px solid rgba(255,176,32,.3);
  border-radius: 4px;
  padding: 0 5px;
  margin-right: 6px;
}

.in-inst {
  border-top: 1px solid var(--line);
  padding: 11px 0;
  font-size: 13px;
}
.in-inst:first-child { border-top: 0; }
.in-inst-meta { color: var(--dim); font-size: 12px; margin-top: 3px; }
.in-inst-lic { color: #ffd9a8; font-size: 12px; margin-top: 5px; line-height: 1.4; }
.in-inst a { color: var(--accent); font-size: 12px; word-break: break-all; }

.in-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 6px 0 20px;
}
.in-save-msg { font-size: 13px; color: var(--dim); }

.credits {
  font-size: 11px;
  line-height: 1.5;
  color: var(--dim);
  border-top: 1px solid var(--line);
  padding-top: 12px;
  margin-top: 8px;
}
.credits b { color: var(--ink); }

@media (min-width: 700px) {
  .guide { width: 132px; right: 20px; bottom: 110px; }
  .bubble { right: 146px; width: 260px; font-size: 13.5px; }
  .sheet { left: auto; right: 18px; bottom: 18px; width: 400px; border-radius: 18px; padding-bottom: 20px; }
  .zones { justify-content: center; background: none; padding-bottom: 16px; }
  .intake { max-width: 760px; margin: 0 auto; padding-left: 20px; padding-right: 20px; }
}
