:root {
  --bg: #f7f5f0;
  --surface: #ffffff;
  --surface-2: #f0ede6;
  --ink: #1d1d1f;
  --ink-2: #55524c;
  --line: #e2ddd2;
  --accent: #ff7a1a;
  --accent-ink: #ffffff;
  --c-black: #1d1d1f;
  --c-green: #2fb36b;
  --c-blue: #3b82f6;
  --c-red: #e5484d;
  --c-purple: #8e4ec6;
  --c-bg: #c9c2b4;
  --prem: #b7791f;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.05);
  --r: 14px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15161a; --surface: #1e2026; --surface-2: #272a31; --ink: #f2f1ee; --ink-2: #aaa69e;
    --line: #4a4e58; --c-bg: #6d675d; --prem: #e8b04b;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25);
  }
}
:root[data-theme="dark"] {
  --bg: #15161a; --surface: #1e2026; --surface-2: #272a31; --ink: #f2f1ee; --ink-2: #aaa69e;
  --line: #4a4e58; --c-bg: #6d675d; --prem: #e8b04b;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 64px; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.55 Inter, system-ui, sans-serif; -webkit-text-size-adjust: 100%; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }
h1, h2, h3 { font-family: "Baloo 2", Inter, sans-serif; line-height: 1.15; margin: 0; }
h1 { font-size: clamp(2.3rem, 6vw, 3.6rem); font-weight: 800; }
h2 { font-size: clamp(1.5rem, 3.5vw, 2rem); font-weight: 800; display: flex; align-items: center; gap: .55rem; }
h3 { font-size: 1.2rem; font-weight: 800; margin-bottom: .5rem; }
p { margin: .4rem 0; }
a { color: inherit; }
.muted { color: var(--ink-2); }
.small { font-size: .85rem; }
.sub { color: var(--ink-2); max-width: 760px; margin: .4rem 0 1.2rem; }
.num { display: inline-grid; place-items: center; width: 1.7em; height: 1.7em; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-size: .75em; flex: none; }
section { padding: 3rem 0 1rem; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); padding: 1.1rem 1.2rem; }
.btn { display: inline-flex; align-items: center; gap: .35rem; border: 1px solid var(--line); background: var(--surface); color: var(--ink); padding: .65rem 1.05rem; border-radius: 999px; font: 600 .95rem Inter, sans-serif; text-decoration: none; cursor: pointer; }
.btn:hover { border-color: var(--ink-2); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.sm { padding: .45rem .8rem; font-size: .85rem; }
.pill { display: inline-block; font-size: .72rem; font-weight: 700; padding: .1rem .5rem; border-radius: 999px; background: var(--surface-2); color: var(--ink-2); vertical-align: middle; }
.pill.prem { background: color-mix(in srgb, var(--prem) 18%, transparent); color: var(--prem); }
.note { font-size: .9rem; background: var(--surface-2); border-radius: 10px; padding: .55rem .75rem; margin-top: .6rem; }

/* hero */
.hero { padding: 3rem 0 2rem; background: radial-gradient(circle at 85% 20%, color-mix(in srgb, var(--accent) 16%, transparent), transparent 55%); }
.hero-in { display: grid; grid-template-columns: 1.1fr 1fr; gap: 2rem; align-items: center; }
.eyebrow { text-transform: uppercase; letter-spacing: .08em; font-size: .78rem; font-weight: 700; color: var(--accent); }
.lead { font-size: 1.1rem; color: var(--ink-2); max-width: 560px; }
.hero-cta { display: flex; gap: .6rem; flex-wrap: wrap; margin-top: 1.2rem; }
.hero-art { display: flex; align-items: center; gap: .6rem; }
.hero-art > div:not(.arrow) { flex: 1; position: relative; border-radius: 12px; overflow: hidden; box-shadow: var(--shadow); }
.paper { background: #fffdf7; border: 1px solid #e6e0d0; transform: rotate(-2deg); }
.screen { background: #16213e; border: 6px solid #2b2b31; transform: rotate(1.5deg); }
.hero-art svg { display: block; width: 100%; height: auto; }
.arrow { font-size: 1.6rem; color: var(--accent); flex: none; }
.tag { position: absolute; top: 6px; right: 8px; font-size: .7rem; font-weight: 700; padding: .05rem .45rem; border-radius: 6px; background: rgba(0,0,0,.6); color: #fff; }

/* toc */
.toc { position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.toc-in { display: flex; gap: .3rem; overflow-x: auto; padding-top: .55rem; padding-bottom: .55rem; scrollbar-width: none; }
.toc a { white-space: nowrap; text-decoration: none; font-size: .88rem; font-weight: 600; padding: .3rem .7rem; border-radius: 999px; color: var(--ink-2); }
.toc a:hover, .toc a.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

/* steps */
.steps { list-style: none; padding: 0; margin: 0 0 1rem; display: grid; grid-template-columns: repeat(6, 1fr); gap: .6rem; counter-reset: s; }
.steps button { width: 100%; height: 100%; text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: .8rem; cursor: pointer; color: var(--ink); font: inherit; box-shadow: var(--shadow); }
.steps button[aria-pressed="true"] { border-color: var(--accent); outline: 2px solid var(--accent); }
.steps .ico { font-size: 1.5rem; display: block; }
.steps b { display: block; font-size: .95rem; margin-top: .2rem; }
.steps small { color: var(--ink-2); font-size: .78rem; }
.step-detail ul, .color-detail ul { margin: .4rem 0 0; padding-left: 1.2rem; }
.step-detail li, .color-detail li { margin: .2rem 0; }

/* colors */
.colors { display: grid; grid-template-columns: repeat(6, 1fr); gap: .6rem; margin-bottom: 1rem; }
.swatch { border: 1px solid var(--line); background: var(--surface); border-radius: var(--r); padding: .8rem; cursor: pointer; text-align: left; color: var(--ink); font: inherit; box-shadow: var(--shadow); }
.swatch[aria-selected="true"] { outline: 3px solid var(--sw); border-color: transparent; }
.swatch .dot { width: 100%; height: 46px; border-radius: 9px; background: var(--sw); margin-bottom: .5rem; box-shadow: inset 0 0 0 1px var(--line); }
.swatch .dot.dashed { background: repeating-linear-gradient(45deg, var(--sw), var(--sw) 6px, transparent 6px, transparent 12px); border: 2px dashed var(--sw); }
.swatch b { display: block; }
.swatch small { color: var(--ink-2); }
.color-detail { border-left: 6px solid var(--sw, var(--accent)); }
.cd-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; margin-top: .8rem; }
.cd-grid h4 { margin: 0 0 .2rem; font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-2); }

/* lab */
.lab { padding: 0; overflow: hidden; }
.lab-tools { display: flex; justify-content: space-between; gap: .6rem; flex-wrap: wrap; padding: .8rem 1rem; border-bottom: 1px solid var(--line); }
.palette { display: flex; gap: .35rem; flex-wrap: wrap; }
.palette button { display: flex; align-items: center; gap: .35rem; border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 999px; padding: .35rem .7rem .35rem .4rem; cursor: pointer; font: 600 .82rem Inter, sans-serif; }
.palette button i { width: 18px; height: 18px; border-radius: 50%; background: var(--sw); display: inline-block; border: 1px solid rgba(0,0,0,.15); }
.palette button[aria-pressed="true"] { outline: 2px solid var(--sw); border-color: transparent; }
.lab-actions { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; }
.chk { font-size: .85rem; display: flex; gap: .3rem; align-items: center; color: var(--ink-2); }
.lab-stage { position: relative; background: #fffdf7; }
.lab-stage canvas { display: block; width: 100%; height: auto; touch-action: none; cursor: crosshair; }
.lab-stage.playing canvas { cursor: default; }
.lab-msg { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; background: rgba(10,12,20,.72); color: #fff; padding: 1rem; }
.lab-msg[hidden] { display: none; }
.lab-msg div { max-width: 440px; }
.lab-msg h3 { font-size: 1.6rem; }
.lab-msg .btn { margin-top: .8rem; }
.lab-foot { padding: .7rem 1rem 1rem; }
.touch { display: flex; gap: .5rem; justify-content: center; margin: .4rem 0; }
.touch button { width: 64px; height: 52px; font-size: 1.4rem; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); color: var(--ink); touch-action: none; user-select: none; -webkit-user-select: none; }

/* grids & cards */
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: .8rem; }
.grid2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: .8rem; margin-bottom: 1rem; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2rem; align-items: start; }
.item { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: .9rem 1rem; box-shadow: var(--shadow); position: relative; }
.item .hd { display: flex; align-items: center; gap: .55rem; margin-bottom: .3rem; }
.item .em { font-size: 1.4rem; width: 2.2rem; height: 2.2rem; display: grid; place-items: center; border-radius: 10px; background: var(--surface-2); flex: none; }
.item b { font-size: 1rem; }
.item .en { font-size: .75rem; color: var(--ink-2); display: block; }
.item p { font-size: .92rem; color: var(--ink-2); margin: .25rem 0 0; }
.item .tip { font-size: .85rem; margin-top: .5rem; padding-top: .5rem; border-top: 1px dashed var(--line); color: var(--ink); }
.item .pills { display: flex; gap: .3rem; flex-wrap: wrap; margin-top: .5rem; }
.item.danger { border-top: 4px solid var(--c-red); }
.list { display: grid; gap: .6rem; }
.filters { display: flex; gap: .7rem; flex-wrap: wrap; align-items: center; margin-bottom: 1rem; }
.filters input { flex: 1 1 220px; max-width: 320px; padding: .6rem .9rem; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; }
.chips { display: flex; gap: .35rem; flex-wrap: wrap; margin-bottom: 1rem; }
.filters .chips { margin: 0; }
.chips button { border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); border-radius: 999px; padding: .35rem .75rem; font: 600 .82rem Inter, sans-serif; cursor: pointer; }
.chips button[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.mode .goal { font-size: .88rem; margin-top: .5rem; }
.mode .uses { display: flex; gap: .3rem; flex-wrap: wrap; margin-top: .5rem; }
.mode .uses span { font-size: .75rem; border-radius: 6px; padding: .1rem .45rem; background: color-mix(in srgb, var(--sw) 16%, transparent); color: var(--ink); border-left: 3px solid var(--sw); }
.howto { padding-left: 1.2rem; margin: .3rem 0; }
.howto li { margin: .25rem 0; }

/* faq */
.faq { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.faq details { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: .8rem 1rem; box-shadow: var(--shadow); }
.faq summary { cursor: pointer; font-weight: 700; list-style: none; display: flex; gap: .5rem; }
.faq summary::before { content: "＋"; color: var(--accent); }
.faq details[open] summary::before { content: "－"; }
.faq details p { color: var(--ink-2); font-size: .93rem; margin-top: .5rem; }

/* safety */
.safe h3 { display: flex; align-items: center; gap: .5rem; }
.safe ul { padding-left: 1.1rem; margin: .3rem 0 0; }
.safe li { margin: .3rem 0; font-size: .93rem; }
.safe .warn { color: var(--c-red); font-weight: 600; }
.checklist ul { list-style: none; padding: 0; margin: .5rem 0 0; display: grid; grid-template-columns: 1fr 1fr; gap: .3rem 1rem; }
.checklist label { display: flex; gap: .5rem; align-items: flex-start; cursor: pointer; font-size: .93rem; padding: .25rem 0; }
.checklist input { margin-top: .25rem; accent-color: var(--accent); }
.checklist input:checked + span { text-decoration: line-through; color: var(--ink-2); }

/* quiz */
.quiz .q { font-size: 1.15rem; font-weight: 700; margin: .3rem 0 .8rem; }
.quiz .opts { display: grid; gap: .45rem; }
.quiz .opts button { text-align: left; border: 1px solid var(--line); background: var(--surface-2); color: var(--ink); border-radius: 10px; padding: .65rem .9rem; font: inherit; cursor: pointer; }
.quiz .opts button.right { background: color-mix(in srgb, var(--c-green) 22%, transparent); border-color: var(--c-green); }
.quiz .opts button.wrong { background: color-mix(in srgb, var(--c-red) 18%, transparent); border-color: var(--c-red); }
.quiz .why { margin-top: .7rem; font-size: .93rem; color: var(--ink-2); }
.quiz .bar { height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; }
.quiz .bar i { display: block; height: 100%; background: var(--accent); transition: width .3s; }
.quiz .nav { display: flex; justify-content: space-between; align-items: center; margin-top: 1rem; }

.foot { margin-top: 3rem; padding: 1.5rem 0 2.5rem; border-top: 1px solid var(--line); color: var(--ink-2); font-size: .85rem; }

@media (max-width: 960px) {
  .steps { grid-template-columns: repeat(3, 1fr); }
  .colors { grid-template-columns: repeat(3, 1fr); }
  .grid3 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 720px) {
  .hero-in, .two, .grid2, .faq, .cd-grid { grid-template-columns: 1fr; }
  .grid3 { grid-template-columns: 1fr; }
  .steps { grid-template-columns: 1fr 1fr; }
  .colors { grid-template-columns: 1fr 1fr; }
  .checklist ul { grid-template-columns: 1fr; }
  .lab-tools { flex-direction: column; }
}
