:root {
  --bg: #15171b;
  --surface: #1d2025;
  --surface-2: #24282e;
  --border: #373c44;
  --text: #f0f1f2;
  --muted: #a7adb5;
  --faint: #858d97;
  --reference: #C7ED72;
  --reference-soft: rgba(199, 237, 114, 0.12);
  --student: #F08078;
  --student-soft: rgba(240, 128, 120, 0.12);
}

html[data-theme="light"] {
  --bg: #f3f4f5;
  --surface: #ffffff;
  --surface-2: #eef0f2;
  --border: #cdd2d7;
  --text: #1b1d20;
  --muted: #525a64;
  --faint: #69727c;
  --reference-soft: rgba(125, 161, 45, 0.14);
  --student-soft: rgba(204, 83, 75, 0.11);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  padding: 28px 18px 44px;
  background: var(--bg);
  color: var(--text);
  font-family: Verdana, Geneva, sans-serif;
}

button { font: inherit; }
button {
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
button:hover:not(:disabled) { border-color: var(--reference); }
button:focus-visible, a:focus-visible { outline: 3px solid var(--reference); outline-offset: 2px; }
button:disabled { cursor: default; opacity: 0.42; }
[hidden] { display: none !important; }

.app { max-width: 820px; margin: 0 auto; }
.top-links {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
  text-align: left;
  font-size: 12px;
}
.top-links a {
  color: var(--muted);
  text-underline-offset: 4px;
}
.top-links a:hover { color: var(--reference); }
header { margin-bottom: 24px; }
.brand h1 { margin: 0; text-align: center; font-size: 29px; letter-spacing: 0.02em; }
.tagline { margin: 6px 0 0; color: var(--muted); font-size: 14px; }
.normalization-note {
  max-width: 720px;
  margin: 12px 0 0;
  color: var(--faint);
  font-size: 12px;
  line-height: 1.55;
}
.header-controls { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-top: 20px; flex-wrap: wrap; }
.segmented { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--border); border-radius: 5px; overflow: hidden; }
.segmented button { border: 0; border-radius: 0; padding: 8px 14px; color: var(--muted); }
.segmented button + button { border-left: 1px solid var(--border); }
.segmented button.active { color: var(--reference); background: var(--reference-soft); }
.theme-control { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.switch { position: relative; width: 48px; height: 26px; padding: 2px; border-radius: 13px; background: var(--surface-2); }
.switch span { position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: var(--reference); transition: transform 0.15s ease; }
html[data-theme="light"] .switch span { transform: translateX(22px); }

.protocol-banner { margin-bottom: 18px; padding: 12px 14px; border: 1px solid var(--border); border-left: 4px solid var(--student); border-radius: 5px; background: var(--surface); color: var(--muted); font-size: 13px; line-height: 1.5; }
.topline { margin-bottom: 12px; color: var(--faint); font-size: 13px; }
.stage { padding: 22px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.instruction { margin: 0 0 18px; color: var(--muted); font-size: 18px; }
.contour-box { position: relative; height: 230px; overflow: hidden; border: 1px solid var(--border); border-radius: 6px; background: var(--surface-2); }
canvas { display: block; width: 100%; height: 100%; }
.legend { position: absolute; top: 12px; right: 12px; display: flex; gap: 14px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 4px; background: var(--surface-2); color: var(--muted); font-size: 12px; }
.legend-item { display: flex; align-items: center; gap: 6px; }
.legend-line { width: 22px; height: 2px; background: var(--reference); }
.legend-line.student { background: var(--student); }
.toolbar, .post-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.primary, .record { min-width: 140px; padding: 11px 18px; }
.primary { border-color: var(--reference); background: var(--reference-soft); color: var(--reference); }
.record { border-color: var(--student); background: var(--student-soft); color: var(--student); }
.secondary { padding: 10px 14px; }
.status { margin-left: auto; color: var(--faint); font-size: 13px; }
.reveals { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; margin-top: 18px; }
.reveals:empty { display: none; }
.reveal-card { padding: 14px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface-2); }
.reveal-label { margin-bottom: 7px; color: var(--faint); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; }
.reveal-text { font-size: 16px; font-style: italic; line-height: 1.5; }
footer { margin-top: 22px; color: var(--faint); font-size: 12px; line-height: 1.6; }
a { color: var(--reference); }
.footer-link { display: block; margin-top: 5px; }

@media (max-width: 640px) {
  body { padding: 20px 12px 36px; }
  .stage { padding: 16px; }
  .contour-box { height: 205px; }
  .status { width: 100%; margin-left: 0; }
}
@media (prefers-reduced-motion: reduce) { .switch span { transition: none; } }
