:root {
  --bg: #eef2f7;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --border: #dbe3ee;
  --text: #102033;
  --muted: #64748b;
  --primary: #009bd3;
  --primary-dark: #007dab;
  --primary-soft: #e0f7ff;
  --shadow: 0 20px 50px rgba(15, 23, 42, 0.08);
  --radius: 22px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, Arial, sans-serif;
  background: radial-gradient(circle at top left, #dff6ff 0, transparent 34%), var(--bg);
  color: var(--text);
}

button, textarea, select, input { font: inherit; }

.shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  min-height: 88px;
  padding: 18px 28px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.identity {
  display: flex;
  align-items: center;
  gap: 18px;
}

.logo-img {
  width: 120px;
  height: 58px;
  object-fit: contain;
  background: white;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 8px;
  box-shadow: var(--shadow);
}

.identity h1 {
  margin: 0;
  font-size: 25px;
  letter-spacing: -0.03em;
}

.identity p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.system-badge {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 10px 14px;
  color: var(--muted);
  font-size: 13px;
  box-shadow: 0 10px 25px rgba(15, 23, 42, 0.04);
}

.system-badge.ok {
  color: #075985;
  background: #e0f7ff;
  border-color: #bae6fd;
}

.system-badge.warn {
  color: #92400e;
  background: #fef3c7;
  border-color: #fde68a;
}

.mode-select {
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  padding: 10px 14px;
  color: var(--text);
  outline: none;
}

.main {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 22px;
  padding: 0 28px 28px;
}

.assistant-panel {
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.welcome-card {
  padding: 24px 26px 16px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(135deg, #ffffff, #f8fafc);
}

.welcome-card h2 {
  margin: 0;
  font-size: 24px;
}

.welcome-card p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 16px 26px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-soft);
}

.chip {
  border: 1px solid var(--border);
  background: white;
  color: var(--text);
  border-radius: 999px;
  padding: 10px 14px;
  cursor: pointer;
}

.chip:hover {
  border-color: var(--primary);
  color: var(--primary-dark);
  background: var(--primary-soft);
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 26px;
  scroll-behavior: smooth;
}

.message {
  display: flex;
  margin-bottom: 18px;
}

.message.user {
  justify-content: flex-end;
}

.bubble {
  max-width: 820px;
  border-radius: 22px;
  padding: 15px 17px;
  line-height: 1.58;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.05);
}

.message.assistant .bubble {
  background: white;
  border: 1px solid var(--border);
}

.message.user .bubble {
  background: var(--primary);
  color: white;
}

.name {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 6px;
}

.message.user .name {
  color: rgba(255, 255, 255, 0.82);
}

.text {
  white-space: pre-wrap;
}

.thinking {
  color: var(--muted);
}

.composer {
  display: grid;
  grid-template-columns: 52px 52px minmax(0, 1fr) 108px 52px;
  gap: 10px;
  padding: 18px;
  border-top: 1px solid var(--border);
  background: white;
}

.composer textarea {
  resize: none;
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 14px 16px;
  outline: none;
  min-height: 54px;
  background: var(--surface-soft);
  color: var(--text);
}

.composer textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(0, 155, 211, 0.1);
}

.send-button, .icon-button, .secondary-button {
  border: 0;
  border-radius: 16px;
  cursor: pointer;
  font-weight: 700;
}

.send-button {
  background: var(--primary);
  color: white;
}

.send-button:hover {
  background: var(--primary-dark);
}

.icon-button {
  background: var(--surface-soft);
  border: 1px solid var(--border);
  font-size: 20px;
}

.icon-button.recording {
  background: #fee2e2;
  border-color: #ef4444;
  color: #b91c1c;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.18);
}

.icon-button.talk-active {
  background: #ecfeff;
  border-color: #06b6d4;
  color: #0e7490;
}

.icon-button.talk-listening {
  background: #dbeafe;
  border-color: #3b82f6;
  color: #1d4ed8;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.16);
}

.side-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: 0 14px 35px rgba(15, 23, 42, 0.05);
}

.card h3 {
  margin: 0 0 12px;
  font-size: 16px;
}

.hint {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.status-list {
  display: grid;
  gap: 8px;
}

.status-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
}

.status-row strong {
  color: var(--text);
}

.file-drop {
  display: block;
  border: 1.5px dashed var(--border);
  border-radius: 18px;
  padding: 18px;
  text-align: center;
  cursor: pointer;
  background: var(--surface-soft);
  margin-bottom: 12px;
}

.file-drop input {
  display: none;
}

.secondary-button {
  width: 100%;
  background: #e0f7ff;
  color: #075985;
  padding: 12px 14px;
}

.examples {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 8px;
}

.examples button {
  width: 100%;
  text-align: left;
  border: 1px solid var(--border);
  background: var(--surface-soft);
  border-radius: 14px;
  padding: 10px 12px;
  cursor: pointer;
  color: var(--text);
}

.examples button:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
}

body.talk-mode-active #appShell {
  display: none;
}

.voice-overlay {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  background:
    radial-gradient(circle at 20% 20%, rgba(255, 255, 255, 0.1), transparent 40%),
    radial-gradient(circle at 80% 70%, rgba(0, 0, 0, 0.12), transparent 45%),
    linear-gradient(160deg, #0b111a 0%, #121926 45%, #0f172a 100%);
}

body.talk-mode-active .voice-overlay {
  display: flex;
}

.voice-overlay-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  padding: 24px;
}

.voice-orb {
  width: min(38vw, 240px);
  aspect-ratio: 1 / 1;
  border-radius: 999px;
  position: relative;
  background: radial-gradient(circle at 30% 30%, #93c5fd 0%, #2563eb 55%, #1d4ed8 100%);
  box-shadow:
    0 0 0 10px rgba(59, 130, 246, 0.16),
    0 0 60px rgba(59, 130, 246, 0.55);
  animation: orbPulseIdle 1.8s ease-in-out infinite;
}

.voice-orb::after {
  content: "";
  position: absolute;
  inset: -14px;
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.26);
  animation: orbRing 2.4s linear infinite;
}

.voice-overlay-state {
  color: #f8fafc;
  font-size: clamp(20px, 2.5vw, 30px);
  font-weight: 700;
  letter-spacing: 0.01em;
  text-align: center;
}

.voice-overlay-hint {
  color: #cbd5e1;
  font-size: clamp(14px, 1.4vw, 18px);
  text-align: center;
}

.voice-overlay-stop {
  margin-top: 8px;
  border: 1px solid rgba(226, 232, 240, 0.45);
  background: rgba(15, 23, 42, 0.58);
  color: #f8fafc;
  border-radius: 999px;
  padding: 10px 18px;
  font-weight: 700;
  cursor: pointer;
}

.voice-overlay-stop:hover {
  background: rgba(30, 41, 59, 0.82);
}

.voice-overlay[data-state="listening"] .voice-orb {
  background: radial-gradient(circle at 30% 30%, #fca5a5 0%, #dc2626 58%, #991b1b 100%);
  box-shadow:
    0 0 0 10px rgba(220, 38, 38, 0.2),
    0 0 60px rgba(248, 113, 113, 0.52);
  animation: orbPulseListening 1.25s ease-in-out infinite;
}

.voice-overlay[data-state="answering"] .voice-orb {
  background: radial-gradient(circle at 30% 30%, #86efac 0%, #22c55e 58%, #15803d 100%);
  box-shadow:
    0 0 0 10px rgba(34, 197, 94, 0.2),
    0 0 60px rgba(74, 222, 128, 0.56);
  animation: orbPulseAnswering 1.05s ease-in-out infinite;
}

@keyframes orbPulseIdle {
  0%, 100% { transform: scale(0.96); }
  50% { transform: scale(1.02); }
}

@keyframes orbPulseListening {
  0%, 100% { transform: scale(0.92); }
  50% { transform: scale(1.06); }
}

@keyframes orbPulseAnswering {
  0%, 100% { transform: scale(0.9); }
  50% { transform: scale(1.1); }
}

@keyframes orbRing {
  0% {
    transform: scale(0.88);
    opacity: 0.64;
  }
  100% {
    transform: scale(1.26);
    opacity: 0;
  }
}

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

@media (max-width: 720px) {
  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .main {
    padding: 0 14px 14px;
  }

  .composer {
    grid-template-columns: 44px 44px 1fr 44px;
  }

  .send-button {
    grid-column: 1 / -1;
    height: 46px;
  }

  .logo-img {
    width: 100px;
  }
}
