:root {
  color-scheme: dark;
  --bg: #101112;
  --surface: #191b1d;
  --surface-2: #222527;
  --line: #35393b;
  --line-strong: #535a5c;
  --text: #f1f2f0;
  --muted: #afb5b6;
  --faint: #858d90;
  --amber: #e7ae65;
  --cyan: #83c2d1;
  --good: #a5c9a8;
  --good-bg: #1f2f25;
  --watch: #efbf80;
  --watch-bg: #3b2d1d;
  --body: "Segoe UI", Arial, sans-serif;
  --mono: Consolas, "Courier New", monospace;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.5 var(--body); }
button, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; }
a { color: inherit; text-decoration: none; }
a:focus-visible, button:focus-visible, summary:focus-visible { outline: 2px solid var(--amber); outline-offset: 3px; }
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { font-weight: 650; letter-spacing: 0; }
[hidden] { display: none !important; }
.skip-link { position: absolute; top: -50px; left: 10px; z-index: 100; padding: 8px 12px; background: var(--text); color: var(--bg); }
.skip-link:focus { top: 10px; }
.mono, code { font-family: var(--mono); font-variant-numeric: tabular-nums; }

.topbar { min-height: 64px; position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 15px; padding: 10px 24px; background: #191b1d; border-bottom: 1px solid var(--line); }
.brand { display: inline-flex; align-items: center; gap: 9px; white-space: nowrap; font-size: 18px; font-weight: 700; line-height: 1; }
.brand-mark { width: 20px; height: 20px; display: flex; align-items: end; gap: 3px; }
.brand-mark i { width: 4px; display: block; background: var(--amber); }
.brand-mark i:nth-child(1) { height: 9px; }
.brand-mark i:nth-child(2) { height: 15px; }
.brand-mark i:nth-child(3) { height: 20px; }
.topbar-divider { height: 23px; width: 1px; background: var(--line-strong); }
.topbar-product { font-weight: 600; color: #cdd1d1; }
.demo-badge, .read-only-label { display: inline-flex; align-items: center; min-height: 26px; border: 1px solid #765c37; border-radius: 3px; padding: 2px 8px; color: #f0c68f; font: 12px var(--mono); white-space: nowrap; }
.topbar-spacer { flex: 1; }
.topbar-clock { color: var(--faint); font: 13px var(--mono); white-space: nowrap; }
.back-link { padding: 5px 0; border-bottom: 1px solid #6b7274; color: #d6dad9; font-size: 14px; white-space: nowrap; }
.back-link:hover { color: var(--amber); border-color: var(--amber); }

.app-shell { display: grid; grid-template-columns: 252px minmax(0, 1fr); min-height: calc(100vh - 64px); }
.sidebar { position: sticky; top: 64px; height: calc(100vh - 64px); min-height: 540px; display: flex; flex-direction: column; padding: 25px 14px 19px; background: #151718; border-right: 1px solid var(--line); }
.workspace-label, .overline, .metric-label, .node-kicker { color: var(--faint); font: 12px var(--mono); letter-spacing: 0; }
.workspace-label { padding-inline: 12px; color: var(--amber); }
.workspace-name { padding: 7px 12px 0; font-size: 19px; font-weight: 650; }
.workspace-meta { padding: 4px 12px 22px; color: var(--muted); font-size: 13px; white-space: nowrap; }
.status-light { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--good); box-shadow: 0 0 0 3px rgba(165,201,168,.08); vertical-align: 1px; margin-right: 4px; flex: none; }
.view-nav { display: grid; gap: 2px; border-top: 1px solid var(--line); padding-top: 17px; }
.view-nav button { width: 100%; min-height: 42px; padding: 8px 12px; border: 1px solid transparent; border-radius: 3px; background: transparent; color: #b9bfc0; text-align: left; cursor: pointer; font-size: 15px; }
.view-nav button:hover { background: #24282a; color: var(--text); }
.view-nav button[aria-selected="true"] { border-color: #4c4f4e; background: #272a2b; color: var(--text); font-weight: 650; }
.view-nav button[aria-selected="true"]::before { content: ""; width: 5px; height: 5px; display: inline-block; margin-right: 9px; vertical-align: 2px; background: var(--amber); }
.sidebar-foot { margin-top: auto; padding: 18px 11px 0; border-top: 1px solid var(--line); display: grid; gap: 6px; }
.sidebar-foot strong { color: var(--amber); font: 12px var(--mono); }
.sidebar-foot span { max-width: 200px; color: var(--faint); font-size: 13px; line-height: 1.45; }
.main-content { width: min(100%, 1450px); min-width: 0; padding: 23px 34px 60px; }
.simulation-notice { display: flex; align-items: center; gap: 10px; min-height: 46px; padding: 9px 12px; border: 1px solid #5e513e; background: #29251e; color: #ded1bc; font-size: 14px; }
.simulation-notice strong { color: #f3d3a4; }
.notice-symbol { width: 17px; height: 17px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--amber); border-radius: 50%; color: var(--amber); font: 12px Georgia, serif; flex: none; }

.page-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 25px; margin: 29px 0 23px; }
.page-heading .overline { color: var(--amber); margin-bottom: 8px; }
.page-heading h1 { margin-bottom: 5px; font-size: 32px; line-height: 1.2; }
.page-subtitle { color: var(--muted); font-size: 15px; }
.network-state { display: inline-flex; align-items: center; gap: 6px; min-height: 30px; margin-top: 9px; padding: 4px 10px; border: 1px solid #42624b; border-radius: 3px; background: var(--good-bg); color: #c4e2c7; font-size: 13px; white-space: nowrap; }
.network-state .status-light { margin: 0; }
.network-state.watch { border-color: #82613a; background: var(--watch-bg); color: #f2d2a6; }
.network-state.watch .status-light { background: var(--watch); }
.metric-strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-top: 1px solid var(--line-strong); border-bottom: 1px solid var(--line-strong); margin-bottom: 34px; }
.metric-strip > div { min-width: 0; padding: 19px 19px 18px; border-right: 1px solid var(--line); }
.metric-strip > div:first-child { padding-left: 0; }
.metric-strip > div:last-child { border-right: 0; }
.metric-strip strong { display: block; margin-top: 5px; font-size: 23px; line-height: 1.25; white-space: normal; overflow-wrap: anywhere; }
.metric-strip small { display: block; margin-top: 2px; color: var(--muted); font-size: 13px; }
.section-title { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin: 0 0 12px; }
.section-title .overline { color: var(--amber); margin-bottom: 3px; }
.section-title h2 { font-size: 19px; }
.section-note { color: var(--faint); font-size: 13px; text-align: right; }
.scenario-bar { display: flex; align-items: center; justify-content: flex-end; gap: 13px; margin: -12px 0 24px; }
.scenario-bar .overline { color: var(--faint); }
.scenario-switch { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 3px; overflow: hidden; }
.scenario-switch button { min-height: 34px; padding: 6px 11px; border: 0; border-right: 1px solid var(--line-strong); background: #202325; color: var(--muted); cursor: pointer; font-size: 13px; white-space: nowrap; }
.scenario-switch button:last-child { border-right: 0; }
.scenario-switch button:hover { color: var(--text); }
.scenario-switch button[aria-pressed="true"] { background: #39332a; color: #f6d09c; font-weight: 650; }

.topology-layout { display: grid; grid-template-columns: minmax(0, 1fr) 285px; gap: 14px; align-items: stretch; }
.topology { min-height: 290px; display: grid; grid-template-columns: minmax(0, 1fr) 30px minmax(0, 1fr) 30px minmax(0, 1.15fr); gap: 0; align-items: center; padding: 18px; border: 1px solid var(--line); background: var(--surface); }
.topology-node { min-width: 0; min-height: 165px; display: flex; flex-direction: column; justify-content: center; padding: 15px 13px; border: 1px solid var(--line-strong); background: #202325; }
.topology-node strong { font-size: 18px; line-height: 1.25; overflow-wrap: anywhere; }
.topology-node > span:nth-of-type(2) { margin-top: 5px; color: var(--muted); font-size: 13px; }
.topology-node small { margin-top: 15px; color: #c1dbc3; font-size: 13px; }
.topology-origin { border-color: #5c8791; }
.topology-origin .node-kicker { color: var(--cyan); }
.node-kicker { margin-bottom: 13px; color: var(--amber); }
.topology-connector { height: 1px; background: var(--cyan); }
.topology-connector span { width: 6px; height: 6px; display: block; position: relative; left: calc(100% - 6px); top: -3px; border-top: 1px solid var(--cyan); border-right: 1px solid var(--cyan); transform: rotate(45deg); }
.topology-players { display: grid; gap: 7px; }
.player-node { min-width: 0; min-height: 64px; display: flex; align-items: center; justify-content: space-between; gap: 5px; padding: 8px 10px; border: 1px solid #515758; border-radius: 0; background: #202325; color: var(--text); text-align: left; cursor: pointer; }
.player-node:hover { border-color: var(--amber); }
.player-node[aria-pressed="true"] { border-color: var(--amber); background: #2a2926; }
.player-node.watch { border-color: #82613a; }
.player-node span:first-child { display: grid; min-width: 0; }
.player-node b { font-size: 14px; overflow-wrap: anywhere; }
.player-node small { color: var(--faint); font-size: 12px; }
.player-state { color: #b9d9bd; font: 12px var(--mono); white-space: nowrap; }
.player-state.watch { color: var(--watch); }
.inspector { min-width: 0; padding: 18px 17px; border: 1px solid var(--line); background: var(--surface); }
.inspector .overline { color: var(--amber); }
.inspector-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 5px; }
.inspector h3 { font-size: 18px; line-height: 1.25; }
.pill { display: inline-flex; align-items: center; justify-content: center; padding: 3px 8px; border-radius: 3px; font: 12px var(--mono); white-space: nowrap; }
.pill-good { background: var(--good-bg); color: #bce2c0; }
.pill-watch { background: var(--watch-bg); color: #f2d2a6; }
.pill-neutral { background: #343a3c; color: #dde2e0; }
.good-text { color: #bce2c0; }
.watch-text { color: var(--watch); }
.inspector dl { margin: 17px 0 0; }
.inspector dl div { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; border-top: 1px solid var(--line); }
.inspector dt { color: var(--muted); font-size: 13px; }
.inspector dd { margin: 0; color: var(--text); font: 13px var(--mono); text-align: right; white-space: nowrap; }
.inspector .good-text { color: #bce2c0; }
.inspector-foot { margin-top: 15px; color: var(--faint); font-size: 13px; }

.charts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-top: 28px; }
.chart-panel { min-width: 0; padding: 16px 18px 12px; border: 1px solid var(--line); background: var(--surface); }
.chart-header { display: flex; justify-content: space-between; align-items: end; gap: 10px; }
.chart-header .overline { margin-bottom: 3px; }
.chart-header h3 { font-size: 16px; }
.chart-header > strong { font: 22px var(--mono); white-space: nowrap; }
.chart-header > strong small { color: var(--muted); font-size: 13px; }
.chart-panel svg { display: block; width: 100%; height: 110px; margin-top: 8px; overflow: visible; }
.chart-panel svg line { stroke: #363b3d; stroke-width: 1; }
.chart-panel svg polyline { fill: none; stroke: var(--amber); stroke-width: 2.3; vector-effect: non-scaling-stroke; stroke-linejoin: round; stroke-linecap: round; }
.chart-panel:nth-child(2) svg polyline { stroke: var(--cyan); }
.chart-axis { display: flex; justify-content: space-between; color: var(--faint); font: 12px var(--mono); }
.activity-line { display: flex; flex-wrap: wrap; gap: 9px 24px; margin-top: 23px; padding-block: 15px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; }
.activity-line b { color: var(--text); font-family: var(--mono); font-weight: 500; }

.table-wrap { width: 100%; overflow-x: auto; border-top: 1px solid var(--line-strong); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 13px 12px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
thead th { color: var(--faint); font: 12px var(--mono); font-weight: 600; }
tbody th { color: var(--text); font-weight: 650; }
tbody td { color: #cdd2d1; }
tbody tr:hover { background: #1a1d1e; }
.sfn-table { min-width: 1200px; }
.sfn-table td:not(:nth-child(2)) { font-family: var(--mono); font-variant-numeric: tabular-nums; }
abbr { text-decoration: none; border-bottom: 1px dotted var(--faint); cursor: help; }
.context-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 36px; margin-top: 36px; }
.context-grid > div { padding-top: 16px; border-top: 1px solid var(--line); }
.context-grid .overline { margin-bottom: 5px; color: var(--amber); }
.context-grid h2 { margin-bottom: 7px; font-size: 19px; }
.context-grid p:last-child { max-width: 460px; color: var(--muted); font-size: 15px; }
.definition-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 26px; margin-top: 32px; }
.definition-row div { display: grid; gap: 4px; padding-top: 11px; border-top: 1px solid var(--line); }
.definition-row strong { font: 13px var(--mono); color: var(--amber); }
.definition-row span { color: var(--muted); font-size: 14px; }

.signaling-summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 34px; border-block: 1px solid var(--line-strong); }
.signaling-summary div { display: grid; gap: 3px; padding: 17px; border-right: 1px solid var(--line); }
.signaling-summary div:first-child { padding-left: 0; }
.signaling-summary div:last-child { border-right: 0; }
.signaling-summary strong { font: 19px var(--mono); overflow-wrap: anywhere; }
.signal-tree { padding: 3px 0; border-top: 1px solid var(--line-strong); }
.signal-tree details { border-bottom: 1px solid var(--line); }
.signal-tree details details { margin-left: 23px; border-bottom: 0; border-top: 1px solid var(--line); }
.signal-tree summary { min-height: 44px; display: flex; flex-wrap: wrap; align-items: center; gap: 9px; padding: 8px 0; list-style: none; cursor: pointer; }
.signal-tree summary::-webkit-details-marker { display: none; }
.tree-chevron { width: 7px; height: 7px; display: inline-block; border-right: 1px solid var(--muted); border-bottom: 1px solid var(--muted); transform: rotate(-45deg); margin-right: 3px; }
details[open] > summary .tree-chevron { transform: rotate(45deg); }
.signal-tree summary strong { font-size: 15px; }
.tree-meta { color: var(--muted); font: 13px var(--mono); }
.signal-tree summary .pill { margin-left: auto; }
.tree-children { padding-left: 23px; border-left: 1px solid #4d5658; }
.flow-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 22px; min-height: 38px; padding: 7px 0; color: #d6dcda; }
.flow-kind { color: var(--cyan); font: 12px var(--mono); }
.flow-row code { color: #c8dddf; font-size: 13px; }
.flow-count { color: var(--faint); font: 13px var(--mono); margin-left: auto; }

.config-section { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 36px; padding: 23px 0 18px; border-top: 1px solid var(--line-strong); }
.config-section .overline { color: var(--amber); margin-bottom: 5px; }
.config-section h2 { font-size: 19px; }
.config-section dl { margin: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px 23px; }
.config-section dl div { min-width: 0; padding-bottom: 9px; border-bottom: 1px solid var(--line); }
.config-section dt { color: var(--faint); font-size: 13px; }
.config-section dd { margin: 3px 0 0; color: var(--text); font-size: 15px; overflow-wrap: anywhere; }
.config-section code { color: var(--cyan); font-size: 14px; }
.noscript { margin-top: 20px; color: var(--amber); }

@media (max-width: 1200px) {
  .topology-layout { grid-template-columns: 1fr; }
  .inspector { max-width: none; }
  .inspector dl { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); column-gap: 20px; }
}

@media (max-width: 900px) {
  .app-shell { display: block; }
  .sidebar { position: static; height: auto; min-height: 0; display: block; padding: 15px 20px 0; border-right: 0; border-bottom: 1px solid var(--line); }
  .workspace-label { display: none; }
  .workspace-name { display: inline-block; padding: 0; }
  .workspace-meta { display: inline-block; padding: 0 0 0 12px; }
  .view-nav { display: flex; gap: 16px; overflow-x: auto; padding: 11px 0 0; margin-top: 12px; border-top: 1px solid var(--line); }
  .view-nav button { width: auto; min-height: 37px; flex: none; padding: 6px 3px; border-radius: 0; border: 0; border-bottom: 2px solid transparent; white-space: nowrap; }
  .view-nav button[aria-selected="true"] { border: 0; border-bottom: 2px solid var(--amber); background: transparent; }
  .view-nav button[aria-selected="true"]::before { display: none; }
  .sidebar-foot { display: none; }
  .main-content { width: 100%; padding-inline: 24px; }
}

@media (max-width: 650px) {
  .topbar { flex-wrap: wrap; gap: 8px 12px; padding-inline: 18px; }
  .topbar-divider, .topbar-product, .topbar-clock { display: none; }
  .topbar-spacer { order: 1; flex-basis: 100%; height: 0; }
  .back-link { order: 2; }
  .main-content { padding: 16px 18px 45px; }
  .simulation-notice { align-items: flex-start; }
  .page-heading { display: block; margin-block: 25px 20px; }
  .page-heading h1 { font-size: 28px; }
  .network-state, .read-only-label { margin-top: 13px; }
  .metric-strip, .signaling-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric-strip > div, .signaling-summary > div { border-right: 0; border-bottom: 1px solid var(--line); padding: 13px 10px; }
  .metric-strip > div:nth-child(odd), .signaling-summary > div:nth-child(odd) { padding-left: 0; border-right: 1px solid var(--line); }
  .metric-strip > div:nth-last-child(-n+2), .signaling-summary > div:nth-last-child(-n+2) { border-bottom: 0; }
  .metric-strip strong { font-size: 20px; }
  .scenario-bar { justify-content: flex-start; flex-wrap: wrap; margin-top: -16px; }
  .topology { grid-template-columns: 1fr; padding: 16px; }
  .topology-node { min-height: 105px; }
  .topology-connector { width: 1px; height: 18px; justify-self: center; }
  .topology-connector span { left: -3px; top: 12px; transform: rotate(135deg); }
  .topology-players { width: 100%; }
  .inspector dl { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .charts, .context-grid, .definition-row { grid-template-columns: 1fr; }
  .config-section { grid-template-columns: 1fr; gap: 16px; }
  .config-section dl { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 400px) {
  .workspace-meta { display: block; padding: 2px 0 0; }
  .section-title { display: block; }
  .section-note { display: block; margin-top: 4px; text-align: left; }
  .inspector dl, .config-section dl { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}
