:root {
  --bg: #faf7f2;
  --surface: #ffffff;
  --ink: #1f1d1a;
  --muted: #6b665e;
  --line: #e4ddd0;
  --accent: #2f6f4f;
  --accent-ink: #ffffff;
  --go: #2f6f4f;
  --go-bg: #e3f1e9;
  --stop: #b4432f;
  --stop-bg: #f7e4df;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161512;
    --surface: #211f1b;
    --ink: #f3efe7;
    --muted: #a39d90;
    --line: #37342d;
    --accent: #5fb58a;
    --accent-ink: #0f1f17;
    --go: #5fb58a;
    --go-bg: #1d2e25;
    --stop: #e27a64;
    --stop-bg: #34211d;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.topbar, main {
  width: 100%;
  max-width: 34rem;
  margin-inline: auto;
  padding-inline: max(1rem, env(safe-area-inset-left));
}
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding-block: max(0.75rem, env(safe-area-inset-top)) 0.5rem;
}
.brand { font-weight: 700; letter-spacing: 0.01em; color: var(--ink); text-decoration: none; }
#account { display: flex; gap: 1rem; flex-wrap: wrap; justify-content: flex-end; }
main { padding-block: 0.5rem 8rem; }

.lead { font-size: 1.75rem; line-height: 1.15; margin: 0.75rem 0 0.25rem; }
.sub { color: var(--muted); margin: 0 0 1.25rem; }
.muted { color: var(--muted); }

.link {
  background: none; border: 0; padding: 0.35rem 0; color: var(--accent);
  font-weight: 600; text-decoration: underline; text-underline-offset: 3px;
}
.link.danger { color: var(--stop); }

/* the 12 marks */
.marks { display: grid; gap: 0.6rem; }
.mark {
  display: grid; grid-template-columns: 2rem 1fr auto; align-items: center; gap: 0.75rem;
  min-height: 3.5rem; padding: 0.6rem 0.9rem; text-align: left;
  background: var(--surface); border: 2px solid var(--line); border-radius: 0.9rem;
  transition: background 0.12s, border-color 0.12s, transform 0.08s;
}
.mark:active { transform: scale(0.985); }
.mark-num { color: var(--muted); font-variant-numeric: tabular-nums; font-weight: 600; }
.mark-text { font-size: 1.05rem; }
.mark-state {
  min-width: 3rem; padding: 0.2rem 0.6rem; text-align: center;
  border-radius: 999px; font-size: 0.85rem; font-weight: 700;
  background: var(--bg); color: var(--muted);
}
.mark[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.mark.inverted[aria-pressed="true"] { background: var(--stop); border-color: var(--stop); color: #fff; }
.mark[aria-pressed="true"] .mark-num { color: inherit; opacity: 0.8; }
.mark[aria-pressed="true"] .mark-state { background: rgba(255, 255, 255, 0.22); color: inherit; }

/* sticky score + submit */
.dock {
  position: fixed; inset: auto 0 0 0; z-index: 2;
  display: flex; align-items: center; gap: 1rem;
  max-width: 34rem; margin-inline: auto;
  padding: 0.75rem max(1rem, env(safe-area-inset-right)) max(0.75rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
  background: var(--bg); border-top: 1px solid var(--line);
}
/* slide to confirm */
.slide {
  --size: 3.25rem;
  position: relative; flex: 1; height: var(--size); overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  border-radius: 999px; background: var(--line);
  touch-action: none; user-select: none; -webkit-user-select: none;
}
.slide-text { padding-left: var(--size); font-weight: 700; color: var(--muted); pointer-events: none; }
.slide-fill { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--accent); opacity: 0.25; pointer-events: none; }
.slide-handle {
  position: absolute; left: 4px; top: 4px;
  width: calc(var(--size) - 8px); height: calc(var(--size) - 8px);
  border: 0; border-radius: 50%; padding: 0;
  background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center; touch-action: none; cursor: grab;
}
/* chevron drawn in CSS so it centers exactly; its visual middle sits ~35% of its width right of the box center */
.slide-handle::before {
  content: ''; width: 0.7rem; height: 0.7rem;
  border-top: 3px solid currentColor; border-right: 3px solid currentColor; border-radius: 1px;
  transform: translateX(-0.25rem) rotate(45deg);
}
.slide.snap .slide-handle, .slide.snap .slide-fill, .slide.snap .slide-text { transition: transform 0.2s, width 0.2s, opacity 0.2s; }

.primary, .secondary {
  min-height: 3rem; padding: 0.6rem 1.25rem; border-radius: 0.8rem; font-weight: 700; border: 2px solid var(--accent);
}
.primary { background: var(--accent); color: var(--accent-ink); }
.secondary { background: transparent; color: var(--accent); }

/* result */
.verdict { margin-top: 0.75rem; padding: 2rem 1.25rem; border-radius: 1.2rem; text-align: center; }
.verdict.go { background: var(--go-bg); color: var(--go); }
.verdict.no { background: var(--stop-bg); color: var(--stop); }
.verdict h1 { font-size: 2.6rem; line-height: 1.05; margin: 0.25rem 0 0.5rem; }
.verdict p { margin: 0; color: var(--ink); }
.verdict-score { font-size: 1rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.tally { margin: 1.25rem 0; padding-left: 1.25rem; color: var(--muted); }
.actions { display: flex; gap: 0.75rem; flex-wrap: wrap; margin-top: 1.25rem; }
.actions > * { flex: 1 1 8rem; }
.notice { margin: 1rem 0; color: var(--muted); }

.save { display: grid; gap: 0.6rem; margin-top: 1.25rem; }
.save input {
  min-height: 3rem; padding: 0.5rem 0.9rem; border-radius: 0.8rem;
  border: 2px solid var(--line); background: var(--surface);
}

/* history */
.history { list-style: none; margin: 1rem 0 0; padding: 0; display: grid; gap: 0.6rem; }
.past {
  display: grid; grid-template-columns: 1fr auto; gap: 0.25rem 0.75rem; align-items: center;
  padding: 0.75rem 0.9rem; background: var(--surface); border: 1px solid var(--line); border-radius: 0.9rem;
}
.past-main { display: grid; min-width: 0; }
.past-main strong { overflow-wrap: anywhere; }
.past .link { grid-column: 2; justify-self: end; font-size: 0.85rem; }
.badge { padding: 0.2rem 0.6rem; border-radius: 99px; font-size: 0.85rem; font-weight: 700; white-space: nowrap; }
.badge.go { background: var(--go-bg); color: var(--go); }
.badge.no { background: var(--stop-bg); color: var(--stop); }
.empty { padding: 1rem 0; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
