:root {
  --bg: #fbfaf7; --surface: #ffffff; --ink: #1b1d21; --muted: #575c66; --line: #dcdde1;
  --accent: #235a97; --accent-ink: #ffffff; --ok: #1d6b3a; --ok-bg: #e5f4ea; --bad: #a3221b; --bad-bg: #fbe9e7;
  --warn: #7a5200; --warn-bg: #fdf2d8; --focus: #f2a20c;
  --code-bg: #ffffff; --gutter-bg: #f1f2f4; --console-bg: #1b1d21; --console-ink: #eceef1; --console-err: #ff9a90; --console-hint: #f3c661; --bad-ink: #ffffff;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15171b; --surface: #1e2126; --ink: #eceef1; --muted: #a9afb9; --line: #343842;
    --accent: #7fb0ff; --accent-ink: #0d1420; --ok: #7fd69c; --ok-bg: #173323; --bad: #ff9a90; --bad-bg: #3a1c1a;
    --warn: #f3c661; --warn-bg: #3a2e12;
    --code-bg: #111317; --gutter-bg: #1a1d22; --console-bg: #0c0d10; --bad-ink: #1b0d0c;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.wrap { max-width: 980px; margin: 0 auto; padding: 0 16px; }
header.site { border-bottom: 1px solid var(--line); background: var(--surface); }
header.site .wrap { display: flex; gap: 16px; align-items: center; justify-content: space-between; padding-top: 12px; padding-bottom: 12px; flex-wrap: wrap; }
.brand { font-weight: 700; color: var(--ink); text-decoration: none; }
nav.top { display: flex; gap: 14px; flex-wrap: wrap; font-size: 0.92rem; }
h1 { font-size: clamp(1.6rem, 4.5vw, 2.3rem); line-height: 1.2; margin: 28px 0 8px; letter-spacing: -0.01em; }
h2 { font-size: 1.3rem; margin: 36px 0 10px; }
h3 { font-size: 1.05rem; margin: 20px 0 6px; }
.lede { color: var(--muted); margin: 0 0 18px; max-width: 70ch; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 18px; margin: 16px 0; }
label { display: block; font-weight: 600; margin: 0 0 6px; }
textarea, input[type=text], input[type=email], input[type=number], select {
  width: 100%; font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px;
}
textarea { resize: vertical; min-height: 84px; }
button, .btn { font: inherit; font-weight: 600; border-radius: 8px; padding: 9px 14px; border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink); cursor: pointer; }
button.ghost { background: transparent; color: var(--accent); }
button:disabled { opacity: 0.55; cursor: default; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.small { font-size: 0.88rem; color: var(--muted); }
.facts { border-left: 4px solid var(--accent); }
.facts ul { margin: 6px 0; padding-left: 20px; }
.pro { border: 2px solid var(--accent); }
.pro h2 { margin-top: 0; }
.pro .thanks { color: var(--ok); font-weight: 600; }
.pro .err { color: var(--bad); }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; }
table { border-collapse: collapse; width: 100%; font-size: 0.93rem; }
th, td { text-align: left; vertical-align: top; padding: 8px; border-bottom: 1px solid var(--line); }
th { background: var(--bg); position: sticky; top: 0; }
.cards { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.cards a.card { display: block; text-decoration: none; color: var(--ink); margin: 0; }
.cards a.card strong { color: var(--accent); }
details { border-bottom: 1px solid var(--line); padding: 10px 0; }
summary { cursor: pointer; font-weight: 600; }
footer.site { border-top: 1px solid var(--line); margin-top: 48px; padding: 20px 0 32px; color: var(--muted); font-size: 0.9rem; }
.card > h2:first-child { margin-top: 0; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.92em; }
.ide { padding: 12px; }
.ide-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.ide-bar .pick { display: flex; gap: 6px; align-items: center; margin-left: auto; }
.ide-bar .pick label { margin: 0; font-weight: 600; font-size: 0.9rem; }
.ide-bar select { width: auto; max-width: 210px; padding: 7px 8px; }
.ide-bar .open-full { margin-left: auto; font-size: 0.9rem; }
.ide-panes { display: grid; gap: 12px; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); }
@media (max-width: 760px) { .ide-panes { grid-template-columns: minmax(0, 1fr); } }
.editor-box { display: flex; border: 1px solid var(--line); border-radius: 8px; background: var(--code-bg); overflow: hidden; }
.editor-box:focus-within { outline: 3px solid var(--focus); outline-offset: 1px; }
.gutter, .code, .console { font: 14px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.gutter { flex: none; min-width: 3ch; padding: 10px 8px 10px 10px; text-align: right; color: var(--muted); background: var(--gutter-bg); border-right: 1px solid var(--line); overflow: hidden; user-select: none; height: 360px; }
.gutter span { display: block; }
.gutter .err-line { color: var(--bad-ink); background: var(--bad); border-radius: 3px; padding: 0 3px; margin-right: -3px; }
textarea.code { flex: 1; min-width: 0; height: 360px; min-height: 0; margin: 0; padding: 10px; border: 0; border-radius: 0; background: transparent; color: var(--ink); resize: none; white-space: pre; overflow: auto; tab-size: 4; }
textarea.code:focus-visible { outline: none; }
.keys { margin: 6px 0 0; }
.output { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.turtle { background: #fff; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; align-self: center; max-width: 100%; }
.turtle iframe { display: block; border: 0; }
.console { margin: 0; flex: 1; min-height: 160px; max-height: 360px; overflow: auto; padding: 10px; border-radius: 8px; background: var(--console-bg); color: var(--console-ink); white-space: pre-wrap; overflow-wrap: anywhere; }
.console .error { color: var(--console-err); font-weight: 700; }
.console .hint { display: block; color: var(--console-hint); margin-top: 4px; }
.console .note { color: var(--console-hint); }
.console .echo { color: var(--console-hint); }
.console .stdin { display: inline-block; width: min(260px, 100%); font: inherit; color: var(--console-ink); background: transparent; border: 0; border-bottom: 2px solid var(--console-hint); border-radius: 0; padding: 0 2px; }
.status { margin: 0; }
.share-panel { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); display: grid; gap: 6px; }
.share-panel label { margin-top: 6px; font-size: 0.93rem; }
.row.nowrap { flex-wrap: nowrap; align-items: stretch; }
.row.nowrap input, .row.nowrap textarea { flex: 1; min-width: 0; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.85rem; }
.row.nowrap textarea { min-height: 64px; resize: vertical; }
.demo-embed { width: 100%; height: 600px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
@media (max-width: 760px) { .gutter, textarea.code { height: 230px; } }
body.embed { background: var(--surface); }
body.embed .ide { border: 0; margin: 0; padding: 8px; }
body.embed .gutter, body.embed textarea.code { height: max(200px, calc(100vh - 130px)); }
body.embed .console { max-height: max(160px, calc(100vh - 130px)); }
@media (min-width: 560px) { body.embed .ide-panes { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); } }
@media (max-width: 559px) { body.embed .gutter, body.embed textarea.code { height: 220px; } }
.embed-foot { margin: 0; padding: 0 10px 8px; }
