:root {
  color-scheme: light;
  font-family: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  background: #f6f2e9;
  color: #26382f;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  --forest: #284b3c;
  --forest-deep: #1d392e;
  --sage: #6b826e;
  --gold: #a17b3d;
  --muted: #657369;
  --paper: #fffdf8;
  --line: #e4dccb;
  --shadow: 0 18px 48px rgb(52 61 43 / 9%);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(ellipse at 12% 0%, rgb(206 220 195 / 43%), transparent 35rem),
    radial-gradient(ellipse at 92% 18%, rgb(239 222 188 / 38%), transparent 30rem),
    #f6f2e9;
}

button, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

.welcome-screen {
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: max(28px, env(safe-area-inset-top)) 18px max(28px, env(safe-area-inset-bottom));
  background:
    radial-gradient(ellipse at 50% 4%, rgb(255 255 255 / 62%), transparent 54%),
    radial-gradient(ellipse at 0% 100%, rgb(222 231 208 / 45%), transparent 38%),
    transparent;
}

.welcome-panel {
  width: min(880px, 100%);
  padding: clamp(24px, 5vw, 48px);
  border: 1px solid rgb(161 123 61 / 28%);
  border-radius: 28px;
  background: linear-gradient(155deg, rgb(255 254 250 / 98%), rgb(250 247 238 / 98%));
  box-shadow: 0 28px 80px rgb(52 61 43 / 13%), inset 0 1px #fff;
}

.welcome-brand {
  margin: 0 0 16px;
  color: var(--sage);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: .24em;
  text-align: center;
}

.welcome-dedication {
  width: fit-content;
  margin: 0 auto 22px;
  border: 1px solid rgb(161 123 61 / 32%);
  border-radius: 999px;
  padding: 8px 15px;
  background: #f6efdf;
  color: #785b2e;
  font-size: 13px;
  font-weight: 650;
  letter-spacing: .025em;
  text-align: center;
}

.welcome-panel h1 {
  max-width: 760px;
  margin: 0 auto 24px;
  color: var(--forest-deep);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(24px, 4vw, 34px);
  font-weight: 600;
  line-height: 1.28;
  text-align: center;
  text-wrap: balance;
}

.welcome-message {
  max-height: min(54vh, 540px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: clamp(18px, 3.5vw, 30px);
  background: rgb(255 255 255 / 72%);
  color: #39483e;
  font-size: clamp(14px, 2vw, 16px);
  line-height: 1.85;
  scrollbar-color: #b7c1af #f2eee5;
  scrollbar-width: thin;
}

.welcome-message p { margin: 0 0 16px; }
.welcome-message p:last-child { margin-bottom: 0; }
.welcome-message strong { color: var(--forest); font-weight: 750; }
.welcome-message .welcome-dedication-message {
  margin: 24px 0 0;
  border-top: 1px solid var(--line);
  padding-top: 18px;
  color: var(--forest);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 15px;
  font-style: italic;
}

.welcome-message .welcome-dedication-message strong {
  display: block;
  margin-bottom: 5px;
  color: var(--gold);
  font-family: "Segoe UI", system-ui, sans-serif;
  font-size: 11px;
  font-style: normal;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.button {
  min-height: 44px;
  border: 1px solid #d5c8ac;
  border-radius: 11px;
  padding: 10px 15px;
  color: var(--forest-deep);
  cursor: pointer;
  transition: background-color .18s ease, border-color .18s ease, transform .18s ease, box-shadow .18s ease;
}

.button:active { transform: translateY(1px); }
.button:focus-visible, input:focus-visible, .psalm-button:focus-visible {
  outline: 3px solid #a17b3d;
  outline-offset: 3px;
}

.button-enter {
  display: block;
  min-width: min(310px, 100%);
  min-height: 52px;
  margin: 25px auto 0;
  border-color: var(--forest);
  background: var(--forest);
  box-shadow: 0 8px 20px rgb(40 75 60 / 16%);
  color: #fffdf8;
  font-size: 14px;
  font-weight: 700;
}

.button-enter:hover:not(:disabled) {
  border-color: var(--forest-deep);
  background: var(--forest-deep);
  box-shadow: 0 10px 24px rgb(40 75 60 / 23%);
}

.button:disabled { cursor: default; opacity: .55; }
.welcome-credit { margin: 20px 0 0; color: #7a8379; font-size: 11px; text-align: center; }
.welcome-error:empty { display: none; }
.welcome-error { margin: 13px 0 0; color: #9c3939; font-size: 13px; text-align: center; }

.app-shell {
  width: min(1380px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 30px clamp(16px, 4vw, 56px) 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.app-header { padding: 2px 3px 4px; }
.brand-kicker {
  margin: 0 0 8px;
  color: var(--sage);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: .2em;
}

h1 {
  margin: 0;
  color: var(--forest);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(29px, 4vw, 38px);
  line-height: 1.15;
  letter-spacing: -.025em;
}

h1 span { color: var(--gold); }
.subtitle { margin: 8px 0 0; color: var(--muted); font-size: 14px; }

.app-notice {
  margin: -7px 0 0;
  border: 1px solid #d5a5a0;
  border-radius: 12px;
  padding: 11px 14px;
  background: #fff3f1;
  color: #773c37;
  font-size: 13px;
  line-height: 1.5;
}

.reflection-card {
  padding: 21px 24px;
  border: 1px solid rgb(161 123 61 / 32%);
  border-radius: 19px;
  background: linear-gradient(145deg, #fffefa, #f8f2e5);
  box-shadow: var(--shadow);
}

.reflection-topline, .reading-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.reflection-topline h2, .section-title {
  margin: 0;
  color: var(--forest);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: .15em;
}

.reflection-text {
  margin: 16px 0 8px;
  color: #26382f;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(18px, 2.4vw, 22px);
  font-weight: 600;
  line-height: 1.55;
}

.reflection-reference { margin: 0; color: var(--gold); font-size: 13px; font-weight: 600; }

.button-message {
  border-color: #d3c4a4;
  background: #f2ead8;
  color: var(--forest);
  font-weight: 650;
  white-space: nowrap;
}

.button-message:hover { border-color: var(--gold); background: #ece0c7; }
.button-secondary { border-color: var(--line); background: #f5f2e9; white-space: nowrap; }
.button-secondary:hover:not(:disabled) { border-color: var(--sage); background: #eaf0e7; }

.daily-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 21px 24px;
  border: 1px solid #cbd6c5;
  border-radius: 19px;
  background: linear-gradient(130deg, #f3f6ee, #fffdf8 76%);
  box-shadow: var(--shadow);
}

.daily-copy { min-width: 0; flex: 1; }
.daily-kicker {
  margin: 0 0 7px;
  color: var(--sage);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: .16em;
}

.daily-card h2 {
  margin: 0;
  color: var(--forest);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(20px, 2.5vw, 25px);
}

.daily-reading-title { margin: 8px 0 4px; color: var(--forest-deep); font-weight: 700; }
.daily-description { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.5; }

#daily-progress {
  display: block;
  width: min(440px, 100%);
  height: 9px;
  margin: 13px 0 5px;
  overflow: hidden;
  border: 0;
  border-radius: 999px;
  background: #e4e9df;
  accent-color: var(--forest);
}

#daily-progress::-webkit-progress-bar { border-radius: 999px; background: #e4e9df; }
#daily-progress::-webkit-progress-value { border-radius: 999px; background: var(--forest); }
#daily-progress::-moz-progress-bar { border-radius: 999px; background: var(--forest); }
.daily-progress-label, .daily-guidance { margin: 0; color: var(--muted); font-size: 12px; }
.daily-guidance { margin-top: 5px; }

.daily-actions {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  width: min(220px, 34%);
}

.button-daily {
  border-color: var(--forest);
  background: var(--forest);
  color: #fffdf8;
  font-weight: 700;
}

.button-daily:hover:not(:disabled) { border-color: var(--forest-deep); background: var(--forest-deep); }
.daily-actions .button { width: 100%; }

.content-layout {
  display: grid;
  grid-template-columns: minmax(245px, 300px) minmax(0, 1fr);
  gap: 20px;
  flex: 1;
  min-height: 390px;
}

.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 19px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.psalm-picker {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
  padding: 18px;
}

.section-title { padding: 2px 1px; }

.psalm-filters {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
}

.filter-button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fbfaf6;
  color: #536257;
  cursor: pointer;
  font-size: 12px;
  font-weight: 650;
}

.filter-button[aria-pressed="true"] {
  border-color: #9eaf9a;
  background: #eaf0e7;
  color: var(--forest-deep);
}

.filter-button:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
#favorite-count { color: var(--gold); }
.favorites-empty { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.5; }

#psalm-search {
  width: 100%;
  min-height: 44px;
  border: 1px solid #dcd6c8;
  border-radius: 11px;
  padding: 10px 12px;
  background: #fbfaf6;
  color: #26382f;
  outline: none;
}

#psalm-search::placeholder { color: #788276; }
#psalm-search:focus { border-color: var(--sage); }

.psalm-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-content: start;
  gap: 7px;
  overflow: auto;
  min-height: 0;
  padding: 1px 3px 1px 1px;
  scrollbar-color: #b7c1af #f2eee5;
  scrollbar-width: thin;
}

.psalm-button {
  min-height: 40px;
  border: 1px solid #e4dfd3;
  border-radius: 9px;
  background: #f8f6f0;
  color: #48594d;
  cursor: pointer;
  transition: background-color .16s ease, border-color .16s ease, color .16s ease;
}

.psalm-button:hover { border-color: #98aa94; background: #edf2e9; }
.psalm-button[aria-pressed="true"] {
  border-color: var(--forest);
  background: var(--forest);
  color: #fffdf8;
  font-weight: 750;
}

.reading-card {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: clamp(18px, 2.8vw, 30px);
}

.reading-header { align-items: flex-start; }
.reading-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.button-favorite { border-color: #d7c7a6; background: #f8f2e5; color: #785b2e; white-space: nowrap; }
.button-favorite:hover:not(:disabled) { border-color: var(--gold); background: #f1e7d0; }
.button-favorite[aria-pressed="true"] { border-color: #b97d72; background: #fbefec; color: #853f3c; }
.reading-header h2 {
  margin: 0;
  color: var(--forest);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 27px;
  line-height: 1.2;
}

.source-note { margin: 7px 0 0; color: var(--muted); font-size: 12px; }
.psalm-text {
  overflow: auto;
  flex: 1;
  min-height: 260px;
  margin-top: 22px;
  padding-right: 7px;
  color: #34443a;
  line-height: 1.85;
  scrollbar-color: #b7c1af #f2eee5;
  scrollbar-width: thin;
}

.verse { margin: 0 0 16px; }
.verse-number { margin-right: 9px; color: var(--gold); font-size: 12px; font-weight: 750; }

footer { padding: 0 2px; text-align: center; }
footer p { margin: 0; color: #747e73; font-size: 11px; }
.footer-dedication {
  max-width: 760px;
  margin: 0 auto 10px;
  color: var(--forest);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 14px;
  line-height: 1.65;
}

.footer-dedication strong { color: var(--gold); }
footer .offline-note { margin-top: 4px; color: #858b7f; font-size: 10px; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  clip-path: inset(50%);
}

@media (min-width: 1000px) and (min-height: 700px) {
  .content-layout { max-height: calc(100vh - 330px); }
}

@media (max-width: 720px) {
  .welcome-screen {
    align-items: start;
    padding: max(14px, env(safe-area-inset-top)) 12px max(18px, env(safe-area-inset-bottom));
  }
  .welcome-panel { border-radius: 21px; }
  .welcome-message { max-height: none; }
  .app-shell { gap: 14px; padding: 20px 13px calc(17px + env(safe-area-inset-bottom)); }
  .content-layout { display: flex; flex-direction: column; min-height: 0; gap: 14px; }
  .reading-card { order: 1; min-height: 390px; }
  .psalm-picker { order: 2; max-height: 285px; }
  .psalm-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .reflection-card { padding: 17px; }
  .daily-card { align-items: stretch; flex-direction: column; gap: 15px; padding: 18px; }
  .daily-actions { width: 100%; }
  .daily-actions .button { width: 100%; }
}

@media (max-width: 420px) {
  .reflection-topline { align-items: flex-start; }
  .reflection-topline h2 { padding-top: 12px; }
  .button-message { min-height: 40px; padding: 8px 10px; font-size: 12px; }
  .reading-header { flex-wrap: wrap; }
  .reading-actions { width: 100%; }
  .reading-actions .button { flex: 1; padding-inline: 9px; font-size: 12px; }
  .psalm-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
