:root {
  color-scheme: dark;
  --bg: #050505;
  --panel: rgba(5, 5, 5, 0.74);
  --line: rgba(255, 255, 255, 0.18);
  --text: #f5f5f5;
  --muted: #a6a6a6;
}

* { box-sizing: border-box; }
html, body { margin: 0; width: 100%; height: 100%; overflow: hidden; background: var(--bg); }
body { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace; color: var(--text); }
button, input { font: inherit; }
button { color: inherit; }

.app { position: relative; width: 100%; height: 100dvh; background: #000; overflow: hidden; }
#video, #sampleCanvas { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
#outputCanvas { position: absolute; inset: 0; width: 100%; height: 100%; background: #000; }

.topbar {
  position: absolute; z-index: 3; top: 0; left: 0; right: 0;
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: calc(14px + env(safe-area-inset-top)) 16px 12px;
  background: linear-gradient(to bottom, rgba(0,0,0,.82), rgba(0,0,0,0));
  pointer-events: none;
}
.topbar h1 { margin: 0; font-size: 14px; letter-spacing: .18em; font-weight: 700; }
.topbar h1 small { font-size: 8px; letter-spacing: .08em; color: var(--muted); font-weight: 500; }
.topbar p { margin: 5px 0 0; color: var(--muted); font-size: 10px; letter-spacing: .14em; }
.iconBtn { pointer-events: auto; width: 42px; height: 42px; border: 1px solid var(--line); border-radius: 50%; background: rgba(0,0,0,.45); font-size: 22px; }
.iconBtn:disabled { opacity: .35; }

.hud { position: absolute; z-index: 3; left: 16px; right: 16px; top: calc(66px + env(safe-area-inset-top)); pointer-events: none; }
.labels { display: inline-block; max-width: 100%; padding: 6px 8px; border: 1px solid var(--line); background: rgba(0,0,0,.52); font-size: 10px; line-height: 1.4; letter-spacing: .08em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.controls {
  position: absolute; z-index: 4; left: 10px; right: 10px; bottom: calc(10px + env(safe-area-inset-bottom));
  padding: 10px; border: 1px solid var(--line); border-radius: 16px; background: var(--panel); backdrop-filter: blur(14px);
}
.modeRow { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 9px; }
.modeBtn { height: 34px; border: 1px solid var(--line); border-radius: 9px; background: rgba(255,255,255,.04); font-size: 10px; letter-spacing: .08em; }
.modeBtn.active { background: #f2f2f2; color: #090909; border-color: #f2f2f2; }
.sliderRow { display: grid; grid-template-columns: 94px 1fr; align-items: center; gap: 8px; min-height: 30px; font-size: 9px; letter-spacing: .08em; color: #ccc; }
.sliderRow input { width: 100%; accent-color: #fff; }
.depthLegend { display: grid; grid-template-columns: repeat(3,1fr); margin: -2px 0 2px 102px; color: #777; font-size: 7px; letter-spacing: .08em; text-align: center; }
.actionRow { display: grid; grid-template-columns: minmax(0, 1fr) 72px; gap: 9px; align-items: stretch; margin-top: 7px; }
.startBtn { width: 100%; min-height: 58px; margin: 0; border: 0; border-radius: 11px; background: #f5f5f5; color: #050505; font-weight: 800; letter-spacing: .08em; }
.startBtn.running { background: rgba(255,255,255,.12); color: #fff; border: 1px solid var(--line); }
.shutterBtn { min-height: 58px; padding: 4px 5px 3px; border: 1px solid var(--line); border-radius: 11px; background: rgba(255,255,255,.04); display: grid; place-items: center; align-content: center; gap: 1px; }
.shutterBtn:disabled { opacity: .28; }
.shutterRing { width: 34px; height: 34px; border: 2px solid #f5f5f5; border-radius: 50%; display: grid; place-items: center; }
.shutterCore { width: 24px; height: 24px; border-radius: 50%; background: #f5f5f5; transition: transform .08s ease; }
.shutterBtn:active:not(:disabled) .shutterCore { transform: scale(.78); }
.shutterLabel { font-size: 7px; line-height: 1; letter-spacing: .12em; color: #bbb; }

.notice { position: absolute; z-index: 6; inset: 50% 20px auto; transform: translateY(-50%); padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: rgba(0,0,0,.9); text-align: center; font-size: 12px; line-height: 1.6; }

@media (min-width: 760px) {
  .controls { left: 50%; right: auto; width: 520px; transform: translateX(-50%); }
}
