:root {
  --bg: #0f172a;
  --panel: #111827;
  --panel-alt: #1f2937;
  --primary: #60a5fa;
  --primary-strong: #2563eb;
  --accent: #34d399;
  --text: #e5e7eb;
  --muted: #9ca3af;
  --warning: #fbbf24;
  --border: rgba(148, 163, 184, 0.2);
  --shadow: rgba(15, 23, 42, 0.45);
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  min-height: 100%;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background: radial-gradient(circle at top, #172554 0%, var(--bg) 40%);
  color: var(--text);
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}

.app-shell {
  width: min(1200px, 100%);
  min-height: 80vh;
  background: rgba(15, 23, 42, 0.82);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: 0 32px 80px var(--shadow);
  display: grid;
  grid-template-columns: 300px 1fr;
  overflow: hidden;
}

.topbar {
  grid-column: 1 / -1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.88);
}

.eyebrow {
  margin: 0 0 4px;
  font-size: 12px;
  letter-spacing: 0.12em;
  color: var(--accent);
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(1.4rem, 2vw, 2rem);
}

.status-pill {
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(52, 211, 153, 0.12);
  color: var(--accent);
  border: 1px solid rgba(52, 211, 153, 0.25);
  font-size: 12px;
  font-weight: 600;
}

.sidebar {
  padding: 22px 18px;
  border-right: 1px solid var(--border);
  background: rgba(17, 24, 39, 0.95);
}

.sidebar h2 {
  margin: 0 0 16px;
  font-size: 1rem;
}

.prompt-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.prompt-chip {
  border: 1px solid var(--border);
  background: rgba(30, 41, 59, 0.9);
  color: var(--text);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 0.93rem;
  cursor: pointer;
  text-align: left;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.prompt-chip:hover {
  border-color: rgba(96, 165, 250, 0.5);
  transform: translateY(-1px);
}

.chat-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.chat-log {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: rgba(15, 23, 42, 0.6);
}

.message {
  max-width: 80%;
  border-radius: 16px;
  padding: 14px 16px;
  line-height: 1.6;
  border: 1px solid var(--border);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12);
}

.message.user {
  align-self: flex-end;
  background: rgba(37, 99, 235, 0.2);
  border-color: rgba(96, 165, 250, 0.3);
}

.message.bot {
  align-self: flex-start;
  background: rgba(17, 24, 39, 0.95);
}

.voice-message {
  width: min(600px, 90%);
  border-left: 3px solid var(--accent);
}

.voice-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.voice-controls button {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 10px;
  background: var(--panel-alt);
  color: var(--text);
  cursor: pointer;
}

.voice-controls button:hover {
  border-color: var(--accent);
}

.voice-status {
  color: var(--muted);
  font-size: 0.88rem;
}

.voice-transcript {
  margin-top: 14px;
}

.voice-transcript summary {
  color: var(--primary);
  cursor: pointer;
}

.voice-transcript p {
  margin: 10px 0 0;
}

.answer-images {
  display: grid;
  gap: 1rem;
  margin-top: 1rem;
}

.answer-images figure {
  margin: 0;
}

.answer-images img {
  display: block;
  max-width: 100%;
  height: auto;
  border: 1px solid var(--line, #d9d4ca);
  border-radius: 6px;
}

.answer-images figcaption {
  margin-top: 0.4rem;
  color: var(--muted, #6b6a65);
  font-size: 0.85rem;
}

.message h3 {
  margin: 0 0 10px;
  font-size: 0.95rem;
  color: var(--primary);
}

.message p {
  margin: 0 0 10px;
}

.message ul,
.message ol {
  margin: 8px 0;
  padding-left: 18px;
}

.message code {
  background: rgba(148, 163, 184, 0.08);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px 6px;
  font-size: 0.88em;
}

.message pre {
  max-width: 100%;
  margin: 0 0 12px;
  overflow-x: auto;
  white-space: pre;
}

.message pre code {
  display: block;
  padding: 12px;
  white-space: pre;
}

.source-list {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.source-list strong {
  display: inline-block;
  margin-bottom: 8px;
  color: var(--warning);
}

.source-list ul {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
}

.composer {
  display: flex;
  gap: 12px;
  padding: 18px 20px;
  border-top: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.9);
}

.composer input {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(17, 24, 39, 0.9);
  color: var(--text);
  padding: 14px 16px;
  font-size: 1rem;
}

.composer input:focus {
  outline: 2px solid rgba(96, 165, 250, 0.4);
  border-color: rgba(96, 165, 250, 0.5);
}

.composer button {
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--primary), var(--primary-strong));
  color: white;
  padding: 14px 20px;
  font-weight: 700;
  cursor: pointer;
}

.composer button:hover {
  filter: brightness(1.06);
}

.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;
}

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

  .sidebar {
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .message {
    max-width: 92%;
  }
}
