:root {
  --bg-deep: #0b0a09;
  --bg-panel: #141210;
  --bg-elevated: #1c1916;
  --bg-paper: #efe6d2;
  --brass: #d4a253;
  --brass-bright: #f0c97d;
  --brass-dim: #7c5e2c;
  --amber: #f59e0b;
  --crimson: #dc2626;
  --emerald: #10b981;
  --text-main: #f3ece0;
  --text-muted: #9e9484;
  --border: rgba(212, 162, 83, 0.22);
  --border-strong: rgba(212, 162, 83, 0.5);
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.65);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background:
    radial-gradient(circle at 20% 0%, rgba(212, 162, 83, 0.08), transparent 45%),
    radial-gradient(circle at 85% 10%, rgba(220, 38, 38, 0.06), transparent 40%),
    var(--bg-deep);
  color: var(--text-main);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  min-height: 100vh;
  line-height: 1.45;
}

.serif {
  font-family: 'Playfair Display', Georgia, 'Times New Roman', serif;
}

.mono {
  font-family: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* Header */
.topbar {
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, #181410 0%, #100e0c 100%);
  padding: 14px 24px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  position: sticky;
  top: 0;
  z-index: 30;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.crest {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid var(--brass);
  background: radial-gradient(circle, #2a2115 0%, #110e0b 100%);
  display: grid;
  place-items: center;
  color: var(--brass-bright);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.04em;
  box-shadow: 0 0 20px rgba(212, 162, 83, 0.2);
}

.brand h1 {
  font-size: 21px;
  letter-spacing: 0.06em;
  color: var(--brass-bright);
  font-weight: 700;
}

.brand-sub {
  font-size: 12px;
  color: var(--text-muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.top-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.phone-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(212, 162, 83, 0.1);
  border: 1px solid var(--border-strong);
  padding: 7px 13px;
  border-radius: 999px;
  font-size: 13px;
  color: var(--brass-bright);
}

.lamp-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--text-muted);
  display: inline-block;
}

.lamp-dot.live {
  background: var(--emerald);
  box-shadow: 0 0 10px var(--emerald);
  animation: pulse 1.8s infinite;
}

.lamp-dot.amber {
  background: var(--amber);
  box-shadow: 0 0 10px var(--amber);
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.55; transform: scale(0.92); }
}

.btn {
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated);
  color: var(--text-main);
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.btn:hover:not(:disabled) {
  border-color: var(--brass-bright);
  background: #26211c;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(135deg, #c9923d 0%, #9f6d22 100%);
  color: #0e0b08;
  border-color: var(--brass-bright);
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, #e0aa53 0%, #b37d2b 100%);
}

.btn-danger {
  background: rgba(220, 38, 38, 0.16);
  border-color: rgba(220, 38, 38, 0.55);
  color: #fca5a5;
}

.btn-danger:hover:not(:disabled) {
  background: rgba(220, 38, 38, 0.28);
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
}

/* Main 3-column grid */
.grid {
  max-width: 1560px;
  margin: 0 auto;
  padding: 20px 24px 36px;
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr) 360px;
  gap: 20px;
  align-items: start;
}

@media (max-width: 1200px) {
  .grid {
    grid-template-columns: 310px minmax(0, 1fr);
  }
  .telemetry-col {
    grid-column: 1 / -1;
  }
}

@media (max-width: 820px) {
  .grid {
    grid-template-columns: 1fr;
    padding: 14px;
  }
}

.panel {
  background: linear-gradient(180deg, #171411 0%, #12100e 100%);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel-header {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: rgba(212, 162, 83, 0.04);
}

.panel-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--brass);
  font-weight: 700;
}

.panel-body {
  padding: 16px;
}

/* Switchboard Jacks */
.extension-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ext-card {
  border: 1px solid var(--border);
  background: #1a1613;
  border-radius: 11px;
  padding: 12px 13px;
  cursor: pointer;
  transition: all 0.18s ease;
  text-align: left;
  width: 100%;
  color: inherit;
}

.ext-card:hover {
  border-color: var(--brass);
  transform: translateY(-1px);
}

.ext-card.active {
  border-color: var(--amber);
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.14) 0%, rgba(28, 23, 18, 0.95) 100%);
  box-shadow: 0 0 24px rgba(245, 158, 11, 0.16);
}

.ext-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}

.ext-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  color: var(--brass-bright);
  letter-spacing: 0.08em;
}

.ext-bulb {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #3a3228;
  border: 1px solid #594a38;
}

.ext-card.active .ext-bulb {
  background: #fbbf24;
  border-color: #fef3c7;
  box-shadow: 0 0 12px #f59e0b;
}

.ext-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-main);
}

.ext-role {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.composure-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.meter {
  height: 5px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.meter-fill {
  height: 100%;
  border-radius: 99px;
  background: var(--emerald);
  transition: width 0.35s ease, background 0.35s ease;
}

.meter-fill.rattled { background: var(--amber); }
.meter-fill.cracked { background: var(--crimson); }

.voice-chip {
  margin-top: 7px;
  font-size: 10px;
  color: var(--text-muted);
  opacity: 0.85;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* DTMF Keypad */
.keypad-wrap {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.keypad-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 10px;
}

.key-btn {
  background: radial-gradient(circle at 35% 30%, #2a241e, #15120f);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  padding: 9px 6px;
  color: var(--brass-bright);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: all 0.12s ease;
}

.key-btn:hover {
  border-color: var(--amber);
  background: #2f261b;
}

.key-btn:active {
  transform: scale(0.96);
}

.key-digit {
  font-size: 17px;
  font-weight: 700;
  line-height: 1.1;
}

.key-label {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Evidence Board */
.clues-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

@media (max-width: 600px) {
  .clues-grid { grid-template-columns: 1fr; }
}

.clue-card {
  border-radius: 10px;
  padding: 12px;
  border: 1px dashed rgba(212, 162, 83, 0.25);
  background: rgba(255, 255, 255, 0.02);
  min-height: 86px;
  transition: all 0.25s ease;
}

.clue-card.found {
  border: 1px solid #c9a76a;
  background: linear-gradient(145deg, #f3ead6 0%, #e7dac0 100%);
  color: #1c1610;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
}

.clue-pin {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.clue-card.found .clue-pin {
  color: #991b1b;
}

.clue-title {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 4px;
}

.clue-quote {
  font-size: 12px;
  opacity: 0.85;
  font-style: italic;
}

/* Transcript */
.wire-log {
  height: 390px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-right: 4px;
}

.msg {
  padding: 10px 13px;
  border-radius: 10px;
  font-size: 14px;
  max-width: 92%;
}

.msg.assistant {
  background: #1e1a16;
  border: 1px solid var(--border);
  align-self: flex-start;
}

.msg.user {
  background: rgba(212, 162, 83, 0.14);
  border: 1px solid rgba(212, 162, 83, 0.35);
  align-self: flex-end;
}

.msg.interrupted {
  border-color: rgba(220, 38, 38, 0.45);
  opacity: 0.85;
}

.msg-meta {
  font-size: 11px;
  color: var(--brass);
  font-weight: 600;
  margin-bottom: 3px;
  display: flex;
  gap: 8px;
  align-items: center;
}

.audio-tag {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 5px;
  background: rgba(245, 158, 11, 0.16);
  color: var(--brass-bright);
  font-size: 11px;
  font-family: 'IBM Plex Mono', monospace;
  margin-right: 4px;
}

/* Prompt bar */
.composer {
  margin-top: 12px;
  display: flex;
  gap: 8px;
}

.composer input {
  flex: 1;
  background: #0f0d0c;
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  padding: 10px 13px;
  color: var(--text-main);
  font-size: 14px;
  outline: none;
}

.composer input:focus {
  border-color: var(--amber);
}

.quick-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 9px;
}

.chip {
  background: rgba(212, 162, 83, 0.08);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 11px;
  cursor: pointer;
}

.chip:hover {
  border-color: var(--brass);
  color: var(--brass-bright);
}

/* Telemetry */
.telemetry-feed {
  height: 410px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 7px;
  font-size: 11px;
}

.tel-item {
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 7px 9px;
  background: #0f0d0b;
}

.tel-item.config { border-left: 3px solid var(--amber); }
.tel-item.dtmf { border-left: 3px solid #38bdf8; }
.tel-item.interrupt { border-left: 3px solid var(--crimson); }
.tel-item.play { border-left: 3px solid #a855f7; }
.tel-item.tool_call { border-left: 3px solid var(--emerald); }

.tel-head {
  display: flex;
  justify-content: space-between;
  color: var(--brass);
  font-weight: 700;
  margin-bottom: 3px;
}

.tel-json {
  color: #c5bcad;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 10.5px;
}

/* Stats strip */
.stats-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}

.stat-box {
  background: #1a1613;
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 8px 10px;
  text-align: center;
}

.stat-val {
  font-size: 18px;
  font-weight: 700;
  color: var(--brass-bright);
}

.stat-lbl {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.banner-solved {
  margin-bottom: 14px;
  padding: 12px 15px;
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.2), rgba(212, 162, 83, 0.16));
  border: 1px solid rgba(16, 185, 129, 0.55);
  color: #d1fae5;
  font-size: 13px;
}

.caller-select {
  background: #141210;
  border: 1px solid var(--border);
  color: var(--text-main);
  border-radius: 7px;
  padding: 5px 8px;
  font-size: 11px;
}

.leaderboard-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 12px;
}

.leaderboard-row:last-child { border-bottom: none; }
