:root {
  --bg: #14151f;
  --bg-elev: #1c1e2b;
  --bg-elev2: #252839;
  --fg: #ece7d8;
  --fg-dim: #9a93a8;
  --accent: #c9a227;
  --accent-soft: rgba(201,162,39,0.16);
  --line: rgba(255,255,255,0.08);
  --reading: 1.18rem;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bot: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--fg);
  font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", system-ui, sans-serif;
  display: flex; flex-direction: column; height: 100dvh; overflow: hidden;
}

/* top bar */
#topbar {
  display: flex; align-items: center; gap: .5rem;
  padding: calc(.6rem + var(--safe-top)) .8rem .6rem;
  background: var(--bg-elev); border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
}
#title {
  flex: 1; margin: 0; font-size: 1.05rem; font-weight: 600; text-align: center;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.icon-btn {
  background: none; border: none; color: var(--fg); font-size: 1.3rem;
  width: 2.4rem; height: 2.4rem; border-radius: .6rem; cursor: pointer;
  display: grid; place-items: center;
}
.icon-btn:active { background: var(--bg-elev2); }

/* main view */
#view { flex: 1 1 auto; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.pad { padding: 1rem 1.1rem calc(2rem + var(--safe-bot)); max-width: 720px; margin: 0 auto; }

/* tab bar */
#tabbar {
  display: flex; flex: 0 0 auto;
  background: var(--bg-elev); border-top: 1px solid var(--line);
  padding-bottom: var(--safe-bot);
}
.tab {
  flex: 1; background: none; border: none; color: var(--fg-dim);
  font-size: .7rem; padding: .5rem 0 .55rem; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: .15rem;
}
.tab span { font-size: 1.25rem; line-height: 1; }
.tab.active { color: var(--accent); }

/* reader */
.chapter-head { font-size: 1.5rem; font-weight: 700; margin: .2rem 0 1rem; }
.verse { line-height: 1.7; font-size: var(--reading); cursor: pointer; border-radius: .3rem; }
.verse:active { background: var(--bg-elev2); }
.verse .vn {
  font-size: .7em; color: var(--accent); font-weight: 700;
  vertical-align: super; margin-right: .25em; user-select: none;
}
.verse.highlight { background: var(--accent-soft); border-radius: .3rem; }
.chap-nav { display: flex; justify-content: space-between; gap: .8rem; margin-top: 2rem; }
.chap-nav button {
  flex: 1; background: var(--bg-elev2); color: var(--fg); border: 1px solid var(--line);
  border-radius: .7rem; padding: .8rem; font-size: .95rem; cursor: pointer;
}
.chap-nav button:disabled { opacity: .35; }

/* generic cards / rows */
.card {
  background: var(--bg-elev); border: 1px solid var(--line); border-radius: .9rem;
  padding: 1rem 1.1rem; margin-bottom: .9rem;
}
.card h2 { margin: 0 0 .5rem; font-size: 1.15rem; }
.muted { color: var(--fg-dim); font-size: .9rem; }
.pill {
  display: inline-block; background: var(--accent-soft); color: var(--accent);
  border-radius: 1rem; padding: .15rem .65rem; font-size: .78rem; margin: .15rem .3rem .15rem 0;
}
.row-btn {
  display: block; width: 100%; text-align: left; background: var(--bg-elev);
  color: var(--fg); border: 1px solid var(--line); border-radius: .8rem;
  padding: .9rem 1rem; margin-bottom: .55rem; font-size: 1rem; cursor: pointer;
}
.row-btn:active { background: var(--bg-elev2); }
.row-btn .sub { display: block; color: var(--fg-dim); font-size: .8rem; margin-top: .15rem; }

/* date stepper for Today */
.datebar { display: flex; align-items: center; gap: .6rem; margin-bottom: 1rem; }
.datebar button { background: var(--bg-elev2); color: var(--fg); border: 1px solid var(--line);
  border-radius: .6rem; width: 2.4rem; height: 2.4rem; font-size: 1.1rem; cursor: pointer; }
.datebar .d { flex: 1; text-align: center; font-weight: 600; }

/* reading links inside Today */
.reading-link { border-left: 3px solid var(--accent); padding-left: .7rem; }
.reading-row { display: flex; align-items: stretch; gap: .5rem; margin-bottom: .55rem; }
.reading-open {
  flex: 1; text-align: left; background: var(--bg-elev); color: var(--fg);
  border: 1px solid var(--line); border-radius: .8rem; padding: .9rem 1rem;
  font-size: 1rem; cursor: pointer;
}
.reading-open:active { background: var(--bg-elev2); }
.reading-open .sub { display: block; color: var(--fg-dim); font-size: .8rem; margin-top: .15rem; }
.play-mini {
  flex: 0 0 auto; width: 3rem; background: var(--bg-elev2); color: var(--accent);
  border: 1px solid var(--line); border-radius: .8rem; font-size: 1.1rem; cursor: pointer;
}
.play-mini.on { background: var(--accent); color: #14151f; }
.play-mini:disabled { opacity: .35; }

/* Listen bar in the Bible reader */
.listen-btn {
  display: inline-flex; align-items: center; gap: .4rem;
  background: var(--bg-elev2); color: var(--accent); border: 1px solid var(--line);
  border-radius: 2rem; padding: .5rem 1.1rem; font-size: .95rem; cursor: pointer;
  margin-bottom: 1.1rem;
}
.listen-btn.on { background: var(--accent); color: #14151f; }
.verse.playing { background: var(--accent-soft); border-radius: .3rem;
  box-shadow: -.6rem 0 0 var(--accent-soft), .6rem 0 0 var(--accent-soft); }

/* prayers */
.segment { margin: 0 0 .9rem; line-height: 1.65; font-size: var(--reading); }
.segment .spk { display: block; color: var(--accent); font-size: .72rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .04em; margin-bottom: .15rem; }

/* search */
.searchbox { position: sticky; top: 0; background: var(--bg); padding: .2rem 0 .8rem; }
.searchbox input {
  width: 100%; background: var(--bg-elev2); border: 1px solid var(--line); color: var(--fg);
  border-radius: .8rem; padding: .8rem 1rem; font-size: 1rem;
}
.result { padding: .8rem 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.result .ref { color: var(--accent); font-weight: 700; font-size: .85rem; }
.result .snip { line-height: 1.5; margin-top: .2rem; }
.result mark { background: var(--accent); color: #14151f; border-radius: .2rem; padding: 0 .1rem; }

/* drawer */
.drawer { position: fixed; inset: 0; z-index: 30; display: flex; }
.drawer::before { content: ""; position: absolute; inset: 0; background: rgba(0,0,0,.55); }
.drawer-panel {
  position: relative; margin-left: 0; width: min(86vw, 360px); background: var(--bg-elev);
  height: 100%; display: flex; flex-direction: column;
  animation: slidein .18s ease; box-shadow: 2px 0 20px rgba(0,0,0,.5);
}
@keyframes slidein { from { transform: translateX(-100%);} to { transform: none;} }
.drawer-head { display: flex; align-items: center; justify-content: space-between;
  padding: calc(.7rem + var(--safe-top)) 1rem .7rem; border-bottom: 1px solid var(--line); }
.drawer-body { overflow-y: auto; padding: .6rem; flex: 1; }
.book-item, .chap-item { cursor: pointer; }
.book-item { padding: .7rem .8rem; border-radius: .6rem; }
.book-item:active { background: var(--bg-elev2); }
.book-sect { color: var(--fg-dim); font-size: .72rem; text-transform: uppercase;
  letter-spacing: .05em; padding: 1rem .8rem .3rem; }
.chap-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: .5rem; }
.chap-item { background: var(--bg-elev2); border: 1px solid var(--line); border-radius: .6rem;
  text-align: center; padding: .7rem 0; }
.chap-item:active { background: var(--accent-soft); }
.back-link { color: var(--accent); cursor: pointer; font-size: .9rem; margin-bottom: .6rem;
  display: inline-block; }

.center { text-align: center; color: var(--fg-dim); padding: 2.5rem 1rem; }
.spinner { width: 1.6rem; height: 1.6rem; border: 2px solid var(--line);
  border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite;
  margin: 1.5rem auto; }
@keyframes spin { to { transform: rotate(360deg);} }
[hidden] { display: none !important; }
