:root {
  color-scheme: light;
  --bg: #f7f4ed;
  --paper: #fffdf8;
  --ink: #211d18;
  --muted: #6c6257;
  --line: #d8d0c3;
  --accent: #8f2f2b;
  --accent-dark: #682019;
  --gold: #b88935;
  --green: #426b55;
  --shadow: 0 18px 60px rgba(52, 39, 22, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(255, 253, 248, 0.8), rgba(247, 244, 237, 0.96)),
    radial-gradient(circle at top left, rgba(184, 137, 53, 0.18), transparent 34rem),
    var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", Arial, sans-serif;
}

.shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 42px 0 56px;
}

.intro {
  max-width: 820px;
  padding: 28px 0 24px;
}

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

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.6rem, 7vw, 5.6rem);
  line-height: 0.96;
}

.subtitle {
  max-width: 700px;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 1.14rem;
  line-height: 1.7;
}

.consultation {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 22px;
  align-items: stretch;
}

.ask-form,
.memory-note,
.answer-panel,
.sources-panel,
.status {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.88);
  box-shadow: var(--shadow);
}

.ask-form {
  padding: 22px;
}

label {
  display: block;
  margin-bottom: 10px;
  font-weight: 800;
}

textarea {
  width: 100%;
  min-height: 148px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 16px;
  background: #fffaf0;
  color: var(--ink);
  font: inherit;
  font-size: 1.02rem;
  line-height: 1.55;
  outline: none;
}

textarea:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 4px rgba(184, 137, 53, 0.2);
}

.form-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 16px;
}

button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 1px solid var(--accent-dark);
  border-radius: 6px;
  padding: 0 18px;
  background: var(--accent);
  color: #fffdf8;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

button:hover {
  background: var(--accent-dark);
}

button:disabled {
  cursor: wait;
  opacity: 0.7;
}

.secondary,
.icon-button {
  border-color: var(--line);
  background: #fffdf8;
  color: var(--ink);
}

.secondary:hover,
.icon-button:hover {
  background: #f0eadf;
}

.icon-button {
  width: 44px;
  padding: 0;
  font-size: 1.2rem;
}

.button-icon {
  font-size: 1.2rem;
}

.memory-note {
  padding: 22px;
  border-left: 4px solid var(--green);
}

.memory-note h2 {
  font-size: 1.08rem;
}

.memory-note p {
  margin: 12px 0 0;
  color: var(--muted);
  line-height: 1.65;
}

.status {
  margin-top: 18px;
  padding: 14px 16px;
  color: var(--muted);
}

.status.error {
  border-color: rgba(143, 47, 43, 0.45);
  color: var(--accent-dark);
}

.answer-panel,
.sources-panel {
  margin-top: 22px;
  padding: 22px;
}

.answer-header,
.sources-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.answer {
  margin-top: 12px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.18rem;
  line-height: 1.85;
  white-space: pre-wrap;
}

.sources {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.source {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 13px 14px;
  background: #fffaf0;
}

.source-title {
  margin: 0;
  overflow-wrap: anywhere;
  font-weight: 800;
}

.source-meta {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.source-file {
  margin: 6px 0 0;
  color: var(--muted);
  opacity: 0.6;
  font-size: 0.74rem;
  overflow-wrap: anywhere;
}

.source-text {
  margin-top: 10px;
}

.source-text > summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 0.92rem;
  user-select: none;
}

.source-text > summary:hover {
  color: inherit;
}

.source-text blockquote {
  margin: 10px 0 0;
  padding: 10px 14px;
  border-left: 3px solid var(--line);
  background: rgba(0, 0, 0, 0.03);
  border-radius: 4px;
  font-style: italic;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.source-verses {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
}

#source-count {
  color: var(--muted);
  font-size: 0.92rem;
}

@media (max-width: 780px) {
  .shell {
    width: min(100% - 22px, 1120px);
    padding-top: 24px;
  }

  .consultation {
    grid-template-columns: 1fr;
  }

  .ask-form,
  .memory-note,
  .answer-panel,
  .sources-panel {
    padding: 18px;
  }

  button {
    width: 100%;
  }

  .icon-button {
    width: 44px;
  }
}
