:root {
  /* type scale */
  --fs-xs: 11px;
  --fs-sm: 12px;
  --fs-md: 13px;
  --fs-base: 14px;
  --fs-lg: 16px;
  --fs-xl: 20px;
  --lh-tight: 1.25;
  --lh: 1.45;
  --lh-loose: 1.55;
  /* spacing */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 24px;
  --s-6: 32px;
  --pad-card: 16px;
  --pad-page: 20px;
  /* radius */
  --r-sm: 4px;
  --r: 6px;
  --r-lg: 10px;
  --radius: var(--r-lg);
  /* controls */
  --control-h: 32px;
  --control-h-sm: 28px;
  --disabled: 0.4;
  --t-fast: 120ms;
  /* elevation */
  --shadow-pop: 0 8px 24px rgba(0, 0, 0, 0.16);
  --backdrop: rgba(0, 0, 0, 0.4);
  /* colors */
  --paper: #eef1f5;
  --panel: #ffffff;
  --sunk: #f6f8fb;
  --ink: #172033;
  --muted: #5b6577;
  --rule: #d3d9e2;
  --rule-strong: #b7c0cd;
  --mark: #f5c400;
  --mark-soft: rgba(245, 196, 0, 0.26);
  --req: #2563eb;
  --ok: #15803d;
  --ok-bg: #16a34a;
  --warn: #b45309;
  --bad: #b91c1c;
  --bad-bg: #dc2626;
  --end: #7c3aed;
  --accent-ai: #9333ea;
  --info: #2563eb;
  --amber: #f59e0b;
  --on-solid: #fff;
  --dot-ok: #22c55e;
  --dot-busy: var(--amber);
  --dot-bad: #ef4444;
  --dot-idle: #64748b;
  --sel: color-mix(in srgb, var(--ink) 8%, var(--panel));
  --sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Noto Sans SC", "Nirmala UI", "Noto Sans Devanagari", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0e1522;
    --panel: #151e2e;
    --sunk: #111a28;
    --ink: #e4e8ef;
    --muted: #95a0b4;
    --rule: #273246;
    --rule-strong: #34425a;
    --mark: #e0b000;
    --mark-soft: rgba(224, 176, 0, 0.2);
    --req: #60a5fa;
    --ok: #4ade80;
    --ok-bg: #15803d;
    --warn: #fbbf24;
    --bad: #f87171;
    --bad-bg: #b91c1c;
    --end: #a78bfa;
    --accent-ai: #c084fc;
    --info: #60a5fa;
    --shadow-pop: 0 8px 24px rgba(0, 0, 0, 0.55);
    --backdrop: rgba(0, 0, 0, 0.6);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --paper: #0e1522;
  --panel: #151e2e;
  --sunk: #111a28;
  --ink: #e4e8ef;
  --muted: #95a0b4;
  --rule: #273246;
  --rule-strong: #34425a;
  --mark: #e0b000;
  --mark-soft: rgba(224, 176, 0, 0.2);
  --req: #60a5fa;
  --ok: #4ade80;
  --ok-bg: #15803d;
  --warn: #fbbf24;
  --bad: #f87171;
  --bad-bg: #b91c1c;
  --end: #a78bfa;
  --accent-ai: #c084fc;
  --info: #60a5fa;
  --shadow-pop: 0 8px 24px rgba(0, 0, 0, 0.55);
  --backdrop: rgba(0, 0, 0, 0.6);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
/* Skip link: off screen until it receives keyboard focus. */
.skip { position: absolute; left: 8px; top: -100px; z-index: 100; padding: 6px 12px; background: var(--panel); color: var(--ink); border: 1px solid var(--rule-strong); border-radius: var(--r); box-shadow: var(--shadow-pop); text-decoration: none; }
.skip:focus { top: 8px; }
html, body { height: 100%; }
html { overflow: hidden; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: var(--fs-base)/var(--lh) var(--sans);
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0;
  overflow: hidden;
}
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: var(--fs-xl); }
h2 { font-size: 15px; }
/* h3 is the section label: small caps-like, muted. */
h3 { font-size: var(--fs-md); margin: 14px 0 6px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: var(--fs-sm); }
.pad { padding: 12px; }
.ok { color: var(--ok); }
.warn { color: var(--warn); }
.bad { color: var(--bad); }
.err { color: var(--bad); }
code, pre, .mono, kbd { font-family: var(--mono); }
.mono { font-size: inherit; }
kbd { font-size: var(--fs-sm); border: 1px solid var(--rule-strong); border-bottom-width: 2px; border-radius: var(--r-sm); padding: 0 5px; background: var(--sunk); }
:focus-visible { outline: 2px solid var(--req); outline-offset: 2px; }
svg:not(.st-ladder) { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
/* Small (15px and under) icons need a heavier stroke to stay legible. */
svg.hi, .ln-dir svg, .meter-row svg { stroke-width: 2; }
.hint { color: var(--muted); font-size: var(--fs-sm); font-weight: 400; }
p.hint { margin: 6px 0 0; }

/* ---------- top bar ---------- */
.bar {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 14px;
  height: 48px;
  background: var(--panel);
  border-bottom: 1px solid var(--rule);
  flex: none;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: var(--fs-lg); letter-spacing: -0.02em; width: 312px; }
.brand svg { width: 24px; height: 24px; stroke: none; stroke-width: 1.6; }
.brand-bg { fill: var(--ink); }
.brand-ink { stroke: var(--mark); fill: none; }
.ws-tabs { display: flex; gap: 2px; align-self: stretch; overflow-x: auto; }
.ws-tabs button {
  font: inherit;
  font-weight: 500;
  color: var(--muted);
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  padding: 0 12px;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color var(--t-fast), border-color var(--t-fast), color var(--t-fast);
}
.ws-tabs button:hover { color: var(--ink); }
.ws-tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--mark); }
.ws-tabs button:focus-visible, .tabs button:focus-visible, .seg.nav button:focus-visible { outline-offset: -2px; }
.ws-tabs b:empty { display: none; }
.ws-tabs b { font-weight: 500; font-size: var(--fs-xs); color: var(--muted); background: var(--paper); border-radius: var(--r-sm); padding: 0 6px; margin-left: 4px; }
.bar-right { margin-left: auto; display: flex; gap: 6px; align-items: center; }

.btn {
  font: inherit;
  font-weight: 500;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--rule-strong);
  border-radius: var(--r);
  min-height: var(--control-h);
  padding: 4px 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  transition: background-color var(--t-fast), border-color var(--t-fast), color var(--t-fast);
}
.btn.small { min-height: var(--control-h-sm); padding: 2px 10px; font-size: var(--fs-md); }
.btn:hover:not(:disabled) { border-color: var(--ink); background: var(--sunk); }
.btn:disabled { opacity: var(--disabled); cursor: default; }
.btn.primary { background: var(--ink); color: var(--panel); border-color: var(--ink); }
.btn.primary:hover:not(:disabled) { background: var(--ink); }
.btn.ghost { border-color: transparent; color: var(--muted); }
.btn.ghost:hover:not(:disabled) { color: var(--ink); border-color: var(--rule-strong); }
.btn.ok { background: var(--ok-bg); border-color: var(--ok-bg); color: var(--on-solid); }
.btn.ok:hover:not(:disabled) { background: var(--ok-bg); border-color: var(--ok-bg); }
.btn.danger { background: var(--bad-bg); border-color: var(--bad-bg); color: var(--on-solid); }
.btn.danger:hover:not(:disabled) { background: var(--bad-bg); border-color: var(--bad-bg); }
.btn[aria-pressed="true"], .btn[aria-pressed="true"]:hover:not(:disabled) { background: var(--sel); border-color: var(--ink); }
.linklike { font: inherit; font-size: var(--fs-md); color: var(--req); background: none; border: 0; cursor: pointer; padding: 0; }
.linklike:hover { text-decoration: underline; }

.menu { position: relative; }
.menu-list {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 30;
  min-width: 290px;
  background: var(--panel);
  border: 1px solid var(--rule-strong);
  border-radius: var(--r);
  padding: 4px;
  box-shadow: var(--shadow-pop);
}
.menu-list.right { left: auto; right: 0; }
.menu.open .menu-list { display: block; }
.menu-list button { display: block; width: 100%; text-align: left; font: inherit; color: var(--ink); background: none; border: 0; border-radius: var(--r-sm); padding: 7px 10px; cursor: pointer; }
.menu-list button:hover, .menu-list button:focus-visible { background: var(--sel); }
.menu-list small { display: block; color: var(--muted); }

/* ---------- shell ---------- */
.shell { flex: 1; display: flex; min-height: 0; min-width: 0; overflow: hidden; }
.ws { flex: 1; min-width: 0; overflow: auto; position: relative; }
.ws-page { padding: 18px var(--pad-page) 28px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.card { background: var(--panel); border: 1px solid var(--rule); border-radius: var(--r-lg); padding: var(--pad-card); min-width: 0; }
.card > h2 { margin-bottom: 8px; }
.card p { margin: 0 0 10px; }
.sect-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.empty-note { color: var(--muted); margin: 6px 0; }
body.dragging .ws { outline: 2px dashed var(--mark); outline-offset: -8px; }
.table-wrap { overflow-x: auto; max-width: 100%; }

/* ---------- phone panel ---------- */
.phone {
  width: 340px;
  flex: none;
  background: var(--panel);
  border-right: 1px solid var(--rule);
  overflow-y: auto;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.acct-row { display: flex; align-items: center; gap: 8px; }
.acct-row select { flex: 1; font-weight: 600; background: var(--panel); }
.acct-state { font-size: var(--fs-sm); color: var(--muted); margin-top: -4px; line-height: var(--lh-tight); }
.acct-state.bad { color: var(--bad); }
.icon-btn { flex: none; display: grid; place-items: center; width: var(--control-h); height: var(--control-h); border: 1px solid var(--rule); background: var(--panel); color: var(--muted); border-radius: var(--r); cursor: pointer; transition: background-color var(--t-fast), border-color var(--t-fast), color var(--t-fast); }
.icon-btn.sm { width: 24px; height: 24px; }
.icon-btn:hover { color: var(--ink); border-color: var(--rule-strong); background: var(--sunk); }
.icon-btn[aria-expanded="true"] { background: var(--sel); border-color: var(--ink); color: var(--ink); }

.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--rule-strong); flex: none; display: inline-block; }
.dot.ok { background: var(--dot-ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--dot-ok) 20%, transparent); }
.dot.busy { background: var(--dot-busy); animation: blink 1s infinite; }
.dot.bad { background: var(--dot-bad); box-shadow: 0 0 0 3px color-mix(in srgb, var(--dot-bad) 18%, transparent); }
.dot.idle { background: var(--dot-idle); }
@keyframes blink { 50% { opacity: 0.35; } }

.dial { display: flex; gap: 6px; }
.dial input {
  flex: 1;
  height: auto;
  font: 500 19px/1.2 var(--sans);
  letter-spacing: 0.01em;
  padding: 8px 10px;
  border-radius: var(--r);
  background: var(--sunk);
  min-width: 0;
}
.dial .icon-btn { height: auto; align-self: stretch; }
.opts { display: grid; gap: 8px; padding: 10px; border: 1px dashed var(--rule-strong); border-radius: var(--r-lg); background: var(--sunk); }
.opts textarea { font-size: var(--fs-sm); }
.opts p { margin: 0; }
.callbar { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.big {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font: 600 15px var(--sans);
  border: 0;
  border-radius: var(--r-lg);
  padding: 11px 0;
  cursor: pointer;
  color: var(--on-solid);
}
.big svg { width: 20px; height: 20px; fill: currentColor; stroke: none; }
.big.call { background: var(--ok-bg); }
.big.hangup { background: var(--bad-bg); }
.big:disabled, .big.hangup:disabled { background: var(--sunk); color: var(--muted); opacity: 1; cursor: default; }
.big.pulse { animation: ring 1.1s infinite; }
@keyframes ring { 0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok-bg) 55%, transparent); } 50% { box-shadow: 0 0 0 7px color-mix(in srgb, var(--ok-bg) 0%, transparent); } }

.tools { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.tool {
  display: grid;
  justify-items: center;
  gap: 3px;
  font: 500 var(--fs-xs) var(--sans);
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--rule);
  border-radius: var(--r-lg);
  padding: 7px 2px 6px;
  cursor: pointer;
  transition: background-color var(--t-fast), border-color var(--t-fast), color var(--t-fast);
}
.tool svg { width: 20px; height: 20px; }
.tool .fill { fill: currentColor; stroke: none; }
.tool:hover:not(:disabled) { border-color: var(--rule-strong); background: var(--sunk); }
.tool:disabled { opacity: var(--disabled); cursor: default; }
.tool[aria-pressed="true"] { background: var(--mark-soft); border-color: var(--mark); }
.tool[data-tool="mute"]:not([aria-pressed="true"]) .slash { display: none; }
.tool[data-tool="record"][aria-pressed="true"] { color: var(--bad); }
.tool[data-tool="dnd"][aria-pressed="true"] { color: var(--bad); }

.xfer { display: grid; gap: 8px; padding: 10px; border: 1px solid var(--mark); border-radius: var(--r-lg); background: var(--mark-soft); }
.xfer-head { font-weight: 600; font-size: var(--fs-md); }
.xfer-btns { display: flex; flex-wrap: wrap; gap: 6px; }
.xfer .hint { margin: 0; }
.xfer .dial input { font-size: 15px; background: var(--panel); }

.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.keypad button {
  display: grid;
  align-content: center;
  justify-items: center;
  height: 46px;
  font: 400 21px/1 var(--sans);
  color: var(--ink);
  background: var(--sunk);
  border: 1px solid var(--rule);
  border-radius: var(--r-lg);
  cursor: pointer;
  user-select: none;
}
/* Decorative letters under the digits: the one place allowed below the 11px floor. */
.keypad button small { font: 500 9.5px/1.3 var(--sans); letter-spacing: 0.1em; color: var(--muted); }
.keypad button:hover { border-color: var(--rule-strong); }
.keypad button:active, .keypad button.hit { background: var(--mark-soft); border-color: var(--mark); }

.lines { display: grid; gap: 6px; }
.lines h2 { font-size: var(--fs-md); text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
#lines { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.line {
  border: 1px solid var(--rule);
  border-left: 4px solid var(--rule-strong);
  border-radius: var(--r-lg);
  padding: 7px 10px;
  cursor: pointer;
  display: grid;
  gap: 2px;
  background: var(--panel);
}
.line.sel { background: var(--sel); border-color: var(--rule-strong); }
.line.st-connected { border-left-color: var(--ok-bg); }
.line.st-incoming { border-left-color: var(--mark); animation: glow 1.1s infinite; }
.line.st-calling, .line.st-ringing, .line.st-early { border-left-color: var(--req); }
.line.held { border-left-color: var(--amber); }
.line.st-ended { opacity: 0.6; }
@keyframes glow { 50% { background: var(--mark-soft); } }
.ln-top { display: flex; align-items: center; gap: 6px; font-size: var(--fs-sm); }
.ln-dir svg { width: 14px; height: 14px; color: var(--muted); }
.ln-state { font-weight: 600; }
.ln-dur { margin-left: auto; font-family: var(--mono); color: var(--muted); }
.ln-remote { font-size: var(--fs-base); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ln-remote span { font-family: var(--mono); font-size: var(--fs-md); }
.ln-meta { font-size: var(--fs-sm); color: var(--muted); }
.ln-act { display: flex; gap: 6px; margin-top: 4px; }

.audio-strip { margin-top: auto; display: grid; gap: 4px; padding-top: 8px; border-top: 1px solid var(--rule); }
.meter-row { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.meter-row svg { width: 15px; height: 15px; }
/* The scale fills from the left; the cover (i) hides the part above the current level. */
.meter { flex: 1; height: 6px; border-radius: var(--r-sm); overflow: hidden; position: relative; background: linear-gradient(90deg, var(--dot-ok) 0 70%, var(--amber) 70% 88%, var(--dot-bad) 88%); }
.meter i { position: absolute; top: 0; right: 0; bottom: 0; width: 100%; background: var(--sunk); transition: width var(--t-fast) linear; }
.meter::after { content: ""; position: absolute; inset: 0; border: 1px solid var(--rule); border-radius: inherit; pointer-events: none; }
.audio-src { font-size: var(--fs-sm); color: var(--muted); }
.meters { display: grid; gap: 6px; margin: 10px 0; max-width: 420px; }

/* ---------- calls page ---------- */
.calls-grid { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 14px; margin-bottom: 14px; }
.cd-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.badge { font-size: var(--fs-xs); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; border-radius: var(--r-sm); padding: 1px 6px; line-height: 1.5; background: var(--paper); color: var(--muted); }
.badge.ok, .badge.st-connected { background: color-mix(in srgb, var(--ok) 14%, transparent); color: var(--ok); }
.badge.warn { background: color-mix(in srgb, var(--warn) 14%, transparent); color: var(--warn); }
.badge.bad { background: color-mix(in srgb, var(--bad) 14%, transparent); color: var(--bad); }
.badge.st-incoming { background: var(--mark-soft); color: var(--ink); }
.badge.st-calling, .badge.st-ringing, .badge.st-early { background: color-mix(in srgb, var(--req) 14%, transparent); color: var(--req); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 3px 14px; margin: 0 0 10px; font-size: var(--fs-md); }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.kv dd .mono { word-break: break-all; }
.recs { border-top: 1px solid var(--rule); margin-top: 12px; }
.recs ul { margin: 0; padding-left: 18px; }
.events-card { display: flex; flex-direction: column; max-height: 380px; }
.events { list-style: none; margin: 6px 0 0; padding: 0; overflow: auto; font-size: var(--fs-md); flex: 1; }
.events li { display: grid; grid-template-columns: 62px 96px 1fr; gap: 8px; padding: 2px 0; border-bottom: 1px solid var(--rule); }
.ev-t { font-family: var(--mono); font-size: var(--fs-sm); color: var(--muted); }
.ev-k { color: var(--muted); }
.ev-error .ev-k, .ev-error .ev-x { color: var(--bad); }
.ev-incoming .ev-k { color: var(--ink); font-weight: 600; }
.ev-reg .ev-k { color: var(--req); }
table.hist { width: 100%; border-collapse: collapse; font-size: var(--fs-md); }
table.hist th { text-align: left; color: var(--muted); font-weight: 500; padding: 4px 8px; border-bottom: 1px solid var(--rule-strong); }
table.hist td { padding: 4px 8px; border-bottom: 1px solid var(--rule); white-space: nowrap; }
table.hist td.num { font-family: var(--mono); }
table.hist tr.missed td:nth-child(2) { color: var(--bad); }
table.hist .acts { text-align: right; }
.hi { width: 15px; height: 15px; color: var(--muted); }
tr.missed .hi { color: var(--bad); }
#hist-filter, #tr-filter { width: 260px; }

/* ---------- trace page ---------- */
.ws-page.trace-page { height: 100%; display: flex; flex-direction: column; padding-bottom: 0; }
.trace-page .page-head .row { gap: 8px 12px; }
.trace-split { position: relative; flex: 1; min-height: 0; display: grid; grid-template-rows: minmax(60px, 1fr) var(--tr-bottom, 42%); border: 1px solid var(--rule); border-radius: var(--r-lg) var(--r-lg) 0 0; overflow: hidden; background: var(--panel); }
.trace-list { overflow: auto; font: var(--fs-sm)/1.6 var(--mono); border-bottom: 1px solid var(--rule-strong); }
.tr-row { display: grid; grid-template-columns: 92px 14px minmax(140px, 190px) minmax(0, 1fr) 118px; gap: 8px; padding: 1px 10px; cursor: pointer; white-space: nowrap; }
.tr-row > span { overflow: hidden; text-overflow: ellipsis; }
.tr-row:hover { background: var(--sunk); }
.tr-row.sel { background: var(--sel); }
.tr-t, .tr-c, .tr-a { color: var(--muted); }
.tr-row.out .tr-d { color: var(--req); }
.tr-row.in .tr-d { color: var(--end); }
.tr-row.r-req .tr-f { font-weight: 600; }
.tr-row.r-ok .tr-f { color: var(--ok); }
.tr-row.r-warn .tr-f { color: var(--warn); }
.tr-row.r-err .tr-f { color: var(--bad); font-weight: 600; }
.tr-row.r-prov .tr-f { color: var(--muted); }
.trace-view { overflow: auto; padding: 10px 14px; background: var(--sunk); }

/* ---------- analysis page ---------- */
.ws-page.analysis-page { height: 100%; padding: 0; display: flex; flex-direction: column; }
.an-empty { padding: 22px; max-width: 980px; display: grid; gap: 10px; }
.an-empty p { margin: 0; max-width: 85ch; }
.an { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.an-bar { display: flex; align-items: center; gap: 8px; padding: 8px 14px; border-bottom: 1px solid var(--rule); background: var(--panel); }
.capinfo { color: var(--muted); font-size: var(--fs-md); flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.an-grid {
  flex: 1;
  display: grid;
  grid-template-columns: var(--an-left, 280px) minmax(0, 1fr);
  grid-template-rows: minmax(80px, 1fr) var(--an-bottom, 42%);
  grid-template-areas: "calls ladder" "calls detail";
  min-height: 0;
  position: relative;
}
.sample-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
.sample-grid button { font: inherit; text-align: left; color: var(--ink); background: var(--panel); border: 1px solid var(--rule); border-left: 3px solid var(--rule-strong); border-radius: var(--r); padding: 9px 12px; cursor: pointer; }
.sample-grid button:hover { border-left-color: var(--mark); background: var(--sunk); }
.sample-grid b { display: block; font-family: var(--mono); font-weight: 500; font-size: var(--fs-md); }
.sample-grid span { color: var(--muted); font-size: var(--fs-sm); }

.calls { grid-area: calls; border-right: 1px solid var(--rule); background: var(--panel); overflow: auto; min-height: 0; }
.calls-head { display: flex; justify-content: space-between; align-items: baseline; padding: 10px 14px 6px; color: var(--muted); }
.calls-head h2 { color: var(--ink); }
#calls { list-style: none; margin: 0; padding: 0 0 12px; }
#calls li { border-bottom: 1px solid var(--rule); display: grid; grid-template-columns: auto 1fr; align-items: stretch; }
#calls li.picked { background: var(--sel); }
.c-pick { display: flex; align-items: flex-start; padding: 10px 0 0 10px; cursor: pointer; }
.c-pick input { margin: 0; cursor: pointer; }
.calls-head { gap: 8px; }
.calls-head .grow { flex: 1; }
.calls-hint { margin: 0; padding: 0 14px 6px; font-size: var(--fs-sm); }
#calls button { width: 100%; font: inherit; text-align: left; color: var(--ink); background: none; border: 0; padding: 8px 14px 8px 11px; border-left: 3px solid transparent; cursor: pointer; display: grid; gap: 1px; }
#calls button:hover { background: var(--sunk); }
#calls button[aria-current="true"] { border-left-color: var(--mark); background: var(--sel); }
.c-top { display: flex; justify-content: space-between; gap: 8px; font-weight: 500; }
.c-parties { font-family: var(--mono); font-size: var(--fs-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.c-meta { color: var(--muted); font-size: var(--fs-sm); display: flex; gap: 10px; }
.state { font-size: var(--fs-sm); font-weight: 600; }
.state.answered { color: var(--ok); }
.state.failed { color: var(--bad); }
.state.cancelled, .state.in_progress { color: var(--warn); }
.state.non_invite { color: var(--muted); }
.cnt-e { color: var(--bad); font-weight: 600; }
.cnt-w { color: var(--warn); font-weight: 600; }

.ladder-wrap { grid-area: ladder; display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.call-head { padding: 8px 16px; border-bottom: 1px solid var(--rule); display: flex; flex-wrap: wrap; gap: 4px 18px; align-items: baseline; }
.call-head h2 { font-family: var(--mono); font-weight: 500; font-size: var(--fs-base); }
.call-head dl { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 0; font-size: var(--fs-md); }
.call-head dt { color: var(--muted); display: inline; }
.call-head dd { display: inline; margin: 0 0 0 4px; font-weight: 500; }
.ladder { flex: 1; overflow: auto; padding: 8px 4px 16px; min-height: 0; }
.ladder svg { display: block; max-width: none; }
.ladder .st-ladder text { font-family: var(--mono); }
.ladder .st-ladder .msg.sel .hit { fill: var(--mark); fill-opacity: 0.35; }

.detail { grid-area: detail; border-top: 1px solid var(--rule-strong); background: var(--panel); display: flex; flex-direction: column; min-height: 0; }
.tabs { display: flex; gap: 2px; padding: 0 10px; border-bottom: 1px solid var(--rule); overflow-x: auto; }
.tabs button { font: inherit; font-weight: 500; color: var(--muted); background: none; border: 0; border-bottom: 2px solid transparent; padding: 8px 12px 7px; cursor: pointer; white-space: nowrap; transition: background-color var(--t-fast), border-color var(--t-fast), color var(--t-fast); }
.tabs button:hover { color: var(--ink); }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--mark); }
.tabs b { font-weight: 600; color: var(--ink); }
.tab-body { flex: 1; overflow: auto; padding: 12px var(--pad-card) 20px; min-height: 0; }

.findings { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; max-width: 980px; }
.findings li { border: 1px solid var(--rule); border-left: 4px solid var(--rule-strong); border-radius: var(--r-sm); padding: 8px 12px; cursor: pointer; }
.findings li:hover { background: var(--sunk); }
.findings li.error { border-left-color: var(--bad); }
.findings li.warning { border-left-color: var(--warn); }
.findings li.info { border-left-color: var(--info); }
.findings .f-title { font-weight: 600; }
.findings .f-sev { font-size: var(--fs-sm); font-weight: 600; margin-right: 6px; }
.findings li.error .f-sev { color: var(--bad); }
.findings li.warning .f-sev { color: var(--warn); }
.findings li.info .f-sev { color: var(--info); }
.findings .f-detail { color: var(--muted); margin-top: 2px; max-width: 95ch; }
.findings .f-rule { font-family: var(--mono); font-size: var(--fs-xs); color: var(--muted); }

.sipmsg { font: var(--fs-md)/var(--lh-loose) var(--mono); white-space: pre-wrap; word-break: break-all; margin: 0; max-width: 140ch; }
.sipmsg .sl { font-weight: 600; }
.sipmsg .hn { color: var(--req); }
.sipmsg .sdp { color: var(--end); }
.sipmsg.preview { background: var(--sunk); border: 1px solid var(--rule); border-radius: var(--r); padding: 10px 12px; font-size: var(--fs-sm); }
.msg-meta { display: flex; flex-wrap: wrap; gap: 4px 16px; color: var(--muted); font-size: var(--fs-md); margin-bottom: 8px; }
.msg-notes { color: var(--warn); margin: 0 0 8px; }

table.media { border-collapse: collapse; font-size: var(--fs-md); min-width: 0; }
table.media th, table.media td { padding: 4px 8px; border-bottom: 1px solid var(--rule); text-align: right; white-space: nowrap; }
table.media th { color: var(--muted); font-weight: 500; white-space: normal; }
table.media td:first-child, table.media th:first-child { text-align: left; font-family: var(--mono); font-size: var(--fs-sm); }
td.bad { color: var(--bad); font-weight: 600; }
td.warn { color: var(--warn); font-weight: 600; }
.trace { max-width: 140ch; }
.trace article { border-bottom: 1px solid var(--rule); padding: 10px 0; }
.trace header { font-size: var(--fs-md); color: var(--muted); margin-bottom: 4px; }
.trace header b { color: var(--ink); font-weight: 600; }
.webrtc { margin-top: 14px; max-width: 760px; }
.webrtc h3 { margin: 0 0 6px; }
.webrtc dl { display: grid; grid-template-columns: max-content 1fr; gap: 3px 14px; margin: 0; font-size: var(--fs-md); }
.webrtc dt { color: var(--muted); }
.webrtc dd { margin: 0; font-family: var(--mono); font-size: var(--fs-sm); }

/* ---------- forms ---------- */
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; }
.row.checks { gap: 6px 20px; }
label { display: grid; gap: 3px; font-size: var(--fs-md); color: var(--muted); }
label.grow { flex: 1; min-width: 200px; }
label.block { display: grid; }
label.check { display: flex; align-items: center; gap: 6px; color: var(--ink); }
input, select, textarea {
  font: inherit;
  font-size: var(--fs-base);
  color: var(--ink);
  background: var(--sunk);
  border: 1px solid var(--rule-strong);
  border-radius: var(--r);
  padding: 4px 8px;
  min-width: 0;
}
input, select { height: var(--control-h); }
textarea { padding: 6px 8px; }
input[type="checkbox"] { accent-color: var(--ink); width: 15px; height: 15px; }
textarea { font-family: var(--mono); font-size: var(--fs-md); width: 100%; resize: vertical; }
.ai-form { display: grid; gap: 10px; max-width: 980px; }
.ai-out { margin-top: 16px; max-width: 95ch; }
.ai-out .answer { white-space: pre-wrap; line-height: var(--lh-loose); }
/* Headings inside generated answers are content headings, not section labels. */
.ai-out .answer h3, .msg-a .answer h3 { font-size: var(--fs-base); text-transform: none; letter-spacing: -0.01em; color: var(--ink); }
.ai-out .answer h3 { margin: 14px 0 4px; }
.ai-out pre { font-size: var(--fs-sm); background: var(--paper); padding: 10px; border-radius: var(--r); overflow: auto; max-height: 50vh; white-space: pre-wrap; }

.seg { display: inline-flex; flex-wrap: wrap; gap: 2px; background: var(--paper); border: 1px solid var(--rule); border-radius: var(--r); padding: 2px; }
.seg button { font: inherit; font-size: var(--fs-md); font-weight: 500; color: var(--muted); background: none; border: 0; border-radius: var(--r-sm); padding: 5px 11px; cursor: pointer; transition: background-color var(--t-fast), border-color var(--t-fast), color var(--t-fast); }
.seg button:hover { color: var(--ink); }
.seg button[aria-selected="true"] { background: var(--panel); color: var(--ink); }
/* .seg.nav: a navigation strip styled like .tabs (underline, no pill). */
.seg.nav { background: none; border: 0; border-bottom: 1px solid var(--rule); border-radius: 0; padding: 0; gap: 2px; }
.seg.nav button { font-size: var(--fs-base); font-weight: 500; border-radius: 0; border-bottom: 2px solid transparent; padding: 8px 12px 7px; margin-bottom: -1px; }
.seg.nav button[aria-selected="true"] { background: none; color: var(--ink); border-bottom-color: var(--mark); }

/* ---------- diagnostics ---------- */
.diag-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(440px, 1fr)); gap: 14px; align-items: start; }
.dg-out:not(:empty) { margin-top: 10px; }
.dg-out p { margin: 0 0 6px; }
table.mini { border-collapse: collapse; font-size: var(--fs-md); width: 100%; }
table.mini th { text-align: left; color: var(--muted); font-weight: 500; padding: 4px 8px 4px 0; border-bottom: 1px solid var(--rule-strong); }
table.mini td { padding: 4px 8px 4px 0; border-bottom: 1px solid var(--rule); vertical-align: top; }
ol.steps { margin: 0; padding-left: 20px; font-size: var(--fs-md); }

/* ---------- settings ---------- */
.settings { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 22px; align-items: start; max-width: 1180px; }
.set-nav { background: var(--panel); border: 1px solid var(--rule); border-radius: var(--r-lg); padding: 8px; position: sticky; top: 0; }
.set-nav ol { list-style: none; margin: 0 0 8px; padding: 0; }
.set-nav-head { display: flex; justify-content: space-between; align-items: baseline; font-size: var(--fs-md); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); padding: 6px 8px 4px; }
.set-nav li button { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; font: inherit; color: var(--ink); background: none; border: 0; border-radius: var(--r-sm); padding: 6px 8px; cursor: pointer; }
.set-nav li button:hover { background: var(--sunk); }
.set-nav li button[aria-current="true"] { background: var(--sel); font-weight: 600; }
.set-body { min-width: 0; display: grid; gap: 14px; }
.set-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.set-form { background: var(--panel); border: 1px solid var(--rule); border-radius: var(--r-lg); padding: var(--pad-card); display: grid; gap: 12px; }
.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px 18px; }
.fld { display: grid; gap: 4px; align-content: start; color: var(--ink); font-weight: 500; }
.fld .hint { display: block; }
label.check.fld { display: flex; align-items: flex-start; flex-wrap: wrap; gap: 4px 8px; font-weight: 500; padding-top: 4px; }
label.check.fld .hint { flex-basis: 100%; padding-left: 23px; }
.set-actions { display: flex; justify-content: flex-end; align-items: center; gap: 10px; }
.codecs { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.codecs li { display: flex; align-items: center; justify-content: space-between; gap: 10px; border: 1px solid var(--rule); border-radius: var(--r); padding: 5px 10px; background: var(--sunk); }
.codecs li:hover { background: var(--sunk); border-color: var(--rule-strong); }
.codecs li:first-child [data-up] { visibility: hidden; }
.hdrs { display: grid; gap: 6px; }
.hdr-row { display: grid; grid-template-columns: 1fr 2fr auto; gap: 6px; align-items: center; }
.set-empty { background: var(--panel); border: 1px solid var(--rule); border-radius: var(--r-lg); padding: 24px; display: grid; gap: 10px; justify-items: start; max-width: 680px; }
.set-empty p { margin: 0; }
input.readonly { background: var(--sunk); color: var(--muted); cursor: default; }
.prov-dialog { border: 1px solid var(--rule); border-radius: var(--r-lg); padding: 0; max-width: 480px; background: var(--panel); color: var(--ink); box-shadow: var(--shadow-pop); }
.prov-dialog::backdrop { background: var(--backdrop); }
.prov-form { padding: var(--pad-page); display: grid; gap: 12px; margin: 0; }
.prov-form h2 { margin: 0; font-size: var(--fs-lg); }
.prov-actions { justify-content: flex-end; margin-top: 4px; }

/* ---------- status bar ---------- */
.status { flex: none; display: flex; align-items: center; gap: 18px; height: 28px; padding: 0 14px; background: var(--panel); border-top: 1px solid var(--rule); font-size: var(--fs-sm); color: var(--muted); white-space: nowrap; overflow: hidden; }
.st-item { display: inline-flex; align-items: center; gap: 6px; }
.st-item .dot { width: 8px; height: 8px; box-shadow: none; }
#st-acct { color: var(--ink); }
.st-spacer { flex: 1; }
.st-err { font: inherit; font-size: var(--fs-sm); font-weight: 600; color: var(--bad); background: none; border: 0; cursor: pointer; }

.toast {
  position: fixed;
  bottom: 56px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--panel);
  padding: 10px 16px;
  border-radius: var(--r);
  border-left: 3px solid var(--ok);
  box-shadow: var(--shadow-pop);
  font-size: var(--fs-md);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  max-width: calc(100vw - 32px);
  z-index: 50;
}
.toast.bad, .toast.error { border-left-color: var(--bad); }
.toast.show { opacity: 1; }

body.web-mode [data-native] { display: none !important; }

@media (max-width: 1100px) {
  .calls-grid { grid-template-columns: 1fr; }
  .brand { width: auto; }
}
@media (max-width: 860px) {
  html { height: auto; overflow: auto; }
  body { position: static; inset: auto; height: auto; overflow: auto; }
  .bar { height: auto; flex-wrap: wrap; padding: 8px 12px; gap: 8px; }
  .ws-tabs { order: 3; flex-basis: 100%; }
  .ws-tabs button { padding: 8px 10px; }
  .shell { flex-direction: column; }
  .phone { width: 100%; border-right: 0; border-bottom: 1px solid var(--rule); overflow: visible; }
  .ws { overflow: visible; }
  .ws-page { padding: 14px 12px 24px; }
  .ws-page.analysis-page, .ws-page.trace-page { height: auto; }
  .an-grid { grid-template-columns: 1fr; grid-template-rows: auto minmax(320px, 60vh) auto; grid-template-areas: "calls" "ladder" "detail"; }
  .gutter { display: none; }
  .calls { border-right: 0; border-bottom: 1px solid var(--rule); max-height: 34vh; }
  .detail { min-height: 50vh; }
  .trace-split { height: 70vh; }
  .settings { grid-template-columns: 1fr; }
  .set-nav { position: static; }
  .diag-grid { grid-template-columns: 1fr; }
  #hist-filter, #tr-filter { width: 100%; }
  table.hist { display: block; overflow-x: auto; }
  .status { flex-wrap: wrap; height: auto; padding: 4px 12px; gap: 4px 14px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ---------- help and about ---------- */
.help { max-width: 1100px; }
.help .lead { font-size: 15px; margin: 0 0 12px; max-width: 80ch; }
.lang-pick { display: flex; align-items: center; gap: 8px; }
.help-toc { display: flex; flex-wrap: wrap; gap: 6px 12px; margin-bottom: 14px; font-size: var(--fs-md); }
.help-toc a, .about a { color: var(--req); text-decoration: none; }
.help-toc a:hover, .about a:hover { text-decoration: underline; }
.help-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 14px; }
.help-grid ul { margin: 0; padding-left: 18px; display: grid; gap: 6px; }
.help-keys { color: var(--muted); margin: 14px 0; }
.about { margin-top: 14px; max-width: 720px; }
.about-head { display: flex; gap: 14px; align-items: center; margin-bottom: 12px; }
.about-head svg { width: 48px; height: 48px; stroke: none; stroke-width: 1.6; }
.about-head h2 { font-size: var(--fs-lg); margin: 0; }
.about-head p { margin: 2px 0 0; color: var(--muted); }
@media (max-width: 860px) { .help-grid { grid-template-columns: 1fr; } }

/* ---------- AI ---------- */
.ws-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ws-col > .ws { flex: 1; }
.ai-btn svg, .ai-dock-head b svg { width: 16px; height: 16px; color: var(--accent-ai); }
.ai-btn[aria-expanded="true"] { background: var(--sel); border-color: var(--ink); }
.ai-using { margin: 0; color: var(--muted); font-size: var(--fs-md); }
.ai-dock { flex: none; height: 42vh; min-height: 220px; display: flex; flex-direction: column; background: var(--panel); border-top: 2px solid var(--accent-ai); box-shadow: var(--shadow-pop); }
.ai-dock-head { display: flex; align-items: center; gap: 10px; padding: 6px 12px; border-bottom: 1px solid var(--rule); flex-wrap: wrap; }
.ai-dock-head b { display: inline-flex; align-items: center; gap: 6px; }
.ai-dock-head select { max-width: 420px; font-size: var(--fs-md); height: var(--control-h-sm); padding: 2px 6px; }
.ai-dock-head .icon-btn { width: 24px; height: 24px; font-size: var(--fs-lg); line-height: 1; }
.ai-chat { flex: 1; overflow: auto; padding: 12px 16px; display: flex; flex-direction: column; gap: 10px; }
.msg-u { align-self: flex-end; max-width: 75%; background: var(--mark-soft); border: 1px solid var(--mark); border-radius: var(--r-lg) var(--r-lg) 2px var(--r-lg); padding: 7px 11px; white-space: pre-wrap; }
.msg-a { align-self: flex-start; max-width: 92%; }
.msg-a .answer { white-space: pre-wrap; line-height: var(--lh-loose); }
.msg-a .answer h3 { margin: 10px 0 2px; }
.msg-e { color: var(--bad); }
.msg-p { font-size: var(--fs-sm); background: var(--sunk); border: 1px solid var(--rule); border-radius: var(--r); padding: 8px 10px; max-height: 260px; overflow: auto; white-space: pre-wrap; margin: 0; }
.ai-empty p { color: var(--muted); margin: 0 0 10px; max-width: 80ch; }
.ai-suggest { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font: inherit; font-size: var(--fs-md); color: var(--ink); background: var(--sunk); border: 1px solid var(--rule-strong); border-radius: var(--r); padding: 4px 11px; cursor: pointer; transition: background-color var(--t-fast), border-color var(--t-fast), color var(--t-fast); }
.chip:hover { border-color: var(--accent-ai); }
.ai-dock-input { display: flex; gap: 8px; padding: 8px 12px; border-top: 1px solid var(--rule); align-items: flex-end; }
.ai-dock-input textarea { flex: 1; font-family: var(--sans); font-size: var(--fs-base); resize: none; }
.dock-btns { display: grid; gap: 4px; }
@media (max-width: 860px) { .ai-dock { height: 60vh; } }

/* ---------- BLF ---------- */
.blf { display: grid; gap: 6px; }
.blf h2 { font-size: var(--fs-md); text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.blf-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }
.blf-item { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 8px; align-items: center; text-align: left; font: inherit; color: var(--ink); background: var(--panel); border: 1px solid var(--rule); border-radius: var(--r); padding: 5px 9px; cursor: pointer; transition: background-color var(--t-fast), border-color var(--t-fast), color var(--t-fast); }
.blf-item:hover { border-color: var(--rule-strong); background: var(--sunk); }
.blf-item .dot { grid-row: span 2; }
.blf-t { font-family: var(--mono); font-size: var(--fs-md); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.blf-s { font-size: var(--fs-xs); color: var(--muted); }
.blf-idle .dot { background: var(--dot-ok); }
.blf-ringing .dot { background: var(--dot-busy); animation: blink 0.6s infinite; }
.blf-busy .dot { background: var(--dot-bad); }
.blf-error .dot, .blf-unknown .dot { background: var(--rule-strong); }
.tools { grid-template-columns: repeat(5, 1fr); }
.tool span { font-size: var(--fs-xs); }

/* Presence */
.pres-row { display: grid; grid-template-columns: auto 1fr; gap: 4px 8px; align-items: center; }
.pres-row select { font: inherit; font-size: var(--fs-md); height: var(--control-h-sm); padding: 2px 6px; border: 1px solid var(--rule); border-radius: var(--r); background: var(--panel); color: var(--ink); }
.pres-row input { grid-column: 2; font: inherit; font-size: var(--fs-md); height: var(--control-h-sm); padding: 2px 8px; border: 1px solid var(--rule); border-radius: var(--r); background: var(--panel); color: var(--ink); }
.pres-row input[hidden] { display: none; }
.pres-err { color: var(--bad); }
.dot.pres-available { background: var(--dot-ok); }
.dot.pres-away { background: var(--dot-busy); }
.dot.pres-busy, .dot.pres-dnd { background: var(--dot-bad); }
.dot.pres-offline, .dot.pres-none, .dot.pres-unknown { background: var(--rule-strong); }
.blf-item.pres-away .dot { box-shadow: 0 0 0 2px color-mix(in srgb, var(--amber) 33%, transparent); }
.blf-item.pres-dnd .dot { box-shadow: 0 0 0 2px color-mix(in srgb, var(--dot-bad) 33%, transparent); }
.blf-item.blf-idle.pres-offline .dot { background: var(--rule-strong); }

/* Interface capture */
.sniff-card { grid-column: 1 / -1; }
.sn-status { font-size: var(--fs-md); color: var(--muted); align-self: center; }
.sniff-card .row + .row { flex-wrap: nowrap; }
.sn-list { max-height: 420px; overflow: auto; }
.sn-list table { font-size: var(--fs-md); }

/* Draggable dividers between reading areas (double-click resets) */
.gutter { position: absolute; z-index: 5; background: transparent; touch-action: none; }
.gutter::after { content: ""; position: absolute; background: var(--rule-strong); opacity: 0; transition: opacity var(--t-fast); }
.gutter:hover::after, .gutter.drag::after { opacity: 1; background: var(--mark); }
.gutter.v { top: 0; bottom: 0; width: 9px; margin-left: -4px; cursor: col-resize; }
.gutter.v::after { top: 0; bottom: 0; left: 3px; width: 3px; }
.gutter.h { height: 9px; margin-top: -4px; cursor: row-resize; }
.gutter.h::after { left: 0; right: 0; top: 3px; height: 3px; }
body.resizing, body.resizing * { user-select: none !important; }
body.resizing.col { cursor: col-resize; }
body.resizing.row { cursor: row-resize; }

/* Live calls table on the Calls page */
.active-card { margin-bottom: 14px; }
table.hist.active tbody tr { cursor: pointer; }
table.hist.active tr.sel td { background: var(--sel); }
table.hist.active tr.ended td { color: var(--muted); }
#active-count { font-weight: 600; color: var(--muted); margin-left: 4px; }

/* Message summary above the raw SIP */
.msg-sum { background: var(--sunk); border: 1px solid var(--rule); border-radius: var(--r-lg); padding: 10px 14px 4px; margin: 8px 0 10px; max-width: 1100px; }
.msg-sum .kv { margin-bottom: 6px; }
.msg-sum .kv dd { word-break: break-word; }

/* Registration panel on the account page */
.acc-reg { margin-top: 14px; }
.acc-reg .sect-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.ar-state { display: flex; align-items: center; gap: 8px; margin: 8px 0; font-weight: 500; }
.ar-state.bad { color: var(--bad); }
.ar-list { display: grid; gap: 2px; font-size: var(--fs-md); max-height: 360px; overflow: auto; }
.ar-list > *:hover { background: var(--sunk); }
.ar-list summary { cursor: pointer; padding: 3px 4px; border-radius: var(--r-sm); }
.ar-list summary:hover { background: var(--sunk); }
.ar-list pre { margin: 4px 0 8px 18px; padding: 8px 10px; background: var(--sunk); border-radius: var(--r); overflow: auto; }
.tr-d.out { color: var(--req); }
.tr-d.in { color: var(--end); }
.fld.invalid input, .fld.invalid select { border-color: var(--bad); box-shadow: 0 0 0 2px color-mix(in srgb, var(--bad) 25%, transparent); }
.fld-err { color: var(--bad); font-size: var(--fs-sm); }
#acct-state.link { cursor: pointer; text-decoration: underline dotted; }

.notice { border: 1px solid var(--rule); border-left: 3px solid var(--mark); background: var(--mark-soft); border-radius: var(--r); padding: 9px 12px; margin: 0 0 12px; font-size: var(--fs-base); }
.notice a { font-weight: 600; margin-left: 4px; }

/* Phone only mode hides the troubleshooting workspaces */
body.phone-mode [data-ws="trace"], body.phone-mode [data-ws="analysis"], body.phone-mode [data-ws="diag"],
body.phone-mode #ai-toggle, body.phone-mode label[for="file"], body.phone-mode .tool[data-tool="analyze"],
body.phone-mode #cd-analyze, body.phone-mode #cd-explain, body.phone-mode #cd-trace, body.phone-mode .events-card,
body.phone-mode #st-net, body.phone-mode #ar-trace, body.phone-mode #ar-an { display: none !important; }
body.phone-mode .calls-grid { grid-template-columns: 1fr; }

/* Explanations */
.explain { display: grid; gap: 14px; max-width: 1100px; }
.explain section h3 { margin: 0 0 6px; }
.explain .kv { grid-template-columns: minmax(130px, max-content) 1fr; }
.explain .kv dd { word-break: break-word; }
/* Problems: only the title carries the severity colour; the body stays ink. */
.x-problems ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 4px; }
.x-problems li { color: var(--ink); border-left: 3px solid var(--rule-strong); padding-left: 10px; }
.x-problems li.error { border-left-color: var(--bad); }
.x-problems li.warning { border-left-color: var(--warn); }
.x-problems li.info { border-left-color: var(--info); }
.x-problems li.error > b { color: var(--bad); }
.x-problems li.warning > b { color: var(--warn); }
.x-problems li.info > b { color: var(--info); }
.x-leg { margin: 14px 0 6px; }
.sdp-explained { margin: 0 0 12px; }
.sdp-explained summary { cursor: pointer; font-weight: 600; margin-bottom: 6px; }
table.sdp-x { border-collapse: collapse; width: 100%; max-width: 1100px; font-size: var(--fs-md); }
table.sdp-x td { border-bottom: 1px solid var(--rule); padding: 3px 10px 3px 0; vertical-align: top; }
table.sdp-x td:first-child { white-space: nowrap; width: 1%; padding-right: 18px; }
.status-help { margin: 0 0 10px; font-size: var(--fs-base); }
.sipmsg .hn.has-help { text-decoration: underline dotted; text-underline-offset: 3px; cursor: help; }
.sipmsg .sl[title] { cursor: help; }

.active-regs { display: grid; gap: 3px; margin: 2px 0 10px; font-size: var(--fs-md); }
.reg-row { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.tag { font: 600 var(--fs-xs)/1.5 var(--mono); border: 1px solid var(--rule-strong); border-radius: var(--r-sm); padding: 1px 6px; color: var(--muted); }

/* Explanations switched off */
body.no-explain [data-tab="explain"], body.no-explain #tab-explain, body.no-explain .sdp-explained,
body.no-explain .status-help, body.no-explain .notice, body.no-explain .calls-hint { display: none !important; }
#explain-toggle[aria-pressed="false"] { opacity: 0.7; }

/* Display filters */
.an-filter { padding: 0 14px 6px; display: grid; gap: 2px; }
.an-filter input { width: 100%; font: var(--fs-sm) var(--mono); }
input.dfilter { font-family: var(--mono); }
input.bad-filter { border-color: var(--bad) !important; background: color-mix(in srgb, var(--bad) 8%, var(--panel)); }
.ladder .st-ladder .msg.match .hit { fill: var(--warn); fill-opacity: 0.3; }
.ladder .st-ladder .msg.match text { font-weight: 700; }

/* RTP player */
.play-btn { width: var(--control-h-sm); height: var(--control-h-sm); font-size: var(--fs-sm); }
.rtp-player { margin: 12px 0; border: 1px solid var(--rule); border-radius: var(--r-lg); padding: 10px 12px; background: var(--panel); max-width: 1100px; }
.rtp-player canvas { width: 100%; height: 110px; display: block; border-radius: var(--r-sm); cursor: pointer; margin: 8px 0; }
.pl-ctl { align-items: center; gap: 10px; }

/* Compact phone window (desktop app, phone-only mode): just the phone. */
.compact-only { display: none !important; }
body.compact .compact-only { display: inline-flex !important; }
body.compact:not(.compact-open) #c-back { display: none !important; }
body.compact .ws-tabs, body.compact .bar-right > :not(.compact-only), body.compact .status { display: none !important; }
body.compact .bar { gap: 8px; padding: 0 10px; }
body.compact .bar-right { margin-left: auto; gap: 4px; }
body.compact .brand { width: auto; }
body.compact .shell { flex-direction: column; }
body.compact .phone { width: 100%; max-width: none; border-right: 0; flex: 1; }
body.compact .ws-col { display: none; }
body.compact.compact-open .phone { display: none; }
body.compact.compact-open .ws-col { display: flex; flex: 1; min-height: 0; }
body.compact .ws-page { padding: 12px; }
body.compact .settings { grid-template-columns: 1fr; }
body.compact .set-nav { position: static; }
body.compact .calls-grid { grid-template-columns: 1fr; }
body.compact table.hist, body.compact .active-wrap { display: block; overflow-x: auto; }
body.compact { height: 100vh; overflow: hidden; }
body.compact .phone { overflow-y: auto; min-height: 0; border-bottom: 0; }
body.compact.compact-open .ws { overflow-y: auto; min-height: 0; }
body.compact .ai-dock { display: none; }

/* Live analysis */
.live-tag { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-sm); font-weight: 600; color: var(--bad); white-space: nowrap; margin-right: 10px; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--bad-bg); animation: livepulse 1.2s ease-in-out infinite; }
@keyframes livepulse { 50% { opacity: 0.25; } }

/* History filters */
.hist-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin: 6px 0 10px; }
.hist-tools #hist-filter { width: 240px; }
.hist-tools .hf { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-sm); color: var(--muted); }
.hist-tools input[type=date], .hist-tools select { font: inherit; font-size: var(--fs-md); height: var(--control-h-sm); padding: 2px 6px; border: 1px solid var(--rule-strong); border-radius: var(--r); background: var(--panel); color: var(--ink); }
table.hist .del { color: var(--bad); }

/* History: selectable rows and the selected call */
table.hist tbody tr[data-hrow] { cursor: pointer; }
table.hist tbody tr[data-hrow]:hover td { background: var(--sunk); }
table.hist tbody tr.sel, table.hist tbody tr.sel:hover td { background: var(--sel); }
.hist-detail .hd-ladder { max-height: 420px; overflow: auto; border: 1px solid var(--rule); border-radius: var(--r-lg); margin: 10px 0 14px; background: var(--sunk); }
.hist-detail .hd-ladder svg { display: block; max-width: none; }
.hist-detail .st-ladder text { font-family: var(--mono); }

#tab-media tr[data-stream] { cursor: pointer; }
#tab-media tr[data-stream]:hover td { background: var(--sunk); }
#tab-media tr[data-stream].sel, #tab-media tr[data-stream].sel:hover td { background: var(--sel); }
.ladder .st-ladder .stream.sel .hit { fill: var(--mark); fill-opacity: 0.35; }

/* Filter query helper */
.fsuggest { position: absolute; z-index: 40; max-height: 320px; overflow-y: auto; background: var(--panel); border: 1px solid var(--rule-strong); border-radius: var(--r); box-shadow: var(--shadow-pop); padding: 4px; font-size: var(--fs-sm); }
.fs-item { display: flex; align-items: baseline; gap: 12px; padding: 4px 8px; border-radius: var(--r-sm); cursor: pointer; white-space: nowrap; }
.fs-item.on, .fs-item:hover { background: var(--sel); }
.fs-l { font-family: var(--mono); font-weight: 600; min-width: 90px; }
.fs-d { color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.fs-op .fs-l { color: var(--req); }
.fs-join .fs-l { color: var(--end); }
.fs-value .fs-l { color: var(--ok); font-weight: 500; }

#call-detail .kv.empty dd { color: var(--muted); }

/* Codec lists */
.codec-pick ol.codecs { list-style: none; margin: 6px 0 0; padding: 0; border: 1px solid var(--rule); border-radius: var(--r); max-height: 360px; overflow-y: auto; background: var(--panel); }
.codec-pick li { display: grid; grid-template-columns: minmax(150px, auto) 1fr auto auto; gap: 10px; align-items: center; padding: 3px 8px; border-bottom: 1px solid var(--rule); }
.codec-pick li:last-child { border-bottom: 0; }
.codec-pick .kbps { color: var(--muted); font-size: var(--fs-sm); text-align: right; }
.codec-pick .cbtns { display: inline-flex; gap: 2px; }
.codec-pick .cbtns .icon-btn { width: 24px; height: 24px; font-size: var(--fs-sm); }
.codec-pick.inherit ol.codecs { opacity: var(--disabled); pointer-events: none; }
.fld.wide { grid-column: 1 / -1; }
#opts .codec-pick li { grid-template-columns: 1fr auto; }
#opts .codec-pick li .muted, #opts .codec-pick li .kbps { display: none; }
#opts .codec-pick ol.codecs { max-height: 180px; }
.opt-h { font-size: var(--fs-sm); font-weight: 600; }

/* Quality over time */
.qfig { position: relative; margin: 14px 0 6px; max-width: 1100px; }
.qfig figcaption { font-size: var(--fs-sm); margin-bottom: 4px; }
svg.qchart { width: 100%; height: auto; display: block; overflow: visible; stroke: none; stroke-width: 0; }
.qchart .ql { font: 600 var(--fs-xs) var(--sans); fill: var(--ink); }
.qchart .qv { font: var(--fs-xs) var(--sans); fill: var(--muted); }
.qchart .qbase { stroke: var(--rule); stroke-width: 1; vector-effect: non-scaling-stroke; }
.qchart .qwarn { stroke: var(--warn); stroke-width: 1; stroke-dasharray: 4 4; vector-effect: non-scaling-stroke; opacity: 0.7; }
.qchart .qline { fill: none; stroke: var(--req); stroke-width: 2; vector-effect: non-scaling-stroke; stroke-linejoin: round; stroke-linecap: round; }
.qchart .qbar { fill: var(--bad); }
.qchart .qev { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 2 3; vector-effect: non-scaling-stroke; }
.qchart .qevl { font: var(--fs-xs) var(--mono); fill: var(--muted); }
.qchart .qcross { stroke: var(--ink); stroke-width: 1; vector-effect: non-scaling-stroke; }
.qtip { position: absolute; top: 24px; background: var(--panel); border: 1px solid var(--rule-strong); border-radius: var(--r); padding: 6px 8px; font-size: var(--fs-sm); pointer-events: none; box-shadow: var(--shadow-pop); min-width: 150px; }
.rtcp-reports { margin: 12px 0; }
.rtcp-reports h4 { margin: 10px 0 4px; font-size: var(--fs-md); }
.rtcp-cell { font-size: var(--fs-sm); max-width: 220px; }

/* Quality chips share the badge metrics. */
.q-chip { font-size: var(--fs-xs); font-weight: 600; padding: 1px 6px; border-radius: var(--r-sm); border: 1px solid currentColor; line-height: 1.5; }
.q-chip.ok { color: var(--ok); }
.q-chip.warn { color: var(--warn); }
.q-chip.bad { color: var(--bad); }
.c-legs { font-size: var(--fs-xs); color: var(--req); cursor: pointer; text-decoration: underline dotted; }

.c-meta { flex-wrap: wrap; row-gap: 3px; }
.q-chip, .c-legs { white-space: nowrap; }

/* Voicemail lamp under the account. */
.vm-btn { display: flex; align-items: center; gap: 8px; width: 100%; margin: 6px 0 0; padding: 6px 10px; border: 1px solid var(--rule); border-radius: var(--r); background: var(--panel); color: var(--muted); font: var(--fs-md) var(--sans); cursor: pointer; text-align: left; transition: background-color var(--t-fast), border-color var(--t-fast), color var(--t-fast); }
.vm-btn svg { width: 18px; height: 18px; }
.vm-btn.on { color: var(--ink); border-color: var(--warn); background: color-mix(in srgb, var(--warn) 14%, transparent); font-weight: 600; }
.vm-btn:hover { border-color: var(--ink); }
.fwd-note { margin-top: 6px; color: var(--warn); font-weight: 600; }
.msg-row .row { display: flex; gap: 6px; margin-top: 4px; }
.msg-row input { flex: 1; min-width: 0; }
/* Ladder view options above the diagram. */
.ladder-bar { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; padding: 6px 16px; font-size: var(--fs-md); color: var(--muted); border-bottom: 1px solid var(--rule); }
.ladder-bar label { display: inline-flex; gap: 6px; align-items: center; margin: 0; }
.ladder-bar select { font: inherit; height: var(--control-h-sm); padding: 2px 8px; width: auto; }
.ladder-bar .check { display: inline-flex; gap: 6px; align-items: center; }
.bk-url { display: flex; gap: 6px; margin-top: 10px; }
.bk-url input { flex: 1; min-width: 0; }
.prov-discover { display: grid; gap: 6px; }
.prov-discover .btn { justify-self: start; }
#prov-found .linklike { font-family: var(--mono); font-size: var(--fs-sm); }
.dg-pre { max-height: 280px; overflow: auto; font-size: var(--fs-sm); white-space: pre-wrap; word-break: break-all; }

/* ---------- navigation and layout pass ---------- */

/* The brand no longer reserves the phone panel's width: the tabs always fit. */
.brand { width: auto; margin-right: 10px; }
.ws-tabs { flex: 1; min-width: 0; }

/* View menu: mode, theme and explanations in one place instead of three labels. */
.view-menu { min-width: 280px; padding: 10px; gap: 10px; }
.menu.open .view-menu { display: grid; }
.view-menu .seg { display: inline-flex; }
.view-menu .seg button, .view-menu .check { display: inline-block; width: auto; }
.view-menu .check { display: flex; }
.view-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: var(--fs-md, 13px); }
.view-row > span:first-child { color: var(--muted); }
.view-row.check { justify-content: flex-start; padding: 2px 0; }
.view-row.check small { display: block; color: var(--muted); font-size: var(--fs-sm, 12px); }
.view-menu .seg button { padding: 4px 10px; }
.menu > .icon-btn[aria-expanded="true"] { background: var(--sunk); }

/* Inline errors next to the control that caused them. */
.dial-err { margin: -4px 0 8px; font-size: var(--fs-sm, 12px); }
#acc-dirty.err { color: var(--bad); }

/* A card with nothing in it takes one line, not a box of air. */
.card.quiet { padding-bottom: 10px; }
.card.quiet .empty-note { margin: 0; }
.hist-tools[hidden] { display: none; }

/* Save bar stays in view on every account tab. */
.set-form .set-actions { position: sticky; bottom: 0; background: var(--panel); padding-top: 10px; margin-top: 6px; border-top: 1px solid var(--rule); z-index: 2; }

/* Trace list header row. */
.tr-row.tr-head { position: sticky; top: 0; z-index: 1; background: var(--panel); color: var(--muted); font-size: var(--fs-xs, 11px); text-transform: uppercase; letter-spacing: .04em; cursor: default; padding-top: 4px; padding-bottom: 4px; border-bottom: 1px solid var(--rule); }
.tr-row.tr-head:hover { background: var(--panel); }

/* Wide ladder: a fade on the right says there is more to the side. */
.ladder-wrap { position: relative; }
.ladder-wrap.scroll-x::after { content: ""; position: absolute; top: 0; right: 0; bottom: 0; width: 28px; pointer-events: none; background: linear-gradient(to right, transparent, var(--panel)); }

/* Rows reachable by keyboard show where the focus is. */
tr[data-hrow]:focus-visible, #lines li:focus-visible { outline: 2px solid var(--req); outline-offset: -2px; }

/* Account section tabs look like the other tab strips when used for navigation. */
.seg.nav { background: none; border: 0; border-bottom: 1px solid var(--rule); border-radius: 0; padding: 0; gap: 2px; }
.seg.nav button { border-radius: 0; border-bottom: 2px solid transparent; background: none; padding: 8px 12px; }
.seg.nav button[aria-selected="true"] { background: none; border-bottom-color: var(--mark); color: var(--ink); }
/* The codec column shows the used codec; offer and answer lists are clipped with the full text on hover. */
.codec-cell { max-width: 34ch; }
.codec-cell .small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hist-detail .codec-cell { max-width: none; }
.hist-detail .codec-cell .small { white-space: normal; }
/* Narrow windows: the ladder keeps room; the call header folds to one line. */
@media (max-width: 1200px) and (min-width: 861px) {
  .an-grid { grid-template-rows: minmax(260px, 1fr) var(--an-bottom, 38%); }
  .call-head { padding: 6px 12px; }
  .call-head dl { gap: 2px 12px; }
  .call-head dd { max-width: 32ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }
}
