:root,
[data-theme="light"] {
  --bg-app: #f5f4f0;
  --bg-surface: #ffffff;
  --bg-subtle: #faf9f6;
  --bg-muted: #eeede8;
  --bg-input: #ffffff;
  --bg-stage: #ebe9e2;
  --stage-dot: rgba(23, 23, 21, 0.08);

  --line: #e2e0d8;
  --line-strong: #c9c6bb;

  --ink: #171715;
  --ink-2: #575650;
  --ink-3: #8a8880;

  --cta-bg: #171715;
  --cta-fg: #faf9f6;
  --cta-hover: #2c2c28;

  --accent: #2b5f6c;
  --accent-soft: rgba(43, 95, 108, 0.09);

  --ok: #1d6f4a;
  --ok-soft: rgba(29, 111, 74, 0.09);
  --warn: #a65b12;
  --warn-soft: rgba(166, 91, 18, 0.1);
  --err: #b83337;
  --err-soft: rgba(184, 51, 55, 0.09);

  --chart-1: #2b5f6c;
  --chart-2: #b5b2a8;
  --chart-3: #1d6f4a;
  --chart-4: #b56c24;
  --chart-grid: #e8e6de;

  --shadow-popover: 0 12px 32px rgba(20, 20, 18, 0.11), 0 2px 6px rgba(20, 20, 18, 0.05);
  --backdrop: rgba(20, 20, 18, 0.28);

  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;

  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", sans-serif;
  --font-mono: "JetBrains Mono", "Cascadia Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}

[data-theme="dark"] {
  --bg-app: #121210;
  --bg-surface: #181816;
  --bg-subtle: #141412;
  --bg-muted: #22221f;
  --bg-input: #141412;
  --bg-stage: #0e0e0c;
  --stage-dot: rgba(236, 235, 230, 0.06);

  --line: #292925;
  --line-strong: #3d3c36;

  --ink: #ecebe6;
  --ink-2: #9e9d95;
  --ink-3: #6e6d66;

  --cta-bg: #ecebe6;
  --cta-fg: #141412;
  --cta-hover: #ffffff;

  --accent: #6ea3b0;
  --accent-soft: rgba(110, 163, 176, 0.13);

  --ok: #46a87a;
  --ok-soft: rgba(70, 168, 122, 0.13);
  --warn: #d48d3b;
  --warn-soft: rgba(212, 141, 59, 0.14);
  --err: #df5b5f;
  --err-soft: rgba(223, 91, 95, 0.14);

  --chart-1: #6ea3b0;
  --chart-2: #4b4a44;
  --chart-3: #46a87a;
  --chart-4: #d48d3b;
  --chart-grid: #252521;

  --shadow-popover: 0 16px 40px rgba(0, 0, 0, 0.52), 0 2px 8px rgba(0, 0, 0, 0.3);
  --backdrop: rgba(0, 0, 0, 0.56);
  color-scheme: dark;
}

*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg-app);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

/* Custom Subtle Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--ink-3);
}

.hidden {
  display: none !important;
}

.mono-num,
.mono-muted,
.mono-timer {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}
.mono-muted {
  font-size: 11.5px;
  color: var(--ink-3);
}
.mono-timer {
  font-size: 11.5px;
  color: var(--ink-2);
  min-width: 34px;
  text-align: right;
}

/* SVG Icons */
.icon {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
  flex-shrink: 0;
}
.icon-caret {
  width: 11px;
  height: 11px;
  stroke: var(--ink-3);
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
  flex-shrink: 0;
}

[data-theme="light"] .icon-sun { display: none; }
[data-theme="dark"] .icon-moon { display: none; }

/* Full-Bleed Architectural Frame */
.app-shell {
  height: 100vh;
  width: 100vw;
  display: flex;
  flex-direction: column;
  background: var(--bg-app);
}

/* Top Bar */
.topbar {
  height: 42px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 14px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--line);
  user-select: none;
}

.topbar-left,
.topbar-right {
  display: flex;
  align-items: center;
  height: 100%;
  gap: 12px;
  min-width: 0;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.brand-title {
  font-family: var(--font-mono);
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: -0.3px;
  color: var(--ink);
}

.cli-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ink-3);
  display: inline-block;
  flex-shrink: 0;
}
.status-dot.dot-ok { background: var(--ok); }
.status-dot.dot-warn { background: var(--warn); }
.status-dot.dot-err { background: var(--err); }

.topbar-divider {
  width: 1px;
  height: 16px;
  background: var(--line);
  flex-shrink: 0;
}

/* Primary Navigation Tabs */
.main-nav {
  display: flex;
  align-items: stretch;
  height: 100%;
  gap: 2px;
}

.nav-tab {
  border: none;
  border-radius: 0;
  background: transparent;
  color: var(--ink-2);
  font-size: 12.5px;
  font-weight: 500;
  padding: 0 11px;
  height: 100%;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  position: relative;
  transition: color 0.12s ease;
}
.nav-tab:hover {
  color: var(--ink);
  background: transparent;
}
.nav-tab.active {
  color: var(--ink);
  font-weight: 600;
  box-shadow: inset 0 -2px 0 var(--ink);
}

.tab-count,
.util-count {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 500;
  color: var(--ink-3);
  background: var(--bg-muted);
  padding: 0 5px;
  border-radius: 3px;
  line-height: 16px;
  font-variant-numeric: tabular-nums;
}
.nav-tab.active .tab-count,
.pane-tab.active .tab-count {
  color: var(--ink);
}

/* Topbar Config Triggers */
.topbar-triggers {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.trigger-chip {
  height: 28px;
  padding: 0 9px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--bg-subtle);
  color: var(--ink);
  font-size: 12px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  max-width: 240px;
  white-space: nowrap;
  transition: border-color 0.12s ease, background 0.12s ease;
}
.trigger-chip:hover,
.trigger-chip.active {
  border-color: var(--line-strong);
  background: var(--bg-muted);
}
.trigger-chip.needs-setup {
  border-color: rgba(166, 91, 18, 0.35);
}
#apiPillText {
  overflow: hidden;
  text-overflow: ellipsis;
}
.trigger-prefix {
  color: var(--ink-3);
  font-size: 11.5px;
}

/* Topbar Utility Buttons */
.topbar-utils {
  display: flex;
  align-items: center;
  gap: 4px;
}

.icon-btn {
  height: 28px;
  padding: 0 8px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  cursor: pointer;
  text-decoration: none;
  transition: color 0.12s ease, background 0.12s ease, border-color 0.12s ease;
}
.icon-btn:hover {
  color: var(--ink);
  background: var(--bg-muted);
}
.icon-btn.icon-only {
  width: 28px;
  padding: 0;
}
.icon-btn:not([href]) {
  opacity: 1;
}
a.icon-btn:not([href]) {
  opacity: 0.35;
  pointer-events: none;
}

/* Standard Buttons & Actions */
button,
.btn {
  font-family: inherit;
}

.btn {
  height: 30px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--bg-surface);
  color: var(--ink);
  font-size: 12px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}
.btn:hover:not(:disabled) {
  background: var(--bg-muted);
  border-color: var(--line-strong);
}
.btn:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}
.btn-sm {
  height: 28px;
  padding: 0 10px;
  font-size: 12px;
}
.btn-xs {
  height: 24px;
  padding: 0 8px;
  font-size: 11.5px;
}
.btn-quiet {
  background: transparent;
  color: var(--ink-2);
}
.btn-solid {
  background: var(--cta-bg);
  border-color: var(--cta-bg);
  color: var(--cta-fg);
  font-weight: 500;
}
.btn-solid:hover:not(:disabled) {
  background: var(--cta-hover);
  border-color: var(--cta-hover);
}
.btn-danger {
  background: var(--err);
  border-color: var(--err);
  color: #fff;
}
.btn-danger:hover:not(:disabled) {
  filter: brightness(1.06);
  background: var(--err);
  border-color: var(--err);
}

.close-btn {
  width: 26px;
  height: 26px;
  padding: 0;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink-3);
  display: grid;
  place-items: center;
  cursor: pointer;
}
.close-btn:hover {
  color: var(--ink);
  background: var(--bg-muted);
}

.text-action {
  border: none;
  background: transparent;
  color: var(--ink-2);
  font-size: 11.5px;
  font-weight: 500;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: color 0.12s ease, background 0.12s ease;
}
.text-action:hover {
  color: var(--ink);
  background: var(--bg-muted);
}
.text-action.text-danger:hover {
  color: var(--err);
  background: var(--err-soft);
}

/* Segmented Inline Switch */
.inline-switch {
  display: inline-flex;
  align-items: center;
  background: var(--bg-muted);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 1px;
  gap: 1px;
}
.switch-item {
  border: none;
  background: transparent;
  color: var(--ink-2);
  font-size: 11.5px;
  font-weight: 500;
  padding: 3px 8px;
  border-radius: 3px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.1s ease, color 0.1s ease;
}
.switch-item:hover {
  color: var(--ink);
}
.switch-item.active {
  background: var(--bg-surface);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

/* Crisp Rectangular Status Tags (Zero Pill Glow) */
.state-badge,
.meta-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 20px;
  padding: 0 6px;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  border: 1px solid var(--line);
  background: var(--bg-subtle);
  color: var(--ink-2);
}
.state-idle {
  background: var(--bg-subtle);
  color: var(--ink-2);
  border-color: var(--line);
}
.state-active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: rgba(43, 95, 108, 0.25);
}
.state-ok {
  background: var(--ok-soft);
  color: var(--ok);
  border-color: rgba(29, 111, 74, 0.24);
}
.state-warn {
  background: var(--warn-soft);
  color: var(--warn);
  border-color: rgba(166, 91, 18, 0.25);
}
.state-err {
  background: var(--err-soft);
  color: var(--err);
  border-color: rgba(184, 51, 55, 0.25);
}

/* Dropdown Menu */
.dropdown-wrap {
  position: relative;
}
.dropdown-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  background: var(--bg-surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  padding: 4px;
  min-width: 176px;
  box-shadow: var(--shadow-popover);
  z-index: 90;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.dropdown-menu button {
  border: none;
  background: transparent;
  color: var(--ink);
  font-size: 12px;
  text-align: left;
  padding: 6px 9px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.dropdown-menu button:hover {
  background: var(--bg-muted);
}

/* Form Controls */
input[type="text"],
input[type="password"],
input[type="number"],
select,
textarea {
  width: 100%;
  background: var(--bg-input);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 5px 9px;
  font-family: inherit;
  font-size: 12.5px;
  outline: none;
  transition: border-color 0.12s ease;
}
input[type="text"],
input[type="password"],
input[type="number"],
select {
  height: 30px;
}
select {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
input:focus,
select:focus,
textarea:focus {
  border-color: var(--ink-2);
}
input[type="number"] {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}
input[readonly] {
  background: var(--bg-subtle);
  color: var(--ink-3);
}
.input-emphasis {
  border-color: var(--accent);
  font-weight: 600;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}
.field label {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--ink-2);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.inline-group {
  display: flex;
  align-items: center;
  gap: 6px;
}
.inline-group select,
.inline-group input {
  flex: 1;
  min-width: 0;
}
.inline-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.checkbox-field {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--ink-2);
  cursor: pointer;
  user-select: none;
}
.checkbox-field input[type="checkbox"] {
  width: 14px;
  height: 14px;
  margin: 0;
  accent-color: var(--ink);
}

.mini-chips {
  display: inline-flex;
  gap: 3px;
}
.chip-btn {
  border: 1px solid var(--line);
  background: var(--bg-subtle);
  color: var(--ink-2);
  font-family: var(--font-mono);
  font-size: 10.5px;
  padding: 1px 5px;
  border-radius: 3px;
  cursor: pointer;
}
.chip-btn:hover {
  color: var(--ink);
  border-color: var(--line-strong);
  background: var(--bg-muted);
}

.form-hint {
  font-size: 11.5px;
  color: var(--ink-3);
}

/* Popover Panels */
.popover-backdrop {
  position: fixed;
  inset: 0;
  background: var(--backdrop);
  z-index: 60;
}

.config-popover {
  position: fixed;
  top: 50px;
  left: 50%;
  transform: translateX(-50%);
  width: min(620px, calc(100vw - 24px));
  max-height: calc(100vh - 70px);
  overflow-y: auto;
  background: var(--bg-surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-popover);
  z-index: 70;
  display: flex;
  flex-direction: column;
}

.popover-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px 12px;
  border-bottom: 1px solid var(--line);
}
.popover-head h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
}
.popover-sub {
  display: block;
  margin-top: 2px;
  font-size: 11.5px;
  color: var(--ink-3);
}

.popover-body {
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.popover-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.popover-grid-rate {
  display: grid;
  grid-template-columns: 1.5fr 0.8fr;
  gap: 12px;
}
.popover-probe-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.probe-status-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  border: 1px solid var(--line);
  font-size: 11.5px;
  color: var(--ink-2);
}
.probe-status-bar code {
  font-family: var(--font-mono);
  color: var(--ink);
}

.popover-details {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  padding: 8px 12px;
}
.popover-details summary {
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-2);
}
.popover-details-grid {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  align-items: end;
}

.popover-foot {
  padding: 10px 18px;
  border-top: 1px solid var(--line);
  background: var(--bg-subtle);
  display: flex;
  justify-content: flex-end;
}

/* Tabular Rate Conversion Ledger inside Pricing Popover */
.rate-ledger {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  overflow: hidden;
}
.rate-ledger-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-bottom: 1px solid var(--line);
}
.rate-ledger-cell {
  padding: 8px 10px;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.rate-ledger-cell:last-child {
  border-right: none;
}
.rate-ledger-cell span {
  font-size: 11px;
  color: var(--ink-3);
}
.rate-ledger-cell strong {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.rate-ledger-formula {
  padding: 6px 10px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

/* Main Views */
.main-view {
  display: none;
  flex: 1;
  min-height: 0;
}
.main-view.active {
  display: flex;
  flex-direction: column;
}
.main-view-scroll.active {
  overflow-y: auto;
}

/* VIEW 1: Flush Split-Pane Workbench */
.workbench-split {
  --left-width: 42%;
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(340px, var(--left-width)) 5px minmax(420px, 1fr);
  background: var(--bg-surface);
}

.split-resizer {
  background: var(--bg-surface);
  cursor: col-resize;
  position: relative;
  user-select: none;
}
.split-resizer::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 2px;
  width: 1px;
  background: var(--line);
  transition: background 0.12s ease, width 0.12s ease, left 0.12s ease;
}
.split-resizer:hover::after,
.split-resizer.dragging::after {
  left: 1px;
  width: 3px;
  background: var(--accent);
}

.pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  background: var(--bg-surface);
}

.pane-bar {
  height: 36px;
  padding: 0 12px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-shrink: 0;
}

.section-kicker {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink-3);
  white-space: nowrap;
}

.exam-selector-group {
  display: flex;
  align-items: center;
  gap: 7px;
  flex: 1;
  min-width: 0;
}
.exam-selector-group select {
  height: 28px;
  line-height: 26px;
  padding: 0 8px;
  font-size: 12px;
  flex: 1;
  min-width: 0;
}

.pane-bar-right {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

/* Composer */
.composer {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-surface);
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}
.composer textarea {
  resize: vertical;
  min-height: 76px;
  max-height: 180px;
  line-height: 1.5;
  padding: 8px 10px;
  font-size: 12.5px;
  background: var(--bg-subtle);
}
.composer textarea:focus {
  background: var(--bg-input);
}

.composer-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}
.composer-status-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Terminal-Style Log Stream */
.stream-bar {
  height: 30px;
  padding: 0 12px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.codex-log-feed {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  background: var(--bg-app);
  display: flex;
  flex-direction: column;
}

.log-entry {
  padding: 7px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-surface);
  font-size: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.log-entry.kind-error {
  border-left: 2px solid var(--err);
  background: var(--err-soft);
}
.log-entry.kind-assistant {
  border-left: 2px solid var(--ok);
}
.log-entry.kind-command_start,
.log-entry.kind-command_done {
  border-left: 2px solid var(--accent);
}

.log-entry-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 11px;
  color: var(--ink-3);
}
.log-entry-head {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.log-kind-tag {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: var(--ink-2);
  background: var(--bg-muted);
  padding: 0 4px;
  border-radius: 2px;
}
.log-entry-title {
  font-weight: 500;
  color: var(--ink);
}
.log-entry-body {
  white-space: pre-wrap;
  word-break: break-word;
  font-family: var(--font-mono);
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--ink);
}
.log-entry.kind-assistant .log-entry-body {
  font-family: var(--font-sans);
  font-size: 12.5px;
}
.log-entry details {
  margin-top: 2px;
}
.log-entry summary {
  cursor: pointer;
  font-size: 11px;
  color: var(--ink-3);
}
.log-entry pre {
  margin: 4px 0 0;
  padding: 6px 8px;
  background: var(--bg-subtle);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 11px;
  max-height: 160px;
}

/* Follow-up Input Bar */
.followup-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-top: 1px solid var(--line);
  background: var(--bg-subtle);
  flex-shrink: 0;
}
.followup-bar input {
  height: 28px;
  font-size: 12px;
}

/* Right Pane Tabs & Unified Preview Toolbar */
.pane-bar-right-head {
  padding-left: 0;
  gap: 8px;
}
.pane-tabs {
  display: flex;
  align-items: stretch;
  height: 100%;
  flex-shrink: 0;
}
.pane-tab {
  border: none;
  border-right: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 500;
  padding: 0 12px;
  height: 100%;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
}
.pane-tab:hover {
  color: var(--ink);
}
.pane-tab.active {
  background: var(--bg-surface);
  color: var(--ink);
  font-weight: 600;
  box-shadow: inset 0 -2px 0 var(--ink);
}

.preview-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
  justify-content: flex-end;
}

.select-compact {
  width: auto !important;
  min-width: 116px;
  max-width: 165px;
  height: 26px !important;
  line-height: 24px;
  padding: 0 8px !important;
  font-size: 11.5px !important;
  flex-shrink: 0;
}

.url-readout {
  flex: 1;
  min-width: 70px;
  max-width: 240px;
  height: 24px;
  line-height: 22px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.preview-icon-group {
  display: flex;
  align-items: center;
  gap: 2px;
}

.right-tab-pane {
  display: none;
  flex: 1;
  min-height: 0;
  flex-direction: column;
}
.right-tab-pane.active {
  display: flex;
}

/* Studio Preview Stage with Subtle Dot Matrix */
.preview-stage {
  flex: 1;
  min-height: 0;
  background-color: var(--bg-stage);
  background-image: radial-gradient(var(--stage-dot) 1px, transparent 1px);
  background-size: 16px 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
  position: relative;
}

.preview-iframe {
  border: none;
  background: #ffffff;
  height: 100%;
  transition: width 0.18s ease;
}
.preview-stage.viewport-desktop .preview-iframe {
  width: 100%;
}
.preview-stage.viewport-tablet .preview-iframe {
  width: 768px;
  max-width: 100%;
  border-left: 1px solid var(--line-strong);
  border-right: 1px solid var(--line-strong);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.12);
}
.preview-stage.viewport-mobile .preview-iframe {
  width: 390px;
  max-width: 100%;
  border-left: 1px solid var(--line-strong);
  border-right: 1px solid var(--line-strong);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.12);
}

/* Quiet Minimal Empty States */
.empty-placeholder {
  max-width: 320px;
  margin: auto;
  padding: 28px 20px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.empty-wireframe {
  width: 42px;
  height: 32px;
  stroke: var(--ink-3);
  stroke-width: 1.2;
  fill: none;
  opacity: 0.65;
  margin-bottom: 4px;
}
.empty-title {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-2);
}
.empty-desc {
  font-size: 12px;
  color: var(--ink-3);
  line-height: 1.55;
}
.empty-desc code {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--ink-2);
}
.empty-state-sm {
  padding: 24px 16px;
  text-align: center;
  font-size: 12px;
  color: var(--ink-3);
}

/* Source Code Split */
.code-split {
  flex: 1;
  display: grid;
  grid-template-columns: 190px 1fr;
  min-height: 0;
}
.code-file-list {
  border-right: 1px solid var(--line);
  overflow-y: auto;
  background: var(--bg-subtle);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.code-file-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 8px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--ink-2);
  text-align: left;
  font-family: var(--font-mono);
  font-size: 11.5px;
  cursor: pointer;
}
.code-file-item:hover {
  background: var(--bg-muted);
  color: var(--ink);
}
.code-file-item.active {
  background: var(--bg-surface);
  color: var(--ink);
  font-weight: 600;
  box-shadow: inset 0 0 0 1px var(--line);
}
.code-viewer-wrap {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--bg-surface);
}
.code-viewer-bar {
  height: 32px;
  padding: 0 12px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.code-viewer {
  flex: 1;
  margin: 0;
  padding: 12px 14px;
  overflow: auto;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg-surface);
}

/* Console Tab */
.console-toolbar {
  height: 32px;
  padding: 0 12px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11.5px;
  color: var(--ink-3);
}
.console-toolbar code {
  font-family: var(--font-mono);
  color: var(--ink-2);
}
.page-console-feed {
  flex: 1;
  overflow-y: auto;
  background: var(--bg-surface);
  font-family: var(--font-mono);
  font-size: 11.5px;
}
.console-line {
  padding: 5px 12px;
  border-bottom: 1px solid var(--line);
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--ink);
}
.console-line.level-error {
  color: var(--err);
  background: var(--err-soft);
}
.console-line.level-warn {
  color: var(--warn);
  background: var(--warn-soft);
}

/* Flush IDE Status Bar */
.statusbar {
  height: 28px;
  flex-shrink: 0;
  padding: 0 14px;
  background: var(--bg-subtle);
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 11.5px;
}
.statusbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.status-metric {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.status-label {
  color: var(--ink-3);
}
.status-metric strong {
  font-weight: 600;
  color: var(--ink);
}
.status-sep {
  width: 1px;
  height: 11px;
  background: var(--line);
}
.statusbar .state-badge {
  height: 18px;
  font-size: 10.5px;
}
.statusbar-link {
  border: none;
  background: transparent;
  color: var(--ink-2);
  font-size: 11.5px;
  font-weight: 500;
  padding: 2px 4px;
  cursor: pointer;
  white-space: nowrap;
}
.statusbar-link:hover {
  color: var(--ink);
  text-decoration: underline;
}

/* VIEW 2 & VIEW 3: Editorial Studio Sheet */
.page-sheet {
  width: 100%;
  max-width: 1380px;
  margin: 0 auto;
  padding: 22px 24px 36px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.page-sheet-narrow {
  max-width: 960px;
}

.sheet-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}
.sheet-header h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.2px;
  color: var(--ink);
}
.sheet-sub {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--ink-3);
}
.sheet-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.title-with-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.repo-link {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--ink-3);
  text-decoration: none;
}
.repo-link:hover {
  color: var(--ink);
  text-decoration: underline;
}

/* Balance Diff Strip */
.balance-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 14px;
  background: var(--bg-surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
}
.balance-strip-label {
  font-size: 12px;
  color: var(--ink-2);
}
.balance-diff-inputs {
  display: flex;
  align-items: center;
  gap: 6px;
}
.balance-diff-inputs input {
  width: 116px;
  height: 28px;
}

/* Unified 4-Column Metric Ledger */
.metric-ledger {
  display: grid;
  grid-template-columns: repeat(4, minmax(190px, 1fr));
  background: var(--bg-surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.ledger-cell {
  padding: 14px 16px;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.ledger-cell:last-child {
  border-right: none;
}
.ledger-label {
  font-size: 11.5px;
  color: var(--ink-3);
}
.ledger-value {
  font-family: var(--font-mono);
  font-size: 21px;
  font-weight: 600;
  letter-spacing: -0.5px;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.ledger-verdict {
  font-family: var(--font-sans);
  font-size: 18px;
  letter-spacing: 0;
}
.ledger-sub {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

/* Section Blocks & Charts */
.section-block {
  background: var(--bg-surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.block-summary,
.block-head {
  padding: 10px 14px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-2);
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--line);
}
.block-summary {
  cursor: pointer;
  user-select: none;
}
details.section-block:not([open]) .block-summary {
  border-bottom: none;
}

.charts-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(300px, 1fr));
}
.chart-pane {
  padding: 12px 16px;
  border-right: 1px solid var(--line);
}
.chart-pane:last-child {
  border-right: none;
}
.chart-title {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--ink-3);
  margin-bottom: 6px;
}
.chart-box {
  min-height: 155px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Financial Ledger Table */
.table-wrap {
  overflow-x: auto;
}
.audit-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.audit-table th {
  text-align: left;
  padding: 8px 12px;
  font-size: 11px;
  font-weight: 500;
  color: var(--ink-3);
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.audit-table th.num-col,
.audit-table td.num-col {
  text-align: right;
}
.audit-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}
.audit-table tbody tr:last-child td {
  border-bottom: none;
}
.audit-table tbody tr:hover td {
  background: var(--bg-subtle);
}
.table-empty {
  text-align: center !important;
  color: var(--ink-3) !important;
  padding: 28px !important;
  font-family: var(--font-sans) !important;
}
.actual-input-cell {
  display: flex;
  align-items: center;
  gap: 5px;
}
.actual-input-cell input {
  width: 96px;
  height: 26px;
  padding: 2px 7px;
  font-size: 11.5px;
}
.sub-line {
  display: block;
  font-size: 10.5px;
  color: var(--ink-3);
  margin-top: 2px;
}

/* View 3: ModelTrace Studio */
.fp-pane {
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.fp-controls-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.fp-target-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.fp-target-summary {
  font-size: 12px;
  color: var(--ink-2);
}
.fp-target-summary code {
  font-family: var(--font-mono);
  color: var(--ink);
  background: var(--bg-muted);
  padding: 1px 5px;
  border-radius: 3px;
}
.fp-controls-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.fp-temp-input {
  width: 88px !important;
  height: 28px !important;
  padding: 3px 7px !important;
  font-size: 11.5px !important;
}
.fp-select-std {
  height: 28px !important;
}

.fp-progress-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}
.fp-progress-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  border: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
}

.fp-manual-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.fp-challenge-cards {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.fp-challenge-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  background: var(--bg-subtle);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.fp-challenge-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 12px;
}
.fp-challenge-prompt {
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.5;
  color: var(--ink-3);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  max-height: 3em;
  overflow: hidden;
}
.fp-challenge-card textarea {
  font-family: var(--font-mono);
  font-size: 11.5px;
  background: var(--bg-input);
}

/* ModelTrace Result Box */
.fp-result-box {
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.fp-hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}
.fp-hero-model {
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.4px;
  color: var(--ink);
}
.fp-hero-meta {
  font-size: 11.5px;
  color: var(--ink-2);
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}

.fp-family-bar-wrap {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.fp-family-legend {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}
.fp-family-bar {
  height: 6px;
  border-radius: 2px;
  overflow: hidden;
  display: flex;
  gap: 2px;
  background: var(--bg-muted);
}
.fp-fam-gpt {
  background: var(--accent);
}
.fp-fam-claude {
  background: var(--warn);
}

.fp-rank-list {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.fp-rank-row {
  display: grid;
  grid-template-columns: 32px minmax(150px, 1.3fr) 58px 1fr 62px 68px;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-surface);
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
}
.fp-rank-row:last-child {
  border-bottom: none;
}
.fp-rank-row.is-claimed {
  background: var(--accent-soft);
}
.fp-rank-bar-track {
  height: 4px;
  background: var(--bg-muted);
  border-radius: 2px;
  overflow: hidden;
}
.fp-rank-bar-fill {
  height: 100%;
  background: var(--ink);
  border-radius: 2px;
}
.fp-rank-row.is-claimed .fp-rank-bar-fill {
  background: var(--accent);
}

.fp-footnote {
  margin: 0;
  font-size: 11.5px;
  color: var(--ink-3);
  line-height: 1.6;
}

/* History Drawer & Modals */
.drawer-backdrop,
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: var(--backdrop);
  z-index: 100;
  display: flex;
  justify-content: flex-end;
}
.modal-backdrop {
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.drawer-panel {
  width: 400px;
  max-width: 94vw;
  height: 100%;
  background: var(--bg-surface);
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
}
.drawer-head,
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}
.drawer-head h3,
.modal-head h3 {
  margin: 0;
  font-size: 13.5px;
  font-weight: 600;
}
.history-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.history-item {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  background: var(--bg-subtle);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.history-item:hover {
  border-color: var(--line-strong);
  background: var(--bg-surface);
}
.history-item-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
}

.modal-card {
  width: 460px;
  max-width: 95vw;
  background: var(--bg-surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow-popover);
}
.modal-card .modal-head {
  padding: 0 0 10px;
  margin-bottom: 10px;
}
.modal-desc {
  font-size: 12px;
  color: var(--ink-2);
  margin: 0 0 10px;
}
.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 14px;
}
.modal-fullscreen {
  width: 96vw;
  height: 94vh;
  background: var(--bg-surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-popover);
}
.fullscreen-iframe {
  flex: 1;
  border: none;
  background: #ffffff;
  width: 100%;
}

@media (max-width: 1080px) {
  html, body {
    height: auto;
    overflow: auto;
  }
  .app-shell {
    height: auto;
  }
  .topbar {
    height: auto;
    flex-wrap: wrap;
    padding: 8px 12px;
  }
  .workbench-split {
    grid-template-columns: 1fr;
  }
  .split-resizer {
    display: none;
  }
  .pane-left,
  .pane-right {
    height: 520px;
    border-bottom: 1px solid var(--line);
  }
  .metric-ledger {
    grid-template-columns: repeat(2, 1fr);
  }
  .ledger-cell:nth-child(2) {
    border-right: none;
  }
  .ledger-cell:nth-child(1),
  .ledger-cell:nth-child(2) {
    border-bottom: 1px solid var(--line);
  }
  .charts-grid {
    grid-template-columns: 1fr;
  }
  .chart-pane {
    border-right: none;
    border-bottom: 1px solid var(--line);
  }
  .chart-pane:last-child {
    border-bottom: none;
  }
}
/* ---- Detection Workbench v2 Extensions ---- */
.main-view {
  display: none;
  flex: 1;
  min-height: 0;
}
.main-view.active {
  display: flex;
  flex-direction: column;
}
.main-view-scroll {
  overflow-y: auto;
}

.bench-layout {
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
  padding: 16px 20px 28px;
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.bench-sidebar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: sticky;
  top: 12px;
}

.bench-form {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.bench-mode-switch {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
}
.bench-mode-switch .switch-item {
  text-align: center;
  justify-content: center;
}

.bench-toggles {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 10px;
  background: var(--bg-subtle);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.bench-actions-row {
  display: flex;
  gap: 8px;
}

.audit-live-feed {
  max-height: 300px;
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.live-step-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 9px;
  background: var(--bg-subtle);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 12px;
}

.bench-report {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.audit-report-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.audit-empty-card {
  padding: 48px 24px;
}

.verdict-banner {
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: var(--bg-surface);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.verdict-banner.light-green {
  border-left: 4px solid var(--ok);
}
.verdict-banner.light-yellow {
  border-left: 4px solid var(--warn);
}
.verdict-banner.light-red {
  border-left: 4px solid var(--err);
}

.verdict-top-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.verdict-axes {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.axis-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  font-size: 12px;
  font-weight: 600;
  background: var(--bg-subtle);
}
.axis-badge.tone-ok { color: var(--ok); border-color: rgba(29, 111, 74, 0.35); background: var(--ok-soft); }
.axis-badge.tone-warn { color: var(--warn); border-color: rgba(166, 91, 18, 0.35); background: var(--warn-soft); }
.axis-badge.tone-err { color: var(--err); border-color: rgba(184, 51, 55, 0.35); background: var(--err-soft); }

.verdict-score-box {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-family: var(--font-mono);
}
.verdict-score-num {
  font-size: 26px;
  font-weight: 700;
  line-height: 1;
}
.verdict-summary-line {
  margin: 0;
  font-size: 12.5px;
  color: var(--ink-2);
}

.flag-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.audit-model-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.upstream-grid {
  padding: 12px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 12px;
}

.upstream-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.upstream-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}
.upstream-card-meta {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-3);
  word-break: break-all;
}
.upstream-card-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.workshop-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 12px;
}
.workshop-output {
  font-family: var(--font-mono);
  font-size: 11.5px;
  background: var(--bg-subtle);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px;
  min-height: 140px;
  max-height: 360px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.tool-pane.hidden {
  display: none !important;
}

/* Native <dialog> accessibility & scroll containment per modern-web-guidance */
.native-dialog {
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
  color: var(--ink);
  padding: 18px;
  width: min(460px, 94vw);
  box-shadow: var(--shadow-popover);
}
.native-dialog-wide {
  width: min(760px, 95vw);
}
.native-dialog[open] {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
dialog:modal {
  overscroll-behavior: contain;
}
dialog::backdrop {
  background: var(--backdrop);
  overflow: hidden;
  overscroll-behavior: contain;
}
.dialog-title {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
}
.dialog-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.auth-error {
  color: var(--err);
  font-size: 12px;
  background: var(--err-soft);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
}

/* Responsive Data Table Wrapper using container queries */
.table-wrapper {
  overflow: auto;
  max-inline-size: 100%;
  max-block-size: min(520px, 75vh);
  container-type: inline-size;
}
.audit-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}
.audit-table thead {
  position: sticky;
  inset-block-start: 0;
  z-index: 2;
  background: var(--bg-subtle);
}

@container (width < 600px) {
  .audit-table th,
  .audit-table td {
    padding: 6px 8px;
    font-size: 11.5px;
  }
}

.report-page-wrap {
  max-width: 1160px;
  margin: 0 auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

@media (max-width: 1080px) {
  .bench-layout {
    grid-template-columns: 1fr;
  }
  .bench-sidebar {
    position: static;
  }
}
