/* ==================== Reset & Design Tokens ==================== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  /* Cool blue-tinted base */
  --bg: #f1f5fb;
  --surface: #fafbff;
  --surface-2: #f3f6fc;
  --surface-3: #eaeff8;
  --border: #d8e0ee;
  --border-light: #e4eaf5;

  /* Text */
  --text: #0f172a;
  --text-secondary: #374151;
  --text-muted: #6b7280;

  /* Accent — rich indigo */
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-light: #818cf8;
  --accent-bg: rgba(79, 70, 229, 0.08);
  --accent-border: rgba(79, 70, 229, 0.22);
  --accent-glow: 0 4px 20px rgba(79, 70, 229, 0.25);

  /* Semantic palette — more saturated */
  --success: #047857;
  --success-light: #10b981;
  --success-bg: #ecfdf5;
  --success-border: #6ee7b7;
  --warning: #b45309;
  --warning-light: #f59e0b;
  --warning-bg: #fffbeb;
  --warning-border: #fcd34d;
  --danger: #b91c1c;
  --danger-light: #f87171;
  --danger-bg: #fef2f2;
  --danger-border: #fca5a5;
  --info: #1d4ed8;
  --info-light: #60a5fa;
  --info-bg: #eff6ff;
  --info-border: #93c5fd;

  /* Extra colors for variety */
  --teal: #0f766e;
  --teal-bg: #f0fdfa;
  --pink: #be185d;
  --pink-bg: #fdf2f8;
  --orange: #c2410c;
  --orange-bg: #fff7ed;

  /* Radius & shadows */
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 3px rgba(15,23,42,0.06);
  --shadow: 0 2px 4px rgba(15,23,42,0.08), 0 1px 2px rgba(15,23,42,0.04);
  --shadow-md: 0 4px 16px rgba(15,23,42,0.1);
  --shadow-lg: 0 12px 40px rgba(15,23,42,0.12);

  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --mono: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
}

body {
  font-family: var(--font);
  background: var(--bg);
  min-height: 100vh;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

/* ==================== Full-width Container ==================== */
.container {
  width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

/* ==================== Header ==================== */
header {
  background: linear-gradient(135deg, #4f46e5 0%, #2563eb 45%, #0891b2 100%);
  padding: 22px 32px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

header::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: radial-gradient(circle at 20% 50%, rgba(255,255,255,0.12) 0%, transparent 60%),
              radial-gradient(circle at 80% 50%, rgba(255,255,255,0.08) 0%, transparent 50%);
}

header h1 {
  font-size: 1.5em;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: white;
  position: relative;
}

header .subtitle {
  font-size: 0.82em;
  color: rgba(255,255,255,0.8);
  margin-top: 2px;
  position: relative;
}

.header-nav {
  margin-top: 14px;
  display: flex;
  justify-content: center;
  gap: 10px;
  position: relative;
}

.header-nav .btn-primary {
  background: rgba(255,255,255,0.18);
  color: white;
  padding: 7px 18px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.82em;
  transition: all 0.15s ease;
  border: 1px solid rgba(255,255,255,0.25);
  backdrop-filter: blur(8px);
}

.header-nav .btn-primary:hover {
  background: rgba(255,255,255,0.28);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

/* ==================== Tab Navigation ==================== */
.tab-nav {
  display: flex;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 32px;
  gap: 2px;
  box-shadow: var(--shadow-sm);
}

.tab-btn {
  padding: 13px 24px;
  border: none;
  background: transparent;
  font-size: 0.88em;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2.5px solid transparent;
  transition: all 0.15s ease;
  margin-bottom: -1px;
  font-family: var(--font);
}

.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.tab-btn:hover:not(.active) {
  color: var(--text-secondary);
  background: var(--surface-2);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ==================== Main ==================== */
main {
  flex: 1;
  padding: 22px 28px;
}

section {
  margin-bottom: 20px;
}

h3 {
  color: var(--text);
  margin-bottom: 10px;
  font-size: 0.88em;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ==================== Two-Column Layout ==================== */
.two-col-layout {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 18px;
  align-items: start;
}

.col-config {
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: sticky;
  top: 16px;
  max-height: calc(100vh - 180px);
  overflow-y: auto;
}

.col-live {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

/* ==================== Status Section ==================== */
.status-section {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 14px;
}

.status-card {
  background: var(--surface);
  padding: 16px 18px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
}

.status-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--accent-border);
}

.status-card h3 {
  font-size: 0.72em;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.status-indicator {
  font-size: 0.88em;
  font-weight: 600;
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  text-align: center;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.status-indicator.connected {
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid var(--success-border);
}

.status-indicator.disconnected {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid var(--danger-border);
}

.status-details > div {
  padding: 5px 0;
  border-bottom: 1px solid var(--border-light);
  font-size: 0.82em;
  color: var(--text-secondary);
}

.status-details > div:last-child { border-bottom: none; }
.status-details strong { color: var(--text-muted); font-weight: 500; }
.status-details span { color: var(--text); }

.stats {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.stat-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px;
  background: var(--accent-bg);
  border-radius: var(--radius-sm);
  font-size: 0.82em;
  border: 1px solid var(--accent-border);
}

.stat-label { color: var(--text-secondary); }

.stat-value {
  font-weight: 700;
  color: var(--accent);
  font-size: 1.15em;
  font-variant-numeric: tabular-nums;
}

.backend-details {
  margin-top: 6px;
  font-size: 0.82em;
  color: var(--text-secondary);
}

.backend-details div { margin: 3px 0; }
.backend-details strong { color: var(--text-muted); font-weight: 500; }

.tools-ref {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--border-light);
}

.tools-ref-label {
  font-size: 0.7em;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 4px;
  font-weight: 600;
}

.tools-ref-item {
  font-size: 0.78em;
  margin-bottom: 3px;
  color: var(--text-secondary);
  line-height: 1.4;
}

.tools-ref-item code {
  font-family: var(--mono);
  color: var(--accent);
  font-weight: 600;
  font-size: 0.95em;
}

.tools-ref-item span {
  color: var(--text-muted);
  font-size: 0.9em;
}

/* ==================== Control Section ==================== */
.control-section {
  background: var(--surface);
  padding: 20px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.model-selector {
  margin-bottom: 14px;
}

.model-selector label {
  display: block;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 5px;
  font-size: 0.8em;
}

.model-selector select {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.88em;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s ease;
}

.model-selector select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-bg);
}

.model-selector select:hover { border-color: var(--accent-light); }

.instructions-controls {
  margin-bottom: 14px;
}

.instructions-controls label {
  display: block;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 5px;
  font-size: 0.8em;
}

.instructions-controls textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.88em;
  line-height: 1.6;
  resize: vertical;
  transition: all 0.15s ease;
  background: var(--surface);
  color: var(--text);
}

.instructions-controls textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-bg);
}

.instructions-controls textarea::placeholder { color: var(--text-muted); }

.help-text {
  display: block;
  margin-top: 4px;
  font-size: 0.78em;
  color: var(--text-muted);
}

/* ==================== Buttons ==================== */
.button-group {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.btn {
  padding: 9px 18px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.85em;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: var(--font);
}

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

.btn-primary {
  background: linear-gradient(135deg, var(--accent) 0%, #2563eb 100%);
  color: white;
  box-shadow: 0 2px 8px rgba(124, 58, 237, 0.25);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: var(--accent-glow);
}

.btn-secondary {
  background: var(--surface-3);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--border);
  color: var(--text);
}

.btn-warning {
  background: var(--warning-bg);
  color: var(--warning);
  border: 1px solid var(--warning-border);
}

.btn-warning:hover:not(:disabled) {
  background: #fef3c7;
  box-shadow: 0 2px 8px rgba(217, 119, 6, 0.15);
}

.btn-success {
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid var(--success-border);
}

.btn-success:hover:not(:disabled) {
  background: #d1fae5;
  box-shadow: 0 2px 8px rgba(5, 150, 105, 0.15);
}

.btn-save {
  background: linear-gradient(135deg, #0891b2 0%, #2563eb 100%);
  color: white;
  box-shadow: 0 2px 8px rgba(8, 145, 178, 0.25);
}

.btn-save:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(8, 145, 178, 0.3);
}

/* ==================== Notifications ==================== */
.notification {
  display: none;
  padding: 10px 14px;
  margin-top: 8px;
  border-radius: var(--radius-sm);
  font-size: 0.85em;
  font-weight: 500;
  animation: slideIn 0.2s ease-out;
}

.notification-success {
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid var(--success-border);
}

.notification-error {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid var(--danger-border);
}

.notification-info {
  background: var(--info-bg);
  color: var(--info);
  border: 1px solid var(--info-border);
}

@keyframes slideIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==================== Conversation ==================== */
.conversation-panel {
  background: var(--surface);
  padding: 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.conversation-log {
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 12px;
  min-height: 300px;
  max-height: 500px;
  overflow-y: auto;
  border: 1px solid var(--border-light);
}

.message {
  padding: 10px 14px;
  margin-bottom: 8px;
  border-radius: var(--radius-sm);
  line-height: 1.55;
  font-size: 0.88em;
}

.message.user {
  background: linear-gradient(135deg, #eff6ff 0%, #e0f2fe 100%);
  color: #1e40af;
  margin-left: 20px;
  border-left: 3px solid #3b82f6;
}

.message.agent, .message.assistant {
  background: linear-gradient(135deg, #faf5ff 0%, #fdf2f8 100%);
  color: #6b21a8;
  margin-right: 20px;
  border-left: 3px solid #a855f7;
}

.message.system {
  background: var(--surface-3);
  color: var(--text-muted);
  text-align: center;
  font-style: italic;
  font-size: 0.82em;
}

.message.tool {
  background: linear-gradient(135deg, #ecfdf5 0%, #f0fdfa 100%);
  color: #065f46;
  font-family: var(--mono);
  font-size: 0.82em;
  border-left: 3px solid var(--success);
}

.audio-status {
  margin-top: 8px;
  padding: 12px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  text-align: center;
  font-size: 0.82em;
  color: var(--text-muted);
}

/* ==================== Tools Section ==================== */
.tools-section {
  background: var(--surface);
  padding: 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.tool-calls-log {
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 12px;
  max-height: 300px;
  overflow-y: auto;
  border: 1px solid var(--border-light);
}

.tool-call-item {
  background: var(--success-bg);
  padding: 10px 12px;
  margin-bottom: 8px;
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--success);
}

.tool-call-item .tool-name {
  font-weight: 600;
  color: var(--success);
  margin-bottom: 3px;
  font-size: 0.88em;
}

.tool-call-item .tool-args {
  font-family: var(--mono);
  font-size: 0.78em;
  margin-top: 4px;
  color: var(--text-secondary);
  background: var(--surface);
  padding: 6px 8px;
  border-radius: 4px;
}

.tool-call-item .tool-result {
  margin-top: 6px;
  padding: 6px 8px;
  background: var(--surface);
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 0.78em;
}

.tool-call-item.handoff {
  background: var(--pink-bg);
  border-left: 3px solid var(--pink);
}

.tool-call-item.handoff .tool-name { color: var(--pink); }

.placeholder {
  text-align: center;
  color: var(--text-muted);
  font-style: italic;
  padding: 18px;
  font-size: 0.82em;
}

/* ==================== Server Logs ==================== */
.server-logs-section {
  background: var(--surface);
  padding: 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.event-log {
  background: #1e1b4b;
  border-radius: var(--radius-sm);
  padding: 16px;
  height: 380px;
  overflow-y: auto;
  font-family: var(--mono);
  font-size: 0.8em;
  line-height: 1.7;
  border: 1px solid #312e81;
}

.event-log::-webkit-scrollbar { width: 6px; }
.event-log::-webkit-scrollbar-track { background: #1e1b4b; border-radius: 3px; }
.event-log::-webkit-scrollbar-thumb { background: #4338ca; border-radius: 3px; }
.event-log::-webkit-scrollbar-thumb:hover { background: #6366f1; }

.event-log .event {
  padding: 3px 0;
  border-bottom: 1px solid #312e81;
  display: flex;
  align-items: flex-start;
}

.event-log .event:last-child { border-bottom: none; }

.event-log .timestamp {
  color: #818cf8;
  margin-right: 10px;
  font-weight: 500;
  min-width: 72px;
  flex-shrink: 0;
  opacity: 0.7;
}

.event-log .event-type {
  color: #c4b5fd;
  margin-right: 10px;
  font-weight: 500;
}

.event-log .event-data {
  color: #a5f3fc;
  flex: 1;
  word-break: break-word;
  white-space: pre-wrap;
}

.event-log .event[data-type="stt"] .event-data {
  color: #fde68a;
  font-weight: 600;
}

.event-log .event[data-type="server_log"][data-level="info"] .event-data { color: #86efac; }
.event-log .event[data-type="server_log"][data-level="warning"] .event-data { color: #fde68a; font-weight: 500; }
.event-log .event[data-type="server_log"][data-level="error"] .event-data { color: #fca5a5; font-weight: 600; }
.event-log .event[data-type="server_log"][data-level="debug"] .event-data { color: #818cf8; opacity: 0.7; }

/* ==================== Metrics ==================== */
.metrics-section {
  background: var(--surface);
  padding: 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.metrics-log {
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 12px;
  max-height: 380px;
  overflow-y: auto;
  font-family: var(--mono);
  font-size: 0.82em;
}

.metric-entry {
  background: var(--surface);
  border-left: 3px solid var(--accent);
  padding: 10px 14px;
  margin-bottom: 10px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  animation: slideIn 0.2s ease-out;
}

.metric-entry.completed { border-left-color: var(--success); }
.metric-entry.cancelled { border-left-color: var(--warning); }

.metric-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  font-weight: 600;
  color: var(--text);
  font-size: 0.88em;
}

.metric-response-id {
  font-size: 0.78em;
  color: var(--text-muted);
  font-family: var(--mono);
}

.metric-timestamp {
  font-size: 0.72em;
  color: var(--text-muted);
}

.metric-details {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 6px;
  margin-top: 6px;
}

.metric-item {
  display: flex;
  flex-direction: column;
  padding: 5px 8px;
  background: var(--surface-2);
  border-radius: 6px;
}

.metric-label {
  font-size: 0.68em;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.metric-value { font-weight: 600; color: var(--text); }
.metric-value.good { color: var(--success); }
.metric-value.warning { color: var(--warning); }
.metric-value.bad { color: var(--danger); }

.metric-tools {
  margin-top: 6px;
  font-size: 0.78em;
  color: var(--text-secondary);
}

.metric-tools strong { color: var(--accent); }

/* ==================== Context Parameters (Outbound) ==================== */
.context-params-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}

.context-param {
  display: flex;
  flex-direction: column;
}

.context-param label {
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 4px;
  font-size: 0.78em;
}

.context-param input,
.context-param select {
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.88em;
  font-family: var(--font);
  transition: all 0.15s ease;
  background: var(--surface);
  color: var(--text);
}

.context-param input:focus,
.context-param select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-bg);
}

.context-param input::placeholder { color: var(--text-muted); }

/* ==================== Tools Info Panel (Outbound) ==================== */
.tools-info-section {
  background: var(--surface);
  padding: 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.tools-info-panel {
  background: linear-gradient(135deg, var(--teal-bg) 0%, var(--success-bg) 100%);
  border: 1px solid var(--success-border);
  border-radius: var(--radius);
  padding: 16px;
}

.tool-signature {
  background: var(--surface);
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
  border-left: 3px solid var(--teal);
  box-shadow: var(--shadow-sm);
}

.tool-signature:last-child { margin-bottom: 0; }

.tool-signature strong {
  font-family: var(--mono);
  color: var(--teal);
  font-size: 0.88em;
}

.tool-signature p {
  margin: 5px 0;
  color: var(--text-secondary);
  font-size: 0.82em;
}

.tool-signature ul {
  margin: 4px 0 0 16px;
  font-size: 0.78em;
  color: var(--text-secondary);
}

.tool-signature ul li { margin-bottom: 2px; }

.tool-signature code {
  background: var(--teal-bg);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 0.92em;
  color: var(--teal);
  font-family: var(--mono);
}

/* ==================== Current Instructions Display ==================== */
.current-instructions-section {
  margin-bottom: 14px;
  padding: 12px 14px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
}

.current-instructions-section .btn-info {
  background: linear-gradient(135deg, #7c3aed 0%, #2563eb 100%);
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.82em;
  font-weight: 500;
  transition: all 0.15s ease;
  font-family: var(--font);
  box-shadow: 0 2px 8px rgba(124, 58, 237, 0.2);
}

.current-instructions-section .btn-info:hover {
  transform: translateY(-1px);
  box-shadow: var(--accent-glow);
}

#currentInstructionsDisplay,
#ob-currentInstructionsDisplay {
  margin-top: 10px;
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 12px;
  border: 1px solid var(--border);
}

.current-instructions-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  flex-wrap: wrap;
  gap: 8px;
}

.current-instructions-header h4 {
  margin: 0;
  color: var(--text);
  font-size: 0.88em;
  font-weight: 600;
}

.instructions-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}

.last-updated {
  font-size: 0.72em;
  color: var(--text-muted);
}

.readonly-instructions {
  background: var(--surface-2);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 10px;
  max-height: 260px;
  overflow-y: auto;
  font-family: var(--mono);
  font-size: 0.78em;
  line-height: 1.6;
  white-space: pre-wrap;
  word-wrap: break-word;
  color: var(--text-secondary);
}

.btn-sm {
  padding: 5px 10px;
  font-size: 0.78em;
  background: var(--surface-3);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.12s ease;
  font-family: var(--font);
}

.btn-sm:hover {
  background: var(--border);
  color: var(--text);
}

/* ==================== Footer ==================== */
footer {
  background: var(--surface);
  text-align: center;
  padding: 12px;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  font-size: 0.78em;
}

/* ==================== Warning Modal ==================== */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(30, 27, 75, 0.5);
  backdrop-filter: blur(8px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  animation: fadeIn 0.15s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-content {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 26px;
  max-width: 480px;
  width: 92%;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.2s ease;
  border: 1px solid var(--border);
}

@keyframes slideUp {
  from { transform: translateY(16px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.modal-content h3 {
  color: var(--danger);
  margin-bottom: 10px;
  font-size: 1.05em;
  text-transform: none;
  letter-spacing: normal;
}

.modal-content p {
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 10px;
  font-size: 0.88em;
}

.warning-box {
  background: var(--warning-bg);
  border: 1px solid var(--warning-border);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin: 14px 0;
}

.warning-box p {
  margin: 3px 0;
  color: var(--warning);
  font-size: 0.85em;
}

.warning-box strong { color: #92400e; }

.backup-reminder {
  background: var(--danger-bg);
  border: 1px solid var(--danger-border);
  border-radius: var(--radius-sm);
  padding: 10px;
  color: var(--danger);
  font-size: 0.85em;
}

.backup-reminder strong { color: #991b1b; }

.modal-actions {
  display: flex;
  gap: 8px;
  margin-top: 18px;
  flex-wrap: wrap;
}

.modal-actions .btn {
  flex: 1;
  min-width: 110px;
  padding: 10px 16px;
  font-size: 0.85em;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: var(--font);
}

.btn-cancel {
  background: var(--surface-3);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.btn-cancel:hover {
  background: var(--border);
  color: var(--text);
}

.btn-danger {
  background: linear-gradient(135deg, #dc2626 0%, #ef4444 100%);
  color: white;
  box-shadow: 0 2px 8px rgba(220, 38, 38, 0.25);
}

.btn-danger:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(220, 38, 38, 0.3);
}

/* ==================== Scrollbar ==================== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #c4b5fd; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* ==================== Legacy ==================== */
.logs-section {
  background: var(--surface);
  color: var(--text);
  padding: 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.logs-section h3 { color: var(--text-muted); }
.backend-openai { border-left: 3px solid var(--success); }
.backend-livekit { border-left: 3px solid var(--accent); }

/* ==================== Responsive ==================== */
@media (max-width: 768px) {
  main { padding: 12px; }
  header { padding: 16px; }
  header h1 { font-size: 1.2em; }

  .tab-nav { padding: 0 12px; }
  .tab-btn { padding: 10px 14px; font-size: 0.82em; }

  .status-section { grid-template-columns: 1fr; }
  .two-col-layout { grid-template-columns: 1fr; }
  .col-config { position: static; max-height: none; }

  .context-params-grid { grid-template-columns: 1fr; }
  .metric-details { grid-template-columns: 1fr; }

  .modal-content { padding: 18px; max-width: 96%; }
  .modal-actions { flex-direction: column; }
  .modal-actions .btn { width: 100%; }

  .current-instructions-header {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* ==================== Live Panel Tabs ==================== */
.live-tab-bar {
  display: flex;
  gap: 2px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 6px 8px 0;
}

.live-tab-btn {
  padding: 8px 16px;
  border: none;
  background: transparent;
  font-size: 0.82em;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2.5px solid transparent;
  transition: all 0.15s ease;
  margin-bottom: -1px;
  font-family: var(--font);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}

.live-tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  background: var(--accent-bg);
}

.live-tab-btn:hover:not(.active) {
  color: var(--text-secondary);
  background: var(--surface-2);
}

.live-panel { display: none; }
.live-panel.active { display: block; }

/* Panel seamlessly connects to tab bar */
section.live-panel {
  border-top-left-radius: 0;
  border-top-right-radius: 0;
  margin-top: 0;
}

/* ==================== Conversation Header ==================== */
.conversation-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.conversation-header h3 {
  margin-bottom: 0;
}

.copy-transcript-btn {
  font-size: 0.75em;
  padding: 4px 10px;
  opacity: 0.8;
  transition: opacity 0.15s;
}

.copy-transcript-btn:hover {
  opacity: 1;
}

/* ==================== Audio Status + VU Meter ==================== */
.audio-status {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding-top: 6px;
}

.vu-meter {
  border-radius: 4px;
  background: var(--surface-3);
  border: 1px solid var(--border-light);
  height: 20px;
  width: 200px;
  flex-shrink: 0;
}

/* ==================== Connection Status Pulse Badge ==================== */
.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  position: relative;
  background: var(--danger);
  transition: background 0.3s ease;
}

.status-indicator.connected .status-dot {
  background: var(--success);
}

.status-indicator.connected .status-dot::after {
  content: '';
  position: absolute;
  top: -3px;
  left: -3px;
  right: -3px;
  bottom: -3px;
  border-radius: 50%;
  border: 2px solid var(--success);
  animation: pulse-ring 1.6s ease-out infinite;
}

@keyframes pulse-ring {
  0%   { transform: scale(0.8); opacity: 0.9; }
  70%  { transform: scale(1.7); opacity: 0; }
  100% { transform: scale(1.7); opacity: 0; }
}
