:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --panel-2: #f1f3f6;
  --border: #dde1e7;
  --text: #1c2430;
  --muted: #637083;
  --accent: #1f6feb;
  --accent-text: #ffffff;
  --accent-soft: #e6effd;
  --focus: #1f6feb;
  --danger: #c93c37;
  --canvas-bg: #fbfbfc;
  --grid: #e9ecf1;
  --node-bg: #ffffff;
  --node-border: #c9d0da;
  --row-alt: #f5f7fa;
  --head-T: #2f5fb3;
  --head-V: #0b6b63;
  --head-P: #6a45b8;
  --head-X: #5b6573;
  --head-text: #ffffff;
  --head-subtext: rgba(255, 255, 255, 0.82);
  --pk: #8a5a12;
  --fk: #2f5fb3;
  --edge-fk: #75829a;
  --edge-lin: #8a63cf;
  --tag-inf: #6b45b5;
  --edge-hover: #1f6feb;
  --select: #f0a000;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.08);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, 0.18);
  --radius: 8px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1318; --panel: #161b22; --panel-2: #1c232c; --border: #2b333e; --text: #e3e8ef; --muted: #93a0b2;
    --accent: #4c8dff; --accent-text: #0b1220; --accent-soft: #1b2a44; --focus: #6ea2ff; --danger: #ff7b72;
    --canvas-bg: #11161c; --grid: #1a2029; --node-bg: #1a2029; --node-border: #34404e; --row-alt: #1f2631;
    --head-T: #2b5aa8; --head-V: #0d6e66; --head-P: #5e3ea6; --head-X: #56606e;
    --pk: #e3b341; --fk: #79a8ff; --edge-fk: #6e7c92; --edge-lin: #a88be6; --tag-inf: #c2a8f5; --edge-hover: #79a8ff; --select: #f2b632;
    --shadow: 0 1px 2px rgba(0,0,0,.4); --shadow-lg: 0 12px 32px rgba(0,0,0,.55);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1318; --panel: #161b22; --panel-2: #1c232c; --border: #2b333e; --text: #e3e8ef; --muted: #93a0b2;
  --accent: #4c8dff; --accent-text: #0b1220; --accent-soft: #1b2a44; --focus: #6ea2ff; --danger: #ff7b72;
  --canvas-bg: #11161c; --grid: #1a2029; --node-bg: #1a2029; --node-border: #34404e; --row-alt: #1f2631;
  --head-T: #2b5aa8; --head-V: #0d6e66; --head-P: #5e3ea6; --head-X: #56606e;
  --pk: #e3b341; --fk: #79a8ff; --edge-fk: #6e7c92; --edge-lin: #a88be6; --tag-inf: #c2a8f5; --edge-hover: #79a8ff; --select: #f2b632;
  --shadow: 0 1px 2px rgba(0,0,0,.4); --shadow-lg: 0 12px 32px rgba(0,0,0,.55);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 var(--sans);
  display: grid; grid-template-rows: auto 1fr auto; overflow: hidden;
}
a { color: var(--accent); }
code, pre, .mono { font-family: var(--mono); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; gap: 16px; padding: 8px 16px; background: var(--panel);
  border-bottom: 1px solid var(--border); min-width: 0;
}
.brand { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }
.brand-mark rect { fill: var(--accent); opacity: .9; }
.brand-mark path { stroke: var(--accent); stroke-width: 2; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-title { font-weight: 650; font-size: 15px; white-space: nowrap; }
.brand-sub { font-size: 12px; color: var(--muted); white-space: nowrap; }
.search { flex: 1 1 auto; display: flex; align-items: center; gap: 8px; max-width: 820px; position: relative; min-width: 0; }
.search-icon { position: absolute; left: 10px; color: var(--muted); pointer-events: none; }
.search input {
  flex: 1 1 auto; min-width: 0; height: 36px; padding: 0 12px 0 34px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--panel-2); font-family: var(--mono); font-size: 13px;
}
.search input:focus { background: var(--panel); border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.top-actions { display: flex; align-items: center; gap: 6px; margin-left: auto; }

.seg { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--panel-2); flex: 0 0 auto; }
.seg button { border: 0; background: transparent; padding: 6px 10px; cursor: pointer; color: var(--muted); font-size: 13px; }
.seg button + button { border-left: 1px solid var(--border); }
.seg button[aria-checked="true"] { background: var(--panel); color: var(--text); font-weight: 600; box-shadow: inset 0 -2px 0 var(--accent); }
.seg.small button { padding: 3px 9px; font-size: 12px; }

.btn {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--panel); cursor: pointer; font-size: 13px; font-weight: 550; white-space: nowrap;
}
.btn:hover:not(:disabled) { background: var(--panel-2); }
.btn.primary { background: var(--accent); color: var(--accent-text); border-color: transparent; }
.btn.primary:hover:not(:disabled) { filter: brightness(1.08); background: var(--accent); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.small { height: 26px; padding: 0 8px; font-size: 12px; }
.icon-btn {
  display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: var(--radius); border: 1px solid transparent;
  background: transparent; cursor: pointer; color: var(--muted); padding: 0;
}
.icon-btn:hover { background: var(--panel-2); color: var(--text); }
.icon-btn svg circle { fill: currentColor; }
.icon-btn svg circle[fill="none"] { fill: none; }

/* ---------- layout ---------- */
.layout { display: grid; grid-template-columns: 340px minmax(0, 1fr) auto; min-height: 0; }
.panel { background: var(--panel); border-right: 1px solid var(--border); min-height: 0; display: flex; flex-direction: column; }
.panel.right { border-right: 0; border-left: 1px solid var(--border); width: 440px; }

.filters { padding: 12px; border-bottom: 1px solid var(--border); display: grid; gap: 10px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px 4px 8px; border: 1px solid var(--border); border-radius: 999px;
  cursor: pointer; font-size: 12.5px; user-select: none; background: var(--panel);
}
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip::before { content: ""; width: 9px; height: 9px; border-radius: 3px; background: var(--muted); }
.chip.kind-T::before { background: var(--head-T); } .chip.kind-V::before { background: var(--head-V); } .chip.kind-P::before { background: var(--head-P); }
.chip:has(input:not(:checked)) { opacity: .5; text-decoration: line-through; }
.chip:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; }
.chip em { font-style: normal; color: var(--muted); font-size: 11.5px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.field { display: grid; gap: 3px; font-size: 12px; color: var(--muted); min-width: 0; }
.field select, .field input, .tool-group select, textarea {
  height: 30px; border: 1px solid var(--border); border-radius: 6px; background: var(--panel); color: var(--text); padding: 0 8px; min-width: 0; width: 100%;
}
textarea { height: auto; padding: 6px 8px; font-family: var(--mono); font-size: 12px; resize: vertical; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; padding: 2px 0; }
.check.small { font-size: 12.5px; }
.check code { font-size: 11.5px; }
.more-filters summary { cursor: pointer; font-size: 12.5px; color: var(--muted); }
.more-filters[open] summary { margin-bottom: 6px; }

.results-head { padding: 8px 12px; font-size: 12px; color: var(--muted); border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; }
.results { list-style: none; margin: 0; padding: 4px 0; overflow: auto; flex: 1 1 auto; min-height: 0; }
.results li { padding: 6px 12px 6px 14px; cursor: pointer; border-left: 3px solid transparent; display: grid; gap: 1px; }
.results li:hover, .results li.active { background: var(--panel-2); }
.results li.active { border-left-color: var(--accent); }
.results li:focus-visible { outline-offset: -2px; }
.r-top { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.r-name { font-family: var(--mono); font-size: 12.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.r-name mark { background: var(--accent-soft); color: inherit; border-radius: 2px; }
.r-kind { font-size: 10px; font-weight: 700; letter-spacing: .04em; padding: 1px 5px; border-radius: 4px; color: #fff; flex: 0 0 auto; }
.r-kind.k-T { background: var(--head-T); } .r-kind.k-V { background: var(--head-V); } .r-kind.k-P { background: var(--head-P); } .r-kind.k-X { background: var(--head-X); }
.r-sub { font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.r-cols { font-size: 11px; color: var(--muted); font-family: var(--mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.results .more { text-align: center; color: var(--accent); font-size: 12.5px; }

/* ---------- canvas ---------- */
.canvas-wrap { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.toolbar {
  display: flex; align-items: center; gap: 10px; padding: 6px 10px; background: var(--panel); border-bottom: 1px solid var(--border);
  flex-wrap: wrap; row-gap: 6px;
}
.tool-group { display: flex; align-items: center; gap: 6px; }
.tool-group select { width: auto; height: 28px; font-size: 12.5px; }
.tool-label { font-size: 12px; color: var(--muted); }
.tool-spacer { flex: 1 1 auto; }
.canvas {
  position: relative; flex: 1 1 auto; min-height: 0; overflow: hidden; background-color: var(--canvas-bg);
  background-image: radial-gradient(var(--grid) 1px, transparent 1px); background-size: 22px 22px;
}
.statusbar { padding: 4px 12px; font-size: 12px; color: var(--muted); background: var(--panel); border-top: 1px solid var(--border); min-height: 25px; }
.statusbar .warn { color: var(--danger); }

.empty { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; padding: 24px; gap: 4px; }
.empty h1 { font-size: 22px; margin: 0 0 4px; font-weight: 650; }
.empty p { color: var(--muted); max-width: 620px; margin: 4px auto; }
.examples { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 14px auto; max-width: 720px; }
.examples button { font-family: var(--mono); font-size: 12px; }
.stats { font-size: 12.5px; }

.legend { position: absolute; left: 10px; bottom: 10px; display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; background: color-mix(in srgb, var(--panel) 92%, transparent); border: 1px solid var(--border); border-radius: 8px; padding: 5px 10px; font-size: 11.5px; color: var(--muted); max-width: calc(100% - 20px); pointer-events: none; }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend .sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.legend .sw.k-T { background: var(--head-T); } .legend .sw.k-V { background: var(--head-V); } .legend .sw.k-P { background: var(--head-P); } .legend .sw.k-X { background: var(--head-X); }
.legend .lg-fk { fill: none; stroke: var(--edge-fk); stroke-width: 1.4; }
.legend .lg-fk.inf { stroke-dasharray: 1.5 3; stroke-linecap: round; }
.legend .lg-lin { fill: none; stroke: var(--edge-lin); stroke-width: 1.4; stroke-dasharray: 4 3; }
.legend .lg-lin-head { fill: var(--edge-lin); }
.busy { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); background: var(--panel); border: 1px solid var(--border); border-radius: 999px; padding: 6px 14px; box-shadow: var(--shadow); display: flex; align-items: center; gap: 8px; font-size: 12.5px; z-index: 5; }
.spinner { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--border); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }

/* ---------- ERD svg ---------- */
.erd-svg { display: block; cursor: grab; touch-action: none; user-select: none; }
.erd-svg.panning { cursor: grabbing; }
.node { cursor: pointer; }
.node-box { fill: var(--node-bg); stroke: var(--node-border); stroke-width: 1; filter: drop-shadow(0 1px 2px rgba(16,24,40,.12)); }
.node-head { fill: var(--head-T); }
.kind-V .node-head { fill: var(--head-V); } .kind-P .node-head { fill: var(--head-P); } .kind-X .node-head { fill: var(--head-X); }
.kind-X .node-box { stroke-dasharray: 5 4; }
.node-title { fill: var(--head-text); font: 600 13px var(--mono); }
.node-sub { fill: var(--head-subtext); font: 11px var(--sans); }
.node-kind { fill: var(--head-subtext); font: 700 9px var(--sans); letter-spacing: .06em; }
.row-bg { fill: var(--row-alt); }
.row-name { fill: var(--text); font: 12px var(--mono); }
.row-type { fill: var(--muted); font: 11px var(--mono); }
.row-icon { fill: var(--muted); font: 700 9px var(--sans); }
.row.pk .row-icon { fill: var(--pk); } .row.fk .row-icon { fill: var(--fk); }
.row.pk .row-name { font-weight: 700; }
.row-more { fill: var(--muted); font: italic 11px var(--sans); }
.node.selected .node-box { stroke: var(--select); stroke-width: 3; }
.node:hover .node-box, .node:focus-visible .node-box { stroke: var(--edge-hover); stroke-width: 2; }
.node:focus-visible { outline: none; }
.node-badge rect { fill: var(--accent); }
.node-badge text { fill: var(--accent-text); font: 600 11px var(--sans); }
.node-badge { cursor: pointer; }
.edge-line { fill: none; stroke: var(--edge-fk); stroke-width: 1.4; }
.edge-hit { fill: none; stroke: transparent; stroke-width: 12; }
.edge-lin .edge-line { stroke: var(--edge-lin); stroke-dasharray: 5 4; }
.edge-fk.inferred .edge-line { stroke-dasharray: 1.5 3; stroke-linecap: round; }
.edge.hover .edge-line { stroke: var(--edge-hover); stroke-width: 2.4; }
.marker-stroke { stroke: var(--edge-fk); stroke-width: 1.4; }
.marker-fill { fill: var(--edge-lin); }
.zoomed-out .row, .zoomed-out .row-more { display: none; }

/* ---------- detail panel ---------- */
.detail-inner { overflow: auto; flex: 1 1 auto; min-height: 0; }
.d-head { padding: 14px 16px 10px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--panel); z-index: 2; }
.d-title { display: flex; align-items: flex-start; gap: 8px; }
.d-title h2 { font: 650 16px/1.3 var(--mono); margin: 0; word-break: break-all; flex: 1 1 auto; }
.d-label { font-size: 13px; color: var(--muted); margin-top: 2px; }
.d-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; color: var(--muted); margin-top: 8px; }
.d-meta b { color: var(--text); font-weight: 600; }
.d-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.d-desc { padding: 12px 16px; font-size: 13px; border-bottom: 1px solid var(--border); }
.d-desc-text { white-space: pre-line; }
.d-desc.empty-desc { color: var(--muted); font-style: italic; }
.d-desc.clamp .d-desc-text { max-height: 8.6em; overflow: hidden; -webkit-mask-image: linear-gradient(#000 60%, transparent); mask-image: linear-gradient(#000 60%, transparent); }
.more-desc { font-family: var(--sans); font-size: 12px; margin-top: 4px; }
.d-source { font-size: 12px; margin-top: 8px; }
.tabs { display: flex; gap: 2px; padding: 0 12px; border-bottom: 1px solid var(--border); position: sticky; top: var(--d-head-h, 0px); background: var(--panel); z-index: 1; overflow-x: auto; }
.tabs button { border: 0; background: none; padding: 8px 10px; font-size: 12.5px; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.tabpanel { padding: 8px 12px 20px; }
.tbl { width: 100%; border-collapse: collapse; font-size: 12px; }
.tbl th { text-align: left; font-weight: 600; color: var(--muted); padding: 5px 6px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--panel); font-size: 11.5px; }
.tbl td { padding: 5px 6px; border-bottom: 1px solid var(--border); vertical-align: top; }
.tbl td.mono { font-family: var(--mono); font-size: 11.5px; word-break: break-all; }
.tbl tr.pk td:first-child .mono { font-weight: 700; }
.tbl td.c-name { width: 46%; }
.tbl td.c-name .mono { font-family: var(--mono); font-size: 11.5px; overflow-wrap: anywhere; }
.tbl .c-type { font-family: var(--mono); font-size: 10.5px; color: var(--muted); margin: 1px 0 2px; }
.tbl .cmt { color: var(--muted); font-size: 11.5px; }
.tag { display: inline-block; font: 700 9.5px var(--sans); padding: 1px 4px; border-radius: 3px; margin-right: 3px; letter-spacing: .03em; vertical-align: 1px; }
.tag.pk { background: color-mix(in srgb, var(--pk) 20%, transparent); color: var(--pk); }
.tag.fk { background: color-mix(in srgb, var(--fk) 18%, transparent); color: var(--fk); }
.tag.nn { background: var(--panel-2); color: var(--muted); }
.tag.inf { background: color-mix(in srgb, var(--edge-lin) 20%, transparent); color: var(--tag-inf, var(--edge-lin)); }
.tag.warn { background: color-mix(in srgb, var(--danger) 16%, transparent); color: var(--danger); }
.linkish { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font-family: var(--mono); font-size: 11.5px; text-align: left; word-break: break-all; }
.linkish:hover { text-decoration: underline; }
.sec-title { font-size: 12px; font-weight: 650; margin: 14px 0 6px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.sec-title:first-child { margin-top: 6px; }
.note { font-size: 12px; color: var(--muted); margin: 6px 0; }
pre.sql, pre.code {
  font: 12px/1.5 var(--mono); background: var(--panel-2); border: 1px solid var(--border); border-radius: 6px; padding: 10px; overflow: auto; white-space: pre; margin: 0;
}
.filter-cols { width: 100%; height: 28px; border: 1px solid var(--border); border-radius: 6px; padding: 0 8px; background: var(--panel); margin-bottom: 6px; font-size: 12px; }

/* ---------- menus, dialogs, toast ---------- */
.menu-wrap { position: relative; }
.menu, .ctx-menu {
  position: absolute; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg);
  padding: 4px; min-width: 230px; z-index: 30; display: grid;
}
.menu { right: 0; top: 36px; }
.ctx-menu { position: fixed; }
.menu button, .ctx-menu button { text-align: left; border: 0; background: none; padding: 7px 10px; border-radius: 5px; cursor: pointer; font-size: 13px; }
.menu button:hover, .ctx-menu button:hover, .menu button:focus-visible, .ctx-menu button:focus-visible { background: var(--panel-2); }
.menu hr, .ctx-menu hr { border: 0; border-top: 1px solid var(--border); margin: 4px 0; }
.ctx-menu .ctx-title { font: 600 12px var(--mono); padding: 6px 10px 4px; color: var(--muted); word-break: break-all; }

.dialog { border: 1px solid var(--border); border-radius: 12px; padding: 0; background: var(--panel); color: var(--text); box-shadow: var(--shadow-lg); width: min(720px, calc(100vw - 32px)); max-height: calc(100vh - 48px); }
.dialog.wide { width: min(1240px, calc(100vw - 32px)); height: min(860px, calc(100vh - 48px)); }
.dialog::backdrop { background: rgba(10, 14, 20, .45); }
.dialog-body { display: flex; flex-direction: column; height: 100%; margin: 0; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.dialog-head h2 { margin: 0; font-size: 16px; }
.prose { padding: 8px 20px 20px; overflow: auto; font-size: 13.5px; }
.prose h3 { font-size: 14px; margin: 18px 0 6px; }
.prose table { border-collapse: collapse; font-size: 12.5px; width: 100%; }
.prose td, .prose th { border-bottom: 1px solid var(--border); padding: 4px 6px; text-align: left; }
.ddl-grid { display: grid; grid-template-columns: 330px minmax(0, 1fr); flex: 1 1 auto; min-height: 0; }
.ddl-options { overflow: auto; padding: 8px 16px 16px; border-right: 1px solid var(--border); display: grid; gap: 4px; align-content: start; }
.ddl-options fieldset { border: 0; padding: 0; margin: 8px 0 0; display: grid; gap: 6px; }
.ddl-options legend { font-size: 12px; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 6px; padding: 0; }
.radio { display: flex; gap: 8px; align-items: baseline; font-size: 13px; cursor: pointer; }
.radio em { font-style: normal; color: var(--muted); font-size: 12px; }
.radio:has(input:disabled) { opacity: .5; cursor: default; }
.audit-cols { display: grid; gap: 2px; padding-left: 24px; }
.audit-cols .check { font-size: 12.5px; }
.audit-cols code { font-size: 12px; }
.ddl-output { display: flex; flex-direction: column; min-width: 0; min-height: 0; padding: 12px 16px 16px; gap: 10px; }
.ddl-out-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); }
.ddl-out-head .btns { display: flex; gap: 6px; }
.ddl-output pre { flex: 1 1 auto; min-height: 0; }

.toast { position: fixed; bottom: 48px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 8px 16px; border-radius: 999px; font-size: 13px; box-shadow: var(--shadow-lg); z-index: 50; }

.footer { display: flex; justify-content: space-between; gap: 12px; padding: 5px 16px; font-size: 11.5px; color: var(--muted); background: var(--panel); border-top: 1px solid var(--border); flex-wrap: wrap; }
.footer a { color: inherit; }

.only-narrow { display: none; }
.scrim { position: absolute; inset: 0; background: rgba(10, 14, 20, .35); z-index: 19; }

/* ---------- responsive ---------- */
@media (max-width: 1440px) {
  .tool-label { display: none; }
}
@media (max-width: 1200px) {
  .panel.right { width: 380px; }
  .layout { grid-template-columns: 300px minmax(0, 1fr) auto; }
}
@media (max-width: 960px) {
  .only-narrow { display: inline-grid; }
  .brand-text { display: none; }
  .layout { grid-template-columns: minmax(0, 1fr); position: relative; }
  .panel.left { position: absolute; inset: 0 auto 0 0; width: min(340px, 88vw); z-index: 20; box-shadow: var(--shadow-lg); transform: translateX(-105%); transition: transform .2s; }
  .panel.left.open { transform: none; }
  .legend { font-size: 10.5px; gap: 2px 8px; padding: 3px 8px; }
  .legend span:nth-child(n+5) { display: none; }
  .panel.right { position: absolute; inset: 0 0 0 auto; width: min(440px, 100vw); z-index: 21; box-shadow: var(--shadow-lg); }
  .search .seg button { padding: 6px 7px; }
  .ddl-grid { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .ddl-options { border-right: 0; border-bottom: 1px solid var(--border); max-height: 42vh; }
  .footer span:first-child { display: none; }
}
@media (max-width: 600px) {
  .topbar { gap: 8px; padding: 8px; flex-wrap: wrap; }
  .search { order: 3; flex-basis: 100%; max-width: none; }
  .btn.primary span { display: none; }
  .toolbar { gap: 8px; padding: 6px 8px; }
  .tool-label { display: none; }
}
