:root {
  --bg: #f6f6f4;
  --card: #ffffff;
  --text: #1c1c1a;
  --muted: #6b6b66;
  --line: #e4e4df;
  --code-bg: #f2f2ee;
  --accent: #2563eb;
  --success: #13735b;
  --error: #c2410c;
  --warning: #a16207;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141413;
    --card: #1e1e1c;
    --text: #ececea;
    --muted: #9a9a94;
    --line: #2f2f2c;
    --code-bg: #262624;
    --accent: #60a5fa;
    --success: #70c9a8;
    --error: #fb923c;
    --warning: #facc15;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

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

a { color: inherit; }
h1 { margin: 0 0 6px; font-size: 24px; letter-spacing: -0.02em; }
h2 { margin: 20px 0 4px; font-size: 14px; }
code, pre, textarea { font: 12px/1.5 ui-monospace, "SF Mono", Menlo, monospace; }
p code { background: var(--code-bg); padding: 1px 4px; border-radius: 4px; }
button { font: inherit; }

.boot-error {
  margin: 16px;
  padding: 12px 16px;
  border: 1px solid var(--error);
  border-radius: 10px;
  background: var(--card);
  font-size: 14px;
}
.boot-error strong { display: block; margin-bottom: 2px; }

/* Layout: a left nav and a main column. */
.app { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }

.lnb {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 20px 16px;
  border-right: 1px solid var(--line);
  background: var(--card);
}

.brand { display: flex; align-items: baseline; gap: 6px; text-decoration: none; margin-bottom: 4px; }
.brand strong { font-size: 20px; letter-spacing: -0.02em; }
.brand span { color: var(--muted); font-size: 13px; }

#search {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font: 14px ui-sans-serif, system-ui, sans-serif;
}

#categories { display: flex; flex-direction: column; gap: 2px; }
#categories a {
  display: flex;
  justify-content: space-between;
  padding: 6px 8px;
  border-radius: 6px;
  text-decoration: none;
  font-size: 14px;
}
#categories a:hover { background: var(--bg); }
#categories a[aria-current="true"] { background: var(--bg); font-weight: 600; }
#categories a span { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }

.lnb-foot { margin-top: auto; display: flex; flex-direction: column; gap: 4px; font-size: 14px; }
.lnb-foot a { padding: 4px 8px; border-radius: 6px; text-decoration: none; color: var(--muted); }
.lnb-foot a:hover, .lnb-foot a[aria-current="true"] { color: var(--text); background: var(--bg); }

main { padding: 32px 32px 64px; min-width: 0; }
.view-head { margin-bottom: 20px; }
.view-head p { margin: 0; color: var(--muted); max-width: 64ch; }

/* Runtime support is part of the work surface, not a separate marketing hero. */
.runtime-band {
  display: grid;
  grid-template-columns: minmax(220px, 1.2fr) minmax(420px, 2fr) minmax(150px, 0.7fr);
  gap: 24px;
  align-items: center;
  margin: 0 0 20px;
  padding: 18px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.runtime-lead h2 { margin: 2px 0 3px; font-size: 17px; }
.runtime-lead p { margin: 0; color: var(--muted); font-size: 13px; }
.runtime-label { color: var(--accent); font-size: 12px; font-weight: 700; }
.runtime-platforms { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.runtime-platforms div { min-width: 0; padding: 3px 14px; border-left: 1px solid var(--line); }
.runtime-platforms strong, .runtime-platforms span { display: block; }
.runtime-platforms strong { font-size: 13px; }
.runtime-platforms span { color: var(--muted); font-size: 12px; }
.runtime-check { padding-left: 16px; border-left: 3px solid var(--success); }
.runtime-check strong, .runtime-check span, .runtime-check small { display: block; }
.runtime-check strong { color: var(--success); font-size: 19px; font-variant-numeric: tabular-nums; }
.runtime-check span { font-size: 12px; font-weight: 700; }
.runtime-check small { color: var(--muted); font-size: 11px; }

/* Tag chips, shared by the browse filter and the detail view. */
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 20px; }
.tag {
  padding: 3px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  color: var(--muted);
  font: 12px ui-monospace, "SF Mono", Menlo, monospace;
  text-decoration: none;
  cursor: pointer;
}
.tag:hover { color: var(--text); border-color: var(--muted); }
.tag[aria-pressed="true"] { color: var(--card); background: var(--text); border-color: var(--text); }

/* Browse grid. */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; min-width: 0; }
.card .meta { display: flex; align-items: baseline; gap: 8px; margin-top: 10px; }
.card .meta .state { margin-left: auto; }
.card h3 { margin: 0; font-size: 15px; }
.card h3 a { text-decoration: none; }
.card h3 a:hover { text-decoration: underline; }
.card p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.empty { color: var(--muted); }

/* Stages host each example's own markup and styles in a shadow root. */
.stage {
  height: 200px;
  display: grid;
  place-items: center;
  background: var(--bg);
  border-radius: 10px;
  overflow: hidden;
}
.stage-large { height: 280px; }
.stage-foot { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.stage-foot .hint { flex: 1; }
.reset {
  margin-left: auto;
  padding: 2px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--card);
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
}
.reset:hover { color: var(--text); border-color: var(--muted); }
.state { font: 12px ui-monospace, "SF Mono", Menlo, monospace; color: var(--muted); }
.hint { font-size: 12px; color: var(--muted); }

/* Detail view. */
.back { display: inline-block; margin-bottom: 16px; color: var(--muted); text-decoration: none; font-size: 14px; }
.back:hover { color: var(--text); }
.detail { display: grid; grid-template-columns: minmax(0, 3fr) minmax(280px, 2fr); gap: 28px; align-items: start; }
.detail-info p { margin: 0 0 12px; color: var(--muted); }
.detail-info .small { font-size: 13px; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; margin: 4px 0 8px; }
.actions button, .playground-tools button, .prompts button {
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--card);
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
}
.actions button:hover, .playground-tools button:hover, .prompts button:hover { border-color: var(--muted); }
.prompts { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.prompts li { display: flex; gap: 8px; align-items: center; justify-content: space-between; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 13px; }

.code { margin-top: 24px; }
.tabs { display: flex; gap: 2px; overflow-x: auto; }
.tabs button {
  flex: 0 0 auto;
  padding: 8px 14px;
  border: 1px solid transparent;
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
  background: none;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
}
.tabs button[aria-selected="true"] { background: var(--code-bg); color: var(--text); border-color: var(--line); }
.code pre {
  margin: 0;
  padding: 14px;
  background: var(--code-bg);
  border: 1px solid var(--line);
  border-radius: 0 8px 8px 8px;
  overflow: auto;
  max-height: 520px;
}

/* Playground. */
.playground { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); gap: 24px; align-items: start; }
/* Compare mode: both stages in a row above the editor, so the judge sees them side by side. */
.playground.compare { grid-template-columns: 1fr; }
.playground.compare .stages { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.playground.compare .stages .verdict { grid-column: 1 / -1; }
.stage-label { margin-bottom: 6px; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; }
.verdict { margin: 4px 0 0; padding: 10px 12px; border-radius: 8px; background: var(--code-bg); font-size: 14px; }
.verdict:empty { display: none; }
.verdict[data-verdict="clear"] { border-left: 3px solid #2563eb; }
.verdict[data-verdict="subtle"] { border-left: 3px solid #d97706; }
.verdict[data-verdict="imperceptible"] { border-left: 3px solid var(--muted); }
#playground-compare[aria-pressed="true"] { border-color: var(--text); }
.playground-tools { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 8px; color: var(--muted); font-size: 13px; }
.playground > div { min-width: 0; }
.playground-tools select { font: 13px ui-sans-serif, system-ui, sans-serif; padding: 5px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--card); color: var(--text); }
textarea {
  width: 100%;
  min-height: 420px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--code-bg);
  color: var(--text);
  resize: vertical;
}
.diagnostics { list-style: none; margin: 8px 0 0; padding: 0; font-size: 13px; }
.diagnostics li { padding: 6px 0; border-top: 1px solid var(--line); }
.diagnostics li:first-child { border-top: 0; }
.diagnostics .error { color: var(--error); }
.diagnostics .warning { color: var(--warning); }
.diagnostics .ok { color: var(--muted); }
.diagnostics .hint { display: block; color: var(--muted); }

@media (max-width: 840px) {
  .app { grid-template-columns: 1fr; }
  .lnb { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; border-right: 0; border-bottom: 1px solid var(--line); padding: 12px 16px; }
  .brand { margin: 0; }
  #search { width: auto; flex: 1; min-width: 140px; }
  #categories { flex-direction: row; flex-wrap: wrap; width: 100%; }
  #categories a { padding: 4px 8px; gap: 6px; }
  .lnb-foot { margin: 0; flex-direction: row; width: 100%; }
  main { padding: 20px 16px 48px; }
  .runtime-band { grid-template-columns: 1fr; gap: 14px; padding: 16px 0; }
  .runtime-platforms div:nth-child(odd) { border-left: 0; padding-left: 0; }
  .runtime-check { padding: 10px 0 0; border-left: 0; border-top: 3px solid var(--success); }
  .detail, .playground { grid-template-columns: 1fr; }
  .playground.compare .stages { grid-template-columns: 1fr; }
}
