:root {
  /* Aged-parchment palette — darker than the original cream (#fbf9f4) per
     request, still a light warm theme rather than a dark-mode flip. --panel
     stays a lighter, cleaner tone than --paper so cards/bubbles read as
     "a page" sitting on top of the darker desk-colored background. */
  --ink: #241c12;
  --ink-soft: #5c4f3a;
  --paper: #e2d3ab;
  --panel: #f3ebd6;
  --line: #7a6438;
  --accent: #6b4f2a;
  --accent-soft: #d8c493;
  --error: #9a3b3b;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  line-height: 1.5;
}

/* --- Top-left site menu: accounts + previous conversations -------------- */

.site-menu {
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 20;
}

.site-menu-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.4rem;
  height: 2.4rem;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  background: var(--panel);
  color: var(--accent);
  cursor: pointer;
}

.site-menu-button[hidden] {
  display: none;
}

.site-menu-button:hover,
.site-menu-button[aria-expanded="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.site-menu-panel {
  position: absolute;
  top: calc(100% + 0.5rem);
  left: 0;
  width: 19rem;
  max-height: min(70vh, 32rem);
  overflow-y: auto;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 0.6rem;
  background: var(--panel);
  box-shadow: 0 0.5rem 1.5rem rgba(36, 28, 18, 0.25);
  font-size: 0.85rem;
  color: var(--ink);
}

.site-menu-panel[hidden] {
  display: none;
}

.menu-heading {
  margin: 0 0 0.5rem;
  font-family: var(--serif);
  font-size: 1rem;
  font-style: italic;
  color: var(--ink);
}

.menu-note {
  margin: 0.5rem 0 0;
  font-size: 0.78rem;
  font-style: italic;
  color: var(--ink-soft);
}

.auth-signin {
  display: flex;
  gap: 0.4rem;
}

.auth-signin input[type="email"] {
  flex: 1;
  min-width: 0;
  padding: 0.35rem 0.6rem;
  font-size: 0.8rem;
  border: 1px solid var(--line);
  border-radius: 0.4rem;
  background: var(--paper);
  color: var(--ink);
}

.auth-signin button,
#auth-signout {
  padding: 0.35rem 0.7rem;
  font-size: 0.8rem;
  border: 1px solid var(--accent);
  border-radius: 0.4rem;
  background: none;
  color: var(--accent);
  cursor: pointer;
  white-space: nowrap;
}

.auth-signin button:hover,
#auth-signout:hover {
  background: var(--accent);
  color: white;
}

.auth-note {
  margin: 0.5rem 0 0;
  font-style: italic;
}

.menu-account-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding-bottom: 0.75rem;
  margin-bottom: 0.75rem;
  border-bottom: 1px solid var(--line);
  font-size: 0.8rem;
  color: var(--ink-soft);
  word-break: break-all;
}

.menu-conversations-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--ink-soft);
}

.menu-sort-toggle {
  display: flex;
  gap: 0.25rem;
}

.menu-sort-button {
  padding: 0.2rem 0.5rem;
  font-size: 0.7rem;
  text-transform: none;
  letter-spacing: normal;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: none;
  color: var(--ink-soft);
  cursor: pointer;
}

.menu-sort-button[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
}

.conversations-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.conversation-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.45rem 0.55rem;
  border: 1px solid transparent;
  border-radius: 0.4rem;
  background: none;
  color: var(--ink);
  cursor: pointer;
  font-size: 0.82rem;
}

.conversation-item:hover {
  border-color: var(--line);
  background: var(--paper);
}

.conversation-item .conversation-title {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-item .conversation-meta {
  display: block;
  font-size: 0.72rem;
  color: var(--ink-soft);
}

header {
  padding: 2.5rem 1.25rem 1rem;
  text-align: center;
}

header h1 {
  font-family: var(--serif);
  font-size: 2rem;
  font-style: italic;
  margin: 0 0 0.35rem;
  letter-spacing: 0.02em;
}

.tagline {
  margin: 0 auto;
  max-width: 34rem;
  color: var(--ink-soft);
  font-size: 0.95rem;
}

main {
  max-width: 46rem;
  margin: 0 auto;
  padding: 0 1.25rem 4rem;
}

.examples {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
  font-size: 0.85rem;
  color: var(--ink-soft);
}

/* An unconditional `display` on an element also toggled via the `hidden`
   attribute needs this override — otherwise the author-stylesheet display
   rule above beats the browser's default `[hidden] { display: none }`,
   and the element never actually hides. */
.examples[hidden] {
  display: none;
}

.example {
  padding: 0.3rem 0.7rem;
  font-size: 0.85rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--ink-soft);
  cursor: pointer;
}

.example:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.source-heading {
  font-family: var(--serif);
  font-size: 1.15rem;
  margin: 1.25rem 0 0.6rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--line);
}

.source-heading:first-child {
  margin-top: 0;
}

.section-note {
  color: var(--ink-soft);
  font-size: 0.9rem;
  font-style: italic;
}

.translation {
  margin-bottom: 1.1rem;
}

.translation h3 {
  margin: 0 0 0.2rem;
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
}

.translation p {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.1rem;
}

.translation.unavailable p {
  font-family: var(--sans);
  font-size: 0.9rem;
  font-style: italic;
  color: var(--ink-soft);
}

.interlinear-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  background: var(--panel);
}

table.interlinear {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.95rem;
}

table.interlinear th,
table.interlinear td {
  padding: 0.5rem 0.7rem;
  text-align: left;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

table.interlinear tr:last-child td {
  border-bottom: none;
}

table.interlinear th {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--ink-soft);
  background: var(--accent-soft);
}

.interlinear-surface {
  font-size: 1.15rem;
}

.interlinear-strongs {
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--ink-soft);
}

.interlinear-variant {
  color: var(--error);
  font-weight: bold;
}

.commentary-entry {
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  background: var(--panel);
  margin-bottom: 0.6rem;
  overflow: hidden;
}

.commentary-entry summary {
  cursor: pointer;
  padding: 0.7rem 0.9rem;
  font-weight: 600;
  list-style: none;
}

.commentary-entry summary::-webkit-details-marker {
  display: none;
}

.commentary-entry summary::before {
  content: "▸ ";
  color: var(--accent);
}

.commentary-entry[open] summary::before {
  content: "▾ ";
}

.commentary-entry .body {
  padding: 0 0.9rem 0.9rem;
  color: var(--ink-soft);
  white-space: pre-wrap;
}

.chat-heading-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

#chat-clear {
  padding: 0.3rem 0.7rem;
  font-size: 0.8rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--ink-soft);
  cursor: pointer;
  white-space: nowrap;
}

#chat-clear:hover {
  border-color: var(--accent);
  color: var(--accent);
}

#chat-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.85rem;
  padding: 2.5rem 1rem;
  color: var(--ink-soft);
}

#chat-empty-state[hidden] {
  display: none;
}

#chat-empty-state p {
  max-width: 26rem;
  margin: 0;
  font-size: 0.95rem;
}

#daily-passage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
}

#daily-passage[hidden] {
  display: none;
}

.daily-passage-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

#daily-passage-button {
  padding: 0.35rem 0.85rem;
  font-size: 0.85rem;
  font-weight: 600;
  border: 1px solid var(--accent);
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  cursor: pointer;
}

#daily-passage-button:hover {
  background: var(--accent);
  color: white;
}

.daily-passage-tag {
  margin: 0;
  max-width: 28rem;
  font-size: 0.85rem;
  font-style: italic;
  color: var(--ink-soft);
}

.daily-passage-tag:empty {
  display: none;
}

/* --- Sign-up nudge, shown under the daily passage --------------------- */

.site-callout {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  max-width: 30rem;
  margin-top: 0.25rem;
  padding: 0.65rem 0.7rem 0.65rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  background: var(--panel);
  font-size: 0.82rem;
  color: var(--ink-soft);
  text-align: left;
}

.site-callout[hidden] {
  display: none;
}

.site-callout p {
  margin: 0;
  flex: 1;
}

#site-callout-dismiss {
  flex-shrink: 0;
  width: 1.5rem;
  height: 1.5rem;
  padding: 0;
  border: none;
  border-radius: 999px;
  background: none;
  color: var(--ink-soft);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}

#site-callout-dismiss:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

#chat-log {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  margin: 1rem 0;
}

.chat-message {
  white-space: pre-wrap;
  line-height: 1.5;
}

.chat-message.user {
  align-self: flex-end;
  max-width: 85%;
  padding: 0.7rem 0.95rem;
  border-radius: 0.7rem;
  background: var(--accent);
  color: white;
  border-bottom-right-radius: 0.15rem;
}

/* Claude's replies are plain flowing text, not a bubble — the point being
   that this reads like a page of prose, not a chat-app message. The
   left/right asymmetry with the user's bubble is what keeps the two
   speakers visually distinct. */
.chat-message.assistant {
  align-self: flex-start;
  max-width: 100%;
  font-family: var(--serif);
  font-size: 1.08rem;
  color: var(--ink);
}

.chat-message.pending {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--ink-soft);
  font-style: italic;
}

.thinking-icon {
  flex-shrink: 0;
}

.thinking-icon .flame {
  transform-box: fill-box;
  transform-origin: center bottom;
  animation: candle-flicker 1.6s ease-in-out infinite;
}

.thinking-icon .glow {
  transform-box: fill-box;
  transform-origin: center;
  animation: candle-glow 1.6s ease-in-out infinite;
}

@keyframes candle-flicker {
  0%, 100% { transform: scaleY(1) scaleX(1) rotate(0deg); opacity: 1; }
  20% { transform: scaleY(1.1) scaleX(0.94) rotate(-3deg); opacity: 0.9; }
  45% { transform: scaleY(0.92) scaleX(1.06) rotate(2deg); opacity: 1; }
  70% { transform: scaleY(1.06) scaleX(0.96) rotate(-2deg); opacity: 0.94; }
}

@keyframes candle-glow {
  0%, 100% { opacity: 0.14; transform: scale(1); }
  50% { opacity: 0.26; transform: scale(1.25); }
}

@media (prefers-reduced-motion: reduce) {
  .thinking-icon .flame,
  .thinking-icon .glow {
    animation: none;
  }
}

.chat-message.error {
  align-self: flex-start;
  max-width: 85%;
  padding: 0.7rem 0.95rem;
  border-radius: 0.7rem;
  background: none;
  border: 1px solid var(--error);
  color: var(--error);
  font-family: var(--sans);
  font-size: 0.9rem;
}

/* The source material Claude gathered while producing a reply — shown
   full-width (not bubble-constrained) since it can include a whole
   interlinear table, unlike the prose messages around it. */
.chat-sources {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.source-passage {
  border: 1px solid var(--line);
  border-radius: 0.6rem;
  background: var(--panel);
  overflow: hidden;
}

.source-passage summary {
  cursor: pointer;
  padding: 0.6rem 0.9rem;
  font-family: var(--serif);
  font-size: 1.1rem;
  font-style: italic;
  list-style: none;
}

.source-passage summary::-webkit-details-marker {
  display: none;
}

.source-passage summary::before {
  content: "▾ ";
  color: var(--accent);
  font-style: normal;
}

.source-passage:not([open]) summary::before {
  content: "▸ ";
}

.source-body {
  padding: 0 0.9rem 0.9rem;
  border-top: 1px solid var(--line);
}

#chat-form {
  display: flex;
  gap: 0.5rem;
  align-items: flex-end;
}

#chat-input {
  flex: 1;
  padding: 0.7rem 0.9rem;
  font-size: 1rem;
  font-family: inherit;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  background: var(--panel);
  color: var(--ink);
  resize: vertical;
}

#chat-input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

#chat-form button {
  padding: 0.7rem 1.2rem;
  font-size: 1rem;
  border: none;
  border-radius: 0.5rem;
  background: var(--accent);
  color: white;
  cursor: pointer;
  align-self: stretch;
}

#chat-form button:hover {
  opacity: 0.9;
}

#chat-form button:disabled {
  opacity: 0.6;
  cursor: default;
}

footer {
  max-width: 46rem;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
  color: var(--ink-soft);
  font-size: 0.8rem;
  text-align: center;
}

footer a {
  color: var(--accent);
}

@media (max-width: 30rem) {
  header h1 {
    font-size: 1.6rem;
  }
  /* .chat-message.user/.error (two classes) are more specific than a bare
     .chat-message rule, so this has to target them by the same selectors
     to actually win the cascade — a bare ".chat-message" rule here would
     be silently overridden and do nothing. */
  .chat-message.user,
  .chat-message.error {
    max-width: 95%;
  }
}
