/* Independent Hlabu: warm paper look, large readable lyrics */
:root {
  --bg: #f6f5f1;
  --surface: #ffffff;
  --ink: #1b1c30;
  --muted: #676879;
  --line: #e2e0da;
  --accent: #222558;      /* navy from the ICI logo */
  --accent-ink: #ffffff;
  --bar: #222558;         /* top bar */
  --bar-ink: #f1efe6;
  --bar-muted: #b9bbd8;
  --chorus: #3d4894;
  --star: #d29a16;
  --hl: #ffe7a6;
  --size: 20px;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Noto Serif", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #11121c; --surface: #1a1b29; --ink: #ecebf3; --muted: #a3a4b8; --line: #2c2e44;
    --accent: #aeb5ff; --accent-ink: #11121c; --bar: #181a35; --bar-ink: #ecebf3; --bar-muted: #9a9dc4;
    --chorus: #c2c8ff; --star: #f1c14e; --hl: #4b4a24;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #11121c; --surface: #1a1b29; --ink: #ecebf3; --muted: #a3a4b8; --line: #2c2e44;
  --accent: #aeb5ff; --accent-ink: #11121c; --bar: #181a35; --bar-ink: #ecebf3; --bar-muted: #9a9dc4;
  --chorus: #c2c8ff; --star: #f1c14e; --hl: #4b4a24;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 var(--sans);
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
svg { width: 24px; height: 24px; fill: currentColor; display: block; }
[hidden] { display: none !important; }

.screen { min-height: 100%; display: flex; flex-direction: column; }

/* ---------- top bars ---------- */
.top {
  position: sticky; top: 0; z-index: 5;
  background: var(--bar); color: var(--bar-ink);
  padding: calc(env(safe-area-inset-top) + 10px) 16px 0;
}
.brand { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.brand-logo { width: 40px; height: 40px; border-radius: 9px; flex: none; box-shadow: 0 0 0 1px rgb(255 255 255 / .15); }
.brand-text { flex: 1; min-width: 0; }
.brand h1 {
  font: 600 clamp(16px, 5vw, 22px)/1.2 var(--serif); margin: 0; letter-spacing: .2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.brand small { color: var(--bar-muted); font-size: 12.5px; font-style: italic; font-family: var(--serif); }
.icon-btn {
  width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; color: inherit; flex: none;
}
.icon-btn:active { background: rgb(255 255 255 / .14); }

.search {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface); border: 0; border-radius: 14px;
  padding: 0 6px 0 12px; height: 50px;
}
.search > svg { color: var(--muted); width: 20px; height: 20px; flex: none; }
.search input {
  flex: 1; min-width: 0; border: 0; outline: 0; background: none; color: var(--ink);
  font: 17px var(--sans); height: 100%;
}
.search input::-webkit-search-cancel-button { filter: grayscale(1); }
.keypad-btn {
  flex: none; height: 38px; padding: 0 12px; border-radius: 10px;
  background: var(--accent); color: var(--accent-ink); font-weight: 600; letter-spacing: .5px; font-size: 15px;
}

.tabs { display: flex; gap: 4px; margin-top: 8px; }
.tabs button {
  flex: 1; padding: 10px 4px 11px; color: var(--bar-muted); font-weight: 500; font-size: 15px;
  border-bottom: 3px solid transparent;
}
.tabs button[aria-selected="true"] { color: var(--bar-ink); border-bottom-color: var(--star); }

/* ---------- list ---------- */
.results { flex: 1; padding: 4px 0 calc(env(safe-area-inset-bottom) + 24px); }
.item {
  display: flex; gap: 14px; align-items: baseline; width: 100%; text-align: left;
  padding: 12px 16px; border-bottom: 1px solid var(--line); text-decoration: none; color: inherit;
}
.item:active { background: var(--line); }
.item .num {
  flex: none; min-width: 2.6em; text-align: right; font: 600 17px var(--serif); color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.item .txt { min-width: 0; flex: 1; }
.item .title { font: 500 16px/1.3 var(--sans); letter-spacing: .3px; }
.item .sub { color: var(--muted); font-size: 14px; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .sub mark, .item .title mark { background: var(--hl); color: inherit; border-radius: 3px; padding: 0 1px; }
.item .fav-dot { flex: none; color: var(--star); width: 16px; height: 16px; align-self: center; }
.empty { padding: 48px 24px; text-align: center; color: var(--muted); }
.empty b { display: block; color: var(--ink); font-size: 17px; margin-bottom: 6px; }
.count { padding: 10px 16px 4px; color: var(--muted); font-size: 13px; }

/* ---------- hymn ---------- */
.hymn-top { display: flex; align-items: center; gap: 2px; padding-bottom: 6px; padding-left: 6px; padding-right: 6px; }
.hymn-top-num { font: 600 18px var(--serif); padding-left: 4px; }
.spacer { flex: 1; }
.aa { font: 600 22px var(--serif); }
.aa.small { font-size: 15px; }
#fav-btn .star { fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linejoin: round; }
#fav-btn[aria-pressed="true"] { color: var(--star); }
#fav-btn[aria-pressed="true"] .star { fill: currentColor; }

.hymn {
  flex: 1; outline: none; width: 100%; max-width: 720px; margin: 0 auto;
  padding: 20px 20px calc(env(safe-area-inset-bottom) + 96px);
  font-family: var(--serif); font-size: var(--size); line-height: 1.55;
}
.hymn h2 {
  font: 600 calc(var(--size) * 1.1)/1.25 var(--serif); margin: 0; letter-spacing: .5px; text-wrap: balance;
}
.hymn .meta {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 16px;
  font: 14px var(--sans); color: var(--muted); margin: 8px 0 22px; padding-bottom: 14px; border-bottom: 1px solid var(--line);
}
.part { margin: 0 0 1.1em; position: relative; }
.verse { padding-left: 1.8em; }
.verse.plain { padding-left: 0; }
.verse .vn {
  position: absolute; left: 0; top: 0; width: 1.4em; text-align: right;
  font-weight: 600; color: var(--accent); font-variant-numeric: tabular-nums;
}
.chorus {
  margin-left: 1.8em; padding-left: .9em; border-left: 3px solid var(--chorus);
  font-style: italic; color: var(--chorus);
}
.line { display: block; padding-left: 1em; text-indent: -1em; } /* wrapped lines hang-indent */

.pager {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 4;
  display: flex; justify-content: space-between; pointer-events: none;
  padding: 0 12px calc(env(safe-area-inset-bottom) + 12px);
}
.pager button {
  pointer-events: auto; display: flex; align-items: center; gap: 4px;
  height: 48px; padding: 0 14px; border-radius: 24px;
  background: var(--surface); border: 1px solid var(--line); color: var(--accent); font-weight: 600;
  box-shadow: 0 2px 10px rgb(0 0 0 / .08);
}
.pager button:disabled { visibility: hidden; }

/* ---------- dialogs ---------- */
dialog {
  border: 0; border-radius: 22px; padding: 18px; width: min(360px, calc(100vw - 32px));
  background: var(--surface); color: var(--ink); box-shadow: 0 20px 60px rgb(0 0 0 / .3);
}
dialog::backdrop { background: rgb(20 12 5 / .45); }
.kp-display {
  height: 76px; border-radius: 14px; background: var(--bg); margin-bottom: 12px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
}
#kp-num { font: 600 34px var(--serif); color: var(--accent); min-height: 40px; font-variant-numeric: tabular-nums; }
#kp-title { color: var(--muted); font-size: 13px; padding: 0 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.kp-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.kp-grid button {
  height: 60px; border-radius: 14px; background: var(--bg); font: 600 24px var(--sans);
}
.kp-grid button:active { background: var(--line); }
.kp-grid .go { background: var(--accent); color: var(--accent-ink); font-size: 18px; }
.kp-grid .go:disabled { opacity: .4; }
.kp-close { display: block; width: 100%; margin-top: 10px; height: 46px; border-radius: 12px; color: var(--muted); font-weight: 500; }

#settings h2 { margin: 2px 0 14px; font: 600 20px var(--serif); }
#settings .row { display: block; margin: 0 0 14px; font-weight: 500; }
#settings input[type=range] { display: block; width: 100%; margin-top: 8px; accent-color: var(--accent); }
#settings fieldset { border: 0; padding: 0; }
#settings legend { padding: 0; margin-bottom: 6px; }
#settings fieldset label { display: flex; align-items: center; gap: 8px; font-weight: 400; padding: 4px 0; }
#settings input[type=radio], #settings input[type=checkbox] { accent-color: var(--accent); width: 20px; height: 20px; }
#settings .check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; }
.preview { font-family: var(--serif); margin: -6px 0 16px; padding: 10px 12px; background: var(--bg); border-radius: 10px; }
.about { color: var(--muted); font-size: 13px; margin: 6px 0 0; }

.toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 80px); transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 20px; font-size: 14px; z-index: 20;
  max-width: calc(100vw - 32px);
}

@media (min-width: 720px) {
  .top { padding-left: max(16px, calc(50% - 360px)); padding-right: max(16px, calc(50% - 360px)); }
  .results { max-width: 720px; margin: 0 auto; width: 100%; }
}

/* ---------- Thuhma / About pages ---------- */
.page {
  width: 100%; max-width: 680px; margin: 0 auto; padding: 22px 20px calc(env(safe-area-inset-bottom) + 40px);
  font-family: var(--serif); font-size: calc(var(--size) * .9); line-height: 1.6;
}
.page h2 { font: 600 calc(var(--size) * 1.1) var(--serif); text-align: center; letter-spacing: 1px; margin: 0 0 16px; }
.page p { margin: 0 0 1em; }
.page .centre { text-align: center; }
.page .signs { display: flex; justify-content: space-between; gap: 16px; margin: 28px 0 20px; text-align: center; }
.page a { color: var(--accent); }
.page .muted { color: var(--muted); font: 13px var(--sans); text-align: center; }
.about-head { text-align: center; margin-bottom: 20px; }
.about-head img { border-radius: 20px; box-shadow: 0 4px 16px rgb(0 0 0 / .18); }
.about-head h2 { margin: 12px 0 2px; }
.about-head p { text-align: center; color: var(--muted); font-style: italic; }
.page:has(.about-head) p { text-align: center; }

/* ---------- menu sheet ---------- */
dialog.sheet { padding: 10px; }
.menu-list { display: flex; flex-direction: column; }
.menu-list a, .menu-list button {
  display: flex; align-items: center; gap: 14px; padding: 14px 12px; border-radius: 12px;
  color: var(--ink); text-decoration: none; font-size: 16px; text-align: left;
}
.menu-list svg { color: var(--accent); }
.menu-list a:active, .menu-list button:active { background: var(--bg); }
