:root {
  --bg: #14101c;
  --surface: #1f1929;
  --surface-2: #2a2236;
  --text: #f3eefb;
  --muted: #b9aecb;
  --brand: #5D04C5;
  --brand-hover: #6f12dc;
  --accent: #C9A6FF;
  --ok: #6fdc9a;
  --warn: #ffd166;
  --bad: #ff6b6b;
  --radius: 14px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 18px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow-wrap: break-word;
}

.top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  padding: max(12px, env(safe-area-inset-top)) 16px 12px;
  border-bottom: 1px solid var(--surface-2);
}
.top h1 { margin: 0; font-size: 20px; line-height: 1.3; }
.top .sub { color: var(--accent); font-weight: 500; }
.who { display: flex; align-items: center; gap: 8px; color: var(--accent); font-weight: 600; }

main {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px 16px max(32px, env(safe-area-inset-bottom));
}

h2 { font-size: 26px; margin: 8px 0 12px; line-height: 1.25; }
h2:focus { outline: none; }
h3 { font-size: 20px; margin: 0 0 8px; }
h4 { font-size: 18px; margin: 24px 0 8px; color: var(--accent); }
p { margin: 0 0 12px; }
.small { font-size: 16px; }
.muted { color: var(--muted); }

.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
  margin: 0 0 16px;
}
.card.accent { border: 2px solid var(--accent); }

.stack { display: flex; flex-direction: column; gap: 12px; margin-bottom: 16px; }
.row { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin: 12px 0; }
.row.between { justify-content: space-between; }
.choices { display: grid; gap: 16px; }

label { font-weight: 600; }
input[type=password], input[type=text] {
  font: inherit;
  font-size: 20px;
  min-height: 52px;
  width: 100%;
  padding: 10px 14px;
  border-radius: 10px;
  border: 2px solid var(--surface-2);
  background: var(--surface);
  color: var(--text);
}

.btn {
  font: inherit;
  font-weight: 600;
  min-height: 52px;
  min-width: 48px;
  padding: 10px 20px;
  border-radius: 12px;
  border: 2px solid var(--accent);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  touch-action: manipulation;
}
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-hover); }
.btn.big { min-height: 64px; font-size: 22px; width: 100%; }
.btn.ghost { border-color: var(--surface-2); background: var(--surface-2); }
.btn.stop, .btn.stop:hover { background: var(--bad); border-color: var(--bad); color: #1b0b0b; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.link {
  font: inherit;
  background: none;
  border: none;
  color: var(--accent);
  text-decoration: underline;
  padding: 12px 4px;
  min-height: 48px;
  cursor: pointer;
}

:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }

.bar { height: 12px; background: var(--surface-2); border-radius: 6px; overflow: hidden; margin: 8px 0 12px; }
.bar span { display: block; height: 100%; width: 0; background: var(--accent); transition: width 0.2s; }
.progress-text { font-size: 20px; font-weight: 600; margin: 0; }

.milestones { list-style: none; padding: 0; margin: 0; font-size: 16px; color: var(--muted); }
.milestones li { padding: 2px 0; }
.milestones li.done { color: var(--ok); }
.milestones .tick { display: inline-block; width: 1.2em; }

.list-head { margin-top: 28px; }
.pieces { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.piece {
  font: inherit;
  width: 100%;
  min-height: 52px;
  display: grid;
  grid-template-columns: 1.6em 1fr auto;
  align-items: center;
  gap: 8px;
  text-align: left;
  justify-items: start;
  padding: 8px 14px;
  border-radius: 12px;
  border: 2px solid var(--surface-2);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
.piece:hover:not(:disabled) { border-color: var(--accent); }
.piece:disabled { opacity: 0.5; cursor: not-allowed; }
.piece .tick { color: var(--ok); font-weight: 700; }
.piece .pt { text-align: left; }
.piece .pm { color: var(--muted); font-size: 16px; justify-self: end; }
.piece.kept .pt { color: var(--accent); }

.tips { padding-left: 1.2em; margin: 0 0 16px; }
.tips li { margin-bottom: 6px; }

.meter {
  position: relative;
  height: 24px;
  background: var(--surface-2);
  border-radius: 12px;
  overflow: hidden;
  margin: 12px 0;
}
.meter .fill {
  position: absolute; inset: 0 auto 0 0; width: 0;
  background: var(--accent);
}
.meter.good .fill { background: var(--ok); }
.meter.hot .fill { background: var(--bad); }
.meter .peak {
  position: absolute; top: 0; bottom: 0; width: 3px; left: 0;
  background: #fff;
}

.result { font-weight: 600; min-height: 1.5em; }
.result.pass { color: var(--ok); }
.result.warn { color: var(--warn); }

.hint { color: var(--accent); font-style: italic; }
.script {
  font-size: 22px;
  line-height: 1.6;
  background: var(--surface);
  border-left: 4px solid var(--brand);
  border-radius: var(--radius);
  padding: 16px;
  margin: 0 0 16px;
}

.recbox {
  position: sticky;
  bottom: 0;
  z-index: 2;
  background: var(--surface);
  border: 1px solid var(--surface-2);
  border-radius: var(--radius);
  padding: 8px 16px max(8px, env(safe-area-inset-bottom));
  box-shadow: 0 -12px 24px rgba(10, 6, 16, 0.85);
}
.recbox .row { margin: 8px 0; }
.recbox .meter { margin: 8px 0 4px; }
@media (hover: none) { #kbd-hint { display: none; } }
.timer { font-size: 26px; font-variant-numeric: tabular-nums; font-weight: 700; }
.flag { font-weight: 600; text-align: right; flex: 1 1 60%; }
.flag.rec { color: var(--bad); }
.flag.ok { color: var(--ok); }
.flag.warn { color: var(--warn); }
.flag.bad { color: var(--bad); }
.saved { color: var(--ok); font-size: 22px; font-weight: 700; margin: 8px 0; }

.status { min-height: 1.5em; color: var(--accent); font-weight: 600; margin-top: 16px; }

@media (min-width: 640px) {
  .choices { grid-template-columns: 1fr 1fr; }
  .btn.big { width: auto; min-width: 240px; }
}

@media (prefers-reduced-motion: reduce) {
  .bar span { transition: none; }
}
