:root {
  color-scheme: dark;
  --bg: #0f1115;
  --card: rgba(23, 26, 33, 0.88);
  --card-strong: #171a21;
  --muted: #98a2b3;
  --text: #f5f7fa;
  --accent: #8ab4ff;
  --accent-strong: #bfd3ff;
  --border: #2a3040;
  --border-strong: #3a4358;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.25);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Inter, system-ui, sans-serif;
  background:
    radial-gradient(circle at top, rgba(138, 180, 255, 0.08), transparent 30%),
    linear-gradient(180deg, #0d1016, #121722);
  color: var(--text);
}

button,
input,
textarea {
  font: inherit;
}

.app {
  max-width: 1120px;
  margin: 0 auto;
  padding: 32px 16px 64px;
}

.hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

header h1 {
  margin: 0 0 8px;
  font-size: clamp(2.2rem, 4vw, 3.3rem);
}

.tagline {
  margin: 0;
  max-width: 720px;
  color: var(--muted);
  line-height: 1.5;
}

.mode-switch {
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: rgba(16, 23, 36, 0.92);
  box-shadow: var(--shadow);
}

.mode-tab {
  min-width: 136px;
  padding: 12px 18px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
}

.mode-tab.active {
  background: linear-gradient(180deg, rgba(138, 180, 255, 0.28), rgba(138, 180, 255, 0.14));
  border-color: rgba(138, 180, 255, 0.28);
  color: var(--text);
}

.mode-panel {
  display: none;
}

.mode-panel.active {
  display: block;
}

.card,
.search-card,
.status-row,
.verse-card,
.empty,
.toc-section,
.chapter-preview {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 18px;
  margin-bottom: 16px;
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
}

form {
  display: flex;
  gap: 12px;
}

input,
textarea {
  flex: 1;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: #0f141d;
  color: var(--text);
  font-size: 1rem;
}

textarea {
  min-height: 64px;
  resize: vertical;
}

button {
  padding: 14px 18px;
  border: 0;
  border-radius: 14px;
  background: var(--accent);
  color: #091120;
  font-weight: 700;
  cursor: pointer;
}

button:hover {
  filter: brightness(1.04);
}

.chip {
  width: auto;
  padding: 6px 10px;
  border-radius: 999px;
  margin-right: 8px;
  margin-bottom: 6px;
  font-size: 0.9rem;
}

.hint,
.meta,
#status,
.muted-copy,
.composer-hint {
  color: var(--muted);
}

.search-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0 16px;
}

.search-summary span {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #101724;
  color: var(--muted);
  font-size: 0.92rem;
}

.load-more-wrap {
  display: flex;
  justify-content: center;
  margin-top: 8px;
}

.toc {
  display: grid;
  gap: 16px;
}

.book-list,
.chapter-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.testament-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #101724;
  color: var(--text);
  font-size: 1rem;
}

.book-btn,
.chapter-btn,
.secondary {
  width: auto;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #101724;
  color: var(--text);
}

.chapter-nav {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.reference {
  margin: 0 0 10px;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--accent);
}

.verse-num {
  color: var(--accent);
  font-weight: 700;
}

.verse-card p,
.message p,
.sidebar-section li {
  margin: 0;
  line-height: 1.65;
}

.message-body {
  display: grid;
  gap: 12px;
}

.assistant-summary,
.assistant-section {
  margin: 0;
}

.assistant-section ul {
  margin: 8px 0 0;
  padding-left: 18px;
  color: var(--muted);
}

.assistant-footer {
  color: var(--muted);
  font-size: 0.9rem;
}

.citation-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.citation-chip {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #101724;
  color: var(--accent-strong);
  font-size: 0.9rem;
}

.retrieved-window + .retrieved-window,
.retrieved-verse + .retrieved-verse {
  margin-top: 14px;
}

.retrieved-window {
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.retrieved-window-seed {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 0.92rem;
}

.assistant-loading {
  opacity: 0.8;
}

.companion-shell {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: 20px;
}

.companion-sidebar,
.companion-chat {
  margin-bottom: 0;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent-strong);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.78rem;
  font-weight: 800;
}

.companion-sidebar h2,
.companion-chat h2,
.sidebar-section h3 {
  margin: 0 0 10px;
}

.disclaimer {
  margin: 20px 0;
  padding: 16px;
  border-radius: 16px;
  border: 1px solid rgba(255, 207, 112, 0.24);
  background: rgba(255, 207, 112, 0.08);
  color: #ffe6aa;
  line-height: 1.6;
}

.sidebar-section + .sidebar-section {
  margin-top: 20px;
}

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

.chat-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(138, 180, 255, 0.14);
  border: 1px solid rgba(138, 180, 255, 0.24);
  color: var(--accent-strong);
  font-size: 0.9rem;
  font-weight: 700;
}

.companion-thread {
  display: grid;
  gap: 14px;
  min-height: 420px;
  max-height: 60vh;
  margin-bottom: 16px;
  overflow: auto;
  padding-right: 4px;
}

.message {
  max-width: 86%;
  padding: 16px;
  border-radius: 18px;
  border: 1px solid var(--border);
}

.message.assistant {
  background: #101724;
}

.message.user {
  margin-left: auto;
  background: rgba(138, 180, 255, 0.16);
  border-color: rgba(138, 180, 255, 0.2);
}

.message-label {
  margin-bottom: 8px;
  color: var(--accent-strong);
  font-size: 0.8rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.composer {
  display: block;
  border-top: 1px solid var(--border);
  padding-top: 16px;
}

.composer textarea {
  width: 100%;
  margin-bottom: 12px;
}

.composer-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.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: 900px) {
  .hero,
  .chat-header,
  .composer-footer {
    flex-direction: column;
    align-items: stretch;
  }

  .companion-shell {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 640px) {
  form {
    flex-direction: column;
  }

  button,
  .mode-tab {
    width: 100%;
  }

  .search-summary span {
    width: 100%;
    justify-content: center;
  }

  .mode-switch {
    width: 100%;
  }
}
