:root {
  --bg: #14110d;
  --surface: #1f1a14;
  --surface-2: #2a231a;
  --text: #f4ede2;
  --muted: #b3a690;
  --accent: #f2a93b;
  --accent-ink: #1b1306;
  --good: #6cc68a;
  --mid: #f2c14e;
  --bad: #ef6b5b;
  --border: #3a3024;
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
  -webkit-text-size-adjust: 100%;
}
[hidden] { display: none !important; }

.top { padding: 14px 16px; border-bottom: 1px solid var(--border); }
.brand { color: var(--text); text-decoration: none; font-weight: 600; }

main { max-width: 640px; margin: 0 auto; padding: 16px; }
h1 { font-size: 1.7rem; line-height: 1.2; margin: 12px 0 8px; }
h2 { font-size: 1.15rem; margin: 0; }
h3 { font-size: 1rem; margin: 18px 0 6px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.error { color: var(--bad); }
code { background: var(--surface-2); padding: 1px 5px; border-radius: 5px; }

.stack { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }

input, textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 10px; padding: 12px;
}
textarea { resize: vertical; margin-bottom: 10px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 600; border-radius: 12px; padding: 12px 16px;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  cursor: pointer; text-decoration: none;
}
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.ghost { background: transparent; }
.btn.big { width: 100%; padding: 16px; font-size: 1.05rem; margin: 6px 0; }
.btn.file { width: 100%; margin: 6px 0; }
.btn:disabled { opacity: .5; }

.list { list-style: none; padding: 0; margin: 8px 0; }
.list li a {
  display: flex; justify-content: space-between; gap: 10px; padding: 12px; margin-bottom: 8px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  color: var(--text); text-decoration: none;
}

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; margin-bottom: 16px;
}
.card.locked { opacity: .45; pointer-events: none; }
.step-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.step-no {
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink); font-weight: 700; flex: none;
}
.pill { margin-left: auto; font-size: .75rem; color: var(--muted); }

.processing { display: flex; align-items: center; gap: 12px; padding: 12px 0; }
.spinner {
  width: 22px; height: 22px; border-radius: 50%; flex: none;
  border: 3px solid var(--border); border-top-color: var(--accent);
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Setup result */
.score { display: flex; align-items: center; gap: 14px; margin: 8px 0 12px; }
.score-num {
  font-size: 2.6rem; font-weight: 800; width: 76px; height: 76px; border-radius: 50%;
  display: grid; place-items: center; border: 4px solid currentColor; flex: none;
}
.good { color: var(--good); } .mid { color: var(--mid); } .bad { color: var(--bad); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.count { display: flex; align-items: center; gap: 10px; margin: 12px 0; }
.count input { width: 80px; text-align: center; }
ul.plain { padding-left: 20px; margin: 4px 0; }

/* Report */
.tabs { display: flex; gap: 6px; overflow-x: auto; margin: 8px 0 12px; }
.tabs button {
  flex: none; font: inherit; font-size: .9rem; padding: 8px 12px; border-radius: 999px;
  border: 1px solid var(--border); background: transparent; color: var(--muted);
}
.tabs button.active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.req { border-top: 1px solid var(--border); padding: 10px 0; }
.req-head { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.tag { font-size: .72rem; padding: 1px 7px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.tag.must { color: var(--accent); }
.quote { color: var(--muted); font-style: italic; font-size: .9rem; }

/* Recorder overlay */
.recorder {
  position: fixed; inset: 0; z-index: 10; background: #000;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; padding: 24px; text-align: center;
}
.rec-label { font-size: 1.1rem; color: var(--muted); margin: 0; }
.rec-dot { width: 18px; height: 18px; border-radius: 50%; background: var(--bad); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .25; } }
.rec-time { font-size: 4rem; font-weight: 300; font-variant-numeric: tabular-nums; }
#rec-level { width: 100%; max-width: 300px; height: 40px; }
.recorder .btn { max-width: 360px; }

.toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom));
  background: var(--accent); color: var(--accent-ink); padding: 14px; border-radius: 12px;
  font-weight: 600; text-align: center; z-index: 20;
}
