/* Onetape — built for one device class: an iPhone held in a hand.
   No desktop breakpoints, no hover states that matter, no layout that assumes
   a mouse. Everything is sized against safe-area insets so the controls clear
   the notch at the top and the home indicator at the bottom. */

:root {
  --bg: #0b0b0d;
  --panel: #141418;
  --panel-2: #1c1c22;
  --ink: #f4f2ee;
  --ink-dim: #a7a49d;
  --ink-faint: #6d6a64;
  --rec: #e4483d;
  --amber: #e8a13a;
  --line: #26262e;
  --radius: 16px;

  /* Read once here so every screen can lay out against the same numbers. */
  --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);
}

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

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font: 400 17px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  /* Stops the whole page rubber-banding when a gesture starts on a scrollable
     child — which on a full-screen camera view looks like the app coming
     loose from the screen. */
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
}

body {
  /* dvh, not vh: Safari's toolbars change the viewport height as they hide,
     and vh keeps the tallest value, so the record button sits below the fold
     until you scroll. dvh tracks the real height. */
  min-height: 100dvh;
  overflow: hidden;
}

#app { min-height: 100dvh; }

/* Nothing in the app is selectable except the things worth copying. */
body { -webkit-user-select: none; user-select: none; }
input, .codes, .invite-out { -webkit-user-select: text; user-select: text; }

button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }

/* ------------------------------------------------------------------ boot */
.boot {
  min-height: 100dvh;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 18px;
}
.boot-text { color: var(--ink-faint); letter-spacing: .18em; text-transform: uppercase; font-size: 13px; margin: 0; }

/* Two reels: the mark used on the loading screen and both gates. */
.boot-mark, .gate-mark {
  display: flex;
  gap: 10px;
  align-items: center;
}
.boot-mark span, .gate-mark span {
  width: 26px; height: 26px;
  border: 3px solid var(--ink-dim);
  border-radius: 50%;
}
.boot-mark span { animation: spin 2.4s linear infinite; }
.boot-mark span:last-child { animation-duration: 3.6s; }
@keyframes spin { to { transform: rotate(360deg); } }
/* One frame, no animation, for anyone who asked the system not to move. */
@media (prefers-reduced-motion: reduce) {
  .boot-mark span { animation: none; }
}

/* ----------------------------------------------------------------- screens */
.screen {
  min-height: 100dvh;
  padding: calc(var(--safe-t) + 20px) calc(var(--safe-r) + 20px)
           calc(var(--safe-b) + 20px) calc(var(--safe-l) + 20px);
}

.gate, .install, .sheet {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 18px;
  text-align: center;
  align-items: center;
}
.gate h1, .install h1, .sheet h1 { font-size: 30px; margin: 4px 0 0; letter-spacing: -.02em; }
.lede { color: var(--ink-dim); margin: 0; max-width: 30ch; }
.gate-note { color: var(--rec); font-size: 15px; min-height: 1.2em; margin: 0; }
.gate-actions { display: flex; flex-direction: column; gap: 10px; width: 100%; max-width: 320px; }

.btn {
  min-height: 52px;
  padding: 0 22px;
  border-radius: 14px;
  background: var(--panel-2);
  color: var(--ink);
  font-weight: 600;
  font-size: 17px;
  transition: transform .08s ease;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--ink); color: #101014; }
.btn-quiet { background: transparent; color: var(--ink-dim); border: 1px solid var(--line); }
.btn[disabled] { opacity: .45; }

.linkish { color: var(--ink-faint); font-size: 15px; text-decoration: underline; padding: 12px; }

.field { display: block; width: 100%; max-width: 320px; text-align: left; }
.field span { display: block; font-size: 14px; color: var(--ink-dim); margin-bottom: 6px; }
.field input {
  width: 100%;
  /* 17px, not 15px: iOS zooms the viewport on focus for anything under 16px,
     and the zoom does not undo itself cleanly in a standalone web app. */
  font-size: 17px;
  min-height: 52px;
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
}
.field input:focus { outline: 2px solid var(--amber); outline-offset: 1px; }

/* -------------------------------------------------------------- install */
.steps { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 14px; text-align: left; max-width: 330px; }
.steps li { display: flex; gap: 12px; align-items: flex-start; color: var(--ink-dim); }
.step-n {
  flex: 0 0 26px; height: 26px;
  display: grid; place-content: center;
  border-radius: 50%;
  background: var(--panel-2);
  color: var(--ink);
  font-size: 14px; font-weight: 600;
}
.steps strong { color: var(--ink); font-weight: 600; }
.ios-share { width: 17px; height: 17px; vertical-align: -3px; color: #4a9df8; }
.install-arrow { color: var(--ink-faint); }
.install-arrow svg { width: 30px; height: 46px; animation: nudge 1.8s ease-in-out infinite; }
@keyframes nudge { 0%,100% { transform: translateY(0); } 50% { transform: translateY(7px); } }
@media (prefers-reduced-motion: reduce) { .install-arrow svg { animation: none; } }

.codes {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
  padding: 16px; margin: 0; width: 100%; max-width: 340px;
  background: var(--panel); border-radius: var(--radius);
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 16px; letter-spacing: .06em; list-style-position: inside;
}

/* --------------------------------------------------------------- record */
.record { padding: 0; position: relative; overflow: hidden; background: #000; }
.preview {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  /* cover, so the viewfinder fills the screen in either orientation. The
     recorded file is the camera's full frame regardless of this crop — what
     you see is a viewport onto it, same as any phone camera app. */
  object-fit: cover;
  background: #000;
}

.hud {
  position: absolute; left: 0; right: 0;
  padding: 0 calc(var(--safe-r) + 16px) 0 calc(var(--safe-l) + 16px);
  display: flex; align-items: center; justify-content: space-between;
  pointer-events: none;
}
.hud > * { pointer-events: auto; }
.hud-top { top: calc(var(--safe-t) + 12px); }
.hud-bottom {
  bottom: calc(var(--safe-b) + 18px);
  flex-direction: column; gap: 10px;
}
.hud-row { display: flex; align-items: center; justify-content: space-between; width: 100%; max-width: 420px; }

.tape-chip {
  display: flex; flex-direction: column; gap: 1px;
  padding: 8px 14px;
  border-radius: 12px;
  background: rgba(10,10,12,.55);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.tape-no { font-size: 13px; font-weight: 600; letter-spacing: .04em; }
.tape-left { font-size: 12px; color: var(--ink-dim); font-variant-numeric: tabular-nums; }

.icon-btn {
  width: 46px; height: 46px;
  display: grid; place-content: center;
  border-radius: 50%;
  background: rgba(10,10,12,.55);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--ink);
}
.icon-btn svg { width: 22px; height: 22px; }

/* 78px across — comfortably past the 44pt minimum, and findable without
   looking, which matters when the thing you are filming is a toddler. */
.rec {
  width: 78px; height: 78px;
  border-radius: 50%;
  border: 4px solid rgba(255,255,255,.9);
  display: grid; place-content: center;
  background: transparent;
}
.rec-inner {
  width: 58px; height: 58px;
  border-radius: 50%;
  background: var(--rec);
  transition: border-radius .18s ease, width .18s ease, height .18s ease;
}
.rec[data-on="1"] .rec-inner { width: 30px; height: 30px; border-radius: 7px; }
.rec:active { transform: scale(.96); }

.gauge {
  position: absolute; left: 0; right: 0;
  top: calc(var(--safe-t) + 68px);
  height: 3px;
  background: rgba(255,255,255,.14);
}
.gauge-fill { height: 100%; width: 0; background: var(--amber); transition: width .4s linear; }
.gauge-fill[data-warn="1"] { background: var(--rec); }

.timecode {
  position: absolute;
  top: calc(var(--safe-t) + 84px);
  left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 8px;
  padding: 6px 13px;
  border-radius: 999px;
  background: rgba(10,10,12,.6);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}
.timecode .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--rec); animation: blink 1.4s steps(1) infinite; }
@keyframes blink { 50% { opacity: .15; } }
@media (prefers-reduced-motion: reduce) { .timecode .dot { animation: none; } }

.hint {
  margin: 0; text-align: center;
  font-size: 13px; color: rgba(255,255,255,.72);
  text-shadow: 0 1px 3px rgba(0,0,0,.7);
  min-height: 1.2em;
  padding: 0 20px;
}

.pending {
  position: absolute;
  top: calc(var(--safe-t) + 12px);
  left: 50%; transform: translateX(-50%);
  padding: 5px 12px;
  border-radius: 999px;
  background: rgba(232,161,58,.18);
  border: 1px solid rgba(232,161,58,.4);
  color: var(--amber);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

/* ----------------------------------------------------------------- lists */
.list, .detail { overflow-y: auto; -webkit-overflow-scrolling: touch; }
.bar { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.bar h1 { font-size: 21px; margin: 0; flex: 1; text-align: center; letter-spacing: -.01em; }
.bar .spacer { width: 46px; }

.rows { display: grid; gap: 10px; }
.row {
  display: flex; gap: 14px; align-items: center;
  padding: 12px;
  background: var(--panel);
  border-radius: var(--radius);
  text-align: left;
  width: 100%;
}
.row:active { background: var(--panel-2); }
.row-thumb {
  width: 76px; height: 54px;
  border-radius: 9px;
  background: var(--panel-2) center/cover no-repeat;
  flex: 0 0 auto;
  display: grid; place-content: center;
  color: var(--ink-faint);
  overflow: hidden;
}
.row-thumb svg { width: 22px; height: 22px; }
.row-main { flex: 1; min-width: 0; }
.row-title { font-weight: 600; font-size: 16px; }
.row-sub { font-size: 13px; color: var(--ink-dim); font-variant-numeric: tabular-nums; }
.row-badge { font-size: 11px; padding: 3px 8px; border-radius: 999px; background: var(--panel-2); color: var(--ink-dim); }
.row-badge[data-kind="open"] { background: rgba(232,161,58,.16); color: var(--amber); }
.row-badge[data-kind="working"] { background: rgba(74,157,248,.16); color: #6fb2fb; }
.row-badge[data-kind="failed"] { background: rgba(228,72,61,.16); color: var(--rec); }
.empty { text-align: center; color: var(--ink-faint); margin-top: 40px; }

.player { width: 100%; border-radius: var(--radius); background: #000; max-height: 62dvh; }
.meta { color: var(--ink-dim); font-size: 14px; margin: 14px 0; font-variant-numeric: tabular-nums; }
.detail-actions { display: flex; gap: 10px; }
.detail-actions .btn { flex: 1; }
.chapters { margin-top: 20px; display: grid; gap: 6px; }
.chapter {
  display: flex; justify-content: space-between;
  padding: 11px 14px;
  background: var(--panel);
  border-radius: 11px;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  width: 100%;
  text-align: left;
}

.group { margin-bottom: 26px; }
.group-title { font-size: 13px; text-transform: uppercase; letter-spacing: .09em; color: var(--ink-faint); margin: 0 0 6px; }
.group-note { font-size: 14px; color: var(--ink-dim); margin: 0 0 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 11px 17px;
  border-radius: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  font-size: 15px;
}
.chip[data-on="1"] { background: var(--ink); color: #101014; border-color: var(--ink); font-weight: 600; }
.passkeys { display: grid; gap: 8px; margin-bottom: 12px; }
.passkey { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; background: var(--panel); border-radius: 12px; font-size: 15px; }
.passkey small { color: var(--ink-faint); display: block; font-size: 12px; }
.invite-out {
  margin-top: 12px; padding: 12px;
  background: var(--panel); border-radius: 12px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 13px; word-break: break-all; color: var(--amber);
}
.version { text-align: center; color: var(--ink-faint); font-size: 12px; margin-top: 30px; }

/* ----------------------------------------------------------------- toast */
.toast {
  position: fixed;
  left: 50%; transform: translateX(-50%);
  bottom: calc(var(--safe-b) + 92px);
  max-width: min(90vw, 420px);
  padding: 12px 18px;
  border-radius: 13px;
  background: rgba(28,28,34,.96);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  color: var(--ink);
  font-size: 15px;
  text-align: center;
  z-index: 50;
  box-shadow: 0 8px 30px rgba(0,0,0,.5);
}
.toast[data-kind="bad"] { background: rgba(96,28,24,.96); }
