:root {
  --bg: #f6f7f9;
  --canvas: #fbfbfc;
  --surface: #ffffff;
  --surface-2: #f3f4f6;
  --border: #e4e6ea;
  --border-strong: #cfd3da;
  --text: #16181d;
  --muted: #646b78;
  --faint: #9aa0aa;
  --accent: #4f5bd5;
  --accent-soft: #eef0ff;
  --good: #1f9d55;
  --good-soft: #e8f6ee;
  --warn: #b7791f;
  --warn-soft: #fdf5e6;
  --bad: #d64545;
  --bad-soft: #fdeeee;
  --edge: #b9c0cc;
  --mono: "JetBrains Mono", "Cascadia Code", "SF Mono", Consolas, monospace;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 4px 14px rgba(16, 24, 40, .06);
  color-scheme: light;
  font-family: "Inter", "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c0d10; --canvas: #0f1014; --surface: #16171c; --surface-2: #1c1e24; --border: #26282f; --border-strong: #353841;
    --text: #e8e9ec; --muted: #9298a3; --faint: #626773; --accent: #8b94ff; --accent-soft: rgba(139,148,255,.12);
    --good: #4cc38a; --good-soft: rgba(76,195,138,.12); --warn: #e2b155; --warn-soft: rgba(226,177,85,.12); --bad: #f07272; --bad-soft: rgba(240,114,114,.12);
    --accent-solid: #5e6ad2; --edge: #454a55; --shadow: 0 1px 2px rgba(0,0,0,.4), 0 6px 18px rgba(0,0,0,.35); color-scheme: dark;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
@media (min-width: 1001px) { html, body { overflow: hidden; } }
html, body { margin: 0; height: 100%; }
body { display: flex; flex-direction: column; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
code { font-family: var(--mono); font-size: 12px; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* top bar */
.topbar { height: 52px; flex-shrink: 0; display: flex; align-items: center; gap: 12px; padding: 0 16px; background: var(--surface); border-bottom: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 650; font-size: 15px; color: var(--text); text-decoration: none; }
.brand svg { color: var(--accent); }
.tagline { color: var(--faint); font-size: 13px; padding-left: 12px; border-left: 1px solid var(--border); }
.top-actions { margin-left: auto; display: flex; gap: 6px; align-items: center; }

.btn { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: 7px; border: 1px solid var(--border-strong); background: var(--surface); font-size: 13px; font-weight: 500; text-decoration: none; color: var(--text); white-space: nowrap; }
.btn:hover { background: var(--surface-2); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.primary { background: var(--accent-solid, var(--accent)); border-color: transparent; color: #fff; }
.btn.primary:hover { filter: brightness(1.07); }
.btn.small { height: 28px; padding: 0 10px; font-size: 12.5px; }
select { height: 32px; border-radius: 7px; border: 1px solid var(--border-strong); background: var(--surface); padding: 0 8px; font-size: 13px; }
.icon-btn { width: 28px; height: 28px; display: inline-grid; place-items: center; border: 0; border-radius: 6px; background: transparent; color: var(--muted); flex-shrink: 0; }
.icon-btn:hover:not(:disabled) { background: var(--bad-soft); color: var(--bad); }
.icon-btn:disabled { opacity: .35; cursor: default; }
.link { border: 0; background: none; color: var(--accent); font-weight: 500; padding: 0; margin-left: auto; }

/* layout */
.app { flex: 1; min-height: 0; display: grid; grid-template-rows: minmax(300px, 52%) minmax(0, 1fr); }

/* diagram */
.canvas { position: relative; background: var(--canvas); background-image: radial-gradient(circle, var(--border) 1px, transparent 1.3px); background-size: 20px 20px; border-bottom: 1px solid var(--border); overflow: auto; }
.lanes { position: absolute; inset: 12px 0 auto; display: grid; grid-template-columns: 1fr 1fr 1fr; text-align: center; font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--faint); pointer-events: none; }
.stage { position: relative; min-height: 100%; display: grid; grid-template-columns: 1fr 1fr 1fr; align-items: center; gap: 0 72px; padding: 44px 48px 24px; min-width: 900px; }
.edges { position: absolute; inset: 0; pointer-events: none; overflow: visible; }
.col { display: flex; flex-direction: column; gap: 12px; position: relative; z-index: 1; align-items: stretch; max-width: 300px; width: 100%; justify-self: center; }
.col.center { max-width: 300px; }

.node { position: relative; display: flex; flex-direction: column; gap: 3px; text-align: left; width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); box-shadow: var(--shadow); transition: border-color .12s, box-shadow .12s, transform .12s; }
.node:hover { border-color: var(--border-strong); transform: translateY(-1px); }
.node.selected { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow); }
.node-head { display: flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.node-head svg { color: var(--faint); }
.node strong { font-size: 15px; font-weight: 600; letter-spacing: -.01em; overflow-wrap: anywhere; }
.node small { font-size: 12px; color: var(--muted); }
.node.off { background: transparent; border-style: dashed; box-shadow: none; }
.node.off strong { color: var(--muted); }
.edit-hint { margin-left: auto; display: inline-flex; align-items: center; gap: 4px; font-weight: 500; text-transform: none; letter-spacing: 0; color: var(--faint); opacity: 0; transition: opacity .12s; }
.node:hover .edit-hint, .node.selected .edit-hint { opacity: 1; }

.node.service { padding: 16px 16px 14px; border-width: 1.5px; border-color: var(--border-strong); }
.node.service .service-name { font-size: 20px; }
.node.service .node-head svg { color: var(--accent); }
.chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.chip { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; padding: 3px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.chip-good { background: var(--good-soft); color: var(--good); border-color: transparent; }

.node.version .pct { margin-left: auto; font-size: 15px; font-weight: 700; color: var(--accent); text-transform: none; letter-spacing: 0; }
.node.version.idle { opacity: .6; }
.bar { height: 4px; border-radius: 2px; background: var(--surface-2); overflow: hidden; margin-top: 6px; }
.bar > span { display: block; height: 100%; background: var(--accent); border-radius: 2px; transition: width .2s; }
.node.rules .rule-line { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text); margin-top: 3px; }
.rule-line .arrow { color: var(--faint); }
.tag { font-family: var(--mono); font-size: 11.5px; padding: 1px 6px; border-radius: 5px; background: var(--accent-soft); color: var(--accent); }
.node.add { flex-direction: row; align-items: center; justify-content: center; gap: 6px; padding: 9px; border-style: dashed; background: transparent; box-shadow: none; color: var(--muted); font-size: 13px; font-weight: 500; }
.node.add:hover { color: var(--accent); border-color: var(--accent); }

.edge { fill: none; stroke: var(--edge); stroke-width: 2; }
.edge.allowed { stroke: var(--good); }
.edge.limited { stroke: var(--warn); }
.edge.rule { stroke: var(--accent); stroke-dasharray: 4 4; }
.edge.blocked { stroke: var(--bad); stroke-dasharray: 5 5; opacity: .7; }
.edge.off { stroke-dasharray: 4 5; }
.edge-flow { fill: none; stroke-width: 2.5; stroke-dasharray: 2 18; stroke-linecap: round; animation: flow 1.4s linear infinite; }
.edge-flow.allowed { stroke: var(--good); } .edge-flow.limited { stroke: var(--warn); } .edge-flow.blocked { display: none; }
@keyframes flow { to { stroke-dashoffset: -40; } }
@media (prefers-reduced-motion: reduce) { .edge-flow { animation: none; display: none; } }
.port { fill: var(--surface); stroke: var(--edge); stroke-width: 2; }
.port.allowed { stroke: var(--good); } .port.limited { stroke: var(--warn); } .port.blocked { stroke: var(--bad); } .port.rule { stroke: var(--accent); }
.blocked-mark circle { fill: var(--surface); stroke: var(--bad); stroke-width: 1.5; }
.blocked-mark path { stroke: var(--bad); stroke-width: 2; stroke-linecap: round; }
.edge-label rect { fill: var(--surface); stroke: var(--border-strong); }
.edge-label text { font-size: 11px; font-weight: 600; fill: var(--text); font-family: inherit; }

/* bottom */
.bottom { min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 400px; }
.yaml-pane { min-width: 0; min-height: 0; display: flex; flex-direction: column; background: var(--surface); border-right: 1px solid var(--border); }
.pane-bar { display: flex; align-items: center; gap: 10px; padding: 8px 12px 8px 16px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.pane-title { display: flex; align-items: center; gap: 10px; min-width: 0; }
.kinds { display: flex; gap: 4px; flex-wrap: wrap; }
.kind { font-size: 11.5px; padding: 2px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-weight: 500; }
.kind.muted { background: var(--surface-2); color: var(--faint); }
.pane-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.pane-actions select { height: 28px; font-size: 12.5px; }
#yaml-status { display: flex; gap: 6px; }
.status { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 500; padding: 3px 8px; border-radius: 999px; }
.status.ok { color: var(--good); background: var(--good-soft); }
.status.warn { color: var(--warn); background: var(--warn-soft); }
.status.bad { color: var(--bad); background: var(--bad-soft); max-width: 420px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.editor { flex: 1; min-height: 0; overflow: hidden; display: flex; }
.editor .cm-editor { flex: 1; min-width: 0; height: 100%; font-size: 12.5px; background: var(--surface); color: var(--text); }
.editor .cm-editor.cm-focused { outline: none; }
.editor .cm-scroller { font-family: var(--mono); line-height: 1.6; }
.editor .cm-content { padding: 10px 0; caret-color: var(--accent); }
.editor .cm-gutters { background: var(--surface); border-right: 0; color: var(--faint); }
.editor .cm-lineNumbers .cm-gutterElement { padding: 0 6px 0 14px; min-width: 38px; }
.editor .cm-activeLine { background: transparent; }
.editor .cm-focused .cm-activeLine { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
.editor .cm-activeLineGutter { background: transparent; color: var(--muted); }
.editor .cm-selectionBackground, .editor .cm-focused .cm-selectionBackground, .editor ::selection { background: color-mix(in srgb, var(--accent) 22%, transparent) !important; }
.editor .cm-linked { background: color-mix(in srgb, var(--accent) 9%, transparent); box-shadow: inset 3px 0 0 var(--accent); }
.editor .cm-lint-marker-error { content: none; }
.editor .cm-diagnostic-error { border-left-color: var(--bad); }
.editor .cm-lintRange-error { background-image: none; text-decoration: underline wavy var(--bad); text-underline-offset: 3px; }
.editor .cm-tooltip { background: var(--surface); border: 1px solid var(--border-strong); border-radius: 8px; box-shadow: var(--shadow); color: var(--text); font-family: inherit; }
.editor .cm-foldGutter .cm-gutterElement { color: var(--faint); padding: 0 4px; }
.tok-propertyName, .tok-definition { color: #3b4cc0; }
.tok-string { color: #0f7a4f; }
.tok-number, .tok-bool, .tok-atom { color: #b5541b; }
.tok-comment { color: var(--faint); font-style: italic; }
.tok-punctuation, .tok-separator, .tok-meta { color: var(--faint); }
.tok-keyword { color: #8a3fb8; }
@media (prefers-color-scheme: dark) {
  .tok-propertyName, .tok-definition { color: #9aa6ff; }
  .tok-string { color: #6fd3a0; }
  .tok-number, .tok-bool, .tok-atom { color: #f0a56b; }
  .tok-keyword { color: #d19af0; }
}

/* side panel */
.panel { min-height: 0; overflow: auto; background: var(--surface); }
.panel-top { position: sticky; top: 0; z-index: 1; padding: 8px 12px; background: var(--surface); border-bottom: 1px solid var(--border); }
.panel-body { padding: 16px 20px 28px; }
.panel h3 { display: flex; align-items: center; gap: 8px; margin: 0 0 6px; font-size: 15px; font-weight: 600; }
.panel h3 svg { color: var(--accent); }
.panel h4 { margin: 20px 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.lead { margin: 0 0 14px; color: var(--muted); font-size: 13px; line-height: 1.5; }
.field { display: flex; flex-direction: column; gap: 5px; margin: 0 0 12px; font-size: 12.5px; font-weight: 500; color: var(--muted); }
.field input, .field textarea, .rule-row input, .rule-row select, .version-row input[type=text], .vpct input { height: 32px; padding: 0 10px; border-radius: 7px; border: 1px solid var(--border-strong); background: var(--surface); font-size: 13px; color: var(--text); font-weight: 400; min-width: 0; }
.field textarea { height: auto; padding: 8px 10px; font-family: var(--mono); font-size: 12.5px; resize: vertical; }
.field input:focus, .field textarea:focus, .rule-row input:focus, .rule-row select:focus, .version-row input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field small { font-weight: 400; color: var(--faint); font-size: 11.5px; line-height: 1.45; }
.grid2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 10px; }
.field input, .field textarea { width: 100%; }
.hint-inline { font-size: 12px; color: var(--muted); margin: -4px 0 4px; line-height: 1.6; }

.toggle { display: flex; align-items: flex-start; gap: 10px; margin: 4px 0 14px; cursor: pointer; font-size: 13px; }
.toggle input { position: absolute; opacity: 0; }
.toggle .switch { flex-shrink: 0; width: 34px; height: 20px; border-radius: 999px; background: var(--border-strong); position: relative; transition: background .15s; margin-top: 1px; }
.toggle .switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .15s; }
.toggle input:checked + .switch { background: var(--accent); }
.toggle input:checked + .switch::after { transform: translateX(14px); }
.toggle input:focus-visible + .switch { outline: 2px solid var(--accent); outline-offset: 2px; }
.toggle small, .option small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; font-weight: 400; }

.options { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.option { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--border); border-radius: 9px; cursor: pointer; font-size: 13px; }
.option:hover { border-color: var(--border-strong); }
.option.chosen { border-color: var(--accent); background: var(--accent-soft); }
.option input { margin: 2px 0 0; accent-color: var(--accent); }
.options.compact .option { padding: 8px 12px; }

.version-list { display: flex; flex-direction: column; gap: 8px; }
.version-row { display: grid; grid-template-columns: 70px minmax(0, 1fr) 72px 28px; align-items: center; gap: 8px; }
.vrange { accent-color: var(--accent); width: 100%; }
.vpct { display: flex; align-items: center; gap: 3px; color: var(--muted); font-size: 12.5px; }
.vpct input { width: 54px; padding: 0 6px; text-align: right; }
.row-actions { display: flex; align-items: center; gap: 6px; margin: 12px 0 4px; }
.total { margin-left: auto; font-size: 12.5px; font-weight: 600; }
.total.ok { color: var(--good); } .total.bad { color: var(--bad); }
.rule-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 10px; border: 1px solid var(--border); border-radius: 9px; margin-bottom: 8px; }
.rule-row input { flex: 1 1 90px; }
.rule-row select { height: 32px; }
.rule-row .arrow { color: var(--faint); }
.empty { color: var(--faint); font-size: 13px; }

.creates { display: flex; align-items: flex-start; line-height: 1.5; gap: 6px; margin: 16px 0 0; padding-top: 12px; border-top: 1px solid var(--border); font-size: 12px; color: var(--muted); }
.creates svg { color: var(--accent); flex-shrink: 0; }
.note { display: flex; gap: 6px; font-size: 12px; color: var(--muted); line-height: 1.5; margin: 10px 0 0; }
.note svg { flex-shrink: 0; margin-top: 2px; }
.summary { margin: 8px 0 16px; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 9px; }
.summary li { position: relative; padding-left: 16px; font-size: 13px; line-height: 1.5; color: var(--text); }
.summary li::before { content: ""; position: absolute; left: 2px; top: 8px; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.summary b { font-weight: 600; }
.tip { display: flex; gap: 6px; font-size: 12.5px; color: var(--muted); background: var(--surface-2); padding: 10px 12px; border-radius: 9px; line-height: 1.5; margin: 0; }
.tip svg { flex-shrink: 0; margin-top: 2px; }
.issues { margin-top: 16px; display: flex; flex-direction: column; gap: 6px; }
.issues p { display: flex; align-items: flex-start; gap: 7px; margin: 0; padding: 8px 10px; border-radius: 8px; background: var(--warn-soft); color: var(--warn); font-size: 12.5px; line-height: 1.45; }
.issues p svg { flex-shrink: 0; margin-top: 1px; }
.issues p span { color: var(--text); }

#toast { position: fixed; bottom: 20px; left: 50%; transform: translate(-50%, 10px); opacity: 0; pointer-events: none; background: var(--text); color: var(--surface); padding: 8px 14px; border-radius: 8px; font-size: 13px; transition: opacity .15s, transform .15s; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 1000px) {
  .bottom { grid-template-columns: 1fr; grid-template-rows: auto minmax(260px, 1fr); }
  .panel { order: -1; border-bottom: 1px solid var(--border); max-height: 50vh; }
  .app { grid-template-rows: auto auto; overflow: auto; }
  body { height: auto; min-height: 100%; }
  .canvas { min-height: 420px; }
  .tagline { display: none; }
}
@media (max-width: 760px) {
  html, body { overflow-x: hidden; }
  .topbar { height: auto; flex-wrap: wrap; padding: 8px 12px; row-gap: 6px; }
  .top-actions { margin-left: 0; width: 100%; }
  .top-actions select { flex: 1; min-width: 0; }
  .lanes, .edges { display: none; }
  .stage { min-width: 0; grid-template-columns: 1fr; gap: 10px; padding: 16px; }
  .col, .col.center { max-width: none; }
  .col::before { display: block; font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--faint); margin: 6px 0 -2px; }
  #callers::before { content: "Who sends traffic"; }
  .col.center::before { content: "↓  Your service"; }
  #destinations::before { content: "↓  Where it goes"; }
  .canvas { min-height: 0; }
  .pane-bar { padding: 8px 12px; }
  .pane-actions { margin-left: 0; width: 100%; flex-wrap: wrap; }
}

/* ---------- round 2: header, history, segmented control ---------- */
.history-buttons { display: flex; gap: 2px; margin-left: 6px; padding-left: 10px; border-left: 1px solid var(--border); }
.icon-btn.plain:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.btn.accent-outline { border-color: color-mix(in srgb, var(--accent) 45%, transparent); color: var(--accent); background: var(--accent-soft); }
.btn.accent-outline:hover { background: color-mix(in srgb, var(--accent) 16%, transparent); }
.btn.wide { width: 100%; justify-content: center; margin: 2px 0 6px; }
.seg { display: inline-flex; padding: 2px; gap: 2px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--border); }
.seg button { height: 24px; padding: 0 9px; border: 0; border-radius: 6px; background: transparent; font-size: 12px; font-weight: 500; color: var(--muted); }
.seg button[aria-checked="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.12), 0 0 0 1px var(--border); }
.status.muted { color: var(--faint); background: var(--surface-2); }
.status { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- diagram additions ---------- */
.col-divider { display: flex; align-items: center; gap: 8px; margin: 6px 0 -2px; font-size: 10.5px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--faint); }
.col-divider::before, .col-divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.node.external .node-head svg { color: #8a5cf6; }
.node .muted { color: var(--faint); }
.chip-accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.chip-warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.chip-muted { opacity: .55; text-decoration: line-through; }
.node.linked { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow); }
.edge.external { stroke: #8a5cf6; stroke-dasharray: 3 4; opacity: .8; }
.edge-flow.external { stroke: #8a5cf6; }
.port.external { stroke: #8a5cf6; }
.edge.trace { stroke: var(--accent); stroke-width: 3; }
.edge-flow.trace { stroke: var(--accent); stroke-width: 3.5; animation-duration: .9s; }
.edge.dim { stroke: var(--edge); opacity: .35; stroke-dasharray: none; }
.port.trace { stroke: var(--accent); } .port.dim { opacity: .35; }
.edge-label.trace rect { stroke: var(--accent); fill: var(--accent-soft); }
.tracing .node.trace-dim { opacity: .38; }
.tracing .node.trace-on { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow); }
.tracing .node.trace-blocked { border-color: var(--bad); box-shadow: 0 0 0 3px var(--bad-soft), var(--shadow); }
.trace-banner { position: sticky; left: 0; bottom: 12px; margin: 0 auto 12px; width: fit-content; max-width: calc(100% - 32px); display: flex; align-items: center; gap: 7px; padding: 8px 14px; border-radius: 999px; font-size: 13px; font-weight: 500; box-shadow: var(--shadow); z-index: 2; }
.trace-banner.allowed { background: var(--accent); color: #fff; }
.trace-banner.blocked { background: var(--bad); color: #fff; }

/* ---------- panel additions ---------- */
.ext-row { display: grid; grid-template-columns: minmax(0, 1fr) 76px 84px 28px; gap: 6px; align-items: center; margin-bottom: 8px; }
.ext-row input, .ext-row select { height: 32px; padding: 0 8px; border-radius: 7px; border: 1px solid var(--border-strong); background: var(--surface); font-size: 13px; min-width: 0; }
.ext-row input:focus, .ext-row select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.options.two { flex-direction: row; } .options.two .option { flex: 1; }
.check { display: flex; gap: 8px; align-items: flex-start; font-size: 12.5px; color: var(--muted); margin: -4px 0 12px; }
.check input { accent-color: var(--accent); margin-top: 2px; }
.panel h4 { display: flex; align-items: center; gap: 6px; }
.issues p.err { background: var(--warn-soft); color: var(--warn); }
.issues p.info { background: var(--accent-soft); color: var(--accent); }
.notice { display: flex; gap: 8px; padding: 10px 12px; margin-bottom: 16px; border-radius: 9px; background: var(--warn-soft); color: var(--warn); font-size: 12.5px; }
.notice svg { flex-shrink: 0; margin-top: 2px; }
.notice b { color: var(--text); font-weight: 600; }
.notice ul { margin: 6px 0; padding-left: 16px; color: var(--text); line-height: 1.5; }
.notice .link { margin: 0; }
.steps { margin: 0 0 16px; padding: 0; list-style: none; counter-reset: step; display: flex; flex-direction: column; gap: 10px; }
.steps li { counter-increment: step; position: relative; padding-left: 26px; font-size: 12.5px; color: var(--muted); }
.steps li::before { content: counter(step); position: absolute; left: 0; top: 0; width: 18px; height: 18px; border-radius: 50%; background: var(--surface-2); color: var(--muted); font-size: 11px; font-weight: 600; display: grid; place-items: center; }
.cmd { display: flex; align-items: center; gap: 4px; margin-top: 4px; padding: 4px 4px 4px 9px; border-radius: 7px; font-size: 11.5px; background: var(--surface-2); color: var(--text); }
.cmd span { flex: 1; overflow-x: auto; white-space: nowrap; scrollbar-width: none; }
.cmd .icon-btn { width: 24px; height: 24px; }
.result { margin-top: 8px; border-radius: 10px; border: 1px solid; overflow: hidden; }
.result.allowed { border-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.result.blocked { border-color: color-mix(in srgb, var(--bad) 45%, transparent); }
.result-head { display: flex; align-items: center; gap: 7px; padding: 9px 12px; font-weight: 600; font-size: 13px; }
.result.allowed .result-head { background: var(--accent-soft); color: var(--accent); }
.result.blocked .result-head { background: var(--bad-soft); color: var(--bad); }
.result ol { margin: 0; padding: 10px 12px 12px 30px; display: flex; flex-direction: column; gap: 6px; }
.result li { font-size: 12.5px; line-height: 1.45; }
.result li.ok::marker { color: var(--good); } .result li.bad::marker { color: var(--bad); }
.result li.bad { color: var(--bad); }
.link-step { all: unset; cursor: pointer; }
.link-step:hover { text-decoration: underline; text-underline-offset: 2px; }

/* ---------- import dialog & drop ---------- */
dialog { border: 0; border-radius: 14px; padding: 0; width: min(640px, calc(100vw - 32px)); background: var(--surface); color: var(--text); box-shadow: 0 24px 64px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(10, 12, 18, .45); backdrop-filter: blur(2px); }
.dialog-body { padding: 20px 22px; display: flex; flex-direction: column; gap: 10px; }
.dialog-body h2 { margin: 0; font-size: 17px; }
.dialog-body .lead { margin: 0; }
#import-text { width: 100%; min-height: 220px; padding: 10px 12px; border-radius: 9px; border: 1px solid var(--border-strong); background: var(--canvas); font-family: var(--mono); font-size: 12.5px; resize: vertical; color: var(--text); }
#import-text:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.import-error { margin: 0; padding: 8px 10px; border-radius: 8px; background: var(--bad-soft); color: var(--bad); font-size: 12.5px; }
.dialog-actions { display: flex; align-items: center; gap: 6px; margin-top: 4px; }
.dialog-actions .spacer { flex: 1; }
.file-btn { position: relative; cursor: pointer; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.drop-overlay { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; background: color-mix(in srgb, var(--accent) 14%, transparent); backdrop-filter: blur(2px); pointer-events: none; }
.drop-overlay div { padding: 18px 26px; border-radius: 14px; border: 2px dashed var(--accent); background: var(--surface); color: var(--accent); font-weight: 600; }

@media (max-width: 1180px) { .tagline { display: none; } .top-actions .btn { padding: 0 9px; } }
@media (max-width: 760px) {
  .history-buttons { margin-left: auto; border: 0; }
  .top-actions { flex-wrap: wrap; }
  .top-actions .accent-outline { order: -1; width: 100%; justify-content: center; }
  .col-divider { margin-top: 8px; }
  .trace-banner { position: static; margin: 0 16px 16px; }
  .seg { order: 5; }
}
