:root {
  --bg-dark: #07050f;
  --bg-card: rgba(17, 13, 30, 0.72);
  --bg-card-hover: rgba(23, 18, 40, 0.85);
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-glow: rgba(139, 92, 246, 0.35);
  --accent-purple: #8b5cf6;
  --accent-cyan: #06b6d4;
  --accent-emerald: #10b981;
  --accent-pink: #ec4899;
  --text-main: #f3f0fc;
  --text-muted: #958ea5;
  --text-faint: #625c72;
  --font-sans: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-dark);
  color: var(--text-main);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
  -webkit-font-smoothing: antialiased;
}

/* Background Ambient Glows */
.ambient-glow {
  position: fixed;
  border-radius: 50%;
  filter: blur(140px);
  pointer-events: none;
  z-index: 0;
  opacity: 0.22;
}

.glow-1 {
  width: 550px;
  height: 550px;
  background: radial-gradient(circle, #7c3aed, #4f46e5);
  top: -150px;
  left: 10%;
}

.glow-2 {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, #06b6d4, #0284c7);
  bottom: 5%;
  right: 5%;
}

.glow-3 {
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, #ec4899, #8b5cf6);
  top: 45%;
  left: 45%;
}

/* App Shell */
.app-shell {
  position: relative;
  z-index: 1;
  max-width: 1440px;
  margin: 0 auto;
  padding: 24px 32px 40px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Topbar */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 28px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-orb {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-cyan));
  padding: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 25px rgba(139, 92, 246, 0.45);
}

.orb-inner {
  width: 100%;
  height: 100%;
  border-radius: 10px;
  background: var(--bg-dark);
  display: flex;
  align-items: center;
  justify-content: center;
}

.orb-inner::after {
  content: "✦";
  font-size: 16px;
  color: var(--accent-cyan);
}

.brand-title {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand-title span {
  font-weight: 400;
  color: var(--text-muted);
}

.brand-sub {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.16em;
  color: var(--accent-purple);
  margin-top: 2px;
}

.topbar-status {
  display: flex;
  align-items: center;
  gap: 12px;
}

.status-pill {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 14px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  border: 1px solid var(--border-subtle);
  background: rgba(255, 255, 255, 0.03);
}

.status-online {
  color: var(--accent-emerald);
  border-color: rgba(16, 185, 129, 0.25);
  background: rgba(16, 185, 129, 0.05);
}

.pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent-emerald);
  box-shadow: 0 0 10px var(--accent-emerald);
  animation: pulseDot 2s infinite;
}

@keyframes pulseDot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}

.status-model {
  color: var(--text-main);
  background: rgba(139, 92, 246, 0.08);
  border-color: rgba(139, 92, 246, 0.25);
}

.btn-ghost {
  display: flex;
  align-items: center;
  gap: 7px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  padding: 7px 15px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--border-glow);
  transform: translateY(-1px);
}

/* Main Grid */
.main-grid {
  display: grid;
  grid-template-columns: 460px 1fr;
  gap: 24px;
  flex: 1;
}

/* Studio Cards */
.studio-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  backdrop-filter: blur(28px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 22px 24px 18px;
  border-bottom: 1px solid var(--border-subtle);
}

.eyebrow {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.18em;
  color: var(--accent-purple);
  margin-bottom: 4px;
}

.card-header h2 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.pill {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 4px 10px;
  border-radius: 99px;
  border: 1px solid var(--border-subtle);
}

.pill-idle { color: var(--text-muted); background: rgba(255, 255, 255, 0.04); }
.pill-listening { color: var(--accent-pink); border-color: rgba(236, 72, 153, 0.35); background: rgba(236, 72, 153, 0.1); }
.pill-transcribing { color: var(--accent-cyan); border-color: rgba(6, 182, 212, 0.35); background: rgba(6, 182, 212, 0.1); }
.pill-ready { color: var(--accent-emerald); border-color: rgba(16, 185, 129, 0.35); background: rgba(16, 185, 129, 0.1); }

/* Voice Studio Body */
.voice-body {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  flex: 1;
}

.visualizer-container {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  padding: 14px;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 110px;
}

#audioVisualizer {
  width: 100%;
  height: 80px;
}

.recording-timer {
  position: absolute;
  top: 10px;
  right: 14px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
}

.voice-controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
}

.mic-button {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  border: 2px solid rgba(139, 92, 246, 0.4);
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.25), rgba(6, 182, 212, 0.25));
  color: var(--text-main);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 8px 25px rgba(139, 92, 246, 0.25);
}

.mic-button:hover {
  transform: scale(1.06);
  border-color: var(--accent-purple);
  box-shadow: 0 10px 35px rgba(139, 92, 246, 0.45);
}

.mic-button.recording {
  border-color: var(--accent-pink);
  background: linear-gradient(135deg, #ec4899, #f43f5e);
  box-shadow: 0 0 35px rgba(236, 72, 153, 0.6);
  animation: micPulse 1.6s infinite;
}

@keyframes micPulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.08); }
  100% { transform: scale(1); }
}

.voice-hint {
  font-size: 12px;
  color: var(--text-muted);
}

/* Transcript Box */
.transcript-box {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.transcript-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  color: var(--text-faint);
}

.transcript-content {
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-main);
  min-height: 60px;
  max-height: 110px;
  overflow-y: auto;
  word-break: break-word;
}

.transcript-content.empty {
  color: var(--text-faint);
  font-style: italic;
}

.transcript-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.btn-action-outline, .btn-action-primary {
  padding: 9px 12px;
  border-radius: 9px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn-action-outline {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
}

.btn-action-outline:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--border-glow);
}

.btn-action-primary {
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-cyan));
  border: 0;
  color: #06040d;
}

.btn-action-primary:hover:not(:disabled) {
  opacity: 0.92;
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(139, 92, 246, 0.35);
}

.btn-action-outline:disabled, .btn-action-primary:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.btn-micro {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.btn-micro:hover:not(:disabled) {
  color: var(--text-main);
  border-color: var(--border-glow);
}

.btn-micro:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* Routing Legend */
.routing-legend {
  padding: 16px 24px;
  border-top: 1px solid var(--border-subtle);
  background: rgba(0, 0, 0, 0.2);
}

.legend-title {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  color: var(--text-faint);
  margin-bottom: 10px;
}

.legend-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.legend-item {
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.legend-badge {
  font-family: var(--font-mono);
  font-size: 9px;
  padding: 2px 6px;
  border-radius: 5px;
  font-weight: 600;
}

.badge-glm { background: rgba(59, 130, 246, 0.15); color: #60a5fa; border: 1px solid rgba(59, 130, 246, 0.3); }
.badge-groq { background: rgba(245, 158, 11, 0.15); color: #fbbf24; border: 1px solid rgba(245, 158, 11, 0.3); }
.badge-gemini { background: rgba(16, 185, 129, 0.15); color: #34d399; border: 1px solid rgba(16, 185, 129, 0.3); }
.badge-or { background: rgba(236, 72, 153, 0.15); color: #f472b6; border: 1px solid rgba(236, 72, 153, 0.3); }

/* Model Switcher */
.model-switcher {
  display: flex;
  gap: 6px;
  background: rgba(0, 0, 0, 0.35);
  padding: 4px;
  border-radius: 12px;
  border: 1px solid var(--border-subtle);
}

.model-tab {
  background: transparent;
  border: 0;
  color: var(--text-muted);
  padding: 6px 14px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  transition: all 0.2s;
}

.model-tab span {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
}

.model-tab small {
  font-size: 9px;
  color: var(--text-faint);
  letter-spacing: 0.04em;
}

.model-tab.active {
  background: rgba(139, 92, 246, 0.18);
  border: 1px solid rgba(139, 92, 246, 0.35);
}

.model-tab.active span {
  color: #fff;
}

.model-tab.active small {
  color: var(--accent-purple);
}

/* Console Messages Feed */
.messages-feed {
  padding: 24px;
  flex: 1;
  overflow-y: auto;
  min-height: 400px;
  max-height: calc(100vh - 360px);
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Empty State */
.empty-state {
  margin: auto;
  text-align: center;
  max-width: 480px;
  padding: 40px 10px;
}

.empty-glow-icon {
  width: 52px;
  height: 52px;
  margin: 0 auto 16px;
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.2), rgba(6, 182, 212, 0.2));
  border: 1px solid var(--border-glow);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: var(--accent-cyan);
  box-shadow: 0 0 35px rgba(139, 92, 246, 0.3);
}

.empty-state h3 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 8px;
}

.empty-state p {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 24px;
}

.quick-prompts {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.quick-prompt-chip {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 12px;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s;
}

.quick-prompt-chip:hover {
  background: rgba(255, 255, 255, 0.07);
  border-color: var(--border-glow);
  color: var(--text-main);
  transform: translateX(3px);
}

/* Chat Message Bubbles */
.chat-row {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}

.chat-row.user {
  flex-direction: row-reverse;
}

.chat-avatar {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}

.chat-avatar.agent {
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-cyan));
  color: #06040d;
  box-shadow: 0 0 15px rgba(139, 92, 246, 0.4);
}

.chat-avatar.user {
  background: #2a223f;
  color: var(--accent-purple);
  border: 1px solid rgba(139, 92, 246, 0.3);
}

.chat-bubble {
  max-width: 82%;
  padding: 16px 20px;
  border-radius: 16px;
  font-size: 13.5px;
  line-height: 1.65;
  word-break: break-word;
}

.chat-row.user .chat-bubble {
  background: #241a3d;
  border: 1px solid rgba(139, 92, 246, 0.35);
  color: #faf5ff;
  border-top-right-radius: 4px;
}

.chat-row.agent .chat-bubble {
  background: rgba(14, 11, 24, 0.9);
  border: 1px solid var(--border-subtle);
  color: #ede9f5;
  border-top-left-radius: 4px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

/* Markdown Typography */
.chat-bubble h1, .chat-bubble h2, .chat-bubble h3 {
  margin: 14px 0 8px;
  font-weight: 700;
  color: #fff;
}

.chat-bubble p {
  margin-bottom: 10px;
}

.chat-bubble p:last-child {
  margin-bottom: 0;
}

.chat-bubble ul, .chat-bubble ol {
  margin: 8px 0 12px 22px;
}

.chat-bubble li {
  margin-bottom: 4px;
}

.chat-bubble pre {
  margin: 12px 0;
  border-radius: 12px;
  background: #100d1c !important;
  border: 1px solid rgba(255, 255, 255, 0.08);
  position: relative;
  overflow: hidden;
}

.code-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 14px;
  background: rgba(255, 255, 255, 0.04);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-faint);
}

.btn-copy-code {
  background: transparent;
  border: 0;
  color: var(--text-muted);
  cursor: pointer;
  font-family: var(--font-sans);
  font-size: 11px;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: color 0.15s;
}

.btn-copy-code:hover {
  color: #fff;
}

.chat-bubble code:not(pre code) {
  font-family: var(--font-mono);
  background: rgba(139, 92, 246, 0.15);
  color: #c4b5fd;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12px;
}

.chat-bubble pre code {
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.5;
  display: block;
  padding: 14px 16px;
  overflow-x: auto;
}

/* Composer Container */
.composer-container {
  padding: 18px 24px 22px;
  border-top: 1px solid var(--border-subtle);
  background: rgba(10, 8, 20, 0.65);
}

.composer-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.shortcut-tip {
  font-size: 11px;
  color: var(--text-faint);
}

.shortcut-tip kbd {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-subtle);
  padding: 2px 5px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 10px;
}

.task-textarea {
  width: 100%;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  color: var(--text-main);
  padding: 14px 16px;
  font-family: var(--font-sans);
  font-size: 13.5px;
  line-height: 1.5;
  resize: vertical;
  min-height: 72px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.task-textarea:focus {
  border-color: var(--border-glow);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.15);
}

.composer-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 12px;
}

.active-tag {
  font-size: 11px;
  color: var(--text-muted);
}

.active-tag strong {
  color: var(--accent-purple);
  font-family: var(--font-mono);
}

.btn-submit {
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-cyan));
  border: 0;
  color: #06040d;
  font-weight: 700;
  font-size: 13px;
  padding: 10px 20px;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s;
  box-shadow: 0 4px 20px rgba(139, 92, 246, 0.3);
}

.btn-submit:hover:not(:disabled) {
  opacity: 0.95;
  transform: translateY(-1px);
  box-shadow: 0 6px 25px rgba(139, 92, 246, 0.45);
}

.btn-submit:disabled {
  opacity: 0.4;
  cursor: wait;
}

/* Footer */
.app-footer {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-faint);
}

.app-footer code {
  color: var(--accent-purple);
  font-family: var(--font-mono);
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-backdrop.open {
  display: flex;
}

.modal-card {
  width: 100%;
  max-width: 520px;
  background: #110e21;
  border: 1px solid var(--border-glow);
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 25px 80px rgba(0, 0, 0, 0.7);
  animation: modalEnter 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalEnter {
  from { opacity: 0; transform: scale(0.95) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-subtle);
}

.modal-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.modal-title h3 {
  font-size: 16px;
  font-weight: 700;
}

.btn-close {
  background: transparent;
  border: 0;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 16px;
}

.btn-close:hover {
  color: #fff;
}

.modal-body {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-desc {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.config-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.config-field label {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
}

.field-val {
  font-size: 13px;
  color: var(--text-main);
}

.input-with-copy {
  display: flex;
  gap: 8px;
}

.input-with-copy input {
  flex: 1;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  color: var(--text-main);
  padding: 8px 12px;
  font-family: var(--font-mono);
  font-size: 12px;
}

.btn-copy {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  padding: 0 14px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-copy:hover {
  background: var(--accent-purple);
  color: #06040d;
}

.field-hint {
  font-size: 11px;
  color: var(--text-faint);
}

.field-hint code {
  color: var(--accent-purple);
}

/* Toast Notification */
.toast {
  position: fixed;
  bottom: 30px;
  right: 30px;
  background: #1f1837;
  border: 1px solid var(--border-glow);
  color: #fff;
  padding: 12px 20px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 200;
  display: flex;
  align-items: center;
  gap: 8px;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

/* Responsive */
@media (max-width: 1080px) {
  .main-grid {
    grid-template-columns: 1fr;
  }
}
