:root {
  --bg: #fbfbf9; --fg: #1d1d1b; --muted: #6b6b66; --line: #e2e1dc;
  --panel: #ffffff; --code-bg: #f3f2ee; --term-bg: #1f2125; --term-fg: #e8e8e3; --term-dim: #8d9099;
  --accent: #c8501e; --accent-soft: #fbe6dc; --ok: #2f7d4f; --ok-soft: #e0f1e6; --warn: #b7791f; --warn-soft: #fbf0d9;
  --project: #2b6cb0; --project-soft: #e1ecf8; --session: #6b46c1; --session-soft: #ece6f8; --timer: #2c7a7b; --timer-soft: #e0f2f1; --human: #b83280; --human-soft: #fbe4f0;
  --radius: 12px;
  --mono: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans: "Geist", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #16171a; --fg: #ececea; --muted: #a0a09a; --line: #2e2f34; --panel: #1e1f23; --code-bg: #26272c;
    --accent-soft: #3a2519; --ok-soft: #1c3326; --warn-soft: #3a2f16; --project-soft: #1c2a3d; --session-soft: #2a2140; --timer-soft: #163232; --human-soft: #3b1a2e; }
}
/* CJK locales. Geist has no kana and no Han glyphs, so Latin keeps rendering in Geist and
   everything else falls through to the system face. No CJK webfont on purpose: a full one
   runs into megabytes, and every desktop already ships a good one. The Latin tracking and
   the leading set below for Geist are wrong for CJK, so both are reset here. */
html[lang="ja"]    { --sans: "Geist", "Inter", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic", "Noto Sans JP", sans-serif; }
html[lang="zh-CN"] { --sans: "Geist", "Inter", "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif; }
html[lang="ja"] body, html[lang="zh-CN"] body { line-height: 1.85; letter-spacing: normal; }
html[lang="ja"] :is(h1, h2, h3, .brand, .card h4, .player .stepname),
html[lang="zh-CN"] :is(h1, h2, h3, .brand, .card h4, .player .stepname) { letter-spacing: normal; }
html[lang="ja"] :is(p, li, td) { line-break: strict; }

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; font-family: var(--sans); color: var(--fg); background: var(--bg); line-height: 1.65; font-size: 17px;
  letter-spacing: -0.003em; font-optical-sizing: auto; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  font-variant-numeric: tabular-nums; text-rendering: optimizeLegibility; }
a { color: var(--project); }
code, pre { font-family: var(--mono); font-size: 0.86em; letter-spacing: 0; }
code { background: var(--code-bg); padding: 2px 6px; border-radius: 6px; }
pre { background: var(--code-bg); padding: 16px 18px; border-radius: var(--radius); overflow-x: auto; line-height: 1.6; }
pre code { background: none; padding: 0; }
h1 { font-size: 2.4rem; font-weight: 600; margin: 0 0 10px; letter-spacing: -0.035em; line-height: 1.1; }
h2 { font-size: 1.7rem; font-weight: 600; margin: 0 0 16px; letter-spacing: -0.028em; line-height: 1.2; }
h3 { font-size: 1.15rem; font-weight: 600; margin: 30px 0 10px; letter-spacing: -0.018em; }
p { margin: 0 0 18px; max-width: 68ch; }
ul, ol { max-width: 68ch; padding-left: 24px; margin: 0 0 18px; }
li { margin-bottom: 9px; }
b, strong { font-weight: 600; }
.layout { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
nav.side { position: sticky; top: 0; height: 100vh; overflow-y: auto; border-right: 1px solid var(--line); padding: 30px 20px; background: var(--panel); }
nav.side .brand { font-weight: 600; font-size: 1.15rem; letter-spacing: -0.03em; margin-bottom: 6px; }
nav.side .brand small { display: block; font-weight: 400; color: var(--muted); font-size: 0.8rem; letter-spacing: 0; line-height: 1.45; margin-top: 4px; }
nav.side .lang { margin-top: 8px; font-size: 0.85rem; }
nav.side .lang a { display: inline; padding: 0; color: var(--project); }
nav.side ol { list-style: none; padding: 0; margin: 18px 0 0; }
nav.side li { margin: 0; }
nav.side a { display: block; padding: 8px 11px; border-radius: 9px; color: var(--fg); text-decoration: none; font-size: 0.92rem; line-height: 1.4; }
nav.side a:hover { background: var(--code-bg); }
nav.side a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
nav.side a .num { display: inline-block; width: 22px; color: var(--muted); font-variant-numeric: tabular-nums; }
nav.side .progress { margin-top: 18px; height: 4px; background: var(--line); border-radius: 2px; overflow: hidden; }
nav.side .progress i { display: block; height: 100%; background: var(--accent); width: 0; transition: width .3s; }
main { padding: 52px 64px 140px; max-width: 1120px; }
section.lesson { padding: 40px 0 52px; border-bottom: 1px solid var(--line); scroll-margin-top: 20px; }
section.lesson:last-child { border-bottom: 0; }
.kicker { color: var(--accent); font-weight: 600; font-size: 0.75rem; letter-spacing: 0.12em; text-transform: uppercase; margin-bottom: 10px; }
.lead { font-size: 1.15rem; line-height: 1.6; max-width: 62ch; color: var(--muted); margin-bottom: 24px; }
.callout { border-left: 3px solid var(--accent); background: var(--accent-soft); padding: 14px 18px; border-radius: 0 var(--radius) var(--radius) 0; margin: 20px 0; max-width: 72ch; }
.callout p:last-child { margin-bottom: 0; }
.callout.ok { border-color: var(--ok); background: var(--ok-soft); }
.callout.warn { border-color: var(--warn); background: var(--warn-soft); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin: 20px 0; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin: 20px 0; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; }
.card h4 { margin: 0 0 8px; font-size: 1.02rem; font-weight: 600; letter-spacing: -0.015em; }
.card p { font-size: 0.94rem; line-height: 1.6; color: var(--muted); margin: 0 0 10px; }
.card p:last-child { margin-bottom: 0; }
.card ul, .card ol { font-size: 0.94rem; line-height: 1.55; color: var(--muted); margin: 0; padding-left: 20px; }
.card li { margin-bottom: 6px; }
.card li:last-child { margin-bottom: 0; }
.card ul + p, .card ol + p { margin-top: 12px; }
.card.project { border-top: 4px solid var(--project); }
.card.session { border-top: 4px solid var(--session); }
.card.dir { border-top: 4px solid var(--muted); }
table { border-collapse: collapse; width: 100%; font-size: 0.94rem; margin: 18px 0 24px; }
th, td { text-align: left; padding: 11px 18px 11px 0; border-bottom: 1px solid var(--line); vertical-align: top; line-height: 1.55; }
th { color: var(--muted); font-weight: 500; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.1em; padding-bottom: 8px; }
.tag { display: inline-block; padding: 1px 7px; border-radius: 6px; font-family: var(--mono); font-size: 0.8rem; background: var(--code-bg); }
.tag.own { background: var(--session-soft); color: var(--session); }
.tag.shared { background: var(--project-soft); color: var(--project); }
.tag.no { background: var(--code-bg); color: var(--muted); }
/* figure */
figure { margin: 26px 0; }
figure svg { width: 100%; height: auto; display: block; }
figcaption { color: var(--muted); font-size: 0.88rem; line-height: 1.55; margin-top: 10px; max-width: 76ch; }
/* file explorer */
.files { display: grid; grid-template-columns: 1fr 1.3fr; gap: 14px; }
.tree { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; font-family: var(--mono); font-size: 0.78rem; line-height: 1.75; overflow-x: auto; }
.tree .root { color: var(--muted); margin: 8px 0 4px; }
.tree .f { padding: 2px 6px; border-radius: 5px; cursor: pointer; white-space: pre; }
.tree .f:hover, .tree .f.on { background: var(--accent-soft); }
.tree .f.new { color: var(--ok); }
.tree .f.chg { color: var(--accent); }
.tree .f.new::after { content: "  +"; }
.tree .f.chg::after { content: "  ~"; }
.tree .f.rd::after { content: "  (read)"; color: var(--muted); }
.fileinfo { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; font-size: 0.92rem; line-height: 1.55; min-height: 90px; }
.fileinfo b { font-family: var(--mono); font-size: 0.85rem; }
.fileinfo .who { color: var(--muted); font-size: 0.85rem; margin-top: 6px; }
/* hooks loop */
.hooks { display: grid; grid-template-columns: 1.3fr 1fr; gap: 16px; align-items: start; }
.hookinfo { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; font-size: 0.92rem; line-height: 1.6; min-height: 120px; }
.hookinfo h4 { margin: 0 0 6px; font-family: var(--mono); font-size: 0.95rem; }
.hooks svg .hk { cursor: pointer; }
.hooks svg .hk rect { fill: var(--panel); stroke: var(--line); stroke-width: 1.5; }
.hooks svg .hk:hover rect, .hooks svg .hk.on rect { stroke: var(--accent); fill: var(--accent-soft); }
.hooks svg text { font-family: var(--mono); font-size: 11px; fill: var(--fg); }
.hooks svg .lbl { font-family: var(--sans); font-size: 11px; fill: var(--muted); }
.hooks svg .loop { fill: none; stroke: var(--line); stroke-width: 2; }
/* quiz */
.quiz .q { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 12px; }
.quiz .q .stmt { margin-bottom: 8px; }
.quiz .q button { font: inherit; font-size: 0.88rem; padding: 7px 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--code-bg); color: var(--fg); cursor: pointer; margin-right: 6px; }
.quiz .q button:hover { border-color: var(--accent); }
.quiz .q.done button { cursor: default; opacity: .55; }
.quiz .q.done button.right { opacity: 1; border-color: var(--ok); background: var(--ok-soft); }
.quiz .q.done button.wrong { opacity: 1; border-color: var(--accent); background: var(--accent-soft); }
.quiz .q .why { margin-top: 8px; font-size: 0.9rem; color: var(--muted); display: none; }
.quiz .q.done .why { display: block; }
/* scenario player */
.player { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin: 22px 0; }
.player .top { display: grid; grid-template-columns: 1.15fr 1fr; gap: 16px; align-items: start; }
.player .top > *, .player .bottom > * { min-width: 0; }
.diagram svg { overflow: visible; }
.diagram svg { width: 100%; height: auto; }
.diagram .node rect { fill: var(--panel); stroke: var(--line); stroke-width: 1.5; transition: all .25s; }
.diagram .node text { font-family: var(--sans); font-size: 12px; fill: var(--fg); }
.diagram .node .sub { font-size: 10px; fill: var(--muted); font-family: var(--mono); }
.diagram .node.on rect { stroke-width: 2.5; }
.diagram .node.kind-project rect { stroke: var(--project); } .diagram .node.kind-project.on rect { fill: var(--project-soft); }
.diagram .node.kind-session rect { stroke: var(--session); } .diagram .node.kind-session.on rect { fill: var(--session-soft); }
.diagram .node.kind-own rect { stroke: var(--session); stroke-dasharray: 4 3; } .diagram .node.kind-own.on rect { fill: var(--session-soft); }
.diagram .node.kind-timer rect { stroke: var(--timer); } .diagram .node.kind-timer.on rect { fill: var(--timer-soft); }
.diagram .node.kind-human rect { stroke: var(--human); } .diagram .node.kind-human.on rect { fill: var(--human-soft); }
.diagram .node.kind-global rect { stroke: var(--muted); stroke-dasharray: 4 3; } .diagram .node.kind-global.on rect { fill: var(--code-bg); }
.diagram .node.dim { opacity: .35; }
.diagram .edge { stroke: var(--line); stroke-width: 1.5; fill: none; opacity: .6; }
.diagram .edge.on { stroke: var(--accent); stroke-width: 2.5; opacity: 1; stroke-dasharray: 6 4; animation: flow .8s linear infinite; }
@keyframes flow { to { stroke-dashoffset: -20; } }
.diagram marker path { fill: var(--line); }
.diagram marker.on path { fill: var(--accent); }
.player .caption { margin-top: 8px; font-size: 0.95rem; min-height: 48px; }
.player .caption b { color: var(--accent); }
.player .term { overflow-wrap: anywhere; background: var(--term-bg); color: var(--term-fg); border-radius: var(--radius); padding: 12px 14px; font-family: var(--mono); font-size: 0.78rem; line-height: 1.45; white-space: pre-wrap; word-break: break-word; max-height: 420px; overflow: auto; }
.player .term .who { color: var(--term-dim); }
.player .term .cmd { color: #ffd27a; }
.player .term .out { color: var(--term-fg); }
.player .term .dim { color: var(--term-dim); }
.player .term .hi { background: rgba(200,80,30,.35); border-radius: 3px; }
.player .bottom { margin-top: 14px; display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.player .tree { max-height: 220px; overflow: auto; }
.player .ctrls { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.player .ctrls button { font: inherit; padding: 6px 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--code-bg); color: var(--fg); cursor: pointer; }
.player .ctrls button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.player .ctrls button:disabled { opacity: .4; cursor: default; }
.player .ctrls .steps { display: flex; gap: 4px; margin-left: auto; }
.player .ctrls .steps i { width: 10px; height: 10px; border-radius: 50%; background: var(--line); display: block; cursor: pointer; }
.player .ctrls .steps i.on { background: var(--accent); }
.player .ctrls .steps i.done { background: var(--muted); }
.player .stepname { font-weight: 600; font-size: 1.02rem; letter-spacing: -0.015em; margin-bottom: 14px; }
.player .phead { font-size: 0.78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 6px; }
.player .stepname small { color: var(--muted); font-weight: 400; margin-left: 8px; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 0.82rem; color: var(--muted); margin-top: 6px; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; border: 2px solid; }
.legend .project i { border-color: var(--project); } .legend .session i { border-color: var(--session); } .legend .own i { border-color: var(--session); border-style: dashed; } .legend .timer i { border-color: var(--timer); } .legend .human i { border-color: var(--human); } .legend .global i { border-color: var(--muted); border-style: dashed; }
.cheat { columns: 2; column-gap: 26px; font-size: 0.9rem; margin: 20px 0; }
.cheat pre { break-inside: avoid; }
.next { margin-top: 34px; }
.next a { display: inline-block; padding: 10px 20px; border-radius: 10px; background: var(--accent); color: #fff; text-decoration: none; font-weight: 500; letter-spacing: -0.01em; }
.stripe { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 22px 0; }
.stripe .s { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; background: var(--panel); font-size: 0.9rem; line-height: 1.55; }
.stripe .s b { display: block; margin-bottom: 6px; font-weight: 600; }
.stripe .s.bad { border-color: var(--accent); }
.stripe .s.good { border-color: var(--ok); }
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; } nav.side { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  main { padding: 24px 20px 80px; } h1 { font-size: 1.9rem; } h2 { font-size: 1.4rem; } .grid2, .grid3, .player .top, .player .bottom, .files, .hooks, .stripe { grid-template-columns: 1fr; } .cheat { columns: 1; }
}
