:root {
  --bg: #000;
  --panel: #16191e;
  --panel-2: #22262d;
  --text: #f3f4f6;
  --muted: #a3a9b3;
  --accent: #f07c3c;
  --ok: #4ade80;
  --warn: #fbbf24;
  --rec: #ef4444;
  --radius: 14px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); overflow: hidden; }
body {
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}
button, select, input { font: inherit; color: inherit; }
button { cursor: pointer; }
svg { width: 24px; height: 24px; fill: currentColor; display: block; }
[hidden] { display: none !important; }
.svg-defs { position: absolute; width: 0; height: 0; overflow: hidden; }

/* ------------------------------------------------------------ camera */
.stage { position: fixed; inset: 0; }
#view {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: contain; background: #000;
}
.flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; transition: opacity .25s; }
.flash.on { opacity: .8; transition: none; }

.topbar {
  position: absolute; left: 0; right: 0; top: 0;
  padding: calc(var(--safe-t) + 10px) calc(var(--safe-r) + 12px) 10px calc(var(--safe-l) + 12px);
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  background: linear-gradient(rgba(0,0,0,.55), transparent);
}
.icon-btn {
  width: 44px; height: 44px; border-radius: 50%; border: 0;
  display: grid; place-items: center;
  background: rgba(0,0,0,.4); color: #fff;
}
.icon-btn.big { width: 52px; height: 52px; }
.icon-btn:active { background: rgba(255,255,255,.2); }
.icon-btn:disabled { opacity: .35; }
.top-right { display: flex; gap: 6px; }
#protect-btn .shield-off { display: none; }
#protect-btn[aria-pressed="false"] .shield-on { display: none; }
#protect-btn[aria-pressed="false"] .shield-off { display: block; }
#protect-btn[aria-pressed="false"] { color: var(--muted); }
#protect-btn[aria-pressed="true"] { color: var(--ok); }
#audio-btn .mic-off { display: none; }
#audio-btn[aria-pressed="false"] .mic-on { display: none; }
#audio-btn[aria-pressed="false"] .mic-off { display: block; }
#audio-btn[aria-pressed="false"] { color: var(--muted); }

.status {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 12px; border-radius: 999px;
  background: rgba(0,0,0,.5); font-size: 13px; font-weight: 600;
  max-width: calc(100vw - 180px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.status .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--warn); flex: none; }
.status.ok .dot { background: var(--ok); }
.status.rec .dot { background: var(--rec); animation: blink 1s steps(2) infinite; }
.status.rec { font-variant-numeric: tabular-nums; }
@keyframes blink { 50% { opacity: .2; } }

.controls {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 14px calc(var(--safe-r) + 16px) calc(var(--safe-b) + 16px) calc(var(--safe-l) + 16px);
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  background: linear-gradient(transparent, rgba(0,0,0,.65) 35%);
}
.chips { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.chips button, .capture-kind button, .seg button {
  border: 0; border-radius: 999px; padding: 7px 14px;
  background: rgba(255,255,255,.14); color: #fff; font-weight: 600; font-size: 14px;
}
.chips button[aria-checked="true"] { background: #fff; color: #000; }
.capture-kind { display: flex; gap: 4px; }
.capture-kind button { background: transparent; color: var(--muted); letter-spacing: .06em; text-transform: uppercase; font-size: 13px; }
.capture-kind button[aria-checked="true"] { color: var(--warn); }
.shutter-row { width: 100%; max-width: 420px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; }
.shutter-row #flip-btn { justify-self: end; }
.shutter {
  width: 76px; height: 76px; border-radius: 50%;
  border: 4px solid #fff; background: transparent; padding: 4px;
  display: grid; place-items: center;
}
.shutter span { display: block; width: 100%; height: 100%; border-radius: 50%; background: #fff; transition: all .2s; }
.shutter:active span { transform: scale(.9); }
.shutter.video span { background: var(--rec); }
.shutter.recording span { width: 44%; height: 44%; border-radius: 6px; }
.shutter:disabled { opacity: .45; }

/* Liggend: bediening rechts, zoals de gewone camera-app */
@media (orientation: landscape) and (max-height: 560px) {
  .controls {
    top: 0; left: auto; width: 200px; justify-content: center;
    padding: calc(var(--safe-t) + 12px) calc(var(--safe-r) + 12px) calc(var(--safe-b) + 12px) 12px;
    background: linear-gradient(90deg, transparent, rgba(0,0,0,.65) 35%);
  }
  .chips { flex-direction: column; align-items: stretch; }
  .shutter-row { grid-template-columns: 1fr; justify-items: center; gap: 12px; }
  .shutter-row .spacer { display: none; }
  .shutter-row #flip-btn { justify-self: center; }
  .topbar { right: 200px; }
}

/* ------------------------------------------------------------- intro */
.intro {
  position: fixed; inset: 0; z-index: 5;
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
  padding: calc(var(--safe-t) + 24px) 28px calc(var(--safe-b) + 24px);
  background: radial-gradient(ellipse at top, #1d2733, #000 70%);
  overflow-y: auto;
}
.intro img { border-radius: 22px; }
.intro h1 { font-size: 24px; margin: 16px 0 6px; }
.intro p { max-width: 380px; margin: 6px 0; color: #d6d9de; }
.intro .small { font-size: 13px; color: var(--muted); }
.intro .primary { margin-top: 22px; padding: 14px 32px; font-size: 17px; }
.error { color: #fca5a5; max-width: 380px; }
.install-hint { margin-top: 18px !important; }

/* ------------------------------------------------------------- sheets */
.sheet {
  position: fixed; inset: 0; z-index: 10;
  display: flex; align-items: flex-end; justify-content: center;
  background: rgba(0,0,0,.55);
}
.sheet-body {
  width: 100%; max-width: 520px; max-height: 88vh; overflow-y: auto;
  background: var(--panel); border-radius: 20px 20px 0 0;
  padding: 18px 18px calc(var(--safe-b) + 18px);
  user-select: text; -webkit-user-select: text;
}
@media (min-width: 600px) { .sheet { align-items: center; } .sheet-body { border-radius: 20px; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.sheet-head h2 { margin: 0; font-size: 19px; }
.sheet-head .icon-btn { background: var(--panel-2); }

.field { display: flex; flex-direction: column; gap: 6px; margin: 16px 0; }
.label { font-weight: 600; display: flex; justify-content: space-between; }
.label output { color: var(--muted); font-weight: 500; font-variant-numeric: tabular-nums; }
.hint { color: var(--muted); font-size: 13px; margin: 0; }
.stats { margin-top: 18px; font-variant-numeric: tabular-nums; }
input[type="range"] { width: 100%; accent-color: var(--accent); height: 28px; }
select {
  background: var(--panel-2); border: 1px solid #333a44; border-radius: 10px; padding: 10px;
}
.switch { display: flex; align-items: center; gap: 10px; margin: 4px 0 0; font-weight: 600; }
.switch input { width: 22px; height: 22px; accent-color: var(--accent); }
.logo-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.logo-row img {
  width: 56px; height: 56px; object-fit: contain; border-radius: 10px;
  background: repeating-conic-gradient(#3a3f47 0 25%, #2a2e35 0 50%) 0 0 / 14px 14px;
}
.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg button { background: var(--panel-2); }
.seg button[aria-checked="true"] { background: var(--accent); color: #111; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  border: 0; border-radius: 12px; padding: 11px 16px; font-weight: 650;
  background: var(--panel-2); color: var(--text);
}
.btn.ghost { background: transparent; border: 1px solid #3a404a; }
.btn.primary, .primary { background: var(--accent); color: #111; border: 0; border-radius: 12px; font-weight: 700; }
.btn:active, .primary:active { filter: brightness(.9); }

.result .media { display: grid; place-items: center; background: #000; border-radius: 12px; overflow: hidden; }
.result .media img, .result .media video { max-width: 100%; max-height: 52vh; display: block; }
.result #result-info { margin: 10px 0 0; }
.actions { display: flex; gap: 8px; margin-top: 14px; }
.actions .btn { flex: 1; }
#save-hint { margin-top: 10px; }

.toast {
  position: fixed; left: 50%; top: calc(var(--safe-t) + 70px); transform: translateX(-50%); z-index: 20;
  background: rgba(20,20,20,.92); border: 1px solid #333; color: #fff;
  padding: 10px 16px; border-radius: 12px; max-width: min(90vw, 420px); text-align: center;
}
