/* JavaScript、ひとつずつ */
:root {
  --bg: #fbfaf6;
  --surface: #ffffff;
  --surface-2: #f4f2ea;
  --text: #23262b;
  --muted: #5c626b;
  --line: #e3e0d6;
  --accent: #0b7a64;
  --accent-ink: #ffffff;
  --accent-soft: #def2ec;
  --accent-strong: #075c4b;
  --warn: #7a4f00;
  --warn-soft: #fff1cf;
  --term-soft: #e8eefb;
  --term: #26427a;
  --err: #b3261e;
  --err-soft: #fdeceb;
  --ok-soft: #e0f4e8;
  --code-bg: #1c2026;
  --code-text: #e8eaed;
  --code-dim: #8d95a0;
  --t-str: #a3e0a8;
  --t-num: #8ab9ff;
  --t-com: #8d95a0;
  --t-kw: #e8b0ff;
  --t-fn: #ffd591;
  --out-bool: #e8b0ff;
  --radius: 10px;
  --font: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic", Meiryo, system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Noto Sans Mono CJK JP", monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171a;
    --surface: #1b1f23;
    --surface-2: #232830;
    --text: #e6e8eb;
    --muted: #a0a7b0;
    --line: #2f353d;
    --accent: #4fcfb0;
    --accent-ink: #06201a;
    --accent-soft: #163a31;
    --accent-strong: #7ae0c7;
    --warn: #ffd98a;
    --warn-soft: #3a2f12;
    --term-soft: #1c2740;
    --term: #a9c1f5;
    --err: #ff8a80;
    --err-soft: #3a1c1a;
    --ok-soft: #173325;
    --code-bg: #0f1215;
  }
}

* { box-sizing: border-box; }
html { scroll-padding-top: 72px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.9;
  -webkit-text-size-adjust: 100%;
}
h1, h2, h3 { line-height: 1.5; margin: 0; }
p { margin: 0 0 1em; }
a { color: var(--accent-strong); }
code {
  font-family: var(--mono);
  font-size: 0.92em;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 0.05em 0.4em;
  word-break: break-all;
}
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
main:focus, main:focus-visible { outline: none; }
.skip { position: absolute; left: -999px; top: 0; background: var(--accent); color: var(--accent-ink); padding: 8px 12px; z-index: 100; }
.skip:focus { left: 8px; top: 8px; }

/* ---- 上の帯 ---- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; color: var(--text); text-decoration: none; letter-spacing: 0.02em; }
.menu-btn { display: none; }
.meter { margin-left: auto; display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); white-space: nowrap; }
.meter-bar { width: 120px; height: 8px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 99px; overflow: hidden; }
.meter-bar > span { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width 0.4s ease; }

/* ---- レイアウト ---- */
.shell { display: flex; align-items: flex-start; max-width: 1180px; margin: 0 auto; }
.sidebar {
  width: 290px; flex: none;
  position: sticky; top: 53px;
  max-height: calc(100vh - 53px); overflow-y: auto;
  padding: 20px 8px 40px 16px;
  font-size: 14px; line-height: 1.6;
}
main { flex: 1; min-width: 0; padding: 28px 24px 80px; max-width: 800px; outline: none; }

/* ---- 目次 ---- */
.nav-part { margin: 0 0 18px; }
.nav-part h2 { font-size: 13px; color: var(--muted); font-weight: 700; margin: 0 0 4px; padding: 0 8px; letter-spacing: 0.04em; }
.nav-group { margin: 0 0 6px; }
.nav-group h3 { font-size: 12px; color: var(--muted); font-weight: 400; margin: 6px 8px 2px; }
.nav-list { list-style: none; margin: 0; padding: 0; }
.nav-link {
  display: flex; gap: 8px; align-items: baseline;
  padding: 5px 8px; border-radius: 7px; text-decoration: none; color: var(--text);
}
.nav-link:hover { background: var(--surface-2); }
.nav-link[aria-current="page"] { background: var(--accent-soft); font-weight: 700; }
.nav-mark { flex: none; width: 1.2em; text-align: center; color: var(--muted); font-size: 12px; }
.nav-link.done .nav-mark { color: var(--accent-strong); font-weight: 700; }
.nav-no { flex: none; color: var(--muted); font-variant-numeric: tabular-nums; font-size: 12px; min-width: 2.2em; }
.nav-soon { padding: 3px 8px; color: var(--muted); font-size: 13px; }
.nav-soon small { margin-left: 6px; opacity: 0.8; }
.nav-goal { color: var(--accent-strong); font-weight: 700; }

/* ---- ホーム ---- */
.hero h1 { font-size: 30px; margin-bottom: 8px; }
.hero .lead { font-size: 18px; color: var(--muted); margin-bottom: 24px; }
.cta { display: inline-flex; align-items: center; gap: 8px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; margin: 0 0 20px; }
.card h2 { font-size: 18px; margin-bottom: 8px; }
.promise { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.promise li { display: flex; gap: 12px; align-items: flex-start; }
.promise .num { flex: none; width: 26px; height: 26px; line-height: 26px; text-align: center; border-radius: 50%; background: var(--accent-soft); color: var(--accent-strong); font-weight: 700; font-size: 13px; }
.cando { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.cando li::before { content: "✓"; color: var(--accent-strong); font-weight: 700; margin-right: 8px; }
.cando-empty { color: var(--muted); }
.roadmap { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.roadmap li { display: flex; gap: 10px; align-items: baseline; }
.roadmap .no { flex: none; min-width: 3.4em; color: var(--muted); font-size: 13px; }
.roadmap .soon { color: var(--muted); }
.tag { display: inline-block; font-size: 12px; line-height: 1.6; padding: 0 8px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); }
.tag.now { background: var(--accent-soft); border-color: transparent; color: var(--accent-strong); font-weight: 700; }
/* 復習用：講師用の画面と、待ち合わせ */
.teacher-panel { background: var(--term-soft); color: var(--text); border: 2px solid var(--term); border-radius: var(--radius); padding: 14px 18px; margin: 0 0 24px; }
.teacher-panel h2 { margin-top: 0; font-size: 18px; color: var(--term); }
.teacher-panel h3 { font-size: 15px; margin: 14px 0 6px; }
.teacher-items > li { margin: 0 0 14px; }
.teacher-banner { background: var(--term-soft); color: var(--term); border-radius: var(--radius); padding: 10px 14px; margin: 0 0 20px; font-size: 14px; font-weight: 600; }
.wait-note { background: var(--warn-soft); color: var(--warn); border: 2px dashed var(--warn); border-radius: var(--radius); padding: 12px 18px; margin: 24px 0; }
.wait-note h2 { margin: 0 0 6px; font-size: 18px; color: var(--warn); }
.wait-note p { margin: 0; }
.proto { background: var(--warn-soft); color: var(--warn); border-radius: var(--radius); padding: 10px 14px; margin: 0 0 20px; font-size: 14px; }

/* ---- ボタン ---- */
.btn {
  font: inherit; font-size: 15px; line-height: 1.4; cursor: pointer;
  padding: 9px 18px; border-radius: 8px; min-height: 44px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 700; }
.btn.primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); color: var(--accent-ink); }
.btn.small { min-height: 36px; padding: 5px 12px; font-size: 14px; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
a.btn { display: inline-flex; align-items: center; text-decoration: none; }

/* ---- ステップのページ ---- */
.crumb { font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.step-title { font-size: 28px; margin-bottom: 14px; }
.newthing {
  display: flex; gap: 14px; align-items: flex-start;
  background: var(--accent-soft); border-radius: var(--radius); padding: 14px 18px; margin-bottom: 22px;
}
.newthing .lab { flex: none; font-size: 12px; font-weight: 700; background: var(--accent); color: var(--accent-ink); border-radius: 99px; padding: 0 10px; line-height: 1.9; margin-top: 2px; }
.newthing .what { font-weight: 700; font-size: 17px; line-height: 1.7; }
.newthing .meta { display: block; font-size: 13px; font-weight: 400; color: var(--muted); }
.connects { color: var(--muted); margin-bottom: 22px; }
.connects strong { color: var(--text); }
.sec { margin: 0 0 34px; }
.sec > h2 { font-size: 20px; margin: 0 0 12px; padding-bottom: 6px; border-bottom: 2px solid var(--line); display: flex; align-items: baseline; gap: 10px; }
.sec > h2 .badge { margin-left: auto; font-size: 13px; }
.sub { font-size: 17px; margin: 22px 0 8px; }
ol, ul { padding-left: 1.4em; margin: 0 0 1em; }
li { margin: 0 0 0.3em; }

.badge { font-size: 12px; font-weight: 700; padding: 0 10px; border-radius: 99px; line-height: 1.8; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--accent-strong); border-color: transparent; }

/* ---- コード ---- */
figure { margin: 0 0 1em; }
.code, .result { border-radius: var(--radius); overflow: hidden; background: var(--code-bg); color: var(--code-text); }
.cap { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 4px 12px; font-size: 12px; color: var(--code-dim); border-bottom: 1px solid rgba(255,255,255,0.08); font-family: var(--font); }
pre.pre { margin: 0; padding: 12px 16px; overflow-x: auto; font-family: var(--mono); font-size: 14.5px; line-height: 1.75; tab-size: 2; }
pre.pre code { background: none; border: 0; padding: 0; font-size: inherit; color: inherit; word-break: normal; }
.result .pre { color: #cfd6df; }
.fig-img img { display: block; max-width: 100%; height: auto; margin: 0 auto; border: 1px solid var(--line); border-radius: 8px; }
.fig-img figcaption { margin-top: 6px; text-align: center; font-size: 13px; color: var(--muted); }
/* Console の見本：本物の Chrome の Console に似せる（白い背景。エラーは薄い赤の行に赤い×、場所は青い字） */
.result.cv { background: transparent; border: 1px solid var(--line); }
.cv .cap { background: var(--surface-2); color: var(--muted); }
.cv-body { background: #ffffff; color: #202124; font-family: var(--mono); font-size: 13.5px; line-height: 1.55; }
.cv-row { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; padding: 6px 14px 6px 12px; border-top: 1px solid #ebedef; }
.cv-row:first-child { border-top: 0; }
.cv-icon { flex: none; width: 14px; height: 14px; margin-right: 2px; align-self: center; }
.cv-icon.is-x { border-radius: 50%; background: #d93025; position: relative; }
.cv-icon.is-x::before, .cv-icon.is-x::after { content: ""; position: absolute; left: 50%; top: 50%; width: 8px; height: 1.6px; background: #fff; transform: translate(-50%, -50%) rotate(45deg); }
.cv-icon.is-x::after { transform: translate(-50%, -50%) rotate(-45deg); }
.cv-msg { flex: 1 1 auto; min-width: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.cv-loc { flex: none; margin-left: auto; color: #1a73e8; text-decoration: underline; }
.cv-row.is-error { background: #fce8e6; color: #5c0011; border-top-color: #f5c6c2; }
.cv-row.cv-at { padding-top: 0; border-top: 0; }
.cv-row.cv-at .cv-icon { visibility: hidden; }
.cv-row.cv-at .cv-loc { margin-left: 0; }
@media (prefers-color-scheme: dark) {
  .cv-body { background: #202124; color: #e8eaed; }
  .cv-row { border-top-color: #35363a; }
  .cv-row.is-error { background: #290000; color: #ff8080; border-top-color: #5c0011; }
  .cv-icon.is-x { background: #ff6b6b; }
  .cv-icon.is-x::before, .cv-icon.is-x::after { background: #290000; }
  .cv-loc { color: #8ab4f8; }
}
.t-s { color: var(--t-str); } .t-n { color: var(--t-num); } .t-c { color: var(--t-com); font-style: italic; } .t-k { color: var(--t-kw); } .t-f { color: var(--t-fn); }
.copy { font: inherit; font-size: 12px; background: transparent; color: var(--code-text); border: 1px solid rgba(255,255,255,0.25); border-radius: 6px; padding: 2px 10px; cursor: pointer; }

/* ---- 注意書き ---- */
.callout { border-radius: var(--radius); padding: 10px 16px; margin: 0 0 1em; font-size: 15px; line-height: 1.8; border-left: 4px solid; }
.callout strong { display: block; margin-bottom: 2px; }
.callout p { margin: 0; }
.callout.term { background: var(--term-soft); border-color: var(--term); }
.callout.tip { background: var(--accent-soft); border-color: var(--accent); }
.callout.warn { background: var(--warn-soft); border-color: var(--warn); }

.tablewrap { overflow-x: auto; margin: 0 0 1em; }
table { border-collapse: collapse; width: 100%; font-size: 15px; background: var(--surface); }
th, td { border: 1px solid var(--line); padding: 7px 12px; text-align: left; vertical-align: top; line-height: 1.7; }
th { background: var(--surface-2); font-weight: 700; white-space: nowrap; }

/* ---- 実行の場所 ---- */
.runbox { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); padding: 14px 16px; margin: 0 0 14px; }
.runbox .prompt { margin-bottom: 10px; }
.editor {
  display: block; width: 100%; min-height: 56px; resize: vertical;
  font-family: var(--mono); font-size: 14.5px; line-height: 1.75; tab-size: 2;
  padding: 10px 14px; border-radius: 8px; border: 2px solid transparent;
  background: var(--code-bg); color: var(--code-text); caret-color: #fff;
}
.editor:focus-visible { border-color: var(--accent); outline: none; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 10px 0 0; }
.toolbar .hintline { font-size: 12px; color: var(--muted); margin-left: auto; }
.console { margin-top: 10px; border-radius: 8px; background: var(--code-bg); color: var(--code-text); overflow: hidden; }
.console .cap { padding: 3px 12px; }
.console-body { padding: 8px 14px; font-family: var(--mono); font-size: 14.5px; line-height: 1.7; min-height: 40px; }
.out-line { white-space: pre-wrap; word-break: break-all; border-bottom: 1px solid rgba(255,255,255,0.06); padding: 1px 0; min-height: 1.7em; }
.out-line:last-child { border-bottom: 0; }
.v-number { color: var(--t-num); }
.v-boolean { color: var(--out-bool); }
.v-undefined, .v-null { color: var(--code-dim); }
.out-empty { color: var(--code-dim); font-family: var(--font); font-size: 13px; }
.err-box { margin-top: 6px; padding: 8px 12px; border-radius: 8px; background: #4a1f1d; color: #ffd0cc; font-family: var(--font); font-size: 14px; line-height: 1.7; }
.err-box .raw { font-family: var(--mono); font-size: 13px; display: block; }
.err-box .where { color: #ffb4ad; font-size: 13px; }
.err-box .jp { display: block; margin-top: 4px; padding-top: 4px; border-top: 1px dashed rgba(255,255,255,0.25); }

.feedback { margin-top: 10px; padding: 10px 14px; border-radius: 8px; font-size: 15px; line-height: 1.8; }
.feedback.ok { background: var(--ok-soft); color: var(--text); border: 1px solid var(--accent); }
.feedback.ng { background: var(--warn-soft); color: var(--text); border: 1px solid var(--warn); }
.feedback ul { margin: 4px 0 0; }
.feedback.error { background: var(--err-soft); }
.win { margin-top: 10px; padding: 12px 16px; border-radius: 8px; background: var(--ok-soft); border: 1px solid var(--accent); font-weight: 700; }
.win::before { content: "✓ 動いた！ "; color: var(--accent-strong); }
.pop { animation: pop 0.45s cubic-bezier(.2,1.4,.4,1); }
@keyframes pop { from { transform: scale(0.96); opacity: 0.4; } to { transform: scale(1); opacity: 1; } }

/* ---- 練習カード ---- */
.practice { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin: 0 0 14px; }
.practice[data-done="true"] { border-color: var(--accent); }
.practice > header { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.practice .kind { font-size: 12px; font-weight: 700; color: var(--term); background: var(--term-soft); border-radius: 99px; padding: 0 10px; line-height: 1.8; }
.practice h3 { font-size: 16px; }
.practice > header .badge { margin-left: auto; }
.choices { display: grid; gap: 8px; margin: 10px 0; }
.choice {
  font: inherit; text-align: left; cursor: pointer; width: 100%;
  border: 2px solid var(--line); background: var(--surface); color: var(--text);
  border-radius: 8px; padding: 8px 14px; min-height: 44px;
  font-family: var(--mono); font-size: 14.5px; line-height: 1.6; white-space: pre-wrap;
}
.choice:hover:not([disabled]) { border-color: var(--accent); background: var(--accent-soft); }
.choice.correct { border-color: var(--accent); background: var(--ok-soft); }
.choice.wrong { border-color: var(--err); background: var(--err-soft); opacity: 0.75; }
.choice[disabled] { cursor: default; }
.explain { margin-top: 10px; padding: 10px 14px; border-radius: 8px; background: var(--surface-2); font-size: 15px; }
.hintbox { margin-top: 10px; font-size: 15px; }
.hintbox li { background: var(--term-soft); border-radius: 8px; padding: 6px 12px; margin-bottom: 6px; list-style: none; }
.hintbox { padding: 0; }
details.solution { margin-top: 10px; }
details.solution summary { cursor: pointer; font-size: 14px; color: var(--muted); }
details.solution .pre { background: var(--code-bg); color: var(--code-text); border-radius: 8px; margin-top: 6px; }

.classify-list { display: grid; gap: 8px; margin: 10px 0; }
.classify-item { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; border: 2px solid var(--line); border-radius: 8px; padding: 6px 12px; }
.classify-item.done { border-color: var(--accent); background: var(--ok-soft); }
.classify-item .val { font-family: var(--mono); font-size: 15px; min-width: 7.5em; }
.classify-item .val.txt { font-family: var(--font); font-size: 15px; min-width: 0; flex: 1 1 14em; }
.classify-item .btns { display: flex; gap: 6px; margin-left: auto; }
.classify-item .note { flex-basis: 100%; font-size: 14px; color: var(--muted); }
.progressline { font-size: 14px; color: var(--muted); }

.drill-top { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.dots { display: flex; gap: 5px; flex-wrap: wrap; }
.dot { width: 12px; height: 12px; border-radius: 50%; background: var(--surface-2); border: 1px solid var(--line); }
.dot.now { border-color: var(--accent); background: var(--accent-soft); }
.dot.ok { background: var(--accent); border-color: var(--accent); }
.dot.seen { background: var(--warn); border-color: var(--warn); }
.drill-q { font-weight: 700; margin-bottom: 8px; }
.answer-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0 0; }
.answer-row input { flex: 1; min-width: 160px; font: inherit; font-family: var(--mono); padding: 8px 12px; border-radius: 8px; border: 2px solid var(--line); background: var(--surface); color: var(--text); min-height: 44px; }
.score { font-size: 18px; font-weight: 700; margin: 8px 0; }

.checklist { list-style: none; padding: 0; margin: 8px 0; display: grid; gap: 6px; }
.checklist label { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; padding: 6px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); }
.checklist input { width: 20px; height: 20px; margin-top: 4px; flex: none; accent-color: var(--accent); }
.checklist label:has(input:checked) { background: var(--ok-soft); border-color: var(--accent); }

/* ---- 本物の環境で手を動かす ---- */
.realsteps { margin: 0 0 12px; padding-left: 1.4em; }
details.expect { margin: 0 0 12px; }
details.expect summary, details.minifb summary { cursor: pointer; font-size: 14px; color: var(--accent-strong); font-weight: 700; padding: 4px 0; }
details.expect figure { margin-top: 8px; }
.checkhead { font-size: 14px; font-weight: 700; margin: 14px 0 4px; }
details.minifb { margin-top: 14px; border-top: 1px dashed var(--line); padding-top: 8px; }
details.minifb summary { color: var(--muted); font-weight: 400; }
details.minifb[open] summary { margin-bottom: 8px; }


/* ---- 図・考えてみよう ---- */
figure.fig { margin: 0 0 1em; padding: 14px 12px 10px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
figure.fig figcaption { margin-top: 6px; text-align: center; font-size: 14px; color: var(--muted); }
.boxsvg { display: block; width: 100%; max-width: 520px; height: auto; margin: 0 auto; }
.boxsvg .mono { font-family: var(--mono); }
.boxsvg .code { font-size: 20px; fill: var(--text); }
.boxsvg .kw { font-weight: 700; }
.boxsvg .nm { fill: var(--accent-strong); font-weight: 700; }
.boxsvg .vl { fill: var(--t-num-fig, #2a5db0); font-weight: 700; }
.boxsvg .bx { fill: var(--surface-2); stroke: var(--accent); stroke-width: 3; }
.boxsvg .tab { fill: var(--accent-soft); stroke: var(--accent); stroke-width: 2; }
.boxsvg .tabtxt { font-size: 21px; fill: var(--accent-strong); font-weight: 700; }
.boxsvg .big { font-size: 40px; }
.boxsvg .arrow { stroke: var(--muted); stroke-width: 2; fill: none; stroke-dasharray: 5 4; }
.boxsvg .ah { fill: var(--muted); }
.boxsvg .lbl { font-family: var(--font); font-size: 18px; fill: var(--muted); }
@media (prefers-color-scheme: dark) { .boxsvg .vl { fill: #8ab9ff; } }
.callout.think { background: var(--surface); border-color: var(--term); border-left-width: 6px; }
.callout.think details { margin-top: 8px; }
.callout.think summary { cursor: pointer; font-weight: 700; color: var(--accent-strong); padding: 4px 0; }
.think-reveal { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line); }
.think-reveal > :last-child { margin-bottom: 0; }


/* ---- 触れる実物（デモ） ---- */
figure.demo { margin: 0 0 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.demo-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 10px 16px; background: var(--surface-2); border-bottom: 1px solid var(--line); }
.demo-sw { margin-left: auto; display: inline-flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
.demo-sw input { width: 40px; height: 22px; accent-color: var(--accent); cursor: pointer; }
.demo-stage { padding: 16px; }
.demo-does { margin: 0; padding: 10px 16px; border-top: 1px dashed var(--line); font-size: 14.5px; color: var(--muted); }
.demo-does strong { color: var(--accent-strong); margin-right: 4px; }
.demo-note { margin: 0; padding: 0 16px 10px; font-size: 13px; color: var(--muted); }
figure.demo.is-off .demo-stage { opacity: 0.85; }
figure.demo.is-off .demo-head { background: var(--warn-soft); }
.demo button:focus-visible, .demo input:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
/* @demos-start：ここから @demos-end までは、naraiba の枠（public/sandbox/demo.html）にも、そのまま使われる。tools/sync-naraiba-demos.mjs が取り出す */
/* デモの見た目：日本のコーポレートサイトによくある、余白が広く、細い線と軽い影の落ち着いた見た目。
   クラス名・ARIA・動きは変えない（demos.js が使っている）。外部のフォント・画像は使わない（naraiba の枠は、通信を止めている）。 */
.d-btn { font: inherit; font-size: 15px; letter-spacing: 0.04em; min-height: 44px; padding: 8px 22px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--text); cursor: pointer; transition: background 0.2s, border-color 0.2s; }
.d-btn:hover { background: var(--accent-soft); border-color: var(--accent); }
.d-btn[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 700; }
.d-btn:focus-visible, .d-burger:focus-visible, .d-acc-btn:focus-visible, .d-tab:focus-visible, .d-tabpanel:focus-visible, .d-form input:focus-visible, .d-scrollbox:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* ハンバーガー */
.d-site { max-width: 380px; margin: 0 auto; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; background: var(--bg); box-shadow: 0 2px 8px rgba(20, 30, 40, 0.08); }
.d-bar { display: flex; align-items: center; justify-content: space-between; padding: 6px 10px 6px 20px; background: var(--surface); border-bottom: 1px solid var(--line); }
.d-logo { font-weight: 700; font-size: 15px; letter-spacing: 0.14em; }
.d-burger { width: 44px; height: 44px; border: 0; background: transparent; cursor: pointer; display: grid; place-content: center; gap: 5px; border-radius: 8px; }
.d-burger span { display: block; width: 24px; height: 2px; background: var(--text); transition: transform 0.25s, opacity 0.25s; }
.d-burger[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.d-burger[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.d-burger[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }
.d-menu { display: none; background: var(--surface); border-bottom: 1px solid var(--line); }
.d-menu.is-open { display: block; }
.d-menu ul { list-style: none; margin: 0; padding: 0; }
.d-menu a { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; color: var(--text); text-decoration: none; letter-spacing: 0.06em; border-top: 1px solid var(--line); }
.d-menu li:first-child a { border-top: 0; }
.d-menu a::after { content: "›"; content: "›" / ""; color: var(--accent); font-size: 20px; line-height: 1; }
.d-menu a:hover { background: var(--accent-soft); }
.d-body { margin: 0; padding: 22px 20px; color: var(--muted); font-size: 14px; line-height: 1.8; }

/* アコーディオン */
.d-acc { max-width: 520px; margin: 0 auto; display: grid; gap: 10px; }
.d-acc-item { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--surface); box-shadow: 0 2px 8px rgba(20, 30, 40, 0.05); }
.d-acc h4 { margin: 0; font-size: inherit; }
.d-acc-btn { width: 100%; display: flex; justify-content: space-between; align-items: center; gap: 12px; text-align: left; font: inherit; font-weight: 700; letter-spacing: 0.04em; min-height: 56px; padding: 12px 18px; border: 0; background: var(--surface); color: var(--text); cursor: pointer; }
.d-acc-btn:hover { background: var(--accent-soft); }
.d-acc-mark { flex: none; width: 28px; height: 28px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-strong); display: grid; place-content: center; font-size: 16px; line-height: 1; }
.d-acc-mark::before { content: "＋"; }
.d-acc-btn[aria-expanded="true"] .d-acc-mark::before { content: "－"; }
.d-acc-panel { padding: 2px 18px 18px; background: var(--surface); color: var(--muted); line-height: 1.8; }
.d-acc-panel p { margin: 0; }

/* タブ：どれも枠線のある「ふだ」に見えるようにし、選んでいるものは、白い面とアクセントの上線でパネルとつなげる */
.d-tabs { max-width: 520px; margin: 0 auto; }
.d-tablist { display: flex; gap: 6px; }
.d-tab { flex: 1 1 0; font: inherit; font-size: 15px; letter-spacing: 0.06em; min-height: 48px; padding: 8px 12px; border: 1px solid var(--line); border-bottom: 0; border-radius: 10px 10px 0 0; background: var(--surface-2); color: var(--muted); cursor: pointer; transition: background 0.2s, color 0.2s; }
.d-tab:hover { background: var(--accent-soft); color: var(--text); }
.d-tab[aria-selected="true"] { position: relative; z-index: 1; margin-bottom: -1px; padding-top: 6px; border-top: 3px solid var(--accent); background: var(--surface); color: var(--accent-strong); font-weight: 700; }
.d-tabpanel { padding: 20px 22px; border: 1px solid var(--line); border-radius: 0 0 12px 12px; background: var(--surface); line-height: 1.8; box-shadow: 0 2px 8px rgba(20, 30, 40, 0.05); }
.d-tabpanel p { margin: 0; }

/* モーダル */
.d-dialog { border: 1px solid var(--line); border-radius: 16px; padding: 28px 28px 24px; max-width: min(92vw, 400px); background: var(--surface); color: var(--text); box-shadow: 0 24px 60px rgba(0, 0, 0, 0.25); }
.d-dialog::backdrop { background: rgba(20, 30, 40, 0.55); }
.d-dialog h4 { margin: 0 0 12px; padding-bottom: 12px; font-size: 18px; letter-spacing: 0.06em; border-bottom: 1px solid var(--line); }
.d-dialog p { margin: 0 0 20px; color: var(--muted); line-height: 1.8; }

/* スライダー */
.d-slider { max-width: 440px; margin: 0 auto; }
.d-viewport { overflow: hidden; border-radius: 14px; border: 1px solid var(--line); box-shadow: 0 2px 8px rgba(20, 30, 40, 0.08); }
.d-track { display: flex; transition: transform 0.35s ease; }
.d-slide { flex: 0 0 100%; min-height: 170px; display: grid; place-content: center; font-weight: 700; font-size: 20px; letter-spacing: 0.1em; color: #23262b; }
.d-slider-ctl { display: flex; align-items: center; justify-content: center; gap: 18px; margin-top: 14px; }
.d-count { min-width: 4em; text-align: center; font-variant-numeric: tabular-nums; letter-spacing: 0.1em; }

/* フォーム */
.d-form { max-width: 440px; margin: 0 auto; padding: 22px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); box-shadow: 0 2px 8px rgba(20, 30, 40, 0.05); }
.d-form label { display: block; font-size: 14px; font-weight: 700; letter-spacing: 0.04em; margin-bottom: 8px; }
.d-form input { width: 100%; font: inherit; min-height: 48px; padding: 10px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--text); }
.d-form input[aria-invalid="true"] { border-color: var(--err); box-shadow: 0 0 0 3px var(--err-soft); }
.d-form input[aria-invalid="false"] { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.d-msg { margin: 8px 0 0; min-height: 1.8em; font-size: 14px; color: var(--muted); }
.d-msg.is-ok { color: var(--accent-strong); font-weight: 700; }
.d-msg.is-ng { color: var(--err); font-weight: 700; }

/* スクロールで出現 */
.d-hint { margin: 0 0 8px; font-size: 14px; color: var(--muted); }
.d-scrollbox { height: 220px; overflow-y: auto; border: 1px solid var(--line); border-radius: 14px; padding: 14px; background: var(--bg); }
.d-reveal { padding: 28px 18px; margin-bottom: 14px; border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 12px; background: var(--surface); font-weight: 700; letter-spacing: 0.04em; opacity: 0; transform: translateY(24px); transition: opacity 0.6s, transform 0.6s; }
.d-reveal.is-visible { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) { .d-reveal { transition: none; transform: none; } .d-track { transition: none; } }

/* 絞り込み */
.d-filter { max-width: 520px; margin: 0 auto; }
.d-filter-btns { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.d-works { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.d-work { padding: 22px 8px; text-align: center; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); font-size: 14px; letter-spacing: 0.04em; box-shadow: 0 2px 8px rgba(20, 30, 40, 0.05); }
.d-work[hidden] { display: none; }
@media (max-width: 480px) { .d-works { grid-template-columns: repeat(2, 1fr); } }
/* @demos-end */

/* ---- つまずき・やらないこと ---- */
.pit { margin: 0 0 10px; }
.pit dt { font-weight: 700; }
.pit dd { margin: 0 0 12px 0; color: var(--muted); }
.notthis { color: var(--muted); }

/* ---- 完了カード・前後 ---- */
.finish { border-radius: var(--radius); padding: 18px 20px; margin: 0 0 20px; background: var(--surface); border: 2px dashed var(--line); }
.finish.complete { border: 2px solid var(--accent); background: var(--ok-soft); }
.finish h2 { font-size: 20px; margin-bottom: 4px; }
.finish p { margin: 0; }
.downloads { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 14px; }
.finish p.muted { margin-top: 6px; font-size: 14px; color: var(--muted); }
.practice.is-optional { border-style: dashed; }
.nav-opt { color: var(--muted); font-size: 12px; }
.pager { display: flex; gap: 12px; justify-content: space-between; flex-wrap: wrap; }

footer.note { margin-top: 40px; font-size: 13px; color: var(--muted); }

/* ---- スマホ ---- */
@media (max-width: 860px) {
  .menu-btn { display: inline-flex; align-items: center; font: inherit; font-size: 14px; min-height: 40px; padding: 4px 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--text); cursor: pointer; }
  .shell { display: block; }
  .sidebar {
    position: fixed; z-index: 40; top: 0; left: 0; bottom: 0; width: min(86vw, 320px); max-height: none;
    background: var(--surface); border-right: 1px solid var(--line); padding-top: 64px;
    transform: translateX(-102%); transition: transform 0.25s ease;
  }
  .sidebar.open { transform: none; }
  .scrim { position: fixed; inset: 0; z-index: 35; background: rgba(0,0,0,0.45); }
  main { padding: 20px 16px 72px; }
  .step-title { font-size: 24px; }
  .hero h1 { font-size: 26px; }
  .meter-bar { width: 64px; }
  .toolbar .hintline { display: none; }
  .classify-item .btns { margin-left: 0; }
}
@media (max-width: 420px) {
  .meter .txt { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* DOM の練習（隔離した枠でのプレビュー） */
.files { margin: 0 0 12px; }
.files > summary { cursor: pointer; font-weight: 700; margin-bottom: 8px; }
.dom-preview { margin: 12px 0; }
.dom-preview .cap { font-size: 0.85rem; color: var(--muted, #6b6258); margin-bottom: 4px; }
.dom-preview .frame-wrap { border: 1px solid var(--line, #e2dccf); border-radius: 8px; overflow: hidden; background: #fff; }
.dom-frame { display: block; width: 100%; height: 200px; border: 0; background: #fff; }
.testlist { list-style: none; margin: 8px 0 0; padding: 0; font-size: 0.95rem; }
.testlist li { padding: 2px 0; }
.testlist li.ok { color: var(--accent-strong); }
.testlist li.ng { color: var(--err); }

/* コード表示・入力の配色は naraiba と共通。枠の中だけを横スクロールする。 */
.code-input, .code-editor-host { min-width: 0; max-width: 100%; }
.code-editor-host .cm-editor { max-width: 100%; }
.code .pre, .solution .pre, .files .pre { background: #1e1e1e; color: #d4d4d4; }
.editor[hidden] { display: none; }
