:root {
  color-scheme: light dark;
  --background: #f3f0e8;
  --surface: #fffdf8;
  --ink: #172321;
  --muted: #64716e;
  --forest: #173f37;
  --gold: #d39a4b;
  --line: #d9d7cf;
  --caption-size: 1.55rem;
  --rolling-height: 16rem;
}

* { box-sizing: border-box; }
html { min-height: 100%; }
body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 100% 0, rgb(155 200 182 / 22%), transparent 34rem),
    var(--background);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}

.site-header {
  align-items: center;
  display: grid;
  gap: .8rem;
  grid-template-columns: 3.4rem minmax(0, 1fr) auto;
  padding: max(1rem, env(safe-area-inset-top)) 1rem 1rem;
  border-bottom: 1px solid var(--line);
  background: rgb(243 240 232 / 88%);
  backdrop-filter: blur(16px);
  position: sticky;
  top: 0;
  z-index: 5;
}

.site-header img { height: 3.4rem; object-fit: contain; width: 3.4rem; }
.church-name {
  color: var(--muted);
  font-size: .67rem;
  font-weight: 800;
  letter-spacing: .13em;
  margin: 0 0 .15rem;
  text-transform: uppercase;
}
h1 { font-family: Georgia, serif; font-size: 1.15rem; line-height: 1.15; margin: 0; }
.mode-badge {
  color: #8c3f36;
  font-size: .68rem;
  font-weight: 900;
  letter-spacing: .12em;
  margin: .22rem 0 0;
}
.state-badge {
  border-radius: 99px;
  background: #e5e5df;
  color: var(--muted);
  font-size: .68rem;
  font-weight: 800;
  padding: .45rem .65rem;
}
.state-badge.live { background: #d7eadf; color: #235f43; }
.state-badge.paused { background: #e2edf3; color: #315d73; }
.state-badge.ended { background: #efe6d8; color: #735527; }
.state-badge.lost { background: #f5dfdc; color: #8c3f36; }

main { margin: 0 auto; max-width: 48rem; padding: 1rem 1rem 5rem; }
.caption-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 1rem;
  box-shadow: 0 .8rem 2rem rgb(23 35 33 / 7%);
  display: flex;
  flex-direction: column;
  height: clamp(24rem, 72dvh, 48rem);
  justify-content: flex-start;
  overflow: hidden;
  padding: 1.25rem;
}
.captions {
  display: block;
  flex: 1;
  font-family: Georgia, "Times New Roman", serif;
  font-size: var(--caption-size);
  line-height: 1.45;
  margin-top: 0;
  min-height: 0;
  overflow-y: auto;
  overflow-anchor: none;
  scroll-behavior: auto;
  scrollbar-width: thin;
  width: 100%;
}
.caption {
  display: inline;
  overflow-wrap: anywhere;
}
.caption::after { content: " "; }
.caption.line-break-after::after {
  content: "";
  display: block;
  height: .55rem;
}
.empty-state {
  color: var(--muted);
  font-family: Georgia, serif;
  font-size: 1.2rem;
  line-height: 1.55;
  margin: auto;
  max-width: 25rem;
  text-align: center;
}
.jump-live {
  background: var(--forest);
  border: 0;
  border-radius: 99px;
  bottom: 7.2rem;
  box-shadow: 0 .5rem 1.4rem rgb(23 63 55 / 24%);
  color: white;
  font-weight: 800;
  left: 50%;
  padding: .7rem 1rem;
  position: fixed;
  transform: translateX(-50%);
  z-index: 4;
}
.reader-controls {
  align-items: center;
  display: flex;
  justify-content: space-between;
  padding: .9rem .15rem .4rem;
}
.reader-controls div { align-items: center; display: flex; gap: .45rem; }
.reader-controls span { color: var(--muted); font-size: .75rem; margin-right: .2rem; }
.reader-controls button {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: .6rem;
  color: var(--ink);
  min-height: 2.5rem;
  padding: .55rem .75rem;
}
.notice { color: var(--muted); font-size: .78rem; line-height: 1.55; margin: .7rem .2rem 0; }
footer {
  bottom: 0;
  display: flex;
  font-size: .68rem;
  justify-content: space-between;
  padding: .8rem 1rem max(.8rem, env(safe-area-inset-bottom));
  position: fixed;
  width: 100%;
  background: var(--forest);
  color: #dce9e4;
}

body.dark {
  --background: #0d211d;
  --surface: #15342d;
  --ink: #f6f1e7;
  --muted: #a7b7b1;
  --line: #34544d;
}
body.dark .site-header { background: rgb(13 33 29 / 90%); }
body.dark .state-badge { background: #2c4841; }

@media (prefers-color-scheme: dark) {
  body:not(.light) {
    --background: #0d211d;
    --surface: #15342d;
    --ink: #f6f1e7;
    --muted: #a7b7b1;
    --line: #34544d;
  }
  body:not(.light) .site-header { background: rgb(13 33 29 / 90%); }
}

@media (min-width: 48rem) {
  .site-header { padding-left: calc((100vw - 46rem) / 2); padding-right: calc((100vw - 46rem) / 2); }
  main { padding-top: 1.5rem; }
  .caption-panel { padding: 2rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; }
}
