:root {
  /* White everywhere and black text only: the screen doubles as a light source while recording. */
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-2: #ffffff;
  --line: #000000;
  --text: #000000;
  --muted: #000000;
  --accent: #000000;
  --accent-ink: #ffffff;
  --danger: #000000;
  --rec: #ff3b30;
  --radius: 14px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html {
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
  background: var(--bg);
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  min-height: 100dvh;
}
[hidden] { display: none !important; }
h1 { font-size: 28px; margin: 0; letter-spacing: -0.02em; }
h2 { font-size: 17px; margin: 0; }
p { margin: 0; }

.view { padding-top: calc(var(--safe-t) + 8px); padding-bottom: calc(var(--safe-b) + 84px); }
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 16px 12px; }
.pad { padding: 0 16px; }
.pad-x { padding: 0 16px 12px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; gap: 10px; }
.grow { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.err { color: var(--danger); font-size: 14px; }
.empty { color: var(--muted); padding: 24px 16px; text-align: center; }
.pill { font-size: 13px; padding: 3px 9px; border-radius: 99px; background: #fff; border: 1px solid #000; color: #000; font-weight: 700; }

/* Buttons */
button, .btn, [role="button"] {
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.btn {
  appearance: none; border: 1px solid var(--line); background: var(--surface-2); color: var(--text);
  font: inherit; font-weight: 600; padding: 13px 16px; border-radius: 12px; text-align: center;
  transition: transform 100ms ease-out, background 100ms;
  cursor: pointer;
}
.btn:active { transform: scale(0.97); }
.btn.primary { background: #fff; color: #000; border: 2px solid #000; }
.btn.primary:active { background: #fff; }
.btn.danger { color: var(--danger); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.small { padding: 8px 14px; font-size: 15px; }
.btn:disabled { opacity: 0.4; }
.file-btn { position: relative; overflow: hidden; }
.file-btn input { position: absolute; inset: 0; opacity: 0; }

/* Inputs */
input, textarea, select { font: inherit; font-size: 16px; color: var(--text); }
.title-input, select, textarea, #gate-input {
  width: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px;
}
.title-input { font-size: 20px; font-weight: 700; }
.script-area { min-height: 46dvh; resize: vertical; line-height: 1.5; }
.script-area.short { min-height: 28dvh; }
.notes { min-height: 84px; resize: vertical; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--muted); }
textarea:focus, input:focus, select:focus { outline: 2px solid #000; outline-offset: -1px; }

/* Lists and cards */
.list { display: flex; flex-direction: column; gap: 8px; padding: 0 16px; }
.item {
  display: flex; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px; width: 100%; text-align: left; color: var(--text); font: inherit;
}
.item:active { background: #fff; }
.item .main { flex: 1; min-width: 0; }
.item .t { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .s { color: var(--muted); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.take { flex-direction: column; align-items: stretch; }
.take .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.take .actions .btn { padding: 9px 12px; font-size: 14px; flex: 1; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.changes { margin: 0; padding-left: 20px; color: var(--muted); font-size: 14px; display: flex; flex-direction: column; gap: 4px; }
.progress { height: 6px; background: #fff; border: 1px solid #000; border-radius: 3px; overflow: hidden; }
.progress div { height: 100%; width: 0; background: var(--accent); transition: width 200ms; }

/* Tabs */
#tabs {
  position: fixed; left: 0; right: 0; bottom: 0; display: flex; background: #fff;
  border-top: 1px solid var(--line);
  padding-bottom: var(--safe-b); z-index: 10;
}
.tab { flex: 1; background: none; border: 0; color: var(--muted); font: inherit; font-size: 15px; font-weight: 600; padding: 16px 0; }
.tab.on { color: #000; text-decoration: underline; text-underline-offset: 5px; text-decoration-thickness: 2px; }
.tab:active { opacity: 0.6; }

/* Gate */
#gate { display: grid; place-items: center; min-height: 100dvh; padding: 24px; }
.gate-box { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 14px; text-align: center; }

/* Prompter: the whole screen is white so it lights the face; text is black only. */
#prompter { position: fixed; inset: 0; background: #fff; color: #000; z-index: 20; overflow: hidden; }
#cam {
  position: absolute; right: 12px; bottom: calc(var(--safe-b) + 98px); width: 84px; height: 112px;
  object-fit: cover; border-radius: 10px; border: 1px solid #000; background: #fff;
}
#cam.mirror { transform: scaleX(-1); }
#pp-panel {
  position: absolute; left: 0; right: 0; top: 0; height: var(--panel-h, 56dvh);
  padding: calc(var(--safe-t) + 6px) 18px 0; overflow: hidden; touch-action: none; background: #fff;
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 calc(var(--safe-t) + 10px), #000 88%, transparent 100%);
          mask-image: linear-gradient(to bottom, transparent 0, #000 calc(var(--safe-t) + 10px), #000 88%, transparent 100%);
}
#pp-text {
  font-size: var(--pp-size, 30px); line-height: 1.32; font-weight: 650; letter-spacing: -0.01em; color: #000;
  will-change: transform; user-select: none; -webkit-user-select: none; text-align: center;
}
#pp-text p { margin: 0 0 0.7em; }
#pp-text span { color: #000; }
#pp-text span.now { text-decoration: underline; text-decoration-thickness: 3px; text-underline-offset: 6px; }
#pp-guide {
  position: absolute; left: 6px; width: 8px; height: 8px; border-radius: 50%; background: #000;
  top: var(--guide-y, 30%); transform: translateY(-50%);
}
#pp-hint {
  position: absolute; left: 0; right: 0; bottom: calc(var(--safe-b) + 104px); text-align: center;
  font-size: 13px; color: #000; pointer-events: none;
}
#pp-count {
  position: absolute; inset: 0; display: grid; place-items: center; font-size: 120px; font-weight: 800;
  color: #000; pointer-events: none;
}
#pp-rec {
  position: absolute; right: 14px; top: calc(var(--panel-h, 56dvh) + 4px); display: flex; align-items: center; gap: 6px;
  background: #fff; border: 1px solid #000; color: #000; padding: 3px 10px; border-radius: 99px; font-size: 14px;
}
#pp-rec span { width: 10px; height: 10px; border-radius: 50%; background: var(--rec); animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0.2; } }
@media (prefers-reduced-motion: reduce) { #pp-rec span { animation: none; } }
#pp-bar {
  position: absolute; left: 0; right: 0; bottom: 0; display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 14px 10px calc(var(--safe-b) + 14px); background: #fff;
}
.pbtn {
  min-width: 44px; height: 44px; border-radius: 22px; border: 1.5px solid #000; background: #fff; color: #000;
  font: inherit; font-weight: 700; font-size: 16px; padding: 0 10px;
}
.pbtn.wide { min-width: 64px; font-size: 14px; }
.pbtn:active { transform: scale(0.94); }
.recbtn {
  width: 70px; height: 70px; border-radius: 50%; border: 3px solid #000; background: #fff; padding: 0;
  display: grid; place-items: center; flex: none;
}
.recbtn span { width: 54px; height: 54px; border-radius: 50%; background: var(--rec); transition: all 160ms ease-out; }
.recbtn.on span { width: 28px; height: 28px; border-radius: 6px; }
.recbtn:active { transform: scale(0.95); }
.pp-badge {
  position: absolute; left: 14px; top: calc(var(--panel-h, 56dvh) + 4px); font-size: 13px;
  background: #fff; border: 1px solid #000; padding: 3px 10px; border-radius: 99px; color: #000;
}

/* Sheet */
#sheet { position: fixed; inset: 0; background: rgba(255,255,255,0.85); z-index: 30; display: flex; align-items: flex-end; }
.sheet-box {
  width: 100%; background: #fff; border-top: 1px solid #000; border-radius: 20px 20px 0 0; padding: 20px 16px calc(var(--safe-b) + 16px);
  max-height: 92dvh; overflow-y: auto; overscroll-behavior: contain;
}
#sheet-video { width: 100%; max-height: 46dvh; border-radius: 12px; background: #000; }

#toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(var(--safe-b) + 96px); z-index: 40;
  background: #fff; border: 1.5px solid #000; color: #000; padding: 12px 14px; border-radius: 12px;
  font-size: 15px; text-align: center;
}

@media (hover: hover) and (pointer: fine) {
  .btn:hover { text-decoration: underline; }
  .item:hover { text-decoration: underline; }
}
