:root {
  --divya-lavender: #9f6df2;
  --divya-lavender-deep: #7b3ee6;
  --divya-lavender-soft: #efe7ff;
  --black: #080606;
  --black-soft: #120c0c;
  --maroon-deep: #2a070c;
  --maroon: #55131b;
  --maroon-bright: #8b2430;
  --gold: #d8aa55;
  --gold-soft: #f1d38b;
  --parchment: #ead7ad;
  --parchment-muted: #bfa678;
  --text: #fff7e8;
  --muted: rgba(255, 247, 232, 0.72);
  --line: rgba(216, 170, 85, 0.22);
  --glass: rgba(31, 12, 13, 0.72);
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.42);
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--black);
}

body {
  position: relative;
  isolation: isolate;
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    url("../bg/1.png") center / cover fixed no-repeat,
    radial-gradient(circle at 18% 8%, rgba(122, 29, 37, 0.34), transparent 34%),
    radial-gradient(circle at 88% 18%, rgba(214, 168, 84, 0.14), transparent 26%),
    linear-gradient(140deg, #070505 0%, #1a070a 42%, #0b0706 100%);
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    linear-gradient(135deg, rgba(8,6,6,0.84), rgba(42,7,12,0.78)),
    radial-gradient(circle at 20% 18%, rgba(159,109,242,0.22), transparent 30%);
}

button,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.ambient-layer {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.015) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.015) 1px, transparent 1px),
    url("./assets/manuscript-texture.svg");
  background-size: 68px 68px, 68px 68px, 720px 720px;
  opacity: 0.28;
  mix-blend-mode: screen;
}

.app-shell {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: 318px minmax(0, 1fr);
  min-height: 100vh;
}

.history-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(24px);
  overflow-y: auto;
}

.sidebar-top,
.topbar,
.ask-actions,
.history-item-top,
.answer-card-header,
.section-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--gold-soft);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.sidebar-top h2 {
  margin: 0;
  font-family: "Cormorant Garamond", serif;
  font-size: 1.55rem;
  line-height: 1;
}

.icon-button,
.history-toggle {
  display: none;
  width: 42px;
  height: 42px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
}

.sidebar-close span {
  position: absolute;
  width: 16px;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
}

.sidebar-close span:first-child {
  transform: rotate(45deg);
}

.sidebar-close span:last-child {
  transform: rotate(-45deg);
}

.new-thread-button,
.ask-button,
.retry-button {
  border: 0;
  border-radius: 999px;
  color: #1b0908;
  background: linear-gradient(135deg, var(--gold-soft), var(--gold), #a46b28);
  box-shadow: 0 14px 35px rgba(216, 170, 85, 0.22);
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  transition: transform 180ms ease, box-shadow 180ms ease, filter 180ms ease;
}

.new-thread-button {
  width: 100%;
  margin: 24px 0 18px;
  padding: 13px 18px;
}

.ask-button {
  min-height: 54px;
  padding: 0 28px;
}

.new-thread-button:hover,
.ask-button:hover,
.retry-button:hover {
  transform: translateY(-1px);
  filter: brightness(1.06);
  box-shadow: 0 18px 48px rgba(216, 170, 85, 0.28);
}

.history-list {
  display: grid;
  gap: 12px;
}

.history-empty {
  margin: 24px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.history-item {
  width: 100%;
  padding: 14px;
  border: 1px solid rgba(216, 170, 85, 0.16);
  border-radius: 16px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.045);
  text-align: left;
  transition: border-color 180ms ease, background 180ms ease, transform 180ms ease;
}

.history-item:hover,
.history-item.active {
  border-color: rgba(216, 170, 85, 0.46);
  background: rgba(216, 170, 85, 0.08);
  transform: translateY(-1px);
}

.history-item strong {
  display: -webkit-box;
  overflow: hidden;
  color: var(--text);
  font-size: 0.92rem;
  line-height: 1.35;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.history-item small {
  color: var(--parchment-muted);
  font-size: 0.74rem;
  white-space: nowrap;
}

.history-item p {
  display: -webkit-box;
  overflow: hidden;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.4;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.main-content {
  min-width: 0;
  padding: 22px clamp(16px, 3vw, 44px) 30px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 8;
  min-height: 66px;
  padding: 10px 0;
  background: linear-gradient(180deg, rgba(10, 6, 6, 0.92), rgba(10, 6, 6, 0.72) 70%, transparent);
  backdrop-filter: blur(18px);
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--text);
  text-decoration: none;
}

.brand-symbol {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border: 1px solid rgba(216, 170, 85, 0.5);
  border-radius: 14px;
  color: var(--gold-soft);
  background: linear-gradient(145deg, var(--divya-lavender-deep), rgba(85, 19, 27, 0.86));
  font-family: Cinzel, serif;
  font-size: 1.45rem;
  font-weight: 700;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.28);
}

.brand-mark strong,
.brand-mark small {
  display: block;
}

.brand-mark strong {
  font-family: Cinzel, serif;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.brand-mark small {
  color: var(--muted);
  font-size: 0.76rem;
}

.topbar-status {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid rgba(216, 170, 85, 0.24);
  border-radius: 999px;
  color: var(--gold-soft);
  background: rgba(216, 170, 85, 0.07);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.topbar-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.dashboard-return {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid rgba(159, 109, 242, 0.42);
  border-radius: 999px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-decoration: none;
  text-transform: uppercase;
  transition: transform 180ms ease, border-color 180ms ease, background 180ms ease;
}

.dashboard-return:hover {
  transform: translateY(-1px);
  border-color: rgba(239, 231, 255, 0.74);
  background: rgba(159, 109, 242, 0.16);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #70d391;
  box-shadow: 0 0 18px rgba(112, 211, 145, 0.85);
}

.hero-section {
  display: grid;
  grid-template-columns: minmax(0, 1.16fr) minmax(300px, 0.84fr);
  gap: clamp(22px, 4vw, 52px);
  align-items: stretch;
  padding: clamp(38px, 7vw, 94px) 0 34px;
}

.hero-copy {
  align-self: center;
  animation: riseIn 520ms ease both;
}

h1 {
  max-width: 920px;
  margin: 0;
  font-family: Cinzel, serif;
  font-size: clamp(2.65rem, 8vw, 6.85rem);
  line-height: 0.92;
  letter-spacing: 0.01em;
  text-wrap: balance;
}

.hero-subtitle {
  max-width: 840px;
  margin: 24px 0 0;
  color: var(--muted);
  font-family: "Cormorant Garamond", serif;
  font-size: clamp(1.2rem, 2.2vw, 1.65rem);
  line-height: 1.36;
}

.ask-panel,
.answer-card,
.empty-state,
.loading-card,
.error-card,
.archive-card-inner {
  border: 1px solid var(--line);
  border-radius: 24px;
  background:
    linear-gradient(150deg, rgba(255, 255, 255, 0.085), rgba(255, 255, 255, 0.035)),
    var(--glass);
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px);
}

.ask-panel {
  max-width: 920px;
  margin-top: 34px;
  padding: clamp(18px, 2.4vw, 28px);
}

.ask-panel label {
  display: block;
  margin-bottom: 13px;
  color: var(--parchment);
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.conversation-mode-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.conversation-mode-toggle {
  display: inline-flex;
  gap: 6px;
  padding: 5px;
  border: 1px solid rgba(216, 170, 85, 0.24);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
}

.conversation-mode-button {
  min-height: 40px;
  border: 0;
  border-radius: 999px;
  padding: 0 18px;
  color: var(--parchment);
  background: transparent;
  font-weight: 900;
  cursor: pointer;
}

.conversation-mode-button.is-active {
  color: #1f1608;
  background: var(--gold-soft);
}

.conversation-language-label {
  display: inline-flex !important;
  align-items: center;
  gap: 10px;
  margin: 0 !important;
}

.conversation-language-label select {
  min-height: 40px;
  border: 1px solid rgba(241, 211, 139, 0.46);
  border-radius: 999px;
  padding: 0 34px 0 14px;
  color: var(--gold-soft);
  background: rgba(255, 255, 255, 0.07);
  font: inherit;
  font-weight: 800;
}

.ask-panel[data-mode="voice"] textarea {
  min-height: 88px;
}

textarea {
  width: 100%;
  min-height: 158px;
  resize: vertical;
  border: 1px solid rgba(216, 170, 85, 0.24);
  border-radius: 18px;
  color: var(--text);
  background:
    linear-gradient(rgba(0, 0, 0, 0.18), rgba(0, 0, 0, 0.18)),
    rgba(255, 248, 222, 0.055);
  outline: none;
  padding: 18px;
  font-size: 1rem;
  line-height: 1.6;
  transition: border-color 180ms ease, box-shadow 180ms ease, background 180ms ease;
}

textarea::placeholder {
  color: rgba(255, 247, 232, 0.42);
}

textarea:focus {
  border-color: rgba(241, 211, 139, 0.72);
  box-shadow: 0 0 0 4px rgba(216, 170, 85, 0.12);
  background: rgba(255, 248, 222, 0.08);
}

.ask-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 16px;
}

#characterCount {
  color: var(--parchment-muted);
  font-size: 0.84rem;
  font-weight: 700;
}

.voice-ask-button,
.clear-question-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  border: 1px solid rgba(241, 211, 139, 0.46);
  border-radius: 999px;
  padding: 0 18px;
  color: var(--gold-soft);
  background: rgba(255, 255, 255, 0.07);
  font-weight: 800;
  cursor: pointer;
  transition: transform 180ms ease, border-color 180ms ease, background 180ms ease;
}

.clear-question-button {
  text-transform: uppercase;
}

.voice-ask-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.voice-ask-button:hover,
.clear-question-button:hover,
.voice-ask-button.is-listening {
  transform: translateY(-1px);
  border-color: rgba(241, 211, 139, 0.8);
  background: rgba(216, 170, 85, 0.14);
}

.voice-ask-button:disabled,
.clear-question-button:disabled {
  cursor: not-allowed;
  opacity: 0.62;
  transform: none;
}

.voice-status {
  display: block;
  min-height: 20px;
  margin-top: 10px;
  color: var(--gold-soft);
  font-size: 0.82rem;
  font-weight: 700;
}

.scripture-voice-live-overlay {
  position: fixed;
  inset: 0;
  z-index: 110000;
  display: grid;
  place-items: center;
  padding: clamp(18px, 4vw, 58px);
  background:
    radial-gradient(circle at 50% 110%, rgba(216, 170, 85, 0.34), transparent 34%),
    radial-gradient(circle at 12% 22%, rgba(123, 62, 230, 0.42), transparent 34%),
    radial-gradient(circle at 82% 12%, rgba(241, 211, 139, 0.22), transparent 30%),
    rgba(2, 6, 22, 0.72);
  backdrop-filter: blur(16px);
}

.scripture-voice-live-overlay[hidden] {
  display: none;
}

.scripture-voice-live-panel {
  position: relative;
  display: grid;
  place-items: center;
  align-content: center;
  gap: clamp(16px, 2.6vw, 28px);
  width: min(1120px, 100%);
  min-height: min(720px, calc(100dvh - 48px));
  padding: clamp(30px, 6vw, 86px) clamp(18px, 5vw, 72px);
  border: 2px solid rgba(232, 238, 255, 0.76);
  border-radius: clamp(24px, 3vw, 38px);
  color: #fff;
  text-align: center;
  background:
    radial-gradient(circle at 50% 48%, rgba(123, 62, 230, 0.38), transparent 34%),
    radial-gradient(circle at 72% 68%, rgba(216, 170, 85, 0.18), transparent 28%),
    linear-gradient(145deg, rgba(13, 8, 28, 0.98), rgba(36, 18, 62, 0.94) 56%, rgba(9, 7, 24, 0.98));
  box-shadow: 0 38px 120px rgba(0, 0, 0, 0.58);
}

.scripture-voice-live-gear {
  position: absolute;
  top: 24px;
  right: 24px;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 999px;
  color: rgba(255,255,255,0.9);
  background: rgba(255,255,255,0.08);
  display: grid;
  place-items: center;
}

.scripture-voice-live-gear svg,
.scripture-voice-live-controls svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.1;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.scripture-voice-live-orb {
  width: clamp(130px, 17vw, 220px);
  aspect-ratio: 1;
  border-radius: 999px;
  background:
    radial-gradient(circle at 26% 22%, rgba(255, 255, 255, 0.58), transparent 11%),
    radial-gradient(circle at 74% 67%, rgba(241, 211, 139, 0.95), transparent 34%),
    radial-gradient(circle at 30% 72%, rgba(123, 62, 230, 0.9), transparent 43%),
    linear-gradient(135deg, #4c1d95, #7b3ee6 54%, #d8aa55);
  box-shadow:
    inset 18px 18px 42px rgba(0, 0, 0, 0.34),
    0 0 0 10px rgba(241, 211, 139, 0.12),
    0 34px 90px rgba(123, 62, 230, 0.34);
  animation: scriptureVoiceOrbPulse 1.45s ease-in-out infinite;
}

@keyframes scriptureVoiceOrbPulse {
  0%, 100% { transform: translateY(0) scale(1); filter: saturate(1); }
  50% { transform: translateY(-7px) scale(1.045); filter: saturate(1.18); }
}

.scripture-voice-live-panel strong {
  font-family: Poppins, Arial, sans-serif;
  font-size: clamp(1.8rem, 5vw, 4.2rem);
  font-weight: 950;
  line-height: 1.02;
  text-shadow: 0 18px 54px rgba(0, 0, 0, 0.45);
}

.scripture-voice-live-panel [data-scripture-voice-subtitle] {
  max-width: 760px;
  color: rgba(236, 242, 255, 0.86);
  font-size: clamp(1rem, 2vw, 1.65rem);
  font-weight: 850;
  line-height: 1.35;
}

.scripture-voice-live-reply {
  width: min(820px, 100%);
  max-height: 180px;
  overflow: auto;
  margin: 0;
  border: 1px solid rgba(241, 211, 139, 0.24);
  border-radius: 18px;
  padding: 16px 18px;
  color: rgba(255, 248, 231, 0.94);
  background: rgba(255, 255, 255, 0.07);
  font-size: clamp(0.95rem, 1.35vw, 1.16rem);
  font-weight: 700;
  line-height: 1.65;
  text-align: left;
}

.scripture-voice-live-controls {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border: 1px solid rgba(217, 226, 255, 0.34);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
}

.scripture-voice-live-controls button {
  width: 74px;
  height: 74px;
  border: 0;
  border-radius: 999px;
  color: #fff;
  background: rgba(111, 135, 202, 0.34);
  display: grid;
  place-items: center;
  cursor: pointer;
}

.scripture-voice-live-controls button:last-child {
  background: linear-gradient(135deg, rgba(123, 62, 230, 0.92), rgba(216, 170, 85, 0.86));
}

.suggested-area {
  max-width: 920px;
  margin-top: 22px;
}

.suggested-area p {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.question-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.question-chip {
  border: 1px solid rgba(216, 170, 85, 0.22);
  border-radius: 999px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  padding: 11px 15px;
  font-size: 0.88rem;
  transition: transform 180ms ease, border-color 180ms ease, background 180ms ease;
}

.question-chip:hover {
  transform: translateY(-1px);
  border-color: rgba(216, 170, 85, 0.52);
  background: rgba(216, 170, 85, 0.1);
}

.archive-card {
  position: relative;
  min-height: 560px;
  border-radius: 28px;
  background:
    linear-gradient(180deg, rgba(216, 170, 85, 0.16), rgba(85, 19, 27, 0.08)),
    url("./assets/manuscript-texture.svg") center / cover;
  box-shadow: 0 26px 85px rgba(0, 0, 0, 0.55);
  overflow: hidden;
  animation: floatIn 680ms 90ms ease both;
}

.archive-card::before {
  content: "";
  position: absolute;
  inset: 18px;
  border: 1px solid rgba(241, 211, 139, 0.22);
  border-radius: 22px;
  pointer-events: none;
}

.archive-card-inner {
  position: absolute;
  inset: auto 26px 26px;
  padding: 28px;
}

.folio-label {
  margin: 0 0 10px;
  color: var(--gold-soft);
  font-size: 0.74rem;
  font-weight: 900;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.archive-card h2 {
  margin: 0;
  font-family: "Cormorant Garamond", serif;
  font-size: clamp(2rem, 4vw, 3rem);
  line-height: 0.96;
}

.folio-lines {
  display: grid;
  gap: 9px;
  margin: 24px 0;
}

.folio-lines span {
  height: 9px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(241, 211, 139, 0.42), transparent);
}

.folio-lines span:nth-child(2) {
  width: 78%;
}

.folio-lines span:nth-child(3) {
  width: 88%;
}

.folio-lines span:nth-child(4) {
  width: 62%;
}

.archive-card ul {
  display: grid;
  gap: 10px;
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
  line-height: 1.5;
}

.answer-stage {
  display: grid;
  gap: 18px;
  max-width: 1180px;
  padding: 18px 0 38px;
}

.empty-state,
.loading-card,
.error-card {
  padding: clamp(22px, 3vw, 34px);
}

.empty-state h2,
.loading-card h2,
.error-card h2 {
  max-width: 780px;
  margin: 0;
  font-family: "Cormorant Garamond", serif;
  font-size: clamp(1.8rem, 4vw, 3rem);
  line-height: 1.05;
}

.empty-state p,
.loading-card p,
.error-card p {
  max-width: 760px;
  margin: 14px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.loading-runes {
  display: flex;
  gap: 8px;
  margin-top: 20px;
}

.loading-runes span {
  width: 34px;
  height: 5px;
  border-radius: 999px;
  background: var(--gold);
  animation: pulseLine 900ms ease-in-out infinite;
}

.loading-runes span:nth-child(2) {
  animation-delay: 120ms;
}

.loading-runes span:nth-child(3) {
  animation-delay: 240ms;
}

.answer-card {
  overflow: hidden;
  animation: answerIn 420ms ease both;
}

.answer-card-header {
  align-items: flex-start;
  padding: clamp(20px, 2.5vw, 30px);
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(90deg, rgba(216, 170, 85, 0.12), transparent),
    rgba(0, 0, 0, 0.16);
}

.answer-card-header h2 {
  margin: 0;
  font-family: "Cormorant Garamond", serif;
  font-size: clamp(1.65rem, 3vw, 2.55rem);
  line-height: 1.05;
}

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

.confidence-pill {
  flex: 0 0 auto;
  border: 1px solid rgba(216, 170, 85, 0.34);
  border-radius: 999px;
  color: var(--gold-soft);
  background: rgba(216, 170, 85, 0.08);
  padding: 9px 12px;
  font-size: 0.74rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.answer-sections {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  background: rgba(216, 170, 85, 0.12);
}

.answer-section {
  min-height: 190px;
  padding: clamp(20px, 2.5vw, 28px);
  background: rgba(16, 9, 9, 0.92);
}

.answer-section.wide {
  grid-column: 1 / -1;
}

.section-title-row {
  justify-content: flex-start;
  margin-bottom: 12px;
}

.section-index {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border: 1px solid rgba(216, 170, 85, 0.3);
  border-radius: 999px;
  color: var(--gold-soft);
  font-size: 0.76rem;
  font-weight: 900;
}

.answer-section h3 {
  margin: 0;
  color: var(--parchment);
  font-size: 0.88rem;
  font-weight: 900;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.answer-section p,
.answer-section li {
  color: rgba(255, 247, 232, 0.84);
  line-height: 1.72;
}

.answer-section p {
  margin: 0;
  white-space: pre-wrap;
}

.answer-section ul {
  margin: 0;
  padding-left: 20px;
}

.followups {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 22px clamp(20px, 2.5vw, 30px) clamp(20px, 2.5vw, 30px);
  border-top: 1px solid var(--line);
}

.followups button {
  border: 1px solid rgba(216, 170, 85, 0.24);
  border-radius: 999px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
  padding: 10px 14px;
}

.teacher-card {
  padding: clamp(24px, 4vw, 40px);
  border: 1px solid rgba(216, 170, 85, 0.22);
  border-radius: 28px;
  background:
    linear-gradient(135deg, rgba(216, 170, 85, 0.14), rgba(255,255,255,0.04)),
    rgba(16, 9, 9, 0.88);
  box-shadow: 0 24px 70px rgba(0,0,0,0.42);
}

.teacher-card h2 {
  margin: 0;
  font-family: "Cormorant Garamond", serif;
  font-size: clamp(1.7rem, 3vw, 2.6rem);
}

.teacher-card p:not(.eyebrow) {
  max-width: 900px;
  color: rgba(255, 247, 232, 0.9);
  font-size: 1.04rem;
  line-height: 1.8;
}

.teacher-card-actions,
.answer-concept-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-top: 18px;
}

.answer-concept-row {
  padding: 18px clamp(20px, 2.5vw, 30px);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 247, 232, 0.045);
}

.concept-pipeline-button {
  background: linear-gradient(135deg, var(--divya-lavender), var(--divya-lavender-deep));
  color: #fff;
  box-shadow: 0 16px 42px rgba(123, 62, 230, 0.28);
}

.concept-pipeline-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  margin: 18px 0;
  padding: 16px;
  border: 1px solid rgba(159, 109, 242, 0.36);
  border-radius: 18px;
  background:
    linear-gradient(135deg, rgba(159, 109, 242, 0.18), rgba(216, 170, 85, 0.08)),
    rgba(255, 247, 232, 0.045);
}

.concept-pipeline-title {
  margin: 0 0 5px;
  color: var(--gold-soft);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.concept-pipeline-copy {
  margin: 0;
  color: rgba(255, 247, 232, 0.74);
  font-size: 0.9rem;
  line-height: 1.45;
}

.concept-pipeline-status {
  display: block;
  min-height: 20px;
  margin: 8px 0 0;
  color: var(--gold-soft);
  font-size: 0.86rem;
  font-weight: 800;
  line-height: 1.45;
}

.concept-pipeline-status a {
  color: #fff;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.teaching-answer-overlay {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(12, 6, 8, 0.74);
  backdrop-filter: blur(12px);
}

.teaching-answer-overlay[hidden] {
  display: none;
}

.teaching-answer-modal {
  position: relative;
  width: min(92vw, 780px);
  max-height: 88vh;
  overflow: auto;
  border: 1px solid rgba(241, 211, 139, 0.44);
  border-radius: 28px;
  padding: clamp(24px, 4vw, 40px);
  background:
    linear-gradient(145deg, rgba(85, 19, 27, 0.96), rgba(14, 9, 9, 0.96)),
    url("./assets/manuscript-texture.svg") center / cover;
  box-shadow: 0 34px 110px rgba(0,0,0,0.62);
}

.teaching-close-button {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 40px;
  height: 40px;
  border: 1px solid rgba(241, 211, 139, 0.38);
  border-radius: 999px;
  color: var(--gold-soft);
  background: rgba(255,255,255,0.06);
  font-size: 1.4rem;
  cursor: pointer;
}

.teaching-answer-modal h2 {
  margin: 0 42px 16px 0;
  font-family: "Cormorant Garamond", serif;
  font-size: clamp(1.7rem, 4vw, 2.8rem);
}

.teaching-answer-text {
  color: rgba(255, 247, 232, 0.92);
  font-size: 1.05rem;
  line-height: 1.86;
}

.teaching-translate-panel {
  display: grid;
  gap: 9px;
  margin: 18px 0 6px;
  padding: 14px;
  border: 1px solid rgba(216, 170, 85, 0.24);
  border-radius: 16px;
  background: rgba(255, 247, 232, 0.06);
}

.teaching-translate-panel label {
  color: var(--gold-soft);
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.teaching-translate-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.teaching-translate-row select {
  flex: 1 1 180px;
  min-height: 44px;
  border: 1px solid rgba(216, 170, 85, 0.32);
  border-radius: 999px;
  padding: 0 14px;
  color: var(--cream);
  background: rgba(16, 9, 9, 0.84);
  font-weight: 800;
}

#teachingTranslateStatus {
  color: rgba(255, 247, 232, 0.72);
  font-size: 0.84rem;
  font-weight: 700;
}

.teaching-audio-panel {
  display: grid;
  gap: 10px;
  margin: 18px 0;
  color: var(--gold-soft);
  font-weight: 800;
}

.teaching-audio-panel audio {
  width: 100%;
}

.teaching-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

@media (max-width: 720px) {
  .concept-pipeline-panel {
    grid-template-columns: 1fr;
  }

  .teacher-card-actions .ask-button,
  .answer-concept-row .ask-button,
  .concept-pipeline-panel .ask-button {
    width: 100%;
  }
}

.response-log-panel {
  position: fixed;
  right: 18px;
  top: 112px;
  z-index: 40;
  width: min(300px, calc(100vw - 36px));
  max-height: calc(100vh - 140px);
  overflow: auto;
  border: 1px solid rgba(216, 170, 85, 0.22);
  border-radius: 20px;
  padding: 16px;
  background: rgba(16, 9, 9, 0.88);
  box-shadow: 0 22px 60px rgba(0,0,0,0.38);
  backdrop-filter: blur(16px);
}

.response-log-panel h2 {
  margin: 0 0 12px;
  color: var(--gold-soft);
  font-size: 0.82rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.response-log-item {
  width: 100%;
  display: grid;
  gap: 6px;
  margin-bottom: 8px;
  border: 1px solid rgba(216, 170, 85, 0.18);
  border-radius: 14px;
  padding: 10px;
  color: var(--text);
  background: rgba(255,255,255,0.05);
  text-align: left;
  cursor: pointer;
}

.response-log-item.active,
.response-log-item:hover {
  border-color: rgba(241, 211, 139, 0.52);
  background: rgba(216, 170, 85, 0.11);
}

.response-log-item strong {
  font-size: 0.82rem;
}

.response-log-item span {
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.45;
}

@media (max-width: 1180px) {
  .response-log-panel {
    position: static;
    width: auto;
    max-height: none;
    margin: 0 18px 24px;
  }
}

.error-card {
  border-color: rgba(238, 115, 89, 0.42);
  background: rgba(62, 15, 15, 0.72);
}

.retry-button {
  margin-top: 18px;
  padding: 13px 18px;
}

.footer-note {
  max-width: 1100px;
  padding: 26px 0 10px;
  border-top: 1px solid var(--line);
  color: rgba(255, 247, 232, 0.6);
  font-size: 0.88rem;
  line-height: 1.6;
}

.mobile-shade {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(0, 0, 0, 0.52);
  backdrop-filter: blur(4px);
}

@keyframes riseIn {
  from {
    opacity: 0;
    transform: translateY(18px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes floatIn {
  from {
    opacity: 0;
    transform: translateY(26px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes answerIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulseLine {
  0%,
  100% {
    opacity: 0.28;
    transform: scaleX(0.76);
  }
  50% {
    opacity: 1;
    transform: scaleX(1.12);
  }
}

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

  .history-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 30;
    width: min(88vw, 340px);
    transform: translateX(-105%);
    transition: transform 220ms ease;
  }

  .history-sidebar.open {
    transform: translateX(0);
  }

  .icon-button,
  .history-toggle {
    display: inline-flex;
  }

  .history-toggle {
    flex-direction: column;
    gap: 4px;
  }

  .history-toggle span {
    width: 17px;
    height: 2px;
    border-radius: 2px;
    background: currentColor;
  }

  .hero-section {
    grid-template-columns: 1fr;
  }

  .archive-card {
    min-height: 390px;
  }
}

@media (max-width: 760px) {
  .main-content {
    padding-inline: 14px;
  }

  .topbar {
    gap: 10px;
  }

  .brand-mark small,
  .topbar-status {
    display: none;
  }

  .dashboard-return {
    min-height: 36px;
    padding: 0 11px;
    font-size: 0.68rem;
  }

  .brand-symbol {
    width: 42px;
    height: 42px;
    border-radius: 13px;
  }

  .hero-section {
    padding-top: 30px;
  }

  h1 {
    font-size: clamp(2.45rem, 16vw, 4.35rem);
  }

  .ask-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .ask-button {
    width: 100%;
  }

  .question-chips {
    flex-direction: column;
  }

  .question-chip {
    width: 100%;
    text-align: left;
  }

  .archive-card {
    min-height: 330px;
  }

  .archive-card-inner {
    inset: auto 14px 14px;
    padding: 20px;
  }

  .answer-card-header {
    flex-direction: column;
  }

  .answer-sections {
    grid-template-columns: 1fr;
  }

  .answer-section {
    min-height: auto;
  }
}

/* Divyaverse visual alignment */
:root {
  --divya-lavender: #9f6df2;
  --divya-lavender-deep: #7b3ee6;
  --divya-lavender-soft: #efe7ff;
  --divya-ink: #050505;
  --divya-muted: #6d6679;
  --divya-card: rgba(255, 255, 255, 0.78);
  --divya-card-strong: rgba(255, 255, 255, 0.9);
  --divya-line: rgba(123, 62, 230, 0.22);
  --text: var(--divya-ink);
  --muted: var(--divya-muted);
  --line: var(--divya-line);
  --glass: var(--divya-card);
  --shadow: 0 24px 70px rgba(9, 6, 20, 0.16);
  color-scheme: light;
}

body {
  color: var(--divya-ink);
  font-family: Poppins, Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    url("../bg/1.png") center / cover fixed no-repeat,
    #fff;
}

body::before {
  background:
    linear-gradient(135deg, rgba(255,255,255,0.72), rgba(239,231,255,0.66) 48%, rgba(255,255,255,0.5)),
    radial-gradient(circle at 20% 14%, rgba(159,109,242,0.18), transparent 34%);
}

.ambient-layer {
  opacity: 0.1;
  mix-blend-mode: normal;
}

.history-sidebar {
  border-right: 1px solid rgba(255,255,255,0.48);
  background: rgba(255,255,255,0.58);
  box-shadow: 16px 0 50px rgba(9, 6, 20, 0.08);
}

.topbar {
  background: linear-gradient(180deg, rgba(255,255,255,0.88), rgba(255,255,255,0.62) 72%, transparent);
}

.brand-mark {
  color: var(--divya-ink);
}

.brand-symbol {
  border: 2px solid var(--divya-lavender);
  color: #fff;
  background: linear-gradient(145deg, var(--divya-lavender), var(--divya-lavender-deep));
  font-family: Poppins, Arial, sans-serif;
  box-shadow: 0 12px 30px rgba(123,62,230,0.24);
}

.brand-mark strong {
  font-family: Poppins, Arial, sans-serif;
  color: var(--divya-lavender-deep);
  font-weight: 900;
}

.brand-mark small,
.history-item p,
.archive-card ul,
.hero-subtitle,
.empty-state p,
.loading-card p,
.error-card p,
.footer-note,
.response-log-item span {
  color: var(--divya-muted);
}

.eyebrow,
.folio-label,
.topbar-status,
.voice-status,
.teaching-audio-panel,
.teaching-close-button {
  color: var(--divya-lavender-deep);
}

h1 {
  color: var(--divya-lavender-deep);
  font-family: Poppins, Arial, sans-serif;
  font-size: clamp(2.3rem, 6vw, 5.4rem);
  font-weight: 900;
  line-height: 0.98;
}

.hero-subtitle {
  font-family: Poppins, Arial, sans-serif;
  font-size: clamp(1rem, 1.55vw, 1.28rem);
  font-weight: 700;
}

.ask-panel,
.answer-card,
.empty-state,
.loading-card,
.error-card,
.archive-card-inner,
.teacher-card,
.teaching-answer-modal,
.response-log-panel {
  border: 2px solid rgba(255,255,255,0.64);
  border-radius: 22px;
  background: var(--divya-card);
  box-shadow: var(--shadow);
  backdrop-filter: blur(24px);
}

.ask-panel label,
.answer-section h3,
.confidence-pill,
.suggested-area p,
.history-item small,
.teaching-translate-panel label,
.response-log-panel h2 {
  color: var(--divya-lavender-deep);
}

textarea {
  border: 2px solid rgba(5,5,5,0.16);
  color: var(--divya-ink);
  background: rgba(255,255,255,0.72);
  font-family: Poppins, Arial, sans-serif;
  font-weight: 600;
}

textarea::placeholder {
  color: rgba(5,5,5,0.42);
}

textarea:focus {
  border-color: rgba(123,62,230,0.62);
  box-shadow: 0 0 0 4px rgba(123,62,230,0.12);
  background: rgba(255,255,255,0.9);
}

.new-thread-button,
.ask-button,
.retry-button {
  color: #fff;
  background: linear-gradient(135deg, var(--divya-lavender), var(--divya-lavender-deep));
  box-shadow: 0 14px 34px rgba(123,62,230,0.26);
}

.new-thread-button:hover,
.ask-button:hover,
.retry-button:hover {
  box-shadow: 0 18px 44px rgba(123,62,230,0.32);
}

.voice-ask-button,
.clear-question-button,
.conversation-mode-button,
.conversation-language-label select,
.dashboard-return,
.question-chip,
.followups button {
  border: 1.5px solid rgba(123,62,230,0.26);
  color: var(--divya-lavender-deep);
  background: rgba(255,255,255,0.58);
}

.voice-ask-button:hover,
.clear-question-button:hover,
.voice-ask-button.is-listening,
.conversation-mode-button:hover,
.dashboard-return:hover,
.question-chip:hover,
.followups button:hover {
  border-color: rgba(123,62,230,0.62);
  background: rgba(239,231,255,0.74);
}

.conversation-mode-toggle {
  border: 1.5px solid rgba(123,62,230,0.2);
  background: rgba(255,255,255,0.48);
}

.conversation-mode-button.is-active {
  color: #fff;
  background: linear-gradient(135deg, var(--divya-lavender), var(--divya-lavender-deep));
}

.topbar-status {
  border-color: rgba(123,62,230,0.24);
  background: rgba(239,231,255,0.72);
}

.history-item,
.response-log-item {
  border: 1.5px solid rgba(123,62,230,0.18);
  color: var(--divya-ink);
  background: rgba(255,255,255,0.5);
}

.history-item:hover,
.history-item.active,
.response-log-item.active,
.response-log-item:hover {
  border-color: rgba(123,62,230,0.48);
  background: rgba(239,231,255,0.68);
}

.history-item strong,
.response-log-item strong,
.archive-card h2,
.empty-state h2,
.loading-card h2,
.error-card h2,
.answer-card-header h2,
.teacher-card h2,
.teaching-answer-modal h2 {
  color: var(--divya-ink);
  font-family: Poppins, Arial, sans-serif;
}

.archive-card {
  background:
    linear-gradient(180deg, rgba(255,255,255,0.28), rgba(239,231,255,0.36)),
    url("../bg/2.png") center / cover;
  box-shadow: 0 24px 70px rgba(9, 6, 20, 0.18);
}

.archive-card::before {
  border-color: rgba(255,255,255,0.62);
}

.answer-card-header {
  border-bottom-color: rgba(123,62,230,0.16);
  background: rgba(239,231,255,0.46);
}

.answer-sections {
  background: rgba(123,62,230,0.14);
}

.answer-section {
  background: rgba(255,255,255,0.82);
}

.answer-section p,
.answer-section li,
.teacher-card p:not(.eyebrow),
.teaching-answer-text {
  color: rgba(5,5,5,0.82);
}

.section-index,
.confidence-pill {
  border-color: rgba(123,62,230,0.28);
  color: var(--divya-lavender-deep);
  background: rgba(239,231,255,0.72);
}

.teaching-answer-overlay {
  background: rgba(31,18,48,0.38);
}

.teaching-answer-modal {
  background:
    linear-gradient(145deg, rgba(255,255,255,0.94), rgba(239,231,255,0.86)),
    url("../bg/3.png") center / cover;
}

.teaching-translate-panel {
  border-color: rgba(123,62,230,0.18);
  background: rgba(255,255,255,0.58);
}

.teaching-translate-row select {
  border-color: rgba(123,62,230,0.26);
  color: var(--divya-ink);
  background: rgba(255,255,255,0.84);
}

#teachingTranslateStatus,
.footer-note {
  color: var(--divya-muted);
}

.teaching-close-button {
  border-color: rgba(123,62,230,0.28);
  background: rgba(255,255,255,0.64);
}

.footer-note {
  border-top-color: rgba(123,62,230,0.18);
}

@media (max-width: 760px) {
  h1 {
    font-size: clamp(2.2rem, 13vw, 3.65rem);
  }
}
