/* Blog defaults (AGENTS.md): warm off-white, dark grey text, ink-green accent, system font.
   Canvas uses two meanings only: green = the ending and its three must-haves, amber dashed = other ways through. */
:root {
  --bg: #faf9f7;
  --surface: #ffffff;
  --soft: #f2f0ec;
  --line: #dcd7ce;
  --edge: #9b958b;
  --fg: #3d3d3d;
  --muted: #77726a;
  --accent: #5c7a6f;
  --accent-soft: #e6eeea;
  --alt: #b8732f;
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font-family: var(--font); font-size: 15px; line-height: 1.7; }
a { color: var(--accent); }

.top { padding: clamp(14px, 2.4vw, 22px) clamp(16px, 2.4vw, 28px) 10px; display: grid; gap: 6px; }
.title-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.lang { flex-shrink: 0; font-size: 14px; color: var(--accent); text-decoration: none; border: 1px solid var(--line); border-radius: 6px; padding: 6px 12px; background: var(--surface); }
.lang:hover { border-color: var(--accent); }
.top h1 { margin: 0; font-size: clamp(22px, 2.6vw, 30px); line-height: 1.3; font-weight: 700; letter-spacing: .01em; text-wrap: balance; }
.top .what { margin: 0; max-width: 72ch; color: var(--fg); }
.top .spoiler { color: var(--muted); font-size: 13px; margin: 0; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; align-items: center; color: var(--muted); font-size: 13px; margin-top: 2px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.lg-goal { width: 16px; height: 12px; border: 2px solid var(--accent); background: var(--accent-soft); border-radius: 3px; }
.lg-main { width: 24px; border-top: 2px solid var(--edge); }
.lg-alt { width: 24px; border-top: 2px dashed var(--alt); }

.stage { position: relative; margin: 0 clamp(8px, 1.2vw, 16px); height: calc(100vh - 150px); height: calc(100dvh - 150px); min-height: 560px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; touch-action: none; }
.stage svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: grab; user-select: none; -webkit-user-select: none; }
.stage svg.dragging { cursor: grabbing; }

.zoom { position: absolute; left: 12px; bottom: 12px; display: flex; align-items: center; gap: 2px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 3px; box-shadow: 0 2px 8px rgba(0,0,0,.06); }
.zoom button { font: inherit; font-size: 15px; color: var(--fg); background: transparent; border: 0; border-radius: 6px; min-width: 40px; height: 36px; padding: 0 10px; cursor: pointer; }
.zoom button:hover { background: var(--soft); }
.zoom output { min-width: 50px; text-align: center; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.zoom .hint { color: var(--muted); font-size: 12px; padding: 0 10px; border-left: 1px solid var(--line); }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.detail { position: absolute; right: 12px; top: 12px; width: min(380px, calc(100% - 24px)); max-height: calc(100% - 24px); overflow: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 16px 18px; box-shadow: 0 10px 28px rgba(40,35,25,.14); font-size: 14px; }
.detail h2 { font-size: 17px; margin: 0 30px 2px 0; line-height: 1.4; text-wrap: balance; }
.detail .place { color: var(--muted); font-size: 13px; }
.detail .tags { margin: 10px 0; display: flex; gap: 6px; flex-wrap: wrap; }
.tag { font-size: 12px; line-height: 1; padding: 4px 6px; border-radius: 4px; border: 1px solid var(--line); color: var(--muted); background: var(--bg); }
.tag.alt { color: var(--alt); border-color: var(--alt); }
.tag.timing { color: var(--fg); border-color: var(--fg); }
.detail .go-here { font-weight: 600; }
.detail a { color: var(--accent); }
.detail p { margin: 8px 0; }
.detail blockquote { margin: 10px 0; padding: 8px 12px; border-left: 3px solid var(--accent); background: var(--soft); border-radius: 0 6px 6px 0; font-size: 13px; }
.detail blockquote cite { display: block; color: var(--muted); font-style: normal; font-size: 12px; margin-top: 4px; }
.detail .meta { color: var(--muted); font-size: 13px; }
.detail .close { position: absolute; right: 8px; top: 8px; width: 36px; height: 36px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); font-size: 20px; cursor: pointer; }
.detail .close:hover { background: var(--soft); color: var(--fg); }

/* SVG */
.node { cursor: pointer; }
.node rect.box { fill: var(--surface); stroke: var(--line); stroke-width: 1; }
.node.gate rect.box { fill: var(--soft); }
.node.goal rect.box { fill: var(--accent-soft); stroke: var(--accent); stroke-width: 2.2; }
.node.target rect.box { fill: var(--surface); stroke: var(--accent); stroke-width: 1.8; }
.node.loc rect.box { fill: var(--surface); stroke: var(--fg); stroke-width: 1.6; }
.node.loc text.lbl { font-size: 14px; font-weight: 700; }
.node.branch rect.box { fill: var(--soft); stroke: var(--fg); stroke-width: 1.4; }
.node.alt rect.box { fill: var(--surface); stroke: var(--alt); stroke-dasharray: 5 4; stroke-width: 1.3; }
.node text { fill: var(--fg); font-family: var(--font); }
.node text.lbl { font-size: 13px; }
.node.gate text.lbl { font-weight: 600; }
.node.goal text.lbl, .node.target text.lbl { font-size: 14px; font-weight: 700; }
.node.branch text.lbl { font-size: 14px; font-weight: 700; }
.node text.sub { font-size: 11px; fill: var(--muted); }
.node text.meta { font-size: 11px; fill: var(--muted); }
.node text.meta.alt { fill: var(--alt); }
.node text.meta.timing { fill: var(--fg); font-weight: 600; }
.node:hover rect.box, .node.sel rect.box { stroke: var(--fg); stroke-width: 2; }
.node:focus { outline: none; }
.node:focus-visible rect.box { stroke: var(--accent); stroke-width: 3; }
.edge { fill: none; stroke: var(--edge); stroke-width: 1.4; }
.edge.alt { stroke: var(--alt); stroke-dasharray: 6 5; }
.band-label { font-size: 17px; font-weight: 700; fill: var(--fg); font-family: var(--font); }
.band-sub { font-size: 13px; fill: var(--muted); font-family: var(--font); }
.band-line { stroke: var(--line); }
svg.focus .node:not(.hl) { opacity: .22; }
svg.focus .edge:not(.hl) { opacity: .08; }
svg.focus .edge.hl { stroke-width: 2.4; }
@media (prefers-reduced-motion: no-preference) { .node, .edge { transition: opacity .15s; } }

/* Text below the canvas: FAQ (readable without JS). */
.article { max-width: 860px; margin: 0 auto; padding: 36px 20px 80px; }
.article h2 { font-size: 21px; margin: 34px 0 10px; }
.article h3 { font-size: 16px; margin: 22px 0 6px; }
.article p { margin: 8px 0; }
.faq dt { font-weight: 600; margin-top: 16px; }
.faq dd { margin: 4px 0 0; color: var(--fg); }
.article .src { color: var(--muted); font-size: 14px; }

.noscript { max-width: 860px; margin: 16px auto; padding: 0 20px; }
.noscript ul { padding-left: 1.3em; }

@media (max-width: 760px) {
  .stage { height: 72vh; height: 72dvh; min-height: 420px; }
  .zoom .hint { display: none; }
  .detail { left: 8px; right: 8px; top: auto; bottom: 8px; width: auto; max-height: 58%; }
}
