:root {
  --bg-1: #0b1220;
  --bg-2: #0f172a;
  --card: rgba(18, 26, 38, 0.6);
  --muted: #94a3b8;
  --accent-1: #3b82f6;
  --accent-2: #8b5cf6;
  --glass-border: rgba(71, 85, 105, 0.18);
  --glass-strong: rgba(255, 255, 255, 0.04);
  --success: linear-gradient(45deg, #10b981, #34d399);
  --warning: linear-gradient(45deg, #f59e0b, #fbbf24);
  --danger: linear-gradient(45deg, #ef4444, #f97316);
  --ui-radius: 14px;
  --pad: 1rem;
  font-synthesis: none;
}

/* ===== Reset / base ===== */
* {
  box-sizing: border-box;
}
html,
body {
  height: 100%;
}
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI",
    Roboto, "Helvetica Neue", Arial;
  color: #e6eef8;
  background: radial-gradient(
      1000px 600px at 10% 10%,
      rgba(99, 102, 241, 0.06),
      transparent 10%
    ),
    linear-gradient(180deg, var(--bg-1) 0%, var(--bg-2) 50%, var(--bg-1) 100%);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: 1.45;
  padding: clamp(12px, 2.5vw, 32px);
}

/* ===== Container & layout ===== */
.container {
  max-width: 1200px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 1.25rem;
  align-items: start;
}

/* On small screens stack */
@media (max-width: 880px) {
  .container {
    grid-template-columns: 1fr;
    padding: 0;
  }
}

/* ===== Header (keeps original title) ===== */
.header {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.25rem;
}

.brand {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.brand h1 {
  font-size: clamp(1.25rem, 2.7vw, 1.6rem);
  margin: 0;
  display: flex;
  gap: 0.5rem;
  align-items: center;
  font-weight: 700;
  background: linear-gradient(45deg, var(--accent-1), var(--accent-2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -0.02em;
}

.subtitle {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0;
}

/* ===== Left panel (controls) ===== */
.panel {
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.02),
    rgba(255, 255, 255, 0.01)
  );
  border-radius: calc(var(--ui-radius) + 4px);
  padding: 1rem;
  border: 1px solid var(--glass-border);
  box-shadow: 0 8px 24px rgba(2, 6, 23, 0.5);
  backdrop-filter: blur(8px) saturate(1.05);
  min-height: 220px;
}

.panel .section-title {
  font-size: 0.9rem;
  color: var(--muted);
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.controls {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.control-row {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  justify-content: space-between;
}

.control-group {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  padding: 0.6rem;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.01), var(--card));
  border-radius: 12px;
  border: 1px solid rgba(71, 85, 105, 0.06);
  width: 100%;
}

.control-group small {
  color: var(--muted);
  font-size: 0.85rem;
}

/* Toggle control (kept IDs) */
.toggle-control {
  position: relative;
  width: 58px;
  height: 32px;
  flex-shrink: 0;
}
.toggle-control input {
  opacity: 0;
  width: 0;
  height: 0;
}
.toggle-slider {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, #253046, #394456);
  border-radius: 999px;
  transition: all 0.22s ease;
  border: 1px solid rgba(255, 255, 255, 0.03);
}
.toggle-slider:before {
  content: "";
  position: absolute;
  left: 4px;
  top: 4px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  transform: translateX(0);
  transition: transform 0.22s cubic-bezier(0.2, 0.9, 0.2, 1);
  box-shadow: 0 4px 14px rgba(2, 6, 23, 0.45);
}
.toggle-control input:checked + .toggle-slider {
  background: linear-gradient(90deg, var(--accent-1), var(--accent-2));
}
.toggle-control input:checked + .toggle-slider:before {
  transform: translateX(26px);
  background: #fff;
}

/* Numeric input */
.input-group label {
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 0.55rem;
  display: block;
}
input[type="number"] {
  width: 100%;
  padding: 0.89rem 0.6rem;
  border-radius: 10px;
  border: 1px solid rgba(71, 85, 105, 0.12);
  background: rgba(255, 255, 255, 0.02);
  color: inherit;
  font-size: 0.95rem;
}
input[type="number"]:focus {
  outline: none;
  box-shadow: 0 6px 18px rgba(59, 130, 246, 0.08);
  border-color: rgba(59, 130, 246, 0.6);
}

/* Buttons - preserve classes and add icon-only / big mic */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.7rem 1rem;
  border-radius: 12px;
  border: 0;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: 0.01em;
  background: linear-gradient(90deg, var(--accent-1), var(--accent-2));
  box-shadow: 0 8px 30px rgba(59, 130, 246, 0.14);
  color: white;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.btn:active {
  transform: translateY(1px);
}
.btn.secondary {
  background: linear-gradient(90deg, #6b7280, #9ca3af);
  box-shadow: 0 8px 30px rgba(107, 114, 128, 0.12);
}
.btn.danger {
  background: var(--danger);
  box-shadow: 0 8px 32px rgba(239, 68, 68, 0.12);
}

/* Big circular mic CTA (non-breaking - new element) */
.mic-cta {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 120px;
  height: 120px;
  border-radius: 999px;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.02),
    rgba(255, 255, 255, 0.01)
  );
  border: 1px solid var(--glass-border);
  box-shadow: 0 18px 40px rgba(2, 6, 23, 0.55),
    inset 0 -8px 30px rgba(0, 0, 0, 0.35);
  margin: 0 auto 0.75rem;
  transition: transform 0.14s ease, box-shadow 0.14s ease;
  cursor: pointer;
}
.mic-cta .mic-inner {
  width: 86px;
  height: 86px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(90deg, var(--accent-1), var(--accent-2));
  box-shadow: 0 10px 26px rgba(59, 130, 246, 0.18);
  color: white;
  font-size: 1.6rem;
  transition: transform 0.14s ease;
}
.mic-cta:active {
  transform: translateY(2px);
}
.mic-cta:focus {
  outline: none;
  box-shadow: 0 0 0 6px rgba(59, 130, 246, 0.12);
}

/* ===== Right panel (transcript / status) ===== */
.main-card {
  background: linear-gradient(
    180deg,
    rgba(12, 18, 30, 0.35),
    rgba(12, 18, 30, 0.25)
  );
  border-radius: calc(var(--ui-radius) + 6px);
  padding: 1.25rem;
  border: 1px solid var(--glass-border);
  box-shadow: 0 14px 40px rgba(2, 6, 23, 0.55);
  backdrop-filter: blur(8px) saturate(1.06);
  min-height: 420px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.85rem;
  background: rgba(255, 255, 255, 0.02);
  border-radius: 999px;
  color: var(--muted);
  font-weight: 600;
  border: 1px solid rgba(71, 85, 105, 0.06);
  min-width: 120px;
  justify-content: center;
}
.status i {
  font-size: 0.6rem;
}

.status.active {
  background: var(--success);
  color: #012018;
  border-color: rgba(16, 185, 129, 0.35);
}
.status.speaking {
  background: var(--warning);
  color: #2b1600;
  border-color: rgba(245, 158, 11, 0.25);
}
.status.error {
  background: var(--danger);
  color: #2b0f0f;
  border-color: rgba(239, 68, 68, 0.25);
}

/* Chat container */
.chat-container {
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.01),
    rgba(255, 255, 255, 0.005)
  );
  padding: 1rem;
  border-radius: 12px;
  border: 1px solid rgba(71, 85, 105, 0.06);
  min-height: 260px;
  max-height: calc(100vh - 340px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  box-shadow: inset 0 2px 12px rgba(0, 0, 0, 0.35);
}

/* Chat messages */
.message {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-bottom: 0.5rem;
}

.message.user {
  align-items: flex-start;
}

.message.ai {
  align-items: flex-end;
}

.message-bubble {
  max-width: 80%;
  padding: 0.75rem 1rem;
  border-radius: 18px;
  font-size: 0.95rem;
  line-height: 1.4;
  word-wrap: break-word;
  position: relative;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.message.user .message-bubble {
  background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
  color: white;
  border-bottom-left-radius: 4px;
}

.message.ai .message-bubble {
  background: linear-gradient(135deg, #6b7280, #9ca3af);
  color: white;
  border-bottom-right-radius: 4px;
}

.message.interim .message-bubble {
  opacity: 0.7;
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.7; }
  50% { opacity: 0.9; }
}

.message-timestamp {
  font-size: 0.75rem;
  color: var(--muted);
  padding: 0 0.5rem;
}

.message.system {
  align-items: center;
  justify-content: center;
}

.message.system .message-bubble {
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
  text-align: center;
  font-style: italic;
  max-width: 100%;
  border-radius: 12px;
}

/* Code block styling within messages */
.message-bubble pre {
  margin: 0.5rem 0;
  padding: 0;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 8px;
  overflow-x: auto;
  border: 1px solid rgba(71, 85, 105, 0.2);
}

.message-bubble pre code {
  font-family: 'Fira Code', 'Monaco', 'Consolas', 'Courier New', monospace;
  font-size: 0.85rem;
  line-height: 1.4;
  padding: 1rem;
  display: block;
  white-space: pre;
  word-wrap: normal;
  overflow-x: auto;
}

.message-bubble p {
  margin: 0.5rem 0;
}

.message-bubble p:first-child {
  margin-top: 0;
}

.message-bubble p:last-child {
  margin-bottom: 0;
}

/* Ensure inline code also looks good */
.message-bubble code:not(pre code) {
  background: rgba(0, 0, 0, 0.2);
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  font-family: 'Fira Code', 'Monaco', 'Consolas', 'Courier New', monospace;
  font-size: 0.9em;
}

#transcript::-webkit-scrollbar {
  width: 10px;
}
#transcript::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.16);
  border-radius: 6px;
  border: 1px solid rgba(0, 0, 0, 0.12);
}

/* small helper row */
.meta-row {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  justify-content: flex-end;
  color: var(--muted);
  font-size: 0.9rem;
}

/* footer buttons group inside main-card (keeps existing buttons active) */
.actions {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  justify-content: flex-end;
}

/* subtle float animation for icons */
.fa-microphone-alt {
  transform: translateY(-1px);
}

/* Recommended: explicit class for the auto-reset control */
.auto-reset-wrapper {
  width: 120px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.45rem;
  padding: 0.45rem;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.01), var(--card));
  border-radius: 12px;
  border: 1px solid rgba(71, 85, 105, 0.06);
}

.auto-reset-wrapper .toggle-control {
  margin: 0;
}

.muted-caption {
  display: block;
  color: var(--muted);
  font-size: 0.85rem;
  margin-top: 2px;
  text-align: center;
  font-weight: 600;
}

/* Collapse button */
.collapse-btn {
  background: transparent;
  border: 0;
  cursor: pointer;
  color: var(--muted);
  padding: 6px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: transform 0.12s ease, color 0.12s ease;
}
.collapse-btn:focus {
  outline: none;
  box-shadow: 0 0 0 6px rgba(99, 102, 241, 0.06);
  color: white;
}
.collapse-btn i {
  width: 14px;
  height: 14px;
}

/* Screen-reader only helper */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Collapsible region animation */
.collapsible-controls {
  overflow: hidden;
  transition: max-height 260ms cubic-bezier(0.2, 0.9, 0.2, 1),
    opacity 200ms ease, transform 200ms ease;
  max-height: 2000px; /* large enough to contain content */
  opacity: 1;
  transform: translateY(0);
}
.collapsible-controls.collapsed {
  max-height: 0;
  opacity: 0;
  transform: translateY(-6px);
  pointer-events: none;
}

/* Make sure the always-visible block looks right when collapsed */
.always-visible {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  align-items: center;
}

/* slightly tighten spacing for main toggle row */
.main-toggle-row .control-group {
  padding: 0.4rem 0.6rem;
}
