:root {
  color-scheme: light;
  --ink: #202a29;
  --muted: #65716e;
  --line: #dce3df;
  --paper: #ffffff;
  --canvas: #f4f6f4;
  --forest: #176b54;
  --forest-deep: #104b3d;
  --lime: #d9f08c;
  --coral: #e4785c;
  --danger: #a23c31;
  font-family: "Aptos", "Segoe UI Variable", "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--canvas);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background-image: radial-gradient(#dfe7e2 0.7px, transparent 0.7px);
  background-size: 16px 16px;
}

button, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.48; }

.topbar {
  height: 64px;
  padding: 0 clamp(20px, 5vw, 72px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #f7fbf8;
  background: var(--forest-deep);
  border-bottom: 3px solid var(--lime);
}

.wordmark, .session-controls, .result-meta { display: flex; align-items: center; }
.wordmark { gap: 10px; color: inherit; text-decoration: none; font-weight: 700; }
.wordmark-mark {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  color: var(--forest-deep);
  background: var(--lime);
  border-radius: 5px;
  font-family: Georgia, serif;
  font-size: 17px;
}
.session-controls { gap: 14px; }
.session-label { color: #c8d8d1; font-size: 13px; }

.workspace {
  width: min(1120px, calc(100% - 40px));
  margin: 42px auto 72px;
  background: var(--paper);
  border: 1px solid var(--line);
  box-shadow: 0 16px 44px rgb(32 52 44 / 8%);
}

.query-section, .results-section { padding: clamp(24px, 4vw, 44px); }
.query-section { border-bottom: 1px solid var(--line); }
.history-section { padding: clamp(24px, 4vw, 44px); border-bottom: 1px solid var(--line); }
.history-section .button-quiet { color: var(--forest-deep); border-color: #bdcbc3; }
.history-message { margin: 0; color: var(--muted); font-size: 13px; }
.history-message[hidden], .history-list[hidden] { display: none; }
.history-list {
  max-height: 264px;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  border-top: 1px solid var(--line);
  list-style: none;
}
.history-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding-right: 6px;
  border-bottom: 1px solid var(--line);
}
.history-item[data-active="true"] { background: #edf5e9; box-shadow: inset 3px 0 0 var(--forest); }
.history-open {
  min-width: 0;
  padding: 10px 12px;
  color: inherit;
  background: transparent;
  border: 0;
  text-align: left;
}
.history-open:hover { background: #eff5ef; }
.history-prompt {
  display: block;
  overflow: hidden;
  font-size: 13px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.history-detail { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; }
.history-section .history-delete { min-height: 32px; padding: 0 10px; font-size: 12px; }
.section-heading, .results-heading, .form-meta, .result-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}
.eyebrow {
  margin: 0 0 9px;
  color: var(--forest);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1.2px;
}
h1, h2, p { margin-top: 0; }
h1 {
  margin-bottom: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(27px, 4vw, 36px);
  font-weight: 500;
  line-height: 1.15;
}
h2 { margin: 0; font-size: 20px; font-weight: 650; }
.access-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 11px;
  color: var(--forest-deep);
  background: #edf5e9;
  border: 1px solid #d8e9ce;
  border-radius: 4px;
  font-size: 12px;
  white-space: nowrap;
}
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #68a65f; }

.query-form { margin-top: 32px; }
.query-form label { display: block; margin-bottom: 9px; font-size: 13px; font-weight: 700; }
.prompt-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; }
textarea {
  width: 100%;
  min-height: 74px;
  padding: 14px 15px;
  resize: vertical;
  color: var(--ink);
  background: #fcfdfc;
  border: 1px solid #bdcbc3;
  border-radius: 4px;
  line-height: 1.45;
}
textarea:focus { outline: 3px solid rgb(23 107 84 / 16%); border-color: var(--forest); }
textarea::placeholder { color: #87928d; }
.button {
  min-height: 40px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  border: 1px solid transparent;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 700;
  transition: background-color 140ms ease, transform 140ms ease;
}
.button:active:not(:disabled) { transform: translateY(1px); }
.button-primary { align-self: stretch; min-width: 132px; color: white; background: var(--forest); }
.button-primary:hover:not(:disabled) { background: #0f5945; }
.button-arrow { font-size: 18px; font-weight: 400; }
.button-quiet { color: inherit; background: transparent; border-color: currentColor; }
.topbar .button-quiet { min-height: 34px; color: #f7fbf8; border-color: #6e9387; }
.results-section .button-quiet { color: var(--forest-deep); border-color: #bdcbc3; }
.form-meta { margin-top: 8px; color: var(--muted); font-size: 11px; }

.results-heading { margin-bottom: 20px; }
.result-meta { color: var(--muted); font-size: 12px; }
.status-line {
  min-height: 38px;
  margin-bottom: 14px;
  padding: 10px 12px;
  color: var(--muted);
  background: #f5f8f6;
  border-left: 3px solid #9aaca3;
  font-size: 12px;
}
.status-line[data-kind="success"] { color: var(--forest-deep); border-color: var(--forest); }
.status-line[data-kind="error"] { color: var(--danger); background: #fff6f4; border-color: var(--coral); }
.status-line[data-kind="loading"] { color: #76521e; background: #fff9e9; border-color: #d5a33b; }
.table-wrap { width: 100%; overflow: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; font-size: 13px; }
thead { color: #f7fbf8; background: #263a35; }
th, td { max-width: 420px; padding: 12px 14px; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
th { font-size: 11px; font-weight: 700; letter-spacing: 0.35px; }
tbody tr:nth-child(even) { background: #f6f8f6; }
tbody tr:hover { background: #eff5ef; }
td.numeric { text-align: right; font-variant-numeric: tabular-nums; }
.empty-state { min-height: 145px; display: grid; place-content: center; justify-items: center; color: var(--muted); }
.empty-state p { margin: 8px 0 0; font-size: 13px; }
.empty-symbol { color: var(--coral); font-family: Georgia, serif; font-size: 27px; }
.footer {
  width: min(1120px, calc(100% - 40px));
  margin: -44px auto 28px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  color: #697571;
  font-size: 11px;
}
.footer .scripture-notice { max-width: 460px; text-align: right; }

.intro-copy { margin: 12px 0 0; max-width: 620px; color: var(--muted); font-size: 14px; line-height: 1.5; }

.verse { margin: 0; }
.verse blockquote {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-style: italic;
  line-height: 1.5;
}
.verse figcaption {
  margin-top: 6px;
  color: var(--forest);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
}
.verse-banner {
  width: min(1120px, calc(100% - 40px));
  margin: 28px auto 0;
  padding: 16px 22px;
  color: var(--forest-deep);
  background: rgb(255 255 255 / 72%);
  border-left: 3px solid var(--lime);
  box-shadow: 0 6px 18px rgb(32 52 44 / 5%);
}
.verse-banner blockquote { font-size: 16px; }
.verse-banner:not([hidden]) + .workspace { margin-top: 18px; }
.verse-login {
  margin-top: 24px;
  padding: 14px 16px;
  color: var(--forest-deep);
  background: #f5f8f6;
  border-left: 3px solid var(--lime);
}
.verse-login blockquote { font-size: 14px; }
.scripture-notice { color: #7b8682; font-size: 10px; line-height: 1.45; }
.login-card .scripture-notice { margin: 10px 0 0; }

.pagination {
  margin-top: 16px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 20px;
  color: var(--muted);
  font-size: 12px;
}
.pagination[hidden] { display: none; }
.page-size { display: inline-flex; align-items: center; gap: 8px; }
.page-size select {
  min-height: 34px;
  padding: 0 8px;
  color: var(--ink);
  background: #fcfdfc;
  border: 1px solid #bdcbc3;
  border-radius: 4px;
  font: inherit;
}
.page-range { font-variant-numeric: tabular-nums; }
.page-buttons { display: inline-flex; align-items: center; gap: 6px; }
.page-buttons .button { min-height: 34px; padding: 0 11px; color: var(--forest-deep); border-color: #bdcbc3; }
.page-number { padding: 0 6px; font-variant-numeric: tabular-nums; white-space: nowrap; }

.login-page {
  display: grid;
  place-items: center;
  padding: 24px 16px;
  border-top: 3px solid var(--lime);
}
.login-card {
  width: min(440px, 100%);
  padding: clamp(28px, 6vw, 44px);
  background: var(--paper);
  border: 1px solid var(--line);
  box-shadow: 0 16px 44px rgb(32 52 44 / 8%);
}
.login-wordmark { margin-bottom: 32px; color: var(--forest-deep); }
.login-card h1 { margin-bottom: 12px; }
.login-copy { margin-bottom: 28px; color: var(--muted); font-size: 14px; line-height: 1.5; }
.login-button { width: 100%; min-height: 46px; justify-content: space-between; padding: 0 18px; }
.login-card .status-line { margin: 16px 0 0; }
.login-footnote {
  margin: 28px 0 0;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 11px;
}

@media (max-width: 640px) {
  .topbar { height: 58px; padding: 0 16px; }
  .session-label { display: none; }
  .workspace { width: calc(100% - 20px); margin: 16px auto 68px; }
  .query-section, .history-section, .results-section { padding: 21px 16px; }
  .section-heading { align-items: flex-start; flex-direction: column; gap: 13px; }
  .prompt-row { grid-template-columns: 1fr; }
  .button-primary { min-height: 44px; }
  .results-heading { align-items: flex-start; }
  .result-meta { align-items: flex-end; flex-direction: column-reverse; gap: 8px; }
  th, td { max-width: 230px; padding: 10px; }
  .footer { width: calc(100% - 32px); flex-direction: column; gap: 8px; }
  .footer .scripture-notice { text-align: left; }
  .verse-banner { width: calc(100% - 20px); margin-top: 14px; padding: 12px 14px; }
  .verse-banner blockquote { font-size: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; }
}