:root {
  --bg: #f6f5f2; --card: #ffffff; --text: #1c1917; --muted: #57534e; --line: #e2dfd9;
  --accent: #1d4ed8; --accent-text: #ffffff; --soft: #eef2ff; --good: #15803d; --bad: #b91c1c; --warn: #a16207;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141311; --card: #1d1c1a; --text: #f4f2ee; --muted: #b5b0a8; --line: #34322e;
    --accent: #7aa2ff; --accent-text: #0b1220; --soft: #1b2236; --good: #4ade80; --bad: #f87171; --warn: #facc15;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 18px/1.5 -apple-system, system-ui, "Segoe UI", sans-serif; }
main { max-width: 680px; margin: 0 auto; padding: 20px 16px 56px; padding-bottom: calc(56px + env(safe-area-inset-bottom, 0px)); }

.top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.brand { font-size: 15px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.demo { font-size: 14px; font-weight: 600; background: #fef3c7; color: #78350f; border-radius: 999px; padding: 4px 12px; }

h1 { font-size: 28px; line-height: 1.2; margin: 0 0 14px; outline: none; }
h2 { font-size: 20px; line-height: 1.3; margin: 28px 0 8px; }
p { margin: 0 0 14px; }
.lead { font-size: 19px; }
.muted { color: var(--muted); font-size: 16px; }
small { color: var(--muted); font-size: 15px; display: block; margin-top: 4px; }

.progress { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; margin-bottom: 6px; }
.progress span { display: block; height: 100%; background: var(--accent); }
.step-label { color: var(--muted); font-size: 15px; margin-bottom: 18px; }

.grid2 { display: grid; grid-template-columns: 1fr; grid-gap: 12px; margin: 12px 0 4px; }
@media (min-width: 640px) { .grid2 { grid-template-columns: 1fr 1fr; } }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; margin: 12px 0; }
.grid2 .card { margin: 0; }
.card h3 { font-size: 17px; margin: 0 0 8px; }

ul.marks, ul.plain { list-style: none; padding: 0; margin: 0; }
ul.marks li { position: relative; padding-left: 26px; margin: 0 0 8px; font-size: 17px; }
ul.marks li:before { position: absolute; left: 0; top: 0; font-weight: 700; }
ul.marks.yes li:before { content: "\2713"; color: var(--good); }
ul.marks.no li:before { content: "\2715"; color: var(--bad); }
ul.marks.open li:before { content: "\2022"; }
ul.plain li { padding-left: 0; margin: 0 0 10px; }

.note { background: var(--soft); border-radius: 12px; padding: 12px 16px; margin: 16px 0; font-size: 17px; }
.note.warn { background: #fef3c7; color: #78350f; }
.error { background: #fee2e2; color: #7f1d1d; border-radius: 12px; padding: 12px 16px; margin: 16px 0; font-weight: 600; }
.success { background: #dcfce7; color: #14532d; border-radius: 12px; padding: 12px 16px; margin: 16px 0; font-weight: 600; }

button { font: inherit; cursor: pointer; }
.btn { display: inline-block; font-weight: 600; padding: 14px 22px; border: 0; border-radius: 12px; background: var(--accent); color: var(--accent-text); margin: 6px 8px 6px 0; }
.btn.secondary { background: transparent; color: var(--accent); border: 1px solid var(--line); }
.btn[disabled] { opacity: .45; cursor: default; }
.btn.small { padding: 10px 16px; font-size: 16px; }
.link { background: none; border: 0; color: var(--accent); text-decoration: underline; padding: 8px 0; font-size: 17px; }
.nav { margin-top: 22px; }
.backrow { margin: 0 0 16px; }

.choice { display: block; width: 100%; text-align: left; background: var(--card); color: var(--text); border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; margin: 12px 0; }
.choice b { display: block; font-size: 19px; margin-bottom: 4px; }
.choice span { color: var(--muted); font-size: 16px; }
.choice.on { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }

ol.steps { list-style: none; counter-reset: step; padding: 0; margin: 14px 0; }
ol.steps li { counter-increment: step; position: relative; padding: 0 0 14px 42px; }
ol.steps li:before { content: counter(step); position: absolute; left: 0; top: 0; width: 30px; height: 30px; border-radius: 50%; background: var(--accent); color: var(--accent-text); font-weight: 700; font-size: 16px; text-align: center; line-height: 30px; }

pre.code { background: #1c1917; color: #f5f5f4; border-radius: 12px; padding: 14px 16px; margin: 10px 0; font: 14px/1.45 ui-monospace, Menlo, Consolas, monospace; white-space: pre-wrap; word-break: break-all; }

.field { display: block; margin: 0 0 18px; font-weight: 600; }
.field small { font-weight: 400; }
.field input[type=text], .field input[type=number], .field textarea, .field select { display: block; width: 100%; margin-top: 6px; padding: 12px 14px; font: inherit; font-weight: 400; color: var(--text); background: var(--card); border: 1px solid var(--line); border-radius: 10px; }
.field textarea { min-height: 130px; font: 14px/1.4 ui-monospace, Menlo, Consolas, monospace; }
.field input:focus, .field textarea:focus, .field select:focus, button:focus-visible, summary:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.check { display: block; position: relative; padding-left: 34px; margin: 12px 0; font-weight: 400; }
.check input { position: absolute; left: 0; top: 3px; width: 22px; height: 22px; }
.radio { display: block; position: relative; padding: 12px 14px 12px 44px; margin: 8px 0; background: var(--card); border: 1px solid var(--line); border-radius: 12px; font-weight: 400; }
.radio input { position: absolute; left: 14px; top: 15px; width: 22px; height: 22px; }

.result { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px 18px; margin: 14px 0; }
.result dl { margin: 0; display: grid; grid-template-columns: auto 1fr; grid-gap: 4px 16px; }
.result dt { color: var(--muted); }
.result dd { margin: 0; font-weight: 600; }

details { margin: 12px 0; }
summary { cursor: pointer; font-weight: 600; color: var(--accent); padding: 6px 0; }
.tablewrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 16px; }
th, td { text-align: left; vertical-align: top; padding: 8px 10px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 600; font-size: 15px; }
table code { font: 13px ui-monospace, Menlo, Consolas, monospace; word-break: break-all; }

a.btn { text-decoration: none; }

#touch-overlay, #color-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; z-index: 50; background: #fff; -webkit-user-select: none; user-select: none; }
#touch-grid { width: 100%; height: 100%; border-collapse: collapse; table-layout: fixed; }
#touch-grid td { border: 1px solid #e7e5e4; padding: 0; }
#touch-grid td.on { background: #22c55e; }
#touch-note { position: fixed; left: 0; right: 0; top: 40%; text-align: center; z-index: 51; pointer-events: none; font-weight: 600; color: #111; }
#touch-skip { position: fixed; left: 50%; bottom: 16px; margin-left: -50px; z-index: 52; }
#color { position: absolute; top: 0; left: 0; right: 0; bottom: 0; }
#colorbar { position: absolute; left: 0; right: 0; bottom: 18px; text-align: center; }

details.example { margin: 22px 0; padding: 14px 18px; background: var(--soft); border: 2px solid var(--accent); border-radius: 14px; }
details.example[open] summary { margin-bottom: 8px; }
details.example .tablewrap { background: var(--card); border-radius: 10px; }
details.example summary { font-size: 18px; }
