:root {
  /* Light palette (default). Colors are also exposed as "-rgb" triples
     (e.g. --accent-2-rgb: 37,99,235) so translucent effects can use plain
     rgba(var(--x-rgb), alpha) instead of the newer color-mix() function —
     rgba()-with-a-variable has worked in every browser since Chrome 49 /
     Firefox 49 / Safari 9.1, so this renders identically everywhere. */
  --bg: #f5f7fa;
  --bg-rgb: 245, 247, 250;
  --panel: #ffffff;
  --panel-2: #f0f2f5;
  --border: #dde1e7;
  --text: #1a1d23;
  --muted: #5b6472;
  --accent: #0f9d68;
  --accent-rgb: 15, 157, 104;
  --accent-2: #2563eb;
  --accent-2-rgb: 37, 99, 235;
  --on-accent: #ffffff;
  --fail: #dc2626;
  --fail-rgb: 220, 38, 38;
  --pass: #16a34a;
  --pass-rgb: 22, 163, 74;
  --code-bg: #eef1f5;
  --shadow: 0 1px 2px rgba(20, 24, 33, 0.04), 0 12px 28px -16px rgba(20, 24, 33, 0.18);
  --shadow-sm: 0 1px 2px rgba(20, 24, 33, 0.06);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c0e13;
    --bg-rgb: 12, 14, 19;
    --panel: #171a21;
    --panel-2: #1e222b;
    --border: #2a2f3a;
    --text: #e6e8ec;
    --muted: #9aa3b2;
    --accent: #6ee7b7;
    --accent-rgb: 110, 231, 183;
    --accent-2: #60a5fa;
    --accent-2-rgb: 96, 165, 250;
    --on-accent: #0b1220;
    --fail: #f87171;
    --fail-rgb: 248, 113, 113;
    --pass: #34d399;
    --pass-rgb: 52, 211, 153;
    --code-bg: #0b0d12;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 16px 32px -18px rgba(0, 0, 0, 0.65);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
  }
}

:root[data-theme="dark"] {
  --bg: #0c0e13;
  --bg-rgb: 12, 14, 19;
  --panel: #171a21;
  --panel-2: #1e222b;
  --border: #2a2f3a;
  --text: #e6e8ec;
  --muted: #9aa3b2;
  --accent: #6ee7b7;
  --accent-rgb: 110, 231, 183;
  --accent-2: #60a5fa;
  --accent-2-rgb: 96, 165, 250;
  --on-accent: #0b1220;
  --fail: #f87171;
  --fail-rgb: 248, 113, 113;
  --pass: #34d399;
  --pass-rgb: 52, 211, 153;
  --code-bg: #0b0d12;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 16px 32px -18px rgba(0, 0, 0, 0.65);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(1300px 750px at 0% -10%, rgba(var(--accent-2-rgb), 0.32), transparent 60%),
    radial-gradient(1100px 680px at 100% 0%, rgba(var(--accent-rgb), 0.26), transparent 58%),
    linear-gradient(180deg, rgba(var(--accent-2-rgb), 0.07), transparent 45%),
    var(--bg);
  background-attachment: fixed;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(var(--bg-rgb), 0.82);
}
@supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  header {
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
  }
}

header h1 {
  font-size: 1.15rem;
  margin: 0;
  letter-spacing: 0.01em;
  font-weight: 700;
  color: var(--accent-2);
}
@supports ((background-clip: text) or (-webkit-background-clip: text)) {
  header h1 {
    background: linear-gradient(135deg, var(--text), var(--accent-2));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
  }
}

.header-right { display: flex; align-items: center; gap: 0.9rem; }

#theme-toggle {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  width: 2.1rem;
  height: 2.1rem;
  padding: 0;
  border-radius: 8px;
  font-size: 1rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

main {
  max-width: 880px;
  margin: 0 auto;
  padding: 1.75rem 1.5rem 3rem;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.35rem 1.5rem;
  margin-bottom: 1.1rem;
  box-shadow: var(--shadow);
}

label { display: block; font-size: 0.85rem; color: var(--muted); margin-bottom: 0.35rem; }

input[type="text"], textarea, select {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 0.6rem 0.7rem;
  font-size: 0.95rem;
  font-family: inherit;
}

textarea { min-height: 90px; resize: vertical; }

button {
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
  color: var(--on-accent);
  border: none;
  border-radius: 9px;
  padding: 0.6rem 1.1rem;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.9rem;
  box-shadow: 0 4px 14px -6px rgba(var(--accent-2-rgb), 0.55);
  transition: transform 0.12s ease, box-shadow 0.12s ease, opacity 0.12s ease;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px -6px rgba(var(--accent-2-rgb), 0.6);
}
button:active:not(:disabled) { transform: translateY(0); }

button.secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: none;
}
button.secondary:hover:not(:disabled) {
  background: var(--panel-2);
  box-shadow: none;
}

button:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-link {
  display: inline-block;
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
  color: var(--on-accent);
  border: none;
  border-radius: 9px;
  padding: 0.6rem 1.1rem;
  font-weight: 600;
  font-size: 0.9rem;
  text-decoration: none;
  box-shadow: 0 4px 14px -6px rgba(var(--accent-2-rgb), 0.55);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.btn-link:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px -6px rgba(var(--accent-2-rgb), 0.6);
}

.row { display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap; }
.field { margin-bottom: 0.85rem; }
.muted { color: var(--muted); font-size: 0.85rem; }

/* Stage navigator: macro axis = which of the 10 items you're on, micro
   axis (pips under the current node) = which block within that item. */
.stage-nav {
  display: flex;
  gap: 0.1rem;
  align-items: flex-start;
  overflow-x: auto;
  padding: 1.1rem 0.25rem 0.85rem;
  margin-bottom: 0.25rem;
}

.stage-node {
  position: relative;
  flex: 1 0 70px;
  min-width: 70px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 0 0.3rem;
}

.stage-node:not(:last-child)::after {
  content: "";
  position: absolute;
  top: 18px;
  left: calc(50% + 23px);
  right: calc(-50% + 23px);
  height: 2px;
  background: var(--border);
}
.stage-node.done:not(:last-child)::after { background: var(--pass); }

.stage-dot {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.82rem;
  font-weight: 700;
  background: var(--panel);
  border: 2px solid var(--border);
  color: var(--muted);
  z-index: 1;
  transition: box-shadow 0.15s ease;
}

.stage-node.done .stage-dot { background: var(--pass); border-color: var(--pass); color: var(--on-accent); }
.stage-node.current .stage-dot {
  background: var(--accent-2);
  border-color: var(--accent-2);
  color: var(--on-accent);
  box-shadow: 0 0 0 5px rgba(var(--accent-2-rgb), 0.2);
}

.stage-label {
  margin-top: 0.4rem;
  font-size: 0.68rem;
  color: var(--muted);
  line-height: 1.25;
  max-width: 84px;
}
.stage-node.current .stage-label { color: var(--text); font-weight: 700; }

.stage-subprogress { display: flex; gap: 3px; margin-top: 0.45rem; }
.block-pip { width: 7px; height: 7px; border-radius: 50%; background: var(--border); }
.block-pip.done { background: var(--pass); }
.block-pip.active {
  background: var(--accent-2);
  box-shadow: 0 0 0 2px rgba(var(--accent-2-rgb), 0.25);
}

pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem;
  overflow-x: auto;
  font-size: 0.85rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.block-card { border-left: 3px solid var(--border); padding-left: 0.9rem; margin-bottom: 1rem; }
.block-card.passed { border-left-color: var(--pass); }
.block-card.active { border-left-color: var(--accent-2); }

.scores { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 0.5rem; margin: 0.75rem 0; }
.score { background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px; padding: 0.5rem 0.6rem; }
.score .label { font-size: 0.75rem; color: var(--muted); }
.score .value { font-size: 1.1rem; font-weight: 700; }
.score.pass .value { color: var(--pass); }
.score.fail .value { color: var(--fail); }

.badge { display: inline-block; padding: 0.15rem 0.5rem; border-radius: 999px; font-size: 0.75rem; font-weight: 700; }
.badge.pass { background: rgba(var(--pass-rgb), 0.18); color: var(--pass); }
.badge.fail { background: rgba(var(--fail-rgb), 0.18); color: var(--fail); }

.feedback-analysis { white-space: pre-wrap; line-height: 1.5; }

details summary { cursor: pointer; color: var(--muted); }

.status-note {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: 0.75rem;
  padding: 0.6rem 0.8rem;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.85rem;
  color: var(--muted);
}
.status-elapsed { color: var(--text); font-variant-numeric: tabular-nums; }

.spinner {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  border: 2px solid var(--border);
  border-top-color: var(--accent-2);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.status-error {
  margin-top: 0.75rem;
  padding: 0.7rem 0.8rem;
  background: rgba(var(--fail-rgb), 0.12);
  border: 1px solid var(--fail);
  border-radius: 8px;
  font-size: 0.85rem;
}
.status-error > div { color: var(--fail); margin-bottom: 0.5rem; }

.site-footer { max-width: 880px; margin: 0 auto; padding: 0 1.5rem 2rem; text-align: center; }
.site-footer a { color: var(--muted); font-size: 0.8rem; text-decoration: none; }
.site-footer a:hover { color: var(--text); text-decoration: underline; }

.how-it-works summary { color: var(--text); font-weight: 600; }
.flow-steps { margin: 0.75rem 0 0; padding-left: 1.25rem; }
.flow-steps li { margin-bottom: 0.5rem; line-height: 1.5; }
.flow-steps li:last-child { margin-bottom: 0; }
