/* ChiAha app. Palette from chiaha.com (navy #0E2230, accent #2C5977, light #70CEEF).
   Diagram styled after Mermaid's redux look: crisp outlines, hard shadow, dot grid.
   Base text is large (17px, scaled by the A−/A+ control). */
:root {
  --bg: #eef3f7; --surface: #ffffff; --surface2: #f2f6f9; --border: #d5dee6;
  --text: #0E2230; --muted: #4c5f6d; --accent: #2C5977; --accent-ink: #ffffff; --accent-lt: #70CEEF;
  --err-bg: #fdecec; --err-border: #e3a5a5; --err-text: #8a1c1c; --sel: #e08a00;
  --canvas: #f8fafc; --dot: #c9d3db; --node-fill: #ffffff; --node-ink: #0E2230; --node-shadow: #c3ced8;
  --edge: #0E2230; --chip: #e3eaf0;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #050d14; --surface: #0E2230; --surface2: #15304a; --border: #29465e;
    --text: #EAF3F8; --muted: #a9bccb; --accent: #70CEEF; --accent-ink: #0E2230; --accent-lt: #70CEEF;
    --err-bg: #3a1c1f; --err-border: #6b2c31; --err-text: #ffb3b3; --sel: #ffb340;
    --canvas: #08121b; --dot: #23384a; --node-fill: #0b1823; --node-ink: #EAF3F8; --node-shadow: #2a4256;
    --edge: #d9e4ec; --chip: #22384b;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #050d14; --surface: #0E2230; --surface2: #15304a; --border: #29465e;
  --text: #EAF3F8; --muted: #a9bccb; --accent: #70CEEF; --accent-ink: #0E2230; --accent-lt: #70CEEF;
  --err-bg: #3a1c1f; --err-border: #6b2c31; --err-text: #ffb3b3; --sel: #ffb340;
  --canvas: #08121b; --dot: #23384a; --node-fill: #0b1823; --node-ink: #EAF3F8; --node-shadow: #2a4256;
  --edge: #d9e4ec; --chip: #22384b;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { font-size: 17px; }
body { margin: 0; background: var(--bg); color: var(--text); font: 1rem/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Nunito, Roboto, sans-serif; }
a { color: var(--accent); }
h1 { font-size: 1.5rem; margin: 0 0 .5rem; }
h2 { font-size: 1.05rem; margin: 0; }
h3 { font-size: 1rem; margin: 1rem 0 .4rem; }
.muted { color: var(--muted); }
.small { font-size: .88rem; }
code { font-family: ui-monospace, Menlo, Consolas, monospace; }
sup { font-size: .55em; }

button, select, input { font: inherit; color: inherit; }
button { padding: .35rem .75rem; border: 1px solid var(--border); background: var(--surface); border-radius: 8px; cursor: pointer; }
button:hover:not(:disabled) { border-color: var(--accent); }
button:disabled { opacity: .45; cursor: default; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; width: 100%; padding: .6rem; }
button.ghost { background: transparent; }
button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, .node:focus-visible { outline: 2px solid var(--accent-lt); outline-offset: 2px; }
input, select { padding: .4rem .5rem; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; width: 100%; min-width: 0; }
input[type="checkbox"] { width: auto; }
label { display: grid; gap: .2rem; font-size: .92rem; margin-bottom: .6rem; }
label.check { display: flex; align-items: center; gap: .5rem; }

/* header */
.brand { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; padding: .5rem 16px; background: var(--surface); border-bottom: 1px solid var(--border); }
.mark { font-weight: 800; font-size: 1.35rem; text-decoration: none; color: var(--text); letter-spacing: .01em; }
.prefs { display: inline-flex; gap: .3rem; align-items: center; margin-left: auto; }
.pref { padding: .2rem .55rem; font-size: .9rem; }
.pct { min-width: 3.2em; text-align: center; font-size: .9rem; color: var(--muted); }
.who { color: var(--muted); font-size: .92rem; }
.foot { text-align: center; color: var(--muted); font-size: .85rem; padding: 1rem 16px 1.5rem; }
.views { display: inline-flex; gap: .3rem; align-items: center; padding: .2rem; border: 1px solid var(--border); border-radius: 10px; background: var(--surface2); }
.views button { border-color: transparent; background: transparent; font-weight: 600; }
.views button[aria-pressed="true"] { background: var(--surface); color: var(--text); border-color: var(--border); }
.views .run-top { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); margin-left: .3rem; }
.badge { display: inline-block; margin-left: .3rem; padding: 0 .4rem; border-radius: 999px; font-size: .75rem; background: var(--accent-lt); color: #0E2230; font-weight: 700; }

/* sign-in */
body.narrow .card { max-width: 460px; margin: 3rem auto; padding: 1.5rem; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; }
body.narrow form { display: grid; gap: .7rem; }
body.narrow button[type="submit"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.msg { background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; padding: .6rem .8rem; font-size: .95rem; }
.msg.err, .err { background: var(--err-bg); border-color: var(--err-border); color: var(--err-text); }

/* ---------- app layout: cards left, full-height canvas right (Model view) ---------- */
body.app { height: 100vh; display: flex; flex-direction: column; }
.workspace { flex: 1; min-height: 0; padding: 12px 16px; gap: 12px; }
.workspace.view-model { display: grid; grid-template-columns: minmax(300px, 400px) minmax(0, 1fr); }
.workspace.view-model .results { display: none; }
.left { display: flex; flex-direction: column; gap: 12px; overflow: auto; min-height: 0; padding-right: 2px; }
.workspace.view-results { display: block; overflow: auto; }
.workspace.view-results .left { display: none; }
.workspace.view-results .stage { height: 62vh; min-height: 380px; margin-bottom: 12px; }
.workspace.view-results #editTools { display: none; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; }
.card-head { display: flex; align-items: center; gap: .5rem; padding: .55rem .6rem .55rem .9rem; }
.card-head h2 .id { margin-left: .35rem; font-family: ui-monospace, Menlo, Consolas, monospace; color: var(--muted); font-weight: 400; }
.card-body { padding: 0 .9rem .9rem; }
.card.collapsed .card-body { display: none; }
button.collapse { margin-left: auto; padding: 0; width: 2rem; height: 2rem; line-height: 1; font-size: 1.1rem; border-color: transparent; background: transparent; color: var(--muted); }
button.collapse:hover { border-color: var(--border); color: var(--text); }
.tabs { display: inline-flex; gap: .2rem; }
.tabs button { border-color: transparent; background: transparent; font-weight: 600; color: var(--muted); border-radius: 8px; }
.tabs button[aria-selected="true"] { color: var(--text); background: var(--surface2); border-color: var(--border); }

.editor { display: flex; border: 1px solid var(--border); border-radius: 8px; background: var(--surface2); height: 19rem; overflow: hidden; }
.gutter { margin: 0; padding: .6rem .4rem; min-width: 3.2em; text-align: right; color: var(--muted); font: .9rem/1.5 ui-monospace, Menlo, Consolas, monospace; overflow: hidden; user-select: none; border-right: 1px solid var(--border); white-space: pre; }
.editor textarea { flex: 1; min-width: 0; margin: 0; padding: .6rem; border: 0; resize: none; background: transparent; color: var(--text); font: .9rem/1.5 ui-monospace, Menlo, Consolas, monospace; white-space: pre; overflow: auto; tab-size: 4; }
.editor textarea:focus { outline: none; }
.problems { list-style: none; padding: 0; margin: .6rem 0 0; display: grid; gap: .3rem; }
.problems li { background: var(--err-bg); border: 1px solid var(--err-border); color: var(--err-text); border-radius: 8px; padding: .35rem .6rem; font-size: .9rem; }
.syntax { margin-top: .6rem; font-size: .9rem; }
.syntax pre { background: var(--surface2); padding: .6rem; border-radius: 8px; overflow-x: auto; font-size: .85rem; }

.chips { display: flex; flex-wrap: wrap; gap: .45rem; }
.chip-btn { background: var(--surface2); font-weight: 600; font-size: .92rem; }
.action-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .45rem; }
.action-grid button { font-size: .92rem; }
.action-grid .wide { grid-column: 1 / -1; }

.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
fieldset.dist { border: 1px solid var(--border); border-radius: 8px; padding: .5rem .7rem .2rem; margin: 0 0 .7rem; }
fieldset.dist legend { font-size: .9rem; padding: 0 .3rem; }
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 0 .6rem; }
ol.order { padding-left: 1.4rem; margin: .2rem 0 .6rem; }
ol.order li { margin: .2rem 0; }
button.mini { padding: 0 .45rem; font-size: .85rem; }

/* ---------- stage: canvas + floating controls (Mermaid-style) ---------- */
.stage { position: relative; min-height: 0; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: var(--canvas); }
.stage:fullscreen { border-radius: 0; }
.canvas { position: absolute; inset: 0; cursor: grab; touch-action: none; }
.canvas.panning { cursor: grabbing; }
.canvas.grid-on { background-image: radial-gradient(var(--dot) 1.2px, transparent 1.3px); background-size: 18px 18px; }
.canvas svg.flow { width: 100%; height: 100%; display: block; }
.float { position: absolute; display: flex; gap: .35rem; align-items: center; flex-wrap: wrap; padding: .3rem; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 2px 10px rgba(0,0,0,.08); z-index: 2; }
.float button { padding: .3rem .6rem; font-size: .9rem; border-color: transparent; }
.float button:hover:not(:disabled) { border-color: var(--border); }
.float button[aria-pressed="true"] { border-color: var(--accent); }
.float .group { display: inline-flex; gap: .2rem; padding-right: .3rem; border-right: 1px solid var(--border); }
.float.tl { top: 10px; left: 10px; right: 230px; width: max-content; max-width: calc(100% - 240px); }
.float.tr { top: 10px; right: 10px; }
.float.tr button { width: 2.1rem; padding: .25rem 0; font-size: 1.05rem; }
.float.bl { bottom: 10px; left: 10px; max-width: calc(100% - 260px); }
.float.bl .hint { color: var(--muted); font-size: .85rem; padding: 0 .3rem; }
.float.br { bottom: 10px; right: 10px; font-size: .85rem; padding: .3rem .6rem; }

.toast { position: absolute; bottom: 64px; left: 50%; transform: translateX(-50%); z-index: 3; max-width: min(560px, 90%); padding: .6rem 2.2rem .6rem .9rem; border-radius: 10px; font-size: .95rem; box-shadow: 0 4px 16px rgba(0,0,0,.18); border: 1px solid var(--border); background: var(--surface); }
.toast.bad { background: var(--err-bg); border-color: var(--err-border); color: var(--err-text); }
.toast ul { margin: .3rem 0 0; padding-left: 1.1rem; }
.toast .x { position: absolute; top: .3rem; right: .35rem; border: 0; background: transparent; font-size: 1.2rem; padding: 0 .4rem; color: inherit; }

/* diagram marks (SVG from the server; classes only) */
svg.flow text { fill: var(--node-ink); font-family: inherit; }
svg.flow text.id { font-size: 11px; fill: var(--muted); }
svg.flow text.label { font-size: 15px; font-weight: 600; }
svg.flow text.sub { font-size: 12.5px; fill: var(--muted); }
svg.flow text.empty { fill: var(--muted); font-size: 15px; }
.node { cursor: pointer; }
.node .body { fill: var(--node-fill); stroke: var(--node-ink); stroke-width: 2; vector-effect: non-scaling-stroke; }
.node .shadow { fill: var(--node-shadow); stroke: none; }
.node:hover .body { stroke: var(--accent); }
.node.selected .body { stroke: var(--sel); stroke-width: 3; }
.node.from .body { stroke: var(--accent-lt); stroke-width: 3; stroke-dasharray: 6 4; }
.node.bad .body { stroke: var(--err-text); stroke-width: 3; }
.node.bad .shadow { fill: var(--err-border); }
.edge { cursor: pointer; }
.edge .line { fill: none; stroke: var(--edge); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; shape-rendering: geometricPrecision; }
.edge .hit { fill: none; stroke: transparent; stroke-width: 14; }
.edge:hover .line { stroke: var(--accent); }
.edge.selected .line { stroke: var(--sel); stroke-width: 3; }
.arrowhead { fill: var(--edge); }
.chip rect { fill: var(--chip); }
.chip text { font-size: 12px; font-weight: 600; }
.result rect { fill: var(--accent); }
svg.flow .result text { font-size: 12px; font-weight: 700; fill: var(--accent-ink); }

/* results view */
.results { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 16px; }
.results h2 { font-size: 1.15rem; margin-bottom: .4rem; }
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: .95rem; }
th, td { padding: .4rem .6rem; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; }
th { color: var(--muted); font-weight: 600; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

@media (max-width: 900px) {
  body.app { height: auto; }
  .workspace.view-model { display: flex; flex-direction: column; }
  .workspace.view-model .stage { height: 62vh; min-height: 360px; order: -1; }
  .left { overflow: visible; }
  .float.tl { right: 10px; max-width: calc(100% - 20px); top: 66px; }
  .float.bl .hint { display: none; }
  .float.bl { max-width: none; }
}
/* charts: categorical slots validated (dataviz validator) on #ffffff and #0E2230 */
:root { --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a; --grid: #e3e9ee; --stop-fill: #fbe0d3; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --grid: #22405a; --stop-fill: #4a2617; } }
:root[data-theme="dark"] { --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --grid: #22405a; --stop-fill: #4a2617; }
.viz-fig { margin: .4rem 0 1rem; }
svg.viz { width: 100%; max-width: 820px; height: auto; display: block; }
svg.viz text { fill: var(--text); font-family: inherit; }
svg.viz text.label { font-size: 14px; }
svg.viz text.value { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
svg.viz text.axis { font-size: 12px; fill: var(--muted); }
svg.viz .grid { stroke: var(--grid); stroke-width: 1; }
svg.viz .avg { stroke: var(--muted); stroke-width: 2; stroke-dasharray: 6 4; }
.seg, .dot { cursor: default; }
.seg.s1, .dot.s1, .swatch.s1 { fill: var(--series-1); background: var(--series-1); }
.seg.s2, .swatch.s2 { fill: var(--series-2); background: var(--series-2); }
.seg.s3, .swatch.s3 { fill: var(--series-3); background: var(--series-3); }
.dot { stroke: var(--surface); stroke-width: 2; }
.seg:hover, .dot:hover { opacity: .8; }
.viz-legend { display: flex; flex-wrap: wrap; gap: .4rem 1.2rem; font-size: .9rem; margin-bottom: .3rem; }
.viz-legend .key { display: inline-flex; align-items: center; gap: .4rem; }
.swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; }
.viz-tip { position: fixed; z-index: 10; pointer-events: none; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 6px; padding: .35rem .55rem; font-size: .88rem; box-shadow: 0 2px 8px rgba(0,0,0,.15); }

.problems li.fix-row { background: var(--surface2); border-color: var(--border); color: var(--text); }
button.fix { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; padding: .25rem .7rem; }

/* guided tour */
.tour-btn { font-weight: 600; }
.tour-spot { position: fixed; z-index: 50; border-radius: 12px; box-shadow: 0 0 0 9999px rgba(5, 13, 20, .45); outline: 3px solid var(--accent-lt); pointer-events: none; transition: all .35s ease; }
.tour-cap { position: fixed; z-index: 51; width: min(360px, calc(100vw - 24px)); background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 12px; padding: .8rem .9rem; box-shadow: 0 8px 28px rgba(0,0,0,.28); transition: left .35s ease, top .35s ease; }
.tour-cap.center { left: 50% !important; top: 30% !important; transform: translateX(-50%); }
.tour-step { font-size: .8rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.tour-text { margin: .35rem 0 .7rem; font-size: 1rem; }
.tour-ctl { display: flex; gap: .4rem; flex-wrap: wrap; }
.tour-ctl button { font-size: .9rem; }
.tour-ctl .primary-ish, .tour-next { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
@media (prefers-reduced-motion: reduce) { .tour-spot, .tour-cap { transition: none; } }

/* interrupt designer (pop-out) */
.int-summary { margin: .2rem 0 .6rem; padding: .5rem .65rem; background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; font-size: .95rem; }
.design-btn { margin-bottom: .4rem; }
.dz-back { position: fixed; inset: 0; z-index: 40; background: rgba(5, 13, 20, .5); display: flex; align-items: center; justify-content: center; padding: 16px; }
.dz { width: min(1160px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 16px 48px rgba(0,0,0,.35); }
.dz-head { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; padding: .8rem 1rem; border-bottom: 1px solid var(--border); }
.dz-head h2 { font-size: 1.15rem; }
.dz-modes { margin-left: auto; }
.dz-body { display: grid; grid-template-columns: minmax(280px, 400px) minmax(0, 1fr); gap: 1rem; padding: 1rem; overflow: auto; min-height: 0; }
.dz-left h3 { margin-top: .2rem; }
.dz-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.dz-field { font-size: .92rem; }
.dz-row { display: flex; gap: .4rem; align-items: center; }
.dz-row input { flex: 1; }
.dz-field input.solved { background: var(--surface2); font-style: italic; }
.dz-solved { font-size: .78rem; color: var(--muted); }
.dz-other { margin: .2rem 0 .8rem; font-size: .92rem; }
.dz-other summary { cursor: pointer; color: var(--accent); }
.small-field { max-width: 12rem; }
.dz-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: .45rem; margin-bottom: .6rem; }
.dz-card { display: grid; gap: .15rem; text-align: left; padding: .45rem; border-radius: 10px; background: var(--surface2); font-size: .82rem; }
.dz-card b { font-size: .9rem; }
.dz-card span { color: var(--muted); line-height: 1.25; }
.dz-card[aria-checked="true"] { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-lt); background: var(--surface); color: var(--text); }
.dz-mini { width: 100%; height: 34px; }
.dz-views { margin-bottom: .2rem; }
.dz-charts h3 { display: flex; align-items: center; gap: .4rem; margin: .5rem 0 .1rem; }
.dz-chart { width: 100%; height: auto; display: block; max-height: 260px; }
.dz-chart text { font-family: inherit; }
.dz-axis { font-size: 12px; fill: var(--muted); }
.dz-label { font-size: 12px; font-weight: 600; fill: var(--text); }
.dz-grid { stroke: var(--grid); stroke-width: 1; }
.dz-line { fill: none; stroke-width: 2.2; vector-effect: non-scaling-stroke; }
.dz-line.s1 { stroke: var(--series-1); } .dz-line.s2 { stroke: var(--series-2); }
.dz-area.s1 { fill: var(--series-1); opacity: .14; } .dz-area.s2 { fill: var(--series-2); opacity: .14; }
.dz-dot.s1 { fill: var(--series-1); } .dz-dot.s2 { fill: var(--series-2); }
.dz-dot { opacity: .75; }
.dz-hover.s1 { fill: var(--series-1); } .dz-hover.s2 { fill: var(--series-2); }
.dz-hover { stroke: var(--surface); stroke-width: 2; }
.dz-mean { stroke: var(--muted); stroke-width: 1.5; stroke-dasharray: 5 4; }
.dz-cap { stroke: var(--err-text); stroke-width: 1.5; stroke-dasharray: 2 3; }
.dz-cross { stroke: var(--muted); stroke-width: 1; }
.dz-stats { display: flex; gap: 1.2rem; flex-wrap: wrap; margin: .1rem 0 .4rem; font-size: .9rem; color: var(--muted); }
.dz-foot { border-top: 1px solid var(--border); padding: .7rem 1rem; display: grid; gap: .5rem; }
.dz-summary { margin: 0; font-weight: 600; }
.dz-foot-row { display: flex; gap: .8rem; align-items: center; flex-wrap: wrap; }
.dz-foot-row label { margin: 0; }
.inline-sel { display: inline-flex !important; align-items: center; gap: .4rem; }
.inline-sel select { width: auto; }
.grow { flex: 1; }
.primary-btn { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
@media (max-width: 800px) { .dz-body { grid-template-columns: 1fr; } }

/* my models */
.plan-badge { font-size: .78rem; font-weight: 700; padding: .1rem .5rem; border-radius: 999px; background: var(--surface2); border: 1px solid var(--border); color: var(--muted); white-space: nowrap; }
.plan-badge.plan-paid, .plan-badge.plan-staff { color: var(--accent); border-color: var(--accent); }
.cur-model { display: flex; gap: .5rem; align-items: center; margin-bottom: .5rem; }
.cur-model input { flex: 1; font-weight: 600; }
.row-btns { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: .5rem; }
.row-btns button { font-size: .9rem; }
.model-list, .history { list-style: none; margin: 0; padding: 0; display: grid; gap: .3rem; }
.model-list li { display: flex; gap: .3rem; align-items: stretch; }
.model-open { flex: 1; display: grid; text-align: left; gap: 0; padding: .35rem .6rem; background: var(--surface2); }
.model-open.current { border-color: var(--accent); }
.history { margin-bottom: .6rem; padding: .4rem; border: 1px dashed var(--border); border-radius: 8px; }
button.linkish { border: 0; background: transparent; color: var(--accent); padding: .15rem .2rem; text-align: left; font-size: .9rem; }

/* right-click menu */
.ctx { position: fixed; z-index: 60; min-width: 200px; padding: .3rem; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.22); display: grid; }
.ctx button { border: 0; background: transparent; text-align: left; padding: .4rem .7rem; border-radius: 6px; font-size: .95rem; }
.ctx button:hover, .ctx button:focus-visible { background: var(--surface2); outline: none; }
.ctx button.danger { color: var(--err-text); }
.ctx hr { border: 0; border-top: 1px solid var(--border); margin: .25rem .3rem; }

/* pricing page */
a.plan-badge { text-decoration: none; }
.pricing { max-width: 980px; margin: 0 auto; padding: 1.5rem 16px 2rem; }
.pricing h1 { font-size: 2rem; margin: .5rem 0 .4rem; }
.lede { font-size: 1.1rem; color: var(--muted); max-width: 46rem; }
.pr-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; margin: 1.4rem 0; }
.pr-card { position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 1.2rem 1.3rem; display: flex; flex-direction: column; }
.pr-card h2 { font-size: 1.3rem; }
.pr-card ul { padding-left: 1.1rem; margin: .6rem 0 1rem; flex: 1; }
.pr-card li { margin: .25rem 0; }
.pr-main { border: 2px solid var(--accent); }
.pr-flag { position: absolute; top: -12px; right: 16px; background: var(--accent); color: var(--accent-ink); font-size: .8rem; font-weight: 700; padding: .1rem .6rem; border-radius: 999px; }
.pr-price { font-size: 2.2rem; font-weight: 800; margin: .3rem 0 0; }
.pr-price span { font-size: 1rem; font-weight: 600; color: var(--muted); }
.pr-btn { display: inline-block; text-align: center; padding: .65rem 1rem; border-radius: 10px; border: 1px solid var(--border); text-decoration: none; font-weight: 700; color: var(--text); background: var(--surface2); }
.pr-btn.primary-btn { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.pr-current { display: inline-block; padding: .6rem 0; font-weight: 700; color: var(--accent); }
.pr-alt { margin: .6rem 0 0; font-size: .95rem; }
.pr-alt .pr-btn { padding: .3rem .7rem; font-size: .9rem; margin-left: .3rem; }
.pr-h { font-size: 1.3rem; margin: 2rem 0 .6rem; }
.pr-table { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; }
.pricing details { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: .6rem .9rem; margin: .4rem 0; }
.pricing summary { cursor: pointer; font-weight: 600; }

/* Ask: the assistant panel (chat.js). Docks on the right on wide screens, full screen on phones. */
.chat-btn { font-weight: 600; }
.chat { position: fixed; top: 0; right: 0; bottom: 0; z-index: 20; width: min(420px, 100vw); display: flex; flex-direction: column;
  background: var(--surface); border-left: 1px solid var(--border); box-shadow: -6px 0 24px rgba(0,0,0,.14); }
.chat[hidden] { display: none; }
.chat-head { display: flex; align-items: center; gap: .6rem; padding: .7rem .9rem; border-bottom: 1px solid var(--border); }
.chat-head h2 { flex: 0 0 auto; }
.chat-head .muted { flex: 1 1 auto; }
.chat-x { border: 0; font-size: 1.1rem; padding: .2rem .5rem; }
.chat-log { flex: 1 1 auto; overflow-y: auto; padding: .9rem; display: flex; flex-direction: column; gap: .6rem; }
.chat-empty { display: flex; flex-direction: column; align-items: flex-start; gap: .5rem; }
.chat-empty p { margin: 0 0 .3rem; }
.msg { max-width: 92%; padding: .55rem .8rem; border-radius: 12px; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.45; }
.msg.user { align-self: flex-end; background: var(--accent); color: var(--accent-ink); border-bottom-right-radius: 4px; }
.msg.assistant { align-self: flex-start; background: var(--surface2); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.msg.pending { color: var(--muted); font-style: italic; }
.msg.bad { background: var(--err-bg); border-color: var(--err-border); color: var(--err-text); }
.msg.change { align-self: stretch; max-width: none; font-size: .92rem; background: transparent; border: 1px dashed var(--border); }
.msg.change.undone { opacity: .6; }
.chat-form { display: flex; gap: .5rem; padding: .7rem .9rem 0; border-top: 1px solid var(--border); }
.chat-form textarea { flex: 1 1 auto; resize: none; font: inherit; padding: .5rem .6rem; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); }
.chat-form button { flex: 0 0 auto; background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.chat-note { margin: .4rem .9rem .7rem; }
@media (min-width: 1200px) { body.chat-open .workspace, body.chat-open header.brand { margin-right: 420px; } }

/* Interrupt designer, Easy mode: one column, no curves. */
.dz.dz-is-easy { width: min(720px, 100%); }
.dz-is-easy .dz-body { grid-template-columns: 1fr; }
.dz-is-easy .dz-right { display: none; }
.dz-is-easy .inline-sel { display: none !important; }
.dz-sentence { font-size: 1.1rem; line-height: 2.4; margin: .2rem 0 .8rem; }
.dz-easy-num { width: 6.5em; font-size: 1.05rem; padding: .3rem .45rem; margin: 0 .2rem; }
.dz-choice h3 { margin: .6rem 0 .35rem; }
.dz-pills { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .45rem; }
.dz-pill { display: grid; gap: .1rem; text-align: left; padding: .5rem .6rem; border-radius: 10px; background: var(--surface2); }
.dz-pill span { color: var(--muted); font-size: .85rem; line-height: 1.3; }
.dz-pill[aria-checked="true"] { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-lt); background: var(--surface); }
.dz-strip { width: 100%; height: auto; display: block; }
.dz-work { fill: var(--series-1); opacity: .85; }
.dz-stop { fill: var(--series-2); }
.dz-strip-key { margin: .3rem 0 0; color: var(--muted); }
.dz-strip-key i { display: inline-block; width: .8em; height: .8em; border-radius: 2px; vertical-align: -1px; }
.key-work { background: var(--series-1); opacity: .85; } .key-stop { background: var(--series-2); }
@media (max-width: 600px) { .dz-pills { grid-template-columns: 1fr; } .dz-sentence { line-height: 2.2; } }
.dz-strip { height: 34px; }
.dz-strip-axis { display: flex; justify-content: space-between; font-size: .82rem; color: var(--muted); margin-top: .15rem; }

/* Easy first (v0.9): run length beside Run, plain findings above the numbers. */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.run-for select { border: 0; background: transparent; font: inherit; font-weight: 600; color: var(--text); padding: .35rem .3rem; cursor: pointer; }
.findings { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: .7rem; margin: .4rem 0 1rem; }
.finding { display: grid; gap: .2rem; padding: .8rem .9rem; border: 1px solid var(--border); border-radius: 12px; background: var(--surface2); }
.f-title { font-size: .85rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.f-big { font-size: 1.35rem; line-height: 1.2; }
.f-line { color: var(--muted); font-size: .95rem; }
.more-numbers { margin-top: 1rem; }
.more-numbers > summary { cursor: pointer; color: var(--accent); font-weight: 600; }
@media (max-width: 600px) {
  .views { flex-wrap: nowrap; }
  .views button, .run-for select { white-space: nowrap; padding-left: .45rem; padding-right: .45rem; }
  .float.br { display: none; }
}

/* Public welcome page (signed-out visitors to /): text + animated flow side by side, steps below. */
.welcome-nav { display: flex; gap: 1rem; align-items: center; margin-left: auto; }
.welcome-main { max-width: 1160px; margin: 0 auto; padding: 1.2rem 16px 2.5rem; }
.w-top { display: grid; grid-template-columns: minmax(0, .85fr) minmax(0, 1.25fr); gap: 2rem; align-items: center; }
.w-hero h1 { font-size: clamp(2rem, 4.4vw, 3rem); line-height: 1.08; margin: 0 0 .8rem; }
.w-hero .lede { font-size: 1.12rem; color: var(--muted); margin: 0; }
.w-cta { display: flex; gap: .7rem; flex-wrap: wrap; margin: 1.2rem 0 .5rem; }
.w-early { color: var(--muted); font-size: .95rem; margin: .3rem 0 0; }
.w-video { margin: 0; border: 1px solid var(--border); border-radius: 14px; overflow: hidden; background: var(--surface); box-shadow: 0 10px 30px rgba(0,0,0,.10); }
.w-video video, .w-video .w-still { display: block; width: 100%; height: auto; }
.w-video .w-still { display: none; }
.w-video figcaption { padding: .45rem .8rem; color: var(--muted); font-size: .9rem; }
/* Reduced motion: the still frame instead of the moving tour. */
@media (prefers-reduced-motion: reduce) { .w-video video { display: none; } .w-video .w-still { display: block; } }
.w-steps { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; margin-top: 1.8rem; }
.w-step { display: grid; gap: .25rem; align-content: start; padding: .9rem 1rem; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.w-step b { font-size: 1.05rem; }
.w-step span { color: var(--muted); }
.w-free { margin: 1rem 0 0; color: var(--muted); }
@media (max-width: 860px) { .w-top { grid-template-columns: 1fr; gap: 1.2rem; } .w-steps { grid-template-columns: 1fr; } }

/* /account */
.notice { padding: .6rem .8rem; border-radius: 8px; background: var(--surface2); border: 1px solid var(--border); }
form.stack { display: grid; gap: .6rem; }
form.stack input { width: 100%; }
button.danger { background: var(--err-bg); color: var(--err-text); border-color: var(--err-border); font-weight: 600; }
body.narrow button.ghost[type="submit"] { background: transparent; color: var(--text); border-color: var(--border); font-weight: 600; }
body.narrow button.danger[type="submit"] { background: var(--err-bg); color: var(--err-text); border-color: var(--err-border); }
ul.connected { list-style: none; padding: 0; display: grid; gap: .4rem; }
ul.connected li { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
form.inline { display: inline; margin-left: auto; }
body.narrow form.inline button { width: auto; padding: .3rem .7rem; }

.pricing .table-wrap { max-width: 100%; }
.pr-table { width: 100%; }
@media (max-width: 600px) {
  .pr-table th, .pr-table td { padding: .45rem .5rem; font-size: .9rem; white-space: normal; }
  .pr-table td:first-child { width: 52%; }
}
