/* Roadmap canvas (roadmap.sh-style) + topic drawer */
:root {
  --rm-bg: #ffffff;
  --rm-main: #fdff00;
  --rm-sub: #ffe599;
  --rm-ink: #000000;
  --rm-line: #2b78e4;
  --rm-done: #d9f2d0;
  --rm-doing: #f59e0b;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --rm-bg: #12161c; --rm-line: #5b9cf0; --rm-done: #b7e4a7; }
}
:root[data-theme="dark"] { --rm-bg: #12161c; --rm-line: #5b9cf0; --rm-done: #b7e4a7; }

/* ---------- hero ---------- */
.rm-hero { padding: 36px 0 20px; display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px 40px; align-items: end; }
.rm-hero .lead { font-size: 1.08rem; color: var(--muted); max-width: 62ch; margin: 0; }
.rm-hero .lead p { margin: 0 0 .5em; }
.rm-tabs { display: flex; gap: 18px; border-bottom: 1px solid var(--border); margin-top: 18px; font-size: .92rem; }
.rm-tabs a { padding: 8px 2px; text-decoration: none; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.rm-tabs a.active { color: var(--text); font-weight: 600; border-color: var(--text); }
.rm-progress { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; box-shadow: var(--shadow); }
.rm-progress .nums { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: .86rem; color: var(--muted); margin: 8px 0 10px; }
.rm-progress .nums b { color: var(--text); }
.rm-progress .progress { height: 9px; }
@media (max-width: 860px) { .rm-hero { grid-template-columns: 1fr; } }

/* ---------- canvas ---------- */
.rm-canvas { position: relative; background: var(--rm-bg); border: 1px solid var(--border); border-radius: 14px; padding: 28px 24px 48px; margin: 8px 0 28px; overflow: hidden; }
.rm-svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.rm-top { display: grid; grid-template-columns: 1fr auto 1fr; gap: 16px; align-items: start; margin-bottom: 26px; }
.rm-legend { border: 2px solid var(--rm-ink); background: #fff; color: #111; border-radius: 6px; padding: 10px 14px; font: .86rem/1.5 var(--hand); justify-self: start; max-width: 300px; }
.rm-legend div { display: flex; gap: 8px; align-items: center; margin: 3px 0; }
.rm-legend .dot { width: 16px; height: 16px; border-radius: 50%; display: inline-grid; place-items: center; color: #fff; font-size: 10px; flex-shrink: 0; }
.rm-legend .dash { width: 26px; height: 14px; border: 1.5px dashed #111; border-radius: 3px; background: var(--rm-sub); flex-shrink: 0; }
.rm-title { font: 700 1.6rem/1.2 var(--hand); color: var(--text); text-align: center; padding-top: 18px; }
.rm-title small { display: block; font: .8rem/1.4 var(--font); color: var(--muted); margin-top: 4px; }
.rm-note { justify-self: end; max-width: 260px; font-size: .84rem; color: var(--muted); background: var(--surface-2); border-radius: 8px; padding: 10px 12px; }
.rm-note a { font-weight: 600; }

.rm-row { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) 300px minmax(0, 1fr); gap: 0 70px; align-items: center; margin: 0 0 34px; }
.rm-side { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.rm-side.left { align-items: flex-end; }
.rm-side.right { align-items: flex-start; }
.rm-fork { position: relative; z-index: 2; display: flex; justify-content: center; margin: -10px 0 26px; }
.rm-fork span { background: var(--rm-bg); border: 2px dashed var(--rm-line); color: var(--rm-line); border-radius: 999px; padding: 3px 14px; font: 700 .82rem/1.4 var(--hand); }

/* nodes */
.node { position: relative; z-index: 2; display: block; text-decoration: none; color: var(--rm-ink); font-family: var(--hand); border: 2px solid var(--rm-ink); border-radius: 6px; transition: transform .08s ease, box-shadow .08s ease; }
.node:hover { transform: translateY(-1px); box-shadow: 0 3px 0 rgba(0, 0, 0, .18); }
.node.main { background: var(--rm-main); text-align: center; padding: 10px 14px; font-size: 1.02rem; font-weight: 700; line-height: 1.25; width: 100%; }
.node.main .code { display: block; font: 700 .7rem/1 var(--mono); letter-spacing: .04em; opacity: .65; margin-bottom: 4px; }
.node.main .cnt { position: absolute; right: -2px; top: -12px; font: 700 .7rem/1 var(--mono); background: #111; color: #fff; border-radius: 999px; padding: 3px 7px; }
.node.sub { background: var(--rm-sub); padding: 6px 12px 6px 30px; font-size: .9rem; line-height: 1.3; width: min(270px, 100%); border-width: 1.5px; }
.node.sub.plain { padding-left: 12px; }
.node.sub .rc { font: 700 .72rem/1 var(--mono); margin-right: 4px; opacity: .7; }
.node.sub.opt { border-style: dashed; }
.node .badge { position: absolute; left: 7px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; border-radius: 50%; display: grid; place-items: center; color: #fff; font: 700 9px/1 var(--font); background: var(--f-ext); }
.node .badge.core { background: var(--f-core); }
.node .badge.be { background: var(--f-be); }
.node .st { position: absolute; right: -9px; top: -9px; width: 20px; height: 20px; border-radius: 50%; display: none; place-items: center; font: 700 11px/1 var(--font); border: 2px solid var(--rm-bg); }
.node.is-done { background: var(--rm-done); }
.node.is-done .txt { text-decoration: line-through; text-decoration-thickness: 1.5px; }
.node.is-done .st { display: grid; background: var(--ok); color: #fff; }
.node.is-doing { box-shadow: 0 0 0 3px var(--rm-doing); }
.node.is-doing .st { display: grid; background: var(--rm-doing); color: #fff; }
.node.is-skip { opacity: .45; }
.node.is-skip .txt { text-decoration: line-through; }
.node.is-skip .st { display: grid; background: #6b7280; color: #fff; }
.node.is-current { outline: 3px solid var(--rm-line); outline-offset: 3px; }
.node.main.is-done { background: #b9e6a8; }

/* below-canvas sections */
.rm-below { display: grid; grid-template-columns: 1.2fr 1fr; gap: 16px; margin-bottom: 40px; }
.rm-below ol { margin: 0; padding-left: 1.4em; }
.rm-below li { margin: 6px 0; }
.rm-below li.key::marker { color: var(--accent); font-weight: 800; }
.rm-below .sub-note { display: block; font-size: .84rem; color: var(--muted); }
@media (max-width: 860px) { .rm-below { grid-template-columns: 1fr; } }

/* mobile: stacked, no connectors */
@media (max-width: 760px) {
  .rm-canvas { padding: 18px 14px 28px; }
  .rm-top { grid-template-columns: 1fr; }
  .rm-legend, .rm-note { justify-self: stretch; max-width: none; }
  .rm-title { padding-top: 0; }
  .rm-svg { display: none; }
  .rm-row { grid-template-columns: 1fr; gap: 8px; margin-bottom: 22px; }
  .rm-row .rm-mainwrap { order: -1; }
  .rm-side, .rm-side.left, .rm-side.right { align-items: stretch; border-left: 3px dotted var(--rm-line); padding-left: 12px; margin-left: 10px; }
  .rm-side:empty { display: none; }
  .node.sub { width: 100%; }
  .rm-fork { margin: 0 0 18px; }
}

/* ---------- drawer ---------- */
.drawer-back { position: fixed; inset: 0; background: rgba(17, 24, 39, .45); z-index: 40; opacity: 0; pointer-events: none; transition: opacity .15s; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(780px, 100vw); background: var(--surface); z-index: 41; box-shadow: -10px 0 40px rgba(0, 0, 0, .2); transform: translateX(102%); transition: transform .2s ease; display: flex; flex-direction: column; }
body.drawer-open { overflow: hidden; }
body.drawer-open .drawer { transform: none; }
body.drawer-open .drawer-back { opacity: 1; pointer-events: auto; }
.dr-head { padding: 16px 22px 14px; border-bottom: 1px solid var(--border); display: grid; gap: 8px; }
.dr-top { display: flex; align-items: center; gap: 10px; }
.dr-crumb { font-size: .82rem; color: var(--muted); margin-right: auto; }
.dr-crumb a { color: inherit; }
.dr-head h2 { margin: 0; font-size: 1.5rem; line-height: 1.25; display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.dr-head h2 .rc { font: 700 .85rem/1 var(--mono); background: var(--rm-sub); color: #000; border: 1.5px solid #000; border-radius: 5px; padding: 4px 7px; }
.dr-meta { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; font-size: .85rem; color: var(--muted); }
.status-seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.status-seg button { font: inherit; font-size: .82rem; border: 0; background: var(--surface); color: var(--text); padding: 5px 11px; cursor: pointer; border-left: 1px solid var(--border); }
.status-seg button:first-child { border-left: 0; }
.status-seg button:hover { background: var(--surface-2); }
.status-seg button.on[data-v="done"] { background: var(--ok); color: #fff; }
.status-seg button.on[data-v="doing"] { background: var(--rm-doing); color: #111; }
.status-seg button.on[data-v="skip"] { background: #6b7280; color: #fff; }
.status-seg button.on[data-v="todo"] { background: var(--surface-2); font-weight: 700; }
.dr-body { flex: 1; overflow-y: auto; padding: 20px 22px 28px; }
.dr-body .lead { font-size: 1.04rem; color: var(--text); margin: 0 0 18px; padding: 12px 14px; background: var(--surface-2); border-radius: 10px; }
.dr-body .lead p { margin: 0 0 .5em; }
.dr-body .lead p:last-child { margin: 0; }
.dr-body section, .dr-body aside { margin-bottom: 20px; }
.dr-body h3 { font-size: 1.08rem; }
.dr-body .box { background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; }
.dr-foot { border-top: 1px solid var(--border); padding: 12px 22px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; background: var(--surface); }
.dr-foot .grow { margin-right: auto; }
.steps { margin: 0; padding-left: 1.4em; }
.steps li { margin: .35em 0; }
.steps li::marker { color: var(--accent); font-weight: 700; }
.ask-pre { white-space: pre-wrap; font: .8rem/1.55 var(--mono); background: var(--surface-2); border-radius: 8px; padding: 10px 12px; margin: 8px 0 0; max-height: 280px; overflow: auto; }
details.more summary { cursor: pointer; color: var(--accent); font-weight: 600; font-size: .9rem; }

/* chapter drawer list */
.ch-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.ch-list a { display: flex; gap: 10px; align-items: center; padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; text-decoration: none; color: var(--text); background: var(--surface); }
.ch-list a:hover { border-color: var(--accent); }
.ch-list .rc { font: 700 .76rem/1 var(--mono); color: var(--muted); min-width: 34px; }
.ch-list .t { flex: 1; }
.ch-list .s { font-size: .8rem; color: var(--muted); }
.ch-list .s.done { color: var(--ok); font-weight: 700; }
.ch-list .s.doing { color: var(--warn); font-weight: 700; }

/* gate */
.gate { border: 2px solid var(--text); border-radius: 10px; padding: 16px 18px; background: var(--surface); }
.gate h3 { display: flex; align-items: center; gap: 8px; }
.gate-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.gate-grid > div { background: var(--surface-2); border-radius: 8px; padding: 10px 12px; font-size: .92rem; }
.gate-grid .lbl { display: block; font-size: .7rem; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
.gate-grid .pass { background: var(--rm-sub); color: #111; }
.gate-grid .pass .lbl { color: #5b4a00; }
.gate-grid .pass code { background: rgba(0, 0, 0, .08); }
.gate-form { display: grid; grid-template-columns: minmax(140px, 200px) 1fr; gap: 10px; align-items: start; }
.gate-foot { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; margin-top: 10px; }
.gate-foot .check { padding: 0; font-weight: 600; }
.saved-at { font-size: .78rem; color: var(--muted); }
@media (max-width: 640px) { .gate-grid, .gate-form { grid-template-columns: 1fr; } .dr-head, .dr-body, .dr-foot { padding-left: 14px; padding-right: 14px; } }

/* resources */
.reads { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.reads a { display: flex; gap: 10px; align-items: baseline; text-decoration: none; color: var(--text); padding: 4px 0; }
.reads a:hover b { text-decoration: underline; }
.reads .type { font: 700 .66rem/1 var(--mono); text-transform: uppercase; letter-spacing: .04em; background: #111827; color: #fff; border-radius: 4px; padding: 3px 6px; flex-shrink: 0; }
.reads b { font-weight: 600; color: var(--accent); }
.reads .why { display: block; font-size: .84rem; color: var(--muted); }
.reads .t { font-family: var(--mono); font-size: .76rem; color: var(--muted); }
