:root {
  color-scheme: dark;
  --bg: #080c13;
  --bg-soft: #0c121d;
  --bg-elev: #101827;
  --surface: rgba(19, 28, 43, 0.86);
  --surface-solid: #131c2b;
  --surface-2: #1b2638;
  --surface-3: #243149;
  --border: #2c3a54;
  --border-soft: rgba(61, 77, 108, 0.62);
  --text: #edf4ff;
  --text-muted: #9dadc5;
  --text-dim: #66758d;
  --accent: #ff8a1f;
  --accent-2: #ffb25c;
  --accent-soft: rgba(255, 138, 31, 0.14);
  --success: #43dd91;
  --success-soft: rgba(67, 221, 145, 0.14);
  --danger: #ff6f7d;
  --danger-soft: rgba(255, 111, 125, 0.14);
  --warn: #ffd166;
  --warn-soft: rgba(255, 209, 102, 0.14);
  --info: #63b3ff;
  --info-soft: rgba(99, 179, 255, 0.14);
  --radius-xs: 6px;
  --radius-sm: 10px;
  --radius: 14px;
  --radius-lg: 22px;
  --shadow-sm: 0 8px 24px rgba(0, 0, 0, 0.24);
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.34);
  --ring: 0 0 0 3px rgba(255, 138, 31, 0.22);
  --sidebar-width: 264px;
  --content-width: 1480px;
  --mono: ui-monospace, "SF Mono", Menlo, Monaco, "Cascadia Code", Consolas, monospace;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}
html {
  min-height: 100%;
  background: var(--bg);
}
body {
  min-height: 100%;
  margin: 0;
  background: radial-gradient(circle at top left, rgba(255, 138, 31, 0.13), transparent 32rem),
    radial-gradient(circle at top right, rgba(99, 179, 255, 0.08), transparent 34rem), var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
}

a {
  color: var(--accent-2);
  text-decoration: none;
}
a:hover {
  text-decoration: none;
  color: var(--accent);
}
code,
pre,
.mono {
  font-family: var(--mono);
}
button,
input,
select,
textarea {
  font: inherit;
}
.svg-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}
.icon {
  width: 18px;
  height: 18px;
  fill: currentColor;
  flex: 0 0 auto;
}
.icon-lg {
  width: 34px;
  height: 34px;
}
.dim {
  color: var(--text-dim);
}
.muted {
  color: var(--text-muted);
}
.center {
  text-align: center;
}
.right {
  text-align: right;
}
.nowrap {
  white-space: nowrap;
}
.truncate {
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.row-gap {
  display: flex;
  align-items: center;
  gap: 10px;
}
.spread {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

/* Shell */
.shell {
  display: flex;
  min-height: 100vh;
}
.sidebar {
  position: sticky;
  top: 0;
  width: var(--sidebar-width);
  height: 100vh;
  display: flex;
  flex-direction: column;
  flex: 0 0 auto;
  border-right: 1px solid var(--border-soft);
  background: linear-gradient(180deg, rgba(13, 20, 32, 0.98), rgba(9, 14, 23, 0.96));
  backdrop-filter: blur(18px);
  z-index: 40;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 22px 20px 20px;
  border-bottom: 1px solid var(--border-soft);
}
.brand > div {
  display: flex;
  min-width: 0;
  flex-direction: column;
}
.brand strong {
  font-size: 17px;
  letter-spacing: -0.02em;
}
.brand span:not(.logo-mark):not(.badge) {
  color: var(--text-dim);
  font-size: 11px;
}
.logo-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 13px;
  color: #1a1005;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 12px 30px rgba(255, 138, 31, 0.24);
}
.nav {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 4px;
  padding: 14px 10px;
  overflow-y: auto;
}
.nav a {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 42px;
  padding: 0 12px;
  border-radius: 11px;
  color: var(--text-muted);
  font-weight: 650;
  transition: background 160ms ease, color 160ms ease, transform 160ms ease;
}
.nav a:hover {
  background: rgba(255, 255, 255, 0.045);
  color: var(--text);
  transform: translateX(2px);
}
.nav a.active {
  color: var(--accent-2);
  background: var(--accent-soft);
}
.nav a.active::before {
  content: "";
  position: absolute;
  left: -10px;
  width: 3px;
  height: 24px;
  border-radius: 0 3px 3px 0;
  background: var(--accent);
}
.sidebar-foot {
  padding: 14px;
  border-top: 1px solid var(--border-soft);
}
.session-card {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  padding: 11px 12px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.025);
}
.session-card div {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.session-card strong {
  font-size: 12px;
}
.session-card span:last-child {
  color: var(--text-dim);
  font-size: 11px;
}
.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 5px var(--success-soft);
}
.main {
  flex: 1;
  min-width: 0;
}
.mobile-topbar {
  display: none;
}
.page-container {
  width: min(var(--content-width), 100%);
  margin: 0 auto;
  padding: 30px 34px 64px;
}

/* Header */
.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}
.page-head h1 {
  margin: 0;
  font-size: clamp(26px, 3vw, 36px);
  line-height: 1.08;
  letter-spacing: -0.04em;
}
.page-head .sub {
  max-width: 720px;
  margin-top: 7px;
  color: var(--text-muted);
  font-size: 14px;
}
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 10px;
  color: var(--accent-2);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

/* Cards/grids */
.card {
  position: relative;
  overflow: hidden;
  padding: 20px;
  margin-bottom: 18px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(28, 39, 59, 0.78), rgba(16, 24, 39, 0.92));
  box-shadow: var(--shadow-sm);
}
.card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.12), transparent);
  pointer-events: none;
}
.card h2 {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0 0 14px;
  font-size: 16px;
  letter-spacing: -0.02em;
}
.card h3 {
  margin: 16px 0 8px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.grid {
  display: grid;
  gap: 18px;
}
.grid-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.grid-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
.stats-grid {
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  margin-bottom: 20px;
}
.stat-card {
  display: block;
  min-height: 128px;
  padding: 18px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  background: linear-gradient(145deg, rgba(31, 43, 64, 0.92), rgba(17, 25, 40, 0.92));
  color: var(--text);
  box-shadow: var(--shadow-sm);
}
.stat-card:hover {
  border-color: rgba(255, 138, 31, 0.5);
  transform: translateY(-1px);
}
.stat-card .label {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.stat-card .value {
  margin-top: 9px;
  font-size: 34px;
  font-weight: 800;
  letter-spacing: -0.05em;
}
.stat-card .hint {
  margin-top: 7px;
  color: var(--text-dim);
  font-size: 12px;
}
.health-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 20px;
}
.health-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.025);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
}

/* Tables */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-sm);
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-soft);
  text-align: left;
  vertical-align: middle;
}
th {
  color: var(--text-dim);
  font-size: 10px;
  font-weight: 850;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
tbody tr {
  transition: background 140ms ease;
}
tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}
tbody tr:last-child td {
  border-bottom: 0;
}
td.mono,
th.mono {
  font-family: var(--mono);
  font-size: 12px;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
}
.badge-success {
  border-color: rgba(67, 221, 145, 0.2);
  background: var(--success-soft);
  color: var(--success);
}
.badge-danger {
  border-color: rgba(255, 111, 125, 0.22);
  background: var(--danger-soft);
  color: var(--danger);
}
.badge-warn {
  border-color: rgba(255, 209, 102, 0.22);
  background: var(--warn-soft);
  color: var(--warn);
}
.badge-accent,
.badge-dev {
  border-color: rgba(255, 138, 31, 0.24);
  background: var(--accent-soft);
  color: var(--accent-2);
}
.badge-info {
  border-color: rgba(99, 179, 255, 0.22);
  background: var(--info-soft);
  color: var(--info);
}

/* Forms */
.form-row {
  margin-bottom: 15px;
}
.form-row label {
  display: block;
  margin-bottom: 7px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 750;
}
.req {
  color: var(--danger);
}
input[type="text"],
input[type="password"],
input[type="number"],
select,
textarea {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
  background: rgba(5, 9, 16, 0.72);
  color: var(--text);
  transition: border 140ms ease, box-shadow 140ms ease, background 140ms ease;
}
input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: var(--ring);
  background: rgba(5, 9, 16, 0.94);
}
input::placeholder,
textarea::placeholder {
  color: #59677e;
}
textarea {
  min-height: 110px;
  resize: vertical;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.55;
}
.hint {
  margin-top: 6px;
  color: var(--text-dim);
  font-size: 11px;
}
.form-error {
  min-height: 18px;
  margin-top: 12px;
  color: var(--danger);
  font-size: 13px;
}

/* Buttons */
.btn,
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.035);
  color: var(--text);
  cursor: pointer;
  font-weight: 750;
  transition: transform 140ms ease, border 140ms ease, background 140ms ease, color 140ms ease,
    box-shadow 140ms ease;
}
.btn:hover,
.icon-btn:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-2);
  transform: translateY(-1px);
}
.btn:focus-visible,
.icon-btn:focus-visible,
a:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}
.btn:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none;
}
.btn-primary {
  border-color: transparent;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #1b1004;
  box-shadow: 0 10px 28px rgba(255, 138, 31, 0.22);
}
.btn-primary:hover {
  background: linear-gradient(135deg, #ff962f, #ffc178);
  color: #120b03;
}
.btn-danger {
  color: var(--danger);
}
.btn-danger:hover {
  border-color: var(--danger);
  background: var(--danger-soft);
  color: var(--danger);
}
.btn-ghost {
  background: transparent;
}
.btn-sm {
  min-height: 31px;
  padding: 0 9px;
  border-radius: 8px;
  font-size: 12px;
}
.btn-block {
  width: 100%;
}
.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin-top: 16px;
}
.icon-btn {
  width: 40px;
  padding: 0;
}

/* Empty/loading */
.empty {
  display: grid;
  place-items: center;
  min-height: 180px;
  padding: 34px 18px;
  color: var(--text-muted);
  text-align: center;
}
.empty .icon {
  width: 36px;
  height: 36px;
  margin-bottom: 10px;
  color: var(--text-dim);
}
.skeleton {
  position: relative;
  overflow: hidden;
  min-height: 120px;
  border-radius: var(--radius);
  background: var(--surface-2);
}
.skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.06), transparent);
  animation: shimmer 1.4s infinite;
}
@keyframes shimmer {
  to {
    transform: translateX(100%);
  }
}

/* Toast */
#toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.toast {
  max-width: 380px;
  padding: 12px 15px;
  border: 1px solid var(--border);
  border-left: 4px solid var(--success);
  border-radius: var(--radius-sm);
  background: rgba(20, 29, 45, 0.96);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity .2s, transform .2s;
}
.toast.show {
  opacity: 1;
  transform: translateY(0);
}
.toast-error {
  border-left-color: var(--danger);
}
.toast-warn {
  border-left-color: var(--warn);
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 22px;
  background: rgba(2, 5, 10, 0.72);
  backdrop-filter: blur(8px);
}
.modal-backdrop.show {
  display: flex;
}
.modal {
  width: min(560px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: #131d2d;
  box-shadow: var(--shadow);
}
.modal h2 {
  margin: 0 36px 16px 0;
  font-size: 21px;
  letter-spacing: -0.03em;
}
.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 24px;
}
.modal-close:hover {
  background: var(--danger-soft);
  color: var(--danger);
}
.reveal-banner {
  padding: 15px;
  margin-bottom: 16px;
  border: 1px solid rgba(255, 209, 102, 0.36);
  border-radius: var(--radius);
  background: var(--warn-soft);
}
.reveal-banner .title {
  margin-bottom: 7px;
  color: var(--warn);
  font-weight: 800;
}
.reveal-banner .secret {
  padding: 10px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.35);
  font-family: var(--mono);
  font-size: 12px;
  user-select: all;
  word-break: break-all;
}

/* Login */
.login-wrap {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: min(430px, 100%);
  padding: 30px;
  border: 1px solid var(--border-soft);
  border-radius: 24px;
  background: linear-gradient(180deg, rgba(28, 39, 59, 0.92), rgba(13, 20, 32, 0.96));
  box-shadow: var(--shadow);
}
.login-brand {
  display: flex;
  align-items: center;
  gap: 13px;
  margin-bottom: 22px;
}
.login-brand h1 {
  margin: 0;
  font-size: 25px;
  letter-spacing: -0.04em;
}
.login-brand span:last-child {
  color: var(--text-dim);
  font-size: 12px;
}
.login-card > .sub {
  margin: -8px 0 22px;
  color: var(--text-muted);
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 15px;
}
.toolbar select {
  width: auto;
  min-width: 150px;
}
.search-field {
  position: relative;
  flex: 1;
  min-width: 220px;
}
.search-field .icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
}
.search-field input {
  padding-left: 39px;
}

/* Combobox */
.combo-box {
  position: relative;
}
.combo-id {
  font-size: 11px;
  opacity: 0.55;
  margin-left: 8px;
}

.combo-list {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  left: 0;
  z-index: 70;
  display: none;
  max-height: 340px;
  overflow-y: auto;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #101827;
  box-shadow: var(--shadow);
}
.combo-list.show {
  display: block;
}
.combo-option {
  display: flex;
  width: 100%;
  flex-direction: column;
  gap: 7px;
  padding: 11px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}
.combo-option:hover,
.combo-option.active {
  background: var(--accent-soft);
}
.combo-main {
  font-weight: 800;
}
.combo-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 11px;
}
.combo-empty {
  padding: 15px;
  color: var(--text-dim);
  text-align: center;
}

.response-panel {
  min-height: 420px;
  max-height: 620px;
  overflow: auto;
  margin: 0;
  padding: 16px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  background: rgba(3, 7, 13, 0.82);
  color: #dce8f8;
  font-size: 12px;
  line-height: 1.6;
  white-space: pre-wrap;
}

/* Charts */
.chart {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  height: 190px;
  padding-top: 14px;
}
.chart-day {
  display: flex;
  min-width: 0;
  flex: 1;
  flex-direction: column;
  align-items: center;
  gap: 7px;
}
.chart-bar {
  width: 100%;
  max-width: 44px;
  min-height: 3px;
  border-radius: 7px 7px 2px 2px;
  background: linear-gradient(to top, var(--danger) var(--err), var(--success) var(--err));
  box-shadow: 0 8px 18px rgba(67, 221, 145, 0.08);
}
.chart-label {
  color: var(--text-dim);
  font-size: 10px;
}
.chart-legend {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-top: 12px;
  color: var(--text-muted);
  font-size: 11px;
}
.legend-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  margin-right: 6px;
  border-radius: 3px;
  background: var(--success);
}
.legend-dot.error {
  background: var(--danger);
}

/* Responsive */
@media (max-width: 980px) {
  .grid-2,
  .grid-3,
  .grid-4 {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: fixed;
    left: 0;
    transform: translateX(-105%);
    transition: transform 190ms ease;
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow);
  }
  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 35;
    display: none;
    background: rgba(0, 0, 0, 0.55);
  }
  .sidebar-backdrop.show {
    display: block;
  }
  .mobile-topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-soft);
    background: rgba(8, 12, 19, 0.88);
    backdrop-filter: blur(16px);
  }
  .mobile-brand {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text);
    font-weight: 850;
  }
  .page-container {
    padding: 22px 18px 48px;
  }
  .page-head {
    flex-direction: column;
  }
}
@media (max-width: 680px) {
  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  .toolbar select {
    width: 100%;
  }
  .stats-grid {
    grid-template-columns: 1fr;
  }
  .page-head h1 {
    font-size: 27px;
  }
  .card {
    padding: 16px;
  }
  .btn-row,
  .page-head .row-gap {
    width: 100%;
  }
  .btn-row .btn,
  .page-head .row-gap .btn {
    flex: 1;
  }
  th,
  td {
    padding: 10px;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

/* Playground response viewer */
.view-tab.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-2);
}
#view-rendered {
  white-space: normal;
}
.resp-block {
  margin-bottom: 14px;
}
.resp-block:last-child {
  margin-bottom: 0;
}
.resp-label {
  margin-bottom: 6px;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.resp-text {
  color: #eaf2ff;
  font-size: 13px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
}
.resp-thinking {
  padding: 10px 12px;
  border-left: 2px solid var(--accent);
  border-radius: 6px;
  background: rgba(255, 138, 31, 0.06);
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.6;
  white-space: pre-wrap;
}
.resp-tool {
  padding: 10px 12px;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  background: rgba(3, 7, 13, 0.6);
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-word;
}
.resp-media {
  max-width: 100%;
  border-radius: 12px;
}
.resp-media-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}
.resp-error {
  padding: 12px;
  border: 1px solid var(--danger);
  border-radius: 8px;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 13px;
  white-space: pre-wrap;
}
/* A cancelled request. Not an error — the user asked for it — so it must not
   look like one, but it is not a result either. */
.resp-note {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text-dim);
  font-size: 13px;
  white-space: pre-wrap;
}
.resp-caret {
  cursor: pointer;
  user-select: none;
}

/* Rendered Markdown (model output) */
.md {
  /* The plain-text panes rely on pre-wrap; Markdown carries its own structure
     and would come out double-spaced under it. */
  white-space: normal;
}
.md > :first-child {
  margin-top: 0;
}
.md > :last-child {
  margin-bottom: 0;
}
.md p {
  margin: 0 0 10px;
}
.md h1,
.md h2,
.md h3,
.md h4,
.md h5,
.md h6 {
  margin: 16px 0 8px;
  color: var(--text);
  font-weight: 800;
  line-height: 1.3;
}
.md h1 {
  font-size: 18px;
}
.md h2 {
  font-size: 16px;
}
.md h3 {
  font-size: 14px;
}
.md h4,
.md h5,
.md h6 {
  font-size: 13px;
}
.md ul,
.md ol {
  margin: 0 0 10px;
  padding-left: 22px;
}
.md li {
  margin: 3px 0;
}
.md li > ul,
.md li > ol {
  margin: 3px 0;
}
.md a {
  color: var(--accent-2);
  text-decoration: underline;
}
.md blockquote {
  margin: 0 0 10px;
  padding: 2px 12px;
  border-left: 2px solid var(--border);
  color: var(--text-muted);
}
.md hr {
  margin: 14px 0;
  border: 0;
  border-top: 1px solid var(--border);
}
.md code {
  padding: 1px 5px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.07);
  font-family: var(--mono, ui-monospace, SFMono-Regular, Menlo, monospace);
  font-size: 0.92em;
}
.md pre {
  margin: 0 0 10px;
  padding: 12px;
  overflow-x: auto;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  background: rgba(3, 7, 13, 0.85);
}
.md pre code {
  padding: 0;
  background: none;
  font-size: 12px;
  line-height: 1.55;
}
/* A wide table must scroll inside its own box, never widen the panel. */
.md table {
  display: block;
  max-width: 100%;
  margin: 0 0 10px;
  overflow-x: auto;
  border-collapse: collapse;
  font-size: 12px;
}
.md th,
.md td {
  padding: 6px 10px;
  border: 1px solid var(--border-soft);
  text-align: left;
  white-space: nowrap;
}
.md th {
  background: rgba(255, 255, 255, 0.04);
  font-weight: 750;
}
.md img {
  max-width: 100%;
  border-radius: 8px;
}

/* Streaming view — thinking state, live caret */
.stream-idle {
  font-size: 12px;
}
.think-block {
  overflow: hidden;
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  background: rgba(255, 138, 31, 0.04);
}
.think-head {
  display: flex;
  gap: 8px;
  align-items: center;
  width: 100%;
  padding: 8px 11px;
  border: 0;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  font: inherit;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-align: left;
  text-transform: uppercase;
}
.think-head:hover {
  color: var(--accent-2);
}
.think-caret {
  font-size: 9px;
  opacity: 0.7;
}
.think-block.active .think-label {
  /* A moving highlight, so "Thinking" reads as happening rather than stuck. */
  background: linear-gradient(
    90deg,
    var(--text-muted) 0%,
    var(--accent-2) 45%,
    var(--text-muted) 90%
  );
  background-clip: text;
  background-size: 220% 100%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: think-shimmer 1.9s linear infinite;
}
@keyframes think-shimmer {
  from {
    background-position: 120% 0;
  }
  to {
    background-position: -120% 0;
  }
}
.think-dots {
  display: none;
  gap: 3px;
}
.think-block.active .think-dots {
  display: inline-flex;
}
.think-dots i {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent);
  animation: think-pulse 1.2s ease-in-out infinite;
}
.think-dots i:nth-child(2) {
  animation-delay: 0.18s;
}
.think-dots i:nth-child(3) {
  animation-delay: 0.36s;
}
@keyframes think-pulse {
  0%,
  60%,
  100% {
    opacity: 0.25;
    transform: translateY(0);
  }
  30% {
    opacity: 1;
    transform: translateY(-2px);
  }
}
.think-body {
  max-height: 190px;
  overflow-y: auto;
  padding: 0 12px 10px;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.6;
}
.think-block.collapsed .think-body {
  display: none;
}

/* Caret on the last line of a streaming answer. */
.resp-text.streaming > :last-child::after {
  content: "";
  display: inline-block;
  width: 7px;
  height: 1em;
  margin-left: 2px;
  border-radius: 1px;
  background: var(--accent);
  vertical-align: text-bottom;
  animation: caret-blink 1s steps(1) infinite;
}
@keyframes caret-blink {
  0%,
  50% {
    opacity: 1;
  }
  50.01%,
  100% {
    opacity: 0;
  }
}

/* Playground progress */
.progress-spinner {
  width: 26px;
  height: 26px;
  margin: 0 auto 12px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Fields corrected from an upstream error */
.field-bad {
  border-color: var(--danger) !important;
}
.field-learned {
  border-color: var(--accent) !important;
}
.field-note {
  margin-top: 4px;
  color: var(--accent-2);
  font-size: 11px;
}
.field-bad ~ .field-note {
  color: var(--danger);
}
.resp-advice {
  margin-bottom: 14px;
  padding: 12px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--text);
  font-size: 13px;
}

/* Provider tabs — pinned inside the model dropdown, browser-tab style */
.combo-options {
  /* The list itself scrolls; a nested scroller would show two scrollbars. */
  padding: 6px;
}
.provider-tabs {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  padding: 8px 8px 0;
  border-bottom: 1px solid var(--border);
  /* Opaque, and the same colour as the list: options scroll UNDER it. */
  background: #101827;
}
.provider-tab {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  padding: 6px 10px;
  border: 1px solid transparent;
  border-bottom: 2px solid transparent;
  border-radius: 7px 7px 0 0;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  font: inherit;
  font-size: 11px;
  font-weight: 750;
  white-space: nowrap;
  transition: color 120ms ease, background 120ms ease, border-color 120ms ease;
}
.provider-tab:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
}
.provider-tab.active {
  border-bottom-color: var(--accent);
  background: rgba(255, 138, 31, 0.08);
  color: var(--accent-2);
}
.provider-count {
  padding: 0 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  font-size: 10px;
  font-weight: 800;
}
.provider-tab.active .provider-count {
  background: rgba(255, 138, 31, 0.25);
  color: var(--accent-2);
}
