/* Layout: a full-bleed camera picture; a compact tool-style toolbar floats at the bottom
   and a single card sits in the middle before the camera is on. */
:root {
  --bg: #ffffff;
  --bg-field: #f5f5f5;
  --bg-hover: rgba(0, 0, 0, 0.06);
  --border: rgba(0, 0, 0, 0.1);
  --divider: #e6e6e6;
  --text: rgba(0, 0, 0, 0.9);
  --text-2: rgba(0, 0, 0, 0.55);
  --track: rgba(0, 0, 0, 0.12);
  --blue: #0c8ce9;
  --green: #14ae5c;
  --red: #f24822;
  --stage: #1e1e1e;
  --page: #ffffff;
  --ink: #0d0d0d;
  --ink-on: #ffffff;
  --border-strong: rgba(0, 0, 0, 0.16);
  --shadow: 0 0 0.5px rgba(0, 0, 0, 0.18), 0 2px 5px rgba(0, 0, 0, 0.15), 0 10px 24px rgba(0, 0, 0, 0.18);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #2c2c2c;
    --bg-field: #383838;
    --bg-hover: rgba(255, 255, 255, 0.08);
    --border: rgba(255, 255, 255, 0.1);
    --divider: rgba(255, 255, 255, 0.12);
    --text: rgba(255, 255, 255, 0.92);
    --text-2: rgba(255, 255, 255, 0.6);
    --track: rgba(255, 255, 255, 0.16);
    --page: #1e1e1e;
    --ink: #ffffff;
    --ink-on: #0d0d0d;
    --border-strong: rgba(255, 255, 255, 0.2);
    --shadow: 0 0 0.5px rgba(0, 0, 0, 0.5), 0 2px 5px rgba(0, 0, 0, 0.25), 0 10px 24px rgba(0, 0, 0, 0.3);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body {
  margin: 0; height: 100%; background: var(--stage); color: var(--text);
  font: 500 11px/16px Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  letter-spacing: 0.005em; overflow: hidden; -webkit-font-smoothing: antialiased;
}
body.idle.live { cursor: none; }
video { position: absolute; width: 2px; height: 2px; opacity: 0; pointer-events: none; }
canvas#view { position: fixed; inset: 0; width: 100%; height: 100%; object-fit: cover; background: var(--stage); }

/* ---------- start screen: the word, one line, two buttons ---------- */
.sheet {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  padding: 24px 16px; overflow-y: auto; background: var(--page);
  transition: opacity 0.25s ease;
}
.sheet.hidden { opacity: 0; pointer-events: none; }
.card { width: 100%; max-width: 380px; margin: auto; display: flex; flex-direction: column; align-items: center; gap: 20px; text-align: center; }
/* While the camera is on, the same content opens as a floating card */
.sheet.over { background: rgba(20, 20, 20, 0.55); }
.sheet.over .card { padding: 24px 20px; background: var(--bg); border: 1px solid var(--border); border-radius: 13px; box-shadow: var(--shadow); }
.brand { margin: 0; }
.brand img { display: block; height: 96px; width: auto; }
.sheet.over .brand img { height: 56px; }
.lead { margin: -4px 0 4px; font-size: 15px; line-height: 22px; font-weight: 400; color: var(--text-2); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.btn {
  font: inherit; font-size: 13px; font-weight: 500; color: var(--text); background: transparent;
  border: 1px solid var(--border-strong); border-radius: 8px; height: 40px; padding: 0 16px; cursor: pointer;
}
.btn:hover { background: var(--bg-hover); }
.btn.primary { background: var(--ink); border-color: var(--ink); color: var(--ink-on); }
.btn.primary:hover { background: var(--ink); opacity: 0.86; }
.btn:disabled { opacity: 0.5; cursor: default; }
.note { margin: 0; font-size: 12px; line-height: 18px; color: var(--text-2); font-weight: 400; max-width: 300px; }
.note.error { color: var(--red); }
.proof { width: 100%; }
.proof summary {
  cursor: pointer; list-style: none; display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; line-height: 18px; font-weight: 500; color: var(--text-2); padding: 4px 8px; border-radius: 6px;
}
.proof summary::-webkit-details-marker { display: none; }
.proof summary:hover { background: var(--bg-hover); color: var(--text); }
.proof summary svg { width: 14px; height: 14px; fill: none; stroke: var(--green); stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
.facts { list-style: none; margin: 12px 0 0; padding: 14px 0 0; border-top: 1px solid var(--divider); display: flex; flex-direction: column; gap: 12px; text-align: left; }
.facts b { display: block; font-size: 12px; line-height: 18px; font-weight: 600; }
.facts span { display: block; font-size: 12px; line-height: 18px; color: var(--text-2); font-weight: 400; }
.facts code { font: 11px/16px ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--bg-field); padding: 1px 4px; border-radius: 4px; color: var(--text); }

/* ---------- floating panels ---------- */
.panel {
  position: fixed; left: 50%; transform: translateX(-50%);
  background: var(--bg); color: var(--text); border: 1px solid var(--border); box-shadow: var(--shadow);
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.panel.top { top: calc(12px + env(safe-area-inset-top, 0px)); height: 32px; padding: 0 12px; border-radius: 8px; display: flex; align-items: center; white-space: nowrap; }
.panel.top.hidden { opacity: 0; transform: translate(-50%, -8px); pointer-events: none; }
.panel.center { top: 50%; transform: translate(-50%, -50%); padding: 14px 20px; border-radius: 13px; font-size: 15px; line-height: 20px; font-weight: 600; text-align: center; max-width: calc(100vw - 32px); }
.panel.center.hidden { opacity: 0; pointer-events: none; }

#chip {
  left: calc(12px + env(safe-area-inset-left, 0px)); top: calc(12px + env(safe-area-inset-top, 0px)); transform: none;
  height: 28px; padding: 0 10px 0 8px; border-radius: 8px; display: flex; align-items: center; gap: 6px; color: var(--text-2);
}
#chip .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green); }
#chip.hidden { opacity: 0; pointer-events: none; }

#recDot { position: fixed; top: calc(14px + env(safe-area-inset-top, 0px)); right: 14px; width: 10px; height: 10px; border-radius: 50%; background: var(--red); box-shadow: 0 0 0 3px rgba(242, 72, 34, 0.25); }
#recDot.hidden { display: none; }

/* left+right+auto margins instead of the 50% trick, so the bar may use the full width before wrapping */
#bar, #more { left: 16px; right: 16px; margin-inline: auto; width: fit-content; transform: none; }
#bar {
  bottom: calc(12px + env(safe-area-inset-bottom, 0px)); display: flex; align-items: center; gap: 8px;
  padding: 8px; border-radius: 13px; flex-wrap: wrap; justify-content: center;
}
#bar.hidden { opacity: 0; transform: translateY(12px); pointer-events: none; }
#hint {
  left: 16px; right: 16px; margin-inline: auto; transform: none; width: fit-content; max-width: min(340px, calc(100vw - 32px));
  bottom: calc(72px + env(safe-area-inset-bottom, 0px)); padding: 14px; border-radius: 13px;
  display: flex; flex-direction: column; gap: 8px;
}
#hint.hidden { opacity: 0; transform: translateY(8px); pointer-events: none; }
#hint b { font-size: 13px; line-height: 18px; font-weight: 600; }
#hint p { margin: 0; font-size: 12px; line-height: 18px; font-weight: 400; color: var(--text-2); }
#hint ol { margin: 0; padding-left: 18px; font-size: 12px; line-height: 18px; font-weight: 400; color: var(--text-2); display: flex; flex-direction: column; gap: 4px; }
#hint .btn { height: 30px; flex: 0 0 auto; }
#more {
  bottom: calc(72px + env(safe-area-inset-bottom, 0px)); display: flex; align-items: center; gap: 8px;
  padding: 8px; border-radius: 13px; flex-wrap: wrap; justify-content: center;
}
#more.hidden { opacity: 0; transform: translateY(8px); pointer-events: none; }
#moreBtn[aria-expanded="true"] { background: var(--bg-hover); }
.sep { width: 1px; height: 24px; background: var(--divider); flex: none; }
.seg { display: flex; gap: 2px; padding: 2px; border-radius: 7px; background: var(--bg-field); }
.seg .tool { height: 28px; padding: 0 10px; }
.seg .tool[aria-pressed="true"] { background: var(--bg); color: var(--text); box-shadow: 0 0 0 1px var(--border), 0 1px 2px rgba(0, 0, 0, 0.12); }

.tool {
  font: inherit; color: var(--text); background: transparent; border: 0; cursor: pointer;
  display: flex; align-items: center; gap: 6px; height: 32px; padding: 0 10px;
  border-radius: 5px; white-space: nowrap; transition: background 0.12s, color 0.12s;
}
.tool:hover { background: var(--bg-hover); }
.tool.strong[aria-pressed="true"] { background: var(--blue); color: #fff; }
.tool svg { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.3; stroke-linecap: round; stroke-linejoin: round; }
.tool svg.fillicon { fill: currentColor; stroke: none; }
.tool.icon { padding: 0 8px; }
.tool kbd, #reveal kbd { font: inherit; color: inherit; opacity: 0.55; margin-left: 2px; }
#record[aria-pressed="true"] { background: var(--red); color: #fff; }

.field { display: flex; align-items: center; gap: 8px; height: 32px; padding: 0 4px; }
.field > label { color: var(--text-2); white-space: nowrap; }
.val { min-width: 32px; height: 24px; padding: 0 6px; border-radius: 5px; background: var(--bg-field); display: flex; align-items: center; justify-content: center; font-variant-numeric: tabular-nums; }

input[type=range] { --p: 50%; -webkit-appearance: none; appearance: none; width: 88px; height: 16px; margin: 0; background: transparent; outline: none; cursor: pointer; }
input[type=range]::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: linear-gradient(to right, var(--blue) var(--p), var(--track) var(--p)); }
input[type=range]::-moz-range-track { height: 4px; border-radius: 2px; background: var(--track); }
input[type=range]::-moz-range-progress { height: 4px; border-radius: 2px; background: var(--blue); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 12px; height: 12px; margin-top: -4px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 0.5px rgba(0,0,0,0.25), 0 1px 3px rgba(0,0,0,0.35); }
input[type=range]::-moz-range-thumb { width: 12px; height: 12px; border: 0; border-radius: 50%; background: #fff; box-shadow: 0 0 0 0.5px rgba(0,0,0,0.25), 0 1px 3px rgba(0,0,0,0.35); }
.tool:focus-visible, .btn:focus-visible, input[type=range]:focus-visible, #reveal:focus-visible, summary:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; border-radius: 5px; }

#meter { position: relative; width: 44px; height: 4px; border-radius: 2px; background: var(--track); overflow: hidden; }
#level { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--green); border-radius: 2px; }
#tick { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--text); }

#reveal {
  bottom: calc(12px + env(safe-area-inset-bottom, 0px)); font: inherit; color: var(--text); cursor: pointer;
  height: 28px; padding: 0 10px; border-radius: 8px; display: flex; align-items: center; gap: 6px;
}
#reveal.hidden { opacity: 0; transform: translate(-50%, 8px); pointer-events: none; }

@media (max-width: 720px) {
  .sep { display: none; }
  input[type=range] { width: 72px; }
}
@media (prefers-reduced-motion: reduce) {
  .panel, .sheet { transition: none; }
}
