/* <meta name="color-scheme"> is the single source of truth for the manual theme override. */
:root {
  color-scheme: light dark;
  --bg: light-dark(#ffffff, #0f1011);
  --rail: light-dark(#f7f8f9, #141517);
  --elev: light-dark(#ffffff, #181a1d);
  --hover: light-dark(#f2f4f7, #1c1e22);
  --active: light-dark(#eceef3, #23262c);
  --line: light-dark(#e6e8ec, #23252a);
  --line-strong: light-dark(#d2d6de, #32363f);
  --ink: light-dark(#111317, #f1f2f4);
  --ink-2: light-dark(#525866, #9096a3);
  --ink-3: light-dark(#6b7280, #767d8c);
  --accent: light-dark(#5e6ad2, #7b86ee);
  --accent-btn: light-dark(#5e6ad2, #5e6ad2);
  --accent-fg: #ffffff;
  --ok: light-dark(#1f883d, #46a758);
  --warn: light-dark(#b45309, #e5a00d);
  --err: light-dark(#cf222e, #e5484d);
  --err-fg: #ffffff;
  --c1: light-dark(#3b6fd4, #689bf2);
  --c2: light-dark(#1f885f, #45b082);
  --c3: light-dark(#6c7380, #7e8594);
  --c4: light-dark(#7c5ce0, #9d83f2);
  --c5: light-dark(#c26318, #e08a3c);
  --dot-grid: light-dark(rgb(17 19 23 / 0.11), rgb(255 255 255 / 0.08));
  --shadow: light-dark(0 12px 32px rgb(17 19 23 / 0.10), 0 18px 48px rgb(0 0 0 / 0.55));
}
:root:has(> head > meta[name="color-scheme"][content="dark"]) { color-scheme: dark; }
:root:has(> head > meta[name="color-scheme"][content="light"]) { color-scheme: light; }

@supports not (color: light-dark(#000, #fff)) {
  :root {
    --bg: #ffffff; --rail: #f7f8f9; --elev: #ffffff; --hover: #f2f4f7; --active: #eceef3;
    --line: #e6e8ec; --line-strong: #d2d6de; --ink: #111317; --ink-2: #525866; --ink-3: #6b7280;
    --accent: #5e6ad2; --accent-btn: #5e6ad2; --accent-fg: #ffffff; --ok: #1f883d; --warn: #b45309; --err: #cf222e; --err-fg: #ffffff;
    --c1: #3b6fd4; --c2: #1f885f; --c3: #6c7380; --c4: #7c5ce0; --c5: #c26318;
    --dot-grid: rgb(17 19 23 / 0.11); --shadow: 0 12px 32px rgb(17 19 23 / 0.10);
  }
  @media (prefers-color-scheme: dark) {
    :root {
      --bg: #0f1011; --rail: #141517; --elev: #181a1d; --hover: #1c1e22; --active: #23262c;
      --line: #23252a; --line-strong: #32363f; --ink: #f1f2f4; --ink-2: #9096a3; --ink-3: #767d8c;
      --accent: #7b86ee; --accent-btn: #5e6ad2; --accent-fg: #ffffff; --ok: #46a758; --warn: #e5a00d; --err: #e5484d; --err-fg: #ffffff;
      --c1: #689bf2; --c2: #45b082; --c3: #7e8594; --c4: #9d83f2; --c5: #e08a3c;
      --dot-grid: rgb(255 255 255 / 0.08); --shadow: 0 18px 48px rgb(0 0 0 / 0.55);
    }
  }
}

.theme-to-light { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not(:has(> head > meta[name="color-scheme"][content="light"])) .theme-to-dark { display: none; }
  :root:not(:has(> head > meta[name="color-scheme"][content="light"])) .theme-to-light { display: inline-flex; }
}
:root:has(> head > meta[name="color-scheme"][content="dark"]) .theme-to-dark { display: none; }
:root:has(> head > meta[name="color-scheme"][content="dark"]) .theme-to-light { display: inline-flex; }

*, *::before, *::after { box-sizing: border-box; }
html { scrollbar-gutter: stable; }
html, body { height: 100%; margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-feature-settings: "cv01", "cv02", "cv03", "cv04";
  font-size: 13px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
code, pre, .mono {
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-variant-numeric: tabular-nums;
}
.num { font-variant-numeric: tabular-nums; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.hidden { display: none !important; }
.muted { color: var(--ink-2); }
.dim { color: var(--ink-3); }
.xs { font-size: 11.5px; }
.med { font-weight: 500; }
.semi { font-weight: 600; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.visually-hidden:where(:not(:focus-within, :active)) {
  position: absolute !important;
  clip-path: inset(50%) !important;
  overflow: hidden !important;
  width: 1px !important;
  height: 1px !important;
  margin: -1px !important;
  padding: 0 !important;
  border: 0 !important;
  white-space: nowrap !important;
}

:where(a, button, input, summary, [tabindex]):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}

.app-shell {
  display: grid;
  grid-template-columns: 224px minmax(0, 1fr);
  min-height: 100dvh;
}

/* Left Rail */
.rail {
  background: var(--rail);
  border-inline-end: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100dvh;
  overflow-y: auto;
}
.rail-brand {
  height: 46px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.brand-mark {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--ink);
}
.brand-icon {
  width: 20px;
  height: 20px;
  border-radius: 5px;
  background: var(--ink);
  color: var(--bg);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.rail-section {
  padding: 12px 8px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.rail-section + .rail-section { border-top: 1px solid var(--line); }
.rail-label {
  padding: 0 8px 5px;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--ink-3);
}

.tablist { display: flex; flex-direction: column; gap: 1px; }
.tab-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  min-block-size: 30px;
  padding: 5px 8px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ink-2);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 500;
  text-align: start;
  cursor: pointer;
}
.tab-btn:hover { color: var(--ink); background: var(--hover); }
.tab-btn[aria-selected="true"] { color: var(--ink); background: var(--active); }
.tab-btn[aria-selected="true"]::before {
  content: "";
  position: absolute;
  inset: 6px auto 6px 0;
  width: 2px;
  border-radius: 1px;
  background: var(--accent);
}
.tab-btn-main { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.tab-count {
  font-size: 11px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  padding: 0 5px;
  border-radius: 4px;
  color: var(--warn);
  background: color-mix(in srgb, var(--warn) 14%, transparent);
}
.tab-count.err { color: var(--err); background: color-mix(in srgb, var(--err) 15%, transparent); }

.rail-host {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  width: 100%;
  min-block-size: 28px;
  padding: 4px 8px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ink-2);
  font-family: inherit;
  font-size: 12.5px;
  text-align: start;
  cursor: pointer;
}
.rail-host:hover { background: var(--hover); color: var(--ink); }
.rail-host[aria-pressed="true"] { background: var(--active); color: var(--ink); font-weight: 500; }
.rail-host-left { display: inline-flex; align-items: center; gap: 7px; min-width: 0; }
.rail-host-meta { display: inline-flex; align-items: center; gap: 6px; flex-shrink: 0; }

.rail-footer {
  margin-top: auto;
  border-top: 1px solid var(--line);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.rail-kv {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11.5px;
  color: var(--ink-2);
}

/* Main Workspace */
.workspace {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 100dvh;
  background: var(--bg);
}
.topbar {
  height: 46px;
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 20;
  flex-shrink: 0;
}
.topbar-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.topbar h1 { font-size: 13.5px; font-weight: 600; letter-spacing: -0.014em; margin: 0; white-space: nowrap; }
.topbar-sep { width: 1px; height: 14px; background: var(--line-strong); flex-shrink: 0; }

/* Controls & Chips */
.dot { width: 6px; height: 6px; border-radius: 999px; display: inline-block; flex-shrink: 0; }
.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-block-size: 24px;
  padding: 2px 7px;
  border-radius: 5px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-2);
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}
button.status-chip { cursor: pointer; }
button.status-chip:hover { background: var(--hover); color: var(--ink); }
.status-chip.warn {
  color: var(--warn);
  background: color-mix(in srgb, var(--warn) 11%, transparent);
  border-color: color-mix(in srgb, var(--warn) 25%, transparent);
}
.status-chip.err {
  color: var(--err);
  background: color-mix(in srgb, var(--err) 12%, transparent);
  border-color: color-mix(in srgb, var(--err) 28%, transparent);
}
.status-chip.ok { color: var(--ink-2); }

.btn, .seg-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-block-size: 26px;
  padding: 3px 9px;
  border-radius: 5px;
  border: 1px solid var(--line-strong);
  background: var(--elev);
  color: var(--ink);
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
}
.btn:hover:not(:disabled) { background: var(--hover); border-color: var(--ink-3); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-sm { min-block-size: 24px; padding: 2px 8px; font-size: 11.5px; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn-ghost:hover:not(:disabled) { background: var(--hover); border-color: transparent; color: var(--ink); }
.btn-primary { background: var(--accent-btn); border-color: var(--accent-btn); color: var(--accent-fg); }
.btn-primary:hover:not(:disabled) { filter: brightness(1.08); background: var(--accent-btn); border-color: var(--accent-btn); }
.btn-danger {
  background: color-mix(in srgb, var(--err) 11%, transparent);
  border-color: color-mix(in srgb, var(--err) 38%, transparent);
  color: var(--err);
}
.btn-danger:hover:not(:disabled) { background: color-mix(in srgb, var(--err) 18%, transparent); border-color: var(--err); }
.btn-warn-active {
  background: color-mix(in srgb, var(--warn) 14%, transparent);
  border-color: color-mix(in srgb, var(--warn) 42%, transparent);
  color: var(--warn);
}

.seg-group {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px;
  border-radius: 6px;
  background: var(--rail);
  border: 1px solid var(--line);
}
.seg-btn {
  min-block-size: 24px;
  padding: 2px 8px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--ink-2);
  font-size: 11.5px;
}
.seg-btn:hover { color: var(--ink); }
.seg-btn.active { background: var(--elev); color: var(--ink); box-shadow: 0 1px 2px rgb(0 0 0 / 0.08); }

.link-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-block-size: 24px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent);
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
}
.link-btn:hover { text-decoration: underline; }

.ext-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-block-size: 24px;
  padding: 2px 7px;
  border-radius: 5px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}
.ext-link:hover { background: var(--hover); border-color: var(--line-strong); text-decoration: none; }

.sim-bar {
  padding: 7px 18px;
  border-bottom: 1px solid color-mix(in srgb, var(--warn) 38%, var(--line));
  background: color-mix(in srgb, var(--warn) 8%, var(--bg));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.tab-panels { display: grid; flex: 1; min-height: 0; }
.tab-panels > [role="tabpanel"] { grid-area: 1 / 1; min-inline-size: 0; align-self: stretch; }
.tab-panels > [role="tabpanel"][hidden] { pointer-events: none; align-self: start; }

/* Topology Workspace */
.topo-shell { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.subbar {
  min-height: 40px;
  padding: 6px 18px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  background: var(--bg);
  flex-shrink: 0;
}
.topo-split { display: grid; grid-template-columns: minmax(0, 1fr); flex: 1; min-height: 0; }
.topo-split:has(> #inspector:not([hidden])) { grid-template-columns: minmax(0, 1fr) 352px; }
.canvas-pane { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg); }
.canvas-stage {
  flex: 1;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 28px 20px 16px;
  min-height: 0;
  overflow: hidden;
  background-image: radial-gradient(var(--dot-grid) 1px, transparent 1px);
  background-size: 20px 20px;
}
#topology-svg { width: 100%; max-width: 1080px; max-height: 100%; height: auto; display: block; user-select: none; }
.canvas-foot {
  padding: 8px 18px;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 11.5px;
  color: var(--ink-2);
  flex-shrink: 0;
}

.inspector {
  border-inline-start: 1px solid var(--line);
  background: var(--rail);
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
}
@media (min-width: 1081px) {
  /* Keep desktop Topology map locked to viewport height so opening the right inspector never shifts the SVG vertically. */
  .workspace:has(#view-overview:not([hidden]) #topo-map-view:not(.hidden)) { height: 100dvh; overflow: hidden; }
  .workspace:has(#view-overview:not([hidden]) #topo-map-view:not(.hidden)) .tab-panels { grid-template-rows: minmax(0, 1fr); overflow: hidden; }
  .workspace:has(#view-overview:not([hidden]) #topo-map-view:not(.hidden)) #view-overview { min-height: 0; overflow: hidden; }
}
.insp-sec {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.insp-sec:last-child { border-bottom: 0; }
.insp-title { font-size: 12px; font-weight: 500; color: var(--ink-2); margin: 0; }
.insp-list { display: flex; flex-direction: column; }
.insp-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 5px 0;
  font-size: 12px;
}
.insp-row + .insp-row { border-top: 1px solid color-mix(in srgb, var(--line) 65%, transparent); }

/* SVG */
.svg-node { cursor: pointer; transition: opacity 0.14s ease; }
.svg-node:hover .node-shell { stroke: var(--accent); }
.svg-node:focus-visible, .svg-link-label:focus-visible { outline: none; }
.svg-node:focus-visible .node-shell { stroke: var(--accent); stroke-width: 2.5; }
.svg-link-label:focus-visible rect { stroke: var(--accent); stroke-width: 2; }
.svg-link-hit { cursor: pointer; fill: none; stroke: transparent; stroke-width: 16; }
.svg-link-path { fill: none; transition: opacity 0.14s ease, stroke-width 0.12s ease; pointer-events: none; }
@keyframes flowDash { to { stroke-dashoffset: -28; } }
.link-animated { stroke-dasharray: 7 6; animation: flowDash 0.85s linear infinite; }
@media (prefers-reduced-motion: reduce) { .link-animated { animation: none; } }

/* Document Views */
.doc-view {
  max-width: 1160px;
  width: 100%;
  padding: 20px 24px 36px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}
.sec-block { display: flex; flex-direction: column; gap: 10px; }
.sec-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.sec-head h2 { font-size: 13.5px; font-weight: 600; letter-spacing: -0.012em; margin: 0; }

.sheet { border: 1px solid var(--line); border-radius: 7px; background: var(--bg); overflow: hidden; }
.sheet-split-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.sheet-split-2 > * + * { border-inline-start: 1px solid var(--line); }
.sheet-split-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.sheet-split-3 > * + * { border-inline-start: 1px solid var(--line); }
.sheet-pane { padding: 14px 16px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12.5px; text-align: left; }
thead th {
  padding: 8px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--rail);
  color: var(--ink-2);
  font-size: 11.5px;
  font-weight: 500;
  white-space: nowrap;
}
tbody td, tbody th { padding: 9px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td, tbody tr:last-child th { border-bottom: 0; }
tbody tr:hover td, tbody tr:hover th { background: var(--hover); }
tbody th { font-weight: 500; color: var(--ink); font-family: "JetBrains Mono", ui-monospace, monospace; font-size: 12px; }

.flat-list > * + * { border-top: 1px solid var(--line); }
.flat-row {
  padding: 9px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 12.5px;
}
.flat-row-btn {
  width: 100%;
  border: 0;
  background: transparent;
  color: inherit;
  font-family: inherit;
  text-align: start;
  cursor: pointer;
}
.flat-row-btn:hover { background: var(--hover); }

.stat-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  margin: 0 -16px;
}
.stat-cell { padding: 11px 16px; display: flex; flex-direction: column; gap: 2px; }
.stat-cell + .stat-cell { border-inline-start: 1px solid var(--line); }
.stat-val { font-size: 18px; font-weight: 600; letter-spacing: -0.02em; }

.cfg-details { width: 100%; min-width: 0; }
.cfg-details summary {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-block-size: 24px;
  padding: 2px 6px;
  margin-inline-start: -6px;
  border-radius: 4px;
  color: var(--ink-2);
  font-size: 11.5px;
  font-weight: 500;
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.cfg-details summary::-webkit-details-marker { display: none; }
.cfg-details summary:hover { color: var(--ink); background: var(--hover); }
.cfg-details .chev { transition: transform 0.14s ease; flex-shrink: 0; }
.cfg-details[open] .chev { transform: rotate(90deg); }
.cfg-body {
  margin-top: 6px;
  padding: 9px 11px;
  border-radius: 5px;
  border: 1px solid var(--line);
  background: var(--rail);
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 11.5px;
  min-width: 0;
  overflow-x: auto;
}
.cfg-grid { display: grid; grid-template-columns: 64px minmax(0, 1fr); gap: 5px 10px; align-items: baseline; }
.cfg-val { min-width: 0; overflow-wrap: anywhere; }

.log-row {
  display: grid;
  grid-template-columns: 52px 42px 62px minmax(0, 1fr);
  column-gap: 12px;
  align-items: center;
  padding: 8px 14px;
  border-bottom: 1px solid var(--line);
  border-left: 2px solid transparent;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 11.5px;
}
.log-row:last-child { border-bottom: 0; }
.log-row:hover { background: var(--hover); }
.log-row-grant-ro { border-left-color: var(--warn); background: color-mix(in srgb, var(--warn) 5%, transparent); }
.log-row-grant-sudo { border-left-color: var(--err); background: color-mix(in srgb, var(--err) 6%, transparent); }
.log-row-revoke { border-left-color: var(--ok); }

input[type="checkbox"] { accent-color: var(--accent); margin: 0; cursor: pointer; }
.filter-group { display: inline-flex; align-items: center; gap: 10px; }
.check-opt {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-block-size: 24px;
  color: var(--ink-2);
  font-size: 12px;
  cursor: pointer;
  user-select: none;
}
.check-opt:has(input:checked) { color: var(--ink); }

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 80;
  padding: 8px 13px;
  border-radius: 6px;
  background: var(--elev);
  border: 1px solid var(--line-strong);
  color: var(--ink);
  box-shadow: var(--shadow);
  font-size: 12px;
  max-width: 400px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.14s ease;
}
.toast[data-show] { opacity: 1; pointer-events: auto; }

.load-error { padding: 24px; color: var(--err); font-family: "JetBrains Mono", monospace; font-size: 12px; }
.mobile-only { display: none; }
.mobile-nodes { display: none; padding: 14px; flex-direction: column; gap: 14px; }

@media (max-width: 1080px) {
  .topo-split, .topo-split:has(> #inspector:not([hidden])) { grid-template-columns: 1fr; }
  .inspector { border-inline-start: 0; border-top: 1px solid var(--line); max-height: none; }
  .sheet-split-3 { grid-template-columns: 1fr; }
  .sheet-split-3 > * + * { border-inline-start: 0; border-top: 1px solid var(--line); }
}
@media (max-width: 860px) {
  .app-shell { grid-template-columns: 1fr; }
  .rail { position: static; height: auto; border-inline-end: 0; border-bottom: 1px solid var(--line); }
  .rail-section { padding: 6px 8px; }
  .rail-label { display: none; }
  .tablist { flex-direction: row; overflow-x: auto; padding-bottom: 2px; }
  .tab-btn { width: auto; flex: none; }
  .tab-btn[aria-selected="true"]::before { inset: auto 6px 0; width: auto; height: 2px; }
  .rail-fleet-sec, .rail-footer { display: none; }
  .sheet-split-2 { grid-template-columns: 1fr; }
  .sheet-split-2 > * + * { border-inline-start: 0; border-top: 1px solid var(--line); }
  .doc-view { padding: 14px; gap: 18px; }
}
@media (max-width: 760px) {
  .desktop-only { display: none !important; }
  .mobile-only { display: inline-flex; }
  .topbar { height: auto; min-height: 40px; padding: 8px 14px; flex-wrap: wrap; }
  .topbar-left { flex-wrap: wrap; gap: 6px; }
  .topbar h1, .topbar-sep, #collector-sources { display: none; }
  .subbar { padding: 8px 14px; }
  #layer-controls, #map-toggles, .canvas-pane { display: none !important; }
  .mobile-nodes { display: flex; }
  #topo-map-view:has(> #inspector:not([hidden])) .mobile-nodes { display: none; }
  .inspector { border-top: 0; background: var(--bg); }
}
