:root {
  /* Layout: an app, not a page. Top bar, step tabs, one workspace (source | wires | output) with a details column. */
  --bg: #F6F7F8;
  --panel: #FFFFFF;
  --fill: #F1F2F4;
  --line: #E2E5E9;
  --line-2: #C9CED5;
  --text: #15181C;
  --text-2: #59616B;
  --text-3: #858D97;
  --accent: #2459D3;
  --accent-soft: #E7EEFC;
  --a2a: #0B8A7A;
  --poppy: #DC4128;
  --amber: #A86400;
  --amber-soft: #FBF0D9;
  --ok: #1B8748;
  --cord: #A4ACB6;
  --str: #1D6B58;
  --lit: #9A5A12;
  --sans: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0E1013; --panel: #15171B; --fill: #1C1F24; --line: #262A31; --line-2: #383D46; --text: #E7E9EC; --text-2: #A2A9B3; --text-3: #737B86;
    --accent: #7AA2FF; --accent-soft: #1A2742; --a2a: #3FC4B0; --poppy: #FF6C54; --amber: #E2AC50; --amber-soft: #32270F; --ok: #4FC383; --cord: #555D68; --str: #7FCBB3; --lit: #E2B578;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0E1013; --panel: #15171B; --fill: #1C1F24; --line: #262A31; --line-2: #383D46; --text: #E7E9EC; --text-2: #A2A9B3; --text-3: #737B86;
  --accent: #7AA2FF; --accent-soft: #1A2742; --a2a: #3FC4B0; --poppy: #FF6C54; --amber: #E2AC50; --amber-soft: #32270F; --ok: #4FC383; --cord: #555D68; --str: #7FCBB3; --lit: #E2B578;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 400 13.5px/1.5 var(--sans); }
button, select, input, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
a { color: inherit; text-decoration-color: var(--line-2); text-underline-offset: 3px; }
a:hover { text-decoration-color: currentColor; }
code { font: 400 0.9em/1.3 var(--mono); background: var(--fill); border-radius: 4px; padding: 1px 4px; overflow-wrap: anywhere; }
h1, h2, h3, p { margin: 0; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- top bar ---------- */
.bar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px 20px; flex-wrap: wrap; padding: 9px 20px; background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; text-decoration: none; white-space: nowrap; }
.brand svg { display: block; }
.bar-links { display: flex; gap: 16px; margin-left: auto; font-size: 13px; color: var(--text-2); }
.bar-links a { text-decoration: none; white-space: nowrap; }
.bar-links a:hover { color: var(--text); }

.seg { display: inline-flex; background: var(--fill); border-radius: 8px; padding: 2px; gap: 2px; }
.seg-b { border: 0; background: transparent; border-radius: 6px; padding: 5px 11px; font-size: 13px; font-weight: 500; color: var(--text-2); cursor: pointer; white-space: nowrap; }
.seg-b:hover { color: var(--text); }
.seg-b[aria-checked="true"] { background: var(--panel); color: var(--text); box-shadow: 0 0 0 1px var(--line), 0 1px 2px rgba(0, 0, 0, 0.06); }
.seg.sm .seg-b { padding: 3px 9px; font-size: 12.5px; }

/* ---------- page head ---------- */
.page { max-width: 1480px; margin: 0 auto; padding: 22px 20px 48px; display: flex; flex-direction: column; gap: 14px; }
.head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 14px 32px; }
.head-text { min-width: 0; flex: 1 1 380px; }
.head h1 { font-size: 20px; font-weight: 600; letter-spacing: -0.01em; text-wrap: balance; }
.head p { color: var(--text-2); margin-top: 3px; max-width: 70ch; }
.flow { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 0; font-size: 12.5px; }
.flow .node { border: 1px solid var(--line-2); background: var(--panel); border-radius: 6px; padding: 4px 9px; font-weight: 500; white-space: nowrap; max-width: 260px; overflow: hidden; text-overflow: ellipsis; }
.flow .node.me { background: var(--text); color: var(--panel); border-color: var(--text); }
.flow .link { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); padding: 0 8px; white-space: nowrap; }
.flow .link::before, .flow .link::after { content: ""; width: 14px; height: 1px; background: var(--line-2); }
.flow .link i { width: 6px; height: 6px; border-radius: 50%; flex: none; }
.flow .link.p-a2a i, .proto.p-a2a i { background: var(--a2a); }
.flow .link.p-poppy i, .proto.p-poppy i { background: var(--poppy); }

/* ---------- steps ---------- */
.steps { display: flex; gap: 2px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.step { text-decoration: none; border: 0; background: transparent; padding: 8px 12px 9px; margin-bottom: -1px; border-bottom: 2px solid transparent; cursor: pointer; color: var(--text-2); font-weight: 500; display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.step i { font: 500 11px/18px var(--mono); font-style: normal; width: 18px; height: 18px; text-align: center; border-radius: 5px; background: var(--fill); color: var(--text-2); }
.step:hover { color: var(--text); }
.step[aria-selected="true"] { color: var(--text); border-bottom-color: var(--text); }
.step[aria-selected="true"] i { background: var(--text); color: var(--panel); }
.says { color: var(--text-2); max-width: 100ch; }
.says b { color: var(--text); font-weight: 500; }

/* ---------- toolbar, settings ---------- */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; }
.tb-label { color: var(--text-2); font-size: 13px; }
.tb-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.ctl { height: 30px; background: var(--panel); border: 1px solid var(--line-2); border-radius: 6px; padding: 0 9px; font-size: 13px; min-width: 0; }
select.ctl { padding-right: 4px; max-width: 320px; }
.ctl.url { width: 260px; font-family: var(--mono); font-size: 12px; }
.ctl::placeholder { color: var(--text-3); }
.btn { height: 30px; display: inline-flex; align-items: center; gap: 6px; background: var(--panel); border: 1px solid var(--line-2); border-radius: 6px; padding: 0 11px; font-size: 13px; font-weight: 500; cursor: pointer; white-space: nowrap; text-decoration: none; }
.btn:hover { background: var(--fill); }
.btn.primary { background: var(--text); border-color: var(--text); color: var(--panel); }
.btn.primary:hover { opacity: 0.88; background: var(--text); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--fill); color: var(--text); }
.btn.sm { height: 26px; padding: 0 8px; font-size: 12.5px; }
.btn[disabled] { opacity: 0.45; cursor: default; }
.btn[aria-expanded="true"] { background: var(--fill); color: var(--text); }
.settings { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: flex-end; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; }
.fld { display: grid; gap: 4px; min-width: 0; }
.fld > span { font-size: 12px; color: var(--text-2); }
.fld input[type="text"] { width: 240px; max-width: 100%; font-family: var(--mono); font-size: 12px; }
.chk { display: flex; align-items: center; gap: 7px; height: 30px; cursor: pointer; }
.chk input { width: 15px; height: 15px; accent-color: var(--text); margin: 0; }
.status { font-size: 13px; color: var(--text-2); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; }
.status.bad { border-color: var(--poppy); color: var(--text); }

/* ---------- workspace ---------- */
.work { display: grid; grid-template-columns: minmax(0, 1fr) 316px; gap: 16px; align-items: start; }
.stage { min-width: 0; }
.board-scroll { overflow-x: auto; }
.board { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) 96px minmax(0, 1fr); min-width: 860px; align-items: start; }
.pane { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; min-width: 0; }
.pane-r { grid-column: 3; }
.pane-head { display: flex; align-items: center; gap: 8px; padding: 7px 8px 7px 12px; border-bottom: 1px solid var(--line); min-height: 42px; }
.proto { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 500; color: var(--text-2); border: 1px solid var(--line); border-radius: 5px; padding: 1px 7px 1px 6px; white-space: nowrap; }
.proto i { width: 6px; height: 6px; border-radius: 50%; }
.proto, .pane-head h3, .pane-tools { flex: none; }
.pane-head h3 { font-size: 13.5px; font-weight: 600; white-space: nowrap; }
.pane-sub { flex: 1 1 0; color: var(--text-3); font-size: 12.5px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pane-tools { margin-left: auto; display: flex; align-items: center; gap: 2px; }
.tag { font-size: 11.5px; font-weight: 500; color: var(--amber); background: var(--amber-soft); border-radius: 4px; padding: 1px 6px; }
.files { display: flex; gap: 2px; padding: 0 8px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.file { border: 0; background: transparent; padding: 7px 8px 8px; margin-bottom: -1px; border-bottom: 2px solid transparent; font-size: 12.5px; color: var(--text-2); cursor: pointer; white-space: nowrap; }
.file:hover { color: var(--text); }
.file[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); font-weight: 500; }
.pane-note { padding: 9px 12px 0; color: var(--text-2); font-size: 12.5px; }

.pane-body { font: 400 12px/1.65 var(--mono); padding: 8px 0 12px; }
.row { position: relative; padding: 0 12px 0 calc(12px + var(--ind) * 1.7ch + 1.7ch); text-indent: -1.7ch; white-space: pre-wrap; overflow-wrap: anywhere; min-height: 1.65em; }
.row .k { color: var(--text); }
.row .p { color: var(--text-3); }
.row .s { color: var(--str); }
.row .n { color: var(--lit); }
.row.gap { min-height: 0; height: 6px; margin-bottom: 6px; border-bottom: 1px solid var(--line); }
.row.http { color: var(--text-2); }
.row.http .hm { color: var(--accent); font-weight: 500; }
.row.http .hk { color: var(--text); }
.row.mapped { cursor: pointer; }
.row.mapped:hover { background: var(--fill); }
.row.mapped.on { background: var(--accent-soft); }
.row.mapped:focus-visible { outline-offset: -2px; }
.board.focus .row:not(.on) { opacity: 0.45; }

.cords { position: absolute; left: 0; top: 0; pointer-events: none; overflow: visible; }
.cords .hit { fill: none; stroke: transparent; stroke-width: 10; pointer-events: stroke; cursor: pointer; }
.cords .cord { fill: none; stroke: var(--cord); stroke-width: 1.25; }
.cords .k-shape .cord { stroke-dasharray: 4 3; }
.cords .j { fill: var(--panel); stroke: var(--cord); stroke-width: 1.25; }
.cords .stub { fill: none; stroke-width: 1.25; }
.cords .k-adapter .stub { stroke: var(--amber); }
.cords .k-adapter .glyph { fill: var(--amber); stroke: none; }
.cords .k-lost .stub { stroke: var(--text-3); }
.cords .k-lost .glyph { fill: none; stroke: var(--text-3); stroke-width: 1.4; }
.cords .c.on .cord { stroke: var(--accent); stroke-width: 2; }
.cords .c.on .j { stroke: var(--accent); fill: var(--accent); }
.cords .c.on .stub, .cords .c.on .glyph { stroke-width: 2; }
.board.focus .cords .c:not(.on) { opacity: 0.25; }

.editor { display: grid; gap: 8px; padding: 10px; }
.editor textarea { width: 100%; min-height: 440px; resize: vertical; background: var(--fill); border: 1px solid var(--line); border-radius: 6px; padding: 10px; font: 400 12px/1.6 var(--mono); white-space: pre; overflow: auto; tab-size: 2; }
.editor-bar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.editor-msg { font-size: 12.5px; color: var(--text-2); flex: 1 1 180px; min-width: 0; overflow-wrap: anywhere; }
.editor-msg.bad { color: var(--poppy); }
.board.editing .pane-r { opacity: 0.5; }

/* ---------- table view ---------- */
.tablewrap { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; overflow-x: auto; }
.maptable { width: 100%; border-collapse: collapse; min-width: 720px; table-layout: fixed; }
.maptable th { text-align: left; font-size: 12px; font-weight: 500; color: var(--text-2); padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.maptable th:nth-child(1), .maptable th:nth-child(3) { width: 25%; }
.maptable th:nth-child(2) { width: 44px; }
.maptable td { padding: 8px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.maptable tr:last-child td { border-bottom: 0; }
.maptable tbody tr { cursor: pointer; }
.maptable tbody tr:hover { background: var(--fill); }
.maptable tbody tr.on { background: var(--accent-soft); }
.maptable .pth { font: 400 12px/1.5 var(--mono); overflow-wrap: anywhere; }
.maptable .pth.none { font: 400 12.5px/1.5 var(--sans); color: var(--text-3); }
.maptable .arr { color: var(--text-3); text-align: center; padding-left: 0; padding-right: 0; }
.maptable .arr svg { vertical-align: middle; }
.maptable .why { color: var(--text-2); }
.maptable .why small { color: var(--text-3); white-space: nowrap; font-size: 12px; }

/* ---------- side column ---------- */
.side { position: sticky; top: 62px; display: grid; gap: 12px; max-height: calc(100vh - 78px); overflow-y: auto; min-width: 0; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px 13px; min-width: 0; }
.card h2, .card summary { font-size: 12.5px; font-weight: 600; color: var(--text); }
.card summary { cursor: pointer; }
.card h2 + *, .card summary + * { margin-top: 9px; }
.kind { display: inline-block; font-size: 11.5px; font-weight: 500; border-radius: 4px; padding: 1px 6px; background: var(--fill); color: var(--text-2); white-space: nowrap; }
.kind.k-adapter { background: var(--amber-soft); color: var(--amber); }
.sel-paths { display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 3px 8px; margin: 9px 0; font-size: 12px; }
.sel-paths dt { color: var(--text-3); }
.sel-paths dd { margin: 0; font-family: var(--mono); overflow-wrap: anywhere; }
.sel-paths dd.none { font-family: var(--sans); color: var(--text-3); }
.sel-note { color: var(--text); }
.sel-ref { color: var(--text-3); font-size: 12px; margin-top: 6px; }
.pager { display: flex; align-items: center; gap: 6px; margin-top: 9px; color: var(--text-2); font-size: 12px; }
.hint { color: var(--text-2); }
.legend { list-style: none; margin: 0; padding: 0; display: grid; gap: 5px; }
.legend li { display: grid; grid-template-columns: 30px minmax(0, 1fr) auto; align-items: center; gap: 8px; color: var(--text-2); }
.legend b { font-weight: 500; color: var(--text); font-variant-numeric: tabular-nums; }
.legend svg { display: block; margin: 0 auto; }
.checks, .todo { list-style: none; margin: 0; padding: 0; display: grid; gap: 9px; }
.checks li { display: grid; grid-template-columns: 14px minmax(0, 1fr); gap: 8px; align-items: baseline; color: var(--text-2); }
.checks .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--line-2); transform: translateY(-1px); justify-self: center; }
.checks .must .dot { background: var(--amber); }
.checks .must { color: var(--text); }
.checks .ok .dot { background: var(--ok); }
.todo { color: var(--text-2); padding-left: 16px; list-style: disc; gap: 7px; }

/* ---------- about, footer ---------- */
.about { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 32px; border-top: 1px solid var(--line); padding-top: 18px; margin-top: 8px; }
.about h2 { font-size: 13.5px; font-weight: 600; margin-bottom: 3px; }
.about p { color: var(--text-2); max-width: 64ch; }
.foot { color: var(--text-3); font-size: 12.5px; display: grid; gap: 3px; max-width: 110ch; }

/* live sandbox */
.live { display: grid; gap: 12px; }
.live[hidden], .work[hidden], .toolbar[hidden] { display: none; }
.live-form { display: flex; gap: 8px; flex-wrap: wrap; }
.live-form .ctl { flex: 1 1 280px; height: 34px; }
.live-form .btn { height: 34px; }
.live-tries { display: flex; gap: 6px; flex-wrap: wrap; }
.live-conv { color: var(--text-2); font-size: 13px; }
.live-empty { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px; display: grid; gap: 8px; color: var(--text-2); max-width: 96ch; }
.live-empty b { color: var(--text); font-weight: 600; }
.turn { display: grid; gap: 8px; padding-top: 6px; }
.turn + .turn { border-top: 1px solid var(--line); padding-top: 16px; margin-top: 6px; }
.turn-q { font-weight: 500; }
.turn-q::before { content: "You: "; color: var(--text-3); font-weight: 400; }
.xgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; align-items: start; }
.xchg .http .h { overflow-wrap: anywhere; }
.xchg .pane-body { max-height: 340px; overflow: auto; }
.jwt { border-bottom: 1px solid var(--line); }
.jwt > summary { cursor: pointer; padding: 7px 12px; font-size: 12.5px; color: var(--text-2); }
.jwt > summary:hover { color: var(--text); }
.jwt[open] > summary { border-bottom: 1px solid var(--line); }

/* download menu */
.menu { position: relative; }
.menu > summary { list-style: none; }
.menu > summary::-webkit-details-marker { display: none; }
.menu[open] > summary { background: var(--fill); color: var(--text); }
.menu-list { position: absolute; right: 0; top: calc(100% + 4px); z-index: 30; min-width: 250px; display: grid; background: var(--panel); border: 1px solid var(--line-2); border-radius: 8px; padding: 4px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12); }
.menu-item { display: flex; justify-content: space-between; align-items: baseline; gap: 14px; text-align: left; background: transparent; border: 0; border-radius: 5px; padding: 7px 9px; font: inherit; font-size: 13px; color: var(--text); cursor: pointer; }
.menu-item:hover, .menu-item:focus-visible { background: var(--fill); }
.menu-item small { color: var(--text-3); font: 400 11.5px/1 var(--mono); }
.trip-key { padding: 0; margin: 0; }

/* round trip */
.trip-head { padding: 14px 14px 12px; border-bottom: 1px solid var(--line); display: grid; gap: 10px; }
.trip-sum { max-width: 86ch; color: var(--text-2); }
.trip-sum b { color: var(--text); font-weight: 600; }
.trip-bar { display: flex; height: 8px; border-radius: 4px; overflow: hidden; background: var(--fill); gap: 2px; }
.trip-bar span { display: block; min-width: 0; }
.tb-same { background: var(--a2a); }
.tb-changed { background: var(--amber); }
.tb-gone { background: var(--text-3); }
.trip-key { list-style: none; display: flex; gap: 6px 18px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-2); }
.trip-key i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 6px; }
.triptable tbody tr { cursor: default; }
.triptable th:nth-child(1) { width: 24%; }
.triptable th:nth-child(3), .triptable th:nth-child(4) { width: 19%; }
.triptable .val { font: 400 12px/1.5 var(--mono); overflow-wrap: anywhere; color: var(--text); }
.triptable .val.none { font: 400 12.5px/1.5 var(--sans); color: var(--text-3); }
.triptable tr.t-same .pth, .triptable tr.t-same .val { color: var(--text-3); }

.view .narrow { display: none; }

@media (max-width: 1080px) {
  .work { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; max-height: none; overflow: visible; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); align-items: start; }
}
@media (max-width: 700px) {
  .maptable { min-width: 0; table-layout: auto; }
  .maptable thead { display: none; }
  .maptable tbody tr { display: grid; grid-template-columns: minmax(0, 1fr) 30px minmax(0, 1fr); border-bottom: 1px solid var(--line); }
  .maptable tbody tr:last-child { border-bottom: 0; }
  .maptable td { border-bottom: 0; padding: 8px 10px; }
  .maptable td.why { grid-column: 1 / -1; padding-top: 0; }
  .triptable tbody tr { grid-template-columns: 30px minmax(0, 1fr) minmax(0, 1fr); }
  .triptable td.pth { grid-column: 2 / -1; grid-row: 1; padding-bottom: 0; }
  .triptable td.arr { grid-column: 1; grid-row: 1; }
  .triptable td.val { grid-row: 2; padding-top: 2px; }
  .triptable td.val:nth-child(3) { grid-column: 1 / 3; }
  .triptable td.val:nth-child(4) { grid-column: 3; }
  .bar { padding: 9px 16px; position: static; }
  .xgrid { grid-template-columns: minmax(0, 1fr); }
  .board { grid-template-columns: minmax(0, 1fr); min-width: 0; gap: 12px; }
  .pane-r { grid-column: 1; }
  .cords { display: none; }
  .steps { scrollbar-width: none; -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent); }
  .view .wide { display: none; }
  .view .narrow { display: inline; }
  .toolbar .ctl { max-width: 100%; }
  .bar-links { margin-left: 0; width: 100%; order: 3; }
  .page { padding: 16px 16px 40px; }
  .about { grid-template-columns: minmax(0, 1fr); }
  .tb-right { margin-left: 0; }
  .ctl.url { width: 100%; flex: 1 1 200px; }
  .fld, .fld input[type="text"] { width: 100%; }
  .flow .node { max-width: 100%; }
}
