:root {
  --bg: #faf9f5;
  --card: #ffffff;
  --text: #2a2a2a;
  --muted: #8a8a85;
  --line: #e8e6df;
  --accent: #5a8d7a;
  --accent-soft: #e6efe9;
  --warn: #c69045;
  --bad: #b35454;
  --shadow: 0 1px 3px rgba(0,0,0,0.04), 0 4px 12px rgba(0,0,0,0.04);
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  min-height: 100vh;
}

.app {
  width: 100%;
  max-width: 480px;
  background: var(--card);
  border-radius: 16px;
  box-shadow: var(--shadow);
  overflow: hidden;
  position: relative;
}

.brand {
  padding: 24px 28px 0; display: flex; justify-content: space-between; align-items: center;
}
.brand .name { font-weight: 700; letter-spacing: -0.2px; }
.brand .step { color: var(--muted); font-size: 12px; }

.screen {
  padding: 28px;
  display: none;
  animation: fade 0.25s ease;
}
.screen.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

h1 {
  font-size: 22px; font-weight: 600; margin: 12px 0 8px; letter-spacing: -0.3px;
}
p { color: #444; margin: 0 0 14px; }
p.muted { color: var(--muted); font-size: 13px; }

ul.points { list-style: none; padding: 0; margin: 16px 0; }
ul.points li {
  padding: 10px 0 10px 26px; position: relative; color: #444; font-size: 14px;
}
ul.points li::before {
  content: ""; position: absolute; left: 0; top: 14px; width: 12px; height: 12px;
  background: var(--accent-soft); border-radius: 50%;
  box-shadow: inset 0 0 0 2px var(--accent);
}

.actions { display: flex; gap: 10px; margin-top: 20px; }
button {
  flex: 1;
  background: var(--accent); color: #fff; border: 0;
  padding: 12px 18px; border-radius: 10px; font: inherit; font-weight: 600;
  cursor: pointer; transition: background 120ms, transform 80ms;
}
button:hover { background: #4a7866; }
button:active { transform: scale(0.98); }
button.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
button.ghost:hover { background: #f5f4ee; }
button:disabled { opacity: 0.5; cursor: not-allowed; }

.consent {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 14px; background: #fbfaf5; border: 1px solid var(--line); border-radius: 10px;
  margin: 16px 0 8px;
}
.consent input { margin-top: 2px; flex-shrink: 0; }
.consent label { font-size: 13px; color: #444; cursor: pointer; }

/* Stage */
.stage {
  position: relative;
  background: #1a1a1a;
  border-radius: 12px;
  overflow: hidden;
  aspect-ratio: 4/5;
  margin: 4px 0 18px;
}
.stage video, .stage canvas {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
}
.stage video { transform: scaleX(-1); }
.stage canvas { pointer-events: none; }

.stage .mask {
  position: absolute; inset: 0;
  background: radial-gradient(ellipse 38% 48% at 50% 48%, transparent 60%, rgba(0,0,0,0.55) 75%);
  pointer-events: none;
}
.stage .ring {
  position: absolute; left: 50%; top: 48%;
  transform: translate(-50%,-50%);
  width: 76%; aspect-ratio: 0.78;
  border: 2px solid rgba(255,255,255,0.55);
  border-radius: 50%;
  pointer-events: none;
  transition: border-color 200ms;
}
.stage .ring.armed { border-color: rgba(90,141,122,0.95); box-shadow: 0 0 0 8px rgba(90,141,122,0.18); }
.stage .ring.fire { border-color: #ffffff; box-shadow: 0 0 0 12px rgba(255,255,255,0.25); }

.stage .prompt {
  position: absolute; left: 0; right: 0; bottom: 18px;
  text-align: center; color: #fff; font-size: 16px; font-weight: 500;
  text-shadow: 0 1px 6px rgba(0,0,0,0.6);
  letter-spacing: 0.1px;
}
.stage .progress {
  position: absolute; left: 0; right: 0; top: 14px;
  display: flex; justify-content: center; gap: 6px;
}
.stage .progress .dot {
  width: 26px; height: 4px; border-radius: 2px; background: rgba(255,255,255,0.3);
  transition: background 200ms;
}
.stage .progress .dot.done { background: var(--accent); }
.stage .progress .dot.active { background: rgba(255,255,255,0.9); }

/* Loading screen */
.loader {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 40px 20px; min-height: 240px;
}
.spinner {
  width: 28px; height: 28px; border-radius: 50%;
  border: 2px solid var(--line); border-top-color: var(--accent);
  animation: spin 700ms linear infinite;
  margin-bottom: 14px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loader p { color: var(--muted); font-size: 14px; margin: 0; }

/* Result screen */
.result-icon {
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; margin: 8px auto 16px;
}
.result-icon.fail { background: #f7e9e4; color: var(--bad); }

.token-box {
  margin-top: 18px; padding: 12px 14px;
  background: #1c1c1c; color: #d8d8d4;
  border-radius: 8px; font-family: ui-monospace, "SF Mono", Consolas, monospace;
  font-size: 11px; line-height: 1.5;
  word-break: break-all;
  max-height: 120px; overflow: auto;
}
.token-box .lbl { color: #9c9c95; font-size: 10px; text-transform: uppercase; letter-spacing: 0.6px; margin-bottom: 4px; }

.kvs {
  display: grid; grid-template-columns: 1fr auto; gap: 4px 12px;
  margin: 14px 0; font-size: 13px;
}
.kvs .k { color: var(--muted); }
.kvs .v { font-weight: 500; }

.boot-status {
  position: absolute; bottom: 12px; left: 28px; right: 28px;
  display: flex; align-items: center; gap: 6px;
  font-size: 11px; color: var(--muted);
}
.boot-status .pulse {
  width: 6px; height: 6px; border-radius: 50%; background: #c69045;
}
.boot-status .pulse.on { background: var(--accent); box-shadow: 0 0 6px var(--accent); }

footer.fineprint {
  font-size: 11px; color: var(--muted); margin-top: 18px;
}
footer.fineprint a { color: var(--muted); }

/* Debug panel (visible only when ?debug=1) */
body:not(.debug) #debug { display: none; }
#debug {
  border-top: 1px dashed var(--line);
  background: #faf9f5;
  padding: 14px 18px;
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  font-size: 11px;
  color: #5a5a5a;
  line-height: 1.55;
}
#debug h3 {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.8px;
  color: #999; margin: 10px 0 4px; font-weight: 600;
}
#debug h3:first-child { margin-top: 0; }
#debug .grid {
  display: grid; grid-template-columns: 110px 1fr;
  gap: 1px 12px;
  font-variant-numeric: tabular-nums;
}
#debug .grid .k { color: #999; }
#debug .pass { color: var(--accent); font-weight: 600; }
#debug .fail { color: var(--bad);    font-weight: 600; }
#debug .warn { color: var(--warn);   font-weight: 600; }
#debug .verdict { font-size: 13px; margin-bottom: 4px; }
#debug code { background: #efeee9; padding: 0 4px; border-radius: 2px; }

/*
 * data-test="W-126-1-overlay"
 * Wave-126 — bundled-POST upload overlay. Per spec/80 §"Wave 126" the
 * overlay sits on top of the screen stack while the W-125-2 bundled
 * captures POST is in flight. Copy is "Almost done..." — chosen
 * because the Q11-verbal stem (see CLAUDE.md Rule-5 forbidden list)
 * is not permitted in the (go) tree. All colour values reuse the
 * :root tokens defined at the top of this file so the wave commit
 * passes CLAUDE.md Rule-3 (no new hex/rgba added).
 *
 * Spinner uses conic-gradient + transform: rotate (lesson H5 — prefer
 * transform over top/left to avoid layout thrash on low-end Android).
 */
.upload-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  background: var(--bg);
  z-index: 1000;
  transition: opacity 200ms ease;
}
.upload-overlay.hidden {
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
}
.upload-spinner {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: conic-gradient(
    var(--accent),
    var(--accent-soft),
    var(--accent)
  );
  -webkit-mask: radial-gradient(circle, transparent 18px, black 19px);
          mask: radial-gradient(circle, transparent 18px, black 19px);
  animation: upload-spin 900ms linear infinite;
}
@keyframes upload-spin { to { transform: rotate(360deg); } }
.upload-text {
  color: var(--text);
  font-size: 16px;
  font-weight: 500;
  margin: 0;
  letter-spacing: -0.1px;
}
@media (prefers-reduced-motion: reduce) {
  .upload-spinner { animation-duration: 3000ms; }
}
