/* Dialogue layout: a route map of the whole conversation on the left, the conversation flowing down on the right. */
:root { --dlg-warm: #c2650a; --dlg-gold: #b8860b; --dlg-who-w: 58px; }
html[data-theme="dark"], body.dark-theme { --dlg-warm: #eba55a; --dlg-gold: #e3b341; }

body.dialogue-page main.container,
body.dialogue-page .site-header .container,
body.dialogue-page footer.container { width: min(100%, 1354px); max-width: none; }
.dlg-layout {
    display: grid;
    grid-template-columns: 250px minmax(0, 1fr);
    grid-template-areas: "map head" "map stage";
    column-gap: 64px;
    align-items: start;
    margin: 38px 0 96px;
}
.dlg-head { grid-area: head; max-width: 960px; }
.dlg-head .post-header { margin-bottom: 34px; padding-bottom: 26px; }
.dlg-banner { margin: 0 0 28px; }
.dlg-banner img { display: block; width: 100%; height: auto; border: 1px solid var(--border-color); border-radius: 8px; }
.dlg-head .post-header h1 { margin-bottom: 14px; }
.dlg-stage { grid-area: stage; min-width: 0; max-width: 960px; }

/* ---------- Route map ---------- */
.dlg-map { grid-area: map; position: sticky; top: 96px; max-height: calc(100vh - 116px); overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: none; padding-bottom: 12px; }
.dlg-map::-webkit-scrollbar { display: none; }
.map-toggle { display: none; }
.map-top { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 14px; }
.map-title { color: var(--text-muted); font: 600 10px/1.6 var(--mono); letter-spacing: .12em; text-transform: uppercase; }
.map-progress { color: var(--text-muted); font: 600 11px var(--mono); }
.map-canvas { position: relative; }
.map-svg { display: block; width: 100%; height: auto; overflow: visible; }
.map-act { fill: var(--dlg-gold); font: 650 10px var(--mono); }
.map-act-line { stroke: var(--border-color); stroke-width: 1; stroke-dasharray: 2 4; }
.map-trunk { stroke: var(--dlg-gold); stroke-width: 2.6; stroke-linecap: round; }
.map-trunk-glow { stroke: var(--dlg-gold); stroke-width: 9; stroke-linecap: round; opacity: .13; }
.map-edge { fill: none; stroke: var(--border-color); stroke-width: 1.4; stroke-linecap: round; transition: stroke .15s; }
.map-edge.is-visited { stroke: color-mix(in srgb, var(--text-muted) 70%, var(--border-color)); }
.map-edge.is-thread { stroke: var(--accent); stroke-width: 1.9; }
.map-edge.is-hover { stroke: var(--text-heading); stroke-width: 1.9; }
.map-hit { fill: transparent; }
.map-node { cursor: pointer; outline: none; }
.map-dot { fill: var(--bg-primary); stroke: var(--text-muted); stroke-width: 1.4; transition: stroke-width .15s; }
.map-node.has-kids:not(.is-main) .map-dot { stroke-width: 1.8; }
.map-node.is-visited .map-dot { fill: var(--text-muted); }
.map-node.is-thread .map-dot { stroke: var(--accent); fill: var(--accent); }
.map-node.is-main .map-dot { stroke: var(--dlg-gold); stroke-width: 2.2; fill: var(--bg-primary); }
.map-node.is-main.is-visited .map-dot { fill: var(--dlg-gold); }
.map-halo { fill: none; stroke-width: 1.6; opacity: 0; transition: opacity .15s; }
.map-node.is-current .map-halo { opacity: 1; stroke: var(--accent); }
.map-node.is-main.is-current .map-halo { stroke: var(--dlg-gold); }
.map-node:hover .map-dot, .map-node:focus-visible .map-dot { stroke-width: 2.8; }
.map-node:focus-visible .map-halo { opacity: 1; stroke: var(--accent); }
.map-flag, .map-tip { position: absolute; transform: translate(12px, -50%); padding: 2px 8px; border-radius: 10px; font: 650 11.5px/1.5 var(--sans); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; pointer-events: none; z-index: 2; }
.map-flag.is-left, .map-tip.is-left { transform: translate(calc(-100% - 12px), -50%); }
.map-flag { background: color-mix(in srgb, var(--accent) 16%, var(--bg-primary)); border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent); color: var(--text-heading); }
.map-flag.is-main { background: color-mix(in srgb, var(--dlg-gold) 16%, var(--bg-primary)); border-color: color-mix(in srgb, var(--dlg-gold) 55%, transparent); }
.map-tip { background: var(--text-heading); color: var(--bg-primary); }
.map-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--border-color); color: var(--text-muted); font: 500 11px var(--sans); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend-item i { display: inline-block; width: 14px; height: 2px; border-radius: 1px; background: var(--border-color); }
.legend-item.is-main i { height: 3px; background: var(--dlg-gold); }
.legend-item.is-thread i { background: var(--accent); }
.map-reset { margin-top: 10px; background: none; border: 0; color: var(--text-muted); cursor: pointer; font: 600 11px var(--mono); padding: 0; }
.map-reset:hover { color: var(--accent); }

/* ---------- Conversation flow ---------- */
/* Room below the newest exchange so it can scroll to the top and the sticky map never runs out of track. */
.dlg-flow { padding-bottom: max(45vh, 320px); }
.dlg-flow > .dlg-node { margin-top: 44px; }
.dlg-flow > .dlg-node:first-child { margin-top: 0; }
.dlg-flow > .dlg-node.is-main:not(:first-child) { padding-top: 40px; border-top: 1px solid var(--border-color); }
.dlg-tag { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; margin-bottom: 14px; color: var(--text-muted); font: 600 11px/1.6 var(--mono); letter-spacing: .05em; text-transform: uppercase; }
.dlg-tag.is-main { color: var(--dlg-gold); }
.dlg-tag .tag-act { color: var(--text-heading); }
.tag-link { background: none; border: 0; color: var(--accent); cursor: pointer; font: inherit; letter-spacing: inherit; padding: 0; text-transform: none; }
.tag-link:hover { text-decoration: underline; text-underline-offset: 3px; }

.dlg-title { margin: 0 0 18px; color: var(--text-heading); font: 650 27px/1.3 var(--serif); letter-spacing: -.015em; }
.dlg-node:not(.is-main) .dlg-title { font-size: 22px; }

/* A topic is a run of turns between "me" and the mentor, labeled in the left gutter. */
.dlg-turn { display: grid; grid-template-columns: var(--dlg-who-w) minmax(0, 1fr); column-gap: 14px; margin-top: 12px; }
.dlg-turn::before { grid-column: 1; padding-top: 4px; font: 600 11px/1.6 var(--mono); letter-spacing: .04em; text-transform: uppercase; }
.dlg-turn > [data-lang] { grid-column: 2; min-width: 0; }
.dlg-turn--me::before { content: "Me"; color: var(--text-muted); }
body[data-lang="zh"] .dlg-turn--me::before { content: "我"; }
/* The other side has no persona: its lines are labeled by what they do, an answer or a question. */
.dlg-turn--you::before { content: "A"; color: var(--accent); }
body[data-lang="zh"] .dlg-turn--you::before { content: "答"; }
.dlg-turn--you.is-ask::before { content: "Q"; }
body[data-lang="zh"] .dlg-turn--you.is-ask::before { content: "问"; }
.dlg-turn--me > [data-lang] { color: var(--text-heading); font: 600 18px/1.65 var(--serif); }
body[data-lang="zh"] .dlg-turn--me > [data-lang] { letter-spacing: .01em; }
.dlg-turn--you.markdown-body { font-size: 16px; line-height: 1.85; }
.dlg-turn--you > [data-lang] > :last-child { margin-bottom: 0; }
.dlg-turn--you + .dlg-turn--me, .dlg-fig + .dlg-turn--me { margin-top: 26px; }
.dlg-fig { margin: 22px 0 0; padding: 18px 18px 14px; border: 1px solid var(--border-color); border-radius: 6px; background: var(--bg-secondary); }
.dlg-fig figcaption { margin-top: 10px; color: var(--text-muted); font-size: 13px; line-height: 1.6; }
.dlg-fig svg { display: block; width: 100%; max-width: 720px; height: auto; margin: 0 auto; }
.dlg-fig--image { background: var(--figure-bg); }
.dlg-fig img { display: block; width: 100%; max-width: 760px; height: auto; margin: 0 auto; border-radius: 4px; }

.dlg-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 22px 0 0 calc(var(--dlg-who-w) + 14px); }
.dlg-chips:empty { display: none; }
.dlg-chip { display: inline-flex; align-items: baseline; gap: 8px; max-width: 100%; background: none; border: 1px solid var(--border-color); border-radius: 18px; color: var(--text-secondary); cursor: pointer; font: 500 13.5px/1.45 var(--sans); padding: 7px 14px; text-align: left; }
.dlg-chip:hover { border-color: var(--accent); color: var(--text-heading); }
.dlg-chip .chip-kind { flex: 0 0 auto; color: var(--accent); font: 650 11px var(--mono); }
.dlg-chip--up .chip-kind, .dlg-chip--sibling .chip-kind { color: var(--text-muted); }
.dlg-chip--main { border-color: color-mix(in srgb, var(--dlg-gold) 60%, var(--border-color)); background: color-mix(in srgb, var(--dlg-gold) 8%, transparent); color: var(--text-heading); }
.dlg-chip--main:hover { border-color: var(--dlg-gold); }
.dlg-chip--main .chip-kind { color: var(--dlg-gold); }
.dlg-chip.is-taken { border-style: dashed; background: none; color: var(--text-muted); }
.dlg-chip.is-taken .chip-kind { color: var(--text-muted); }
.dlg-end { color: var(--text-muted); font-size: 14px; }

.dlg-stream { animation: dlg-stream .42s cubic-bezier(.2, .7, .2, 1) both; }
@keyframes dlg-stream { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- Figures and widgets ---------- */
.fig-box { fill: var(--bg-primary); stroke: var(--border-color); stroke-width: 1.2; }
.fig-soft { fill: var(--bg-secondary); stroke: var(--border-color); stroke-width: 1; }
.fig-accent { fill: color-mix(in srgb, var(--accent) 16%, var(--bg-primary)); stroke: var(--accent); stroke-width: 1.2; }
.fig-accent-solid { fill: var(--accent); }
.fig-box-accent { fill: var(--bg-primary); stroke: var(--accent); stroke-width: 1.4; }
.fig-on-accent { fill: var(--bg-primary); font: 650 12px var(--sans); }
.fig-knock { paint-order: stroke; stroke: var(--bg-secondary); stroke-width: 5px; stroke-linejoin: round; }
.fig-sep { stroke: var(--bg-secondary); stroke-width: 1.4; fill: none; }
.fig-part { fill: none; stroke: var(--border-color); stroke-width: 1.2; }
.fig-band-accent { fill: var(--accent); opacity: .1; }
.fig-band-warm { fill: var(--dlg-warm); opacity: .12; }
.fig-warm { fill: color-mix(in srgb, var(--dlg-warm) 18%, var(--bg-primary)); stroke: var(--dlg-warm); stroke-width: 1.2; }
.fig-warm-solid { fill: var(--dlg-warm); }
.fig-muted-solid { fill: var(--text-muted); }
.fig-line { stroke: var(--border-color); stroke-width: 1.4; fill: none; }
.fig-line-accent { stroke: var(--accent); stroke-width: 1.4; fill: none; }
.fig-line-warm { stroke: var(--dlg-warm); stroke-width: 1.4; fill: none; }
.fig-t { fill: var(--text-secondary); font: 500 12px var(--sans); }
.fig-th { fill: var(--text-heading); font: 650 13px var(--sans); }
.fig-m { fill: var(--text-muted); font: 600 10.5px var(--mono); }
.fig-ma { fill: var(--accent); font: 650 10.5px var(--mono); }
.fig-mw { fill: var(--dlg-warm); font: 650 10.5px var(--mono); }
.fig-big { fill: var(--text-heading); font: 650 20px var(--serif); }
.l-zh { display: none; }
body[data-lang="zh"] .l-zh { display: inline; }
body[data-lang="zh"] .l-en { display: none; }

.w-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; margin-bottom: 14px; }
.w-controls label { display: flex; align-items: center; gap: 10px; color: var(--text-secondary); font: 600 12px var(--mono); }
.w-controls input[type="range"] { width: 170px; accent-color: var(--accent); }
.w-controls output { min-width: 3.5em; color: var(--text-heading); font: 650 13px var(--mono); }
.w-seg { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.w-seg button { background: var(--bg-primary); border: 1px solid var(--border-color); border-radius: 4px; color: var(--text-secondary); cursor: pointer; font: 600 12px var(--sans); padding: 5px 10px; }
.w-seg button:hover { border-color: var(--accent); }
.w-seg button[aria-pressed="true"] { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--bg-primary)); color: var(--accent); }
.w-readout { margin-top: 12px; color: var(--text-secondary); font-size: 14px; line-height: 1.65; }
.w-readout b { color: var(--text-heading); font-weight: 650; }
.w-readout .ok { color: var(--accent); }
.w-readout .bad { color: var(--dlg-warm); }
.w-rows { display: grid; gap: 9px; }
.w-row { display: grid; grid-template-columns: 150px minmax(0, 1fr) 64px; align-items: center; gap: 12px; font-size: 13px; color: var(--text-secondary); }
.w-row .lbl { font: 600 12px var(--mono); }
.w-row .val { text-align: right; font: 650 13px var(--mono); color: var(--text-heading); }
.w-track { position: relative; height: 12px; border-radius: 3px; background: var(--bg-primary); border: 1px solid var(--border-color); overflow: hidden; }
.w-fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 2px; background: var(--text-muted); transition: width .2s; }
.w-fill.accent { background: var(--accent); }
.w-fill.warm { background: var(--dlg-warm); }
.w-row.is-limit .lbl, .w-row.is-limit .val { color: var(--dlg-warm); }
.w-row.is-limit .w-fill { background: var(--dlg-warm); }
.w-mark { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--text-heading); }

@media (max-width: 1100px) {
    .dlg-layout { grid-template-columns: 200px minmax(0, 1fr); column-gap: 40px; }
}
@media (max-width: 960px) {
    .dlg-layout { grid-template-columns: minmax(0, 1fr); grid-template-areas: "head" "map" "stage"; margin-top: 30px; }
    .dlg-map { position: static; max-height: none; margin-bottom: 30px; border: 1px solid var(--border-color); border-radius: 6px; padding: 0; }
    .map-toggle { display: flex; justify-content: space-between; gap: 12px; width: 100%; background: none; border: 0; cursor: pointer; color: var(--text-heading); font: 650 14px var(--sans); padding: 12px 14px; text-align: left; }
    .map-toggle .here { color: var(--text-muted); font: 500 12px var(--sans); }
    .map-body { display: none; padding: 0 14px 14px; max-width: 320px; }
    .dlg-map.is-open .map-body { display: block; }
    :root { --dlg-who-w: 40px; }
    .dlg-title { font-size: 23px; }
    .dlg-node:not(.is-main) .dlg-title { font-size: 20px; }
    .dlg-turn--me > [data-lang] { font-size: 17px; }
    .w-row { grid-template-columns: 112px minmax(0, 1fr) 54px; }
    .w-controls input[type="range"] { width: 130px; }
}
@media (max-width: 600px) {
    .dlg-chips { margin-left: 0; }
}
@media (prefers-reduced-motion: reduce) {
    .dlg-stream { animation: none; }
}

/* Draft: the raw notes the post was written from, opened from the date line. */
.dlg-draft-open { background: none; border: 1px solid var(--border-color); border-radius: 11px; color: var(--accent); cursor: pointer; font: inherit; margin-left: 2px; padding: 2px 10px; }
.dlg-draft-open:hover { border-color: var(--accent); }
.dlg-draft { background: var(--bg-primary); border: 1px solid var(--border-color); border-radius: 10px; box-shadow: 0 24px 64px rgba(0, 0, 0, .28); color: var(--text-primary); margin: auto; max-height: min(86vh, 920px); padding: 0; width: min(780px, calc(100vw - 32px)); }
.dlg-draft[open] { display: flex; flex-direction: column; }
.dlg-draft::backdrop { background: rgba(0, 0, 0, .45); }
.dlg-draft-head { align-items: flex-start; border-bottom: 1px solid var(--border-color); display: flex; gap: 16px; justify-content: space-between; padding: 18px 20px 14px; }
.dlg-draft-head h2 { color: var(--text-heading); font: 650 17px/1.3 var(--sans); margin: 0; }
.dlg-draft-head p { color: var(--text-muted); font: 13px/1.5 var(--sans); margin: 4px 0 0; }
.dlg-draft-close { background: none; border: 1px solid transparent; border-radius: 6px; color: var(--text-muted); cursor: pointer; font-size: 16px; line-height: 1; padding: 6px 8px; }
.dlg-draft-close:hover { border-color: var(--border-color); color: var(--text-heading); }
.dlg-draft-text { background: var(--code-bg); color: var(--text-primary); flex: 1 1 auto; font: 13px/1.7 var(--mono); margin: 0; min-height: 0; overflow: auto; overflow-wrap: anywhere; padding: 16px 20px 22px; white-space: pre-wrap; }
body:has(.dlg-draft[open]) { overflow: hidden; }
