:root {
  --bg: #faf7f0;
  --card: #f1ebdd;
  --surface: #fffdf8;
  --text: #24211c;
  --muted: #6f685c;
  --line: #e2dccd;
  --accent: #a8691b;
  --good: #2f7a43;
  --good-bg: #e3f2e6;
  --bad: #a33b2f;
  --bad-bg: #f7e4e1;
  --button: #2b2925;
  --button-text: #fff;
  --shadow: 0 6px 22px rgba(60, 40, 10, .12);
  --tabs-h: 62px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1a17;
    --card: #2a2722;
    --surface: #23211d;
    --text: #ece6da;
    --muted: #a39a8a;
    --line: #3a362f;
    --accent: #e0a45a;
    --good: #7fd194;
    --good-bg: #1f3325;
    --bad: #f0a197;
    --bad-bg: #3a2220;
    --button: #ece6da;
    --button-text: #1b1a17;
    --shadow: 0 6px 22px rgba(0, 0, 0, .4);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.5 -apple-system, system-ui, sans-serif;
  -webkit-text-size-adjust: 100%;
}

main {
  max-width: 560px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 20px) 16px calc(env(safe-area-inset-bottom) + var(--tabs-h) + 28px);
}

a { color: inherit; }
h1 { font-size: 28px; margin: 0 0 4px; line-height: 1.2; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 28px 0 6px; }
.muted { color: var(--muted); }
.serif { font-family: Georgia, "Times New Roman", serif; }
.lbl { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--accent); font-weight: 600; }

.back { display: inline-block; color: var(--muted); text-decoration: none; margin-bottom: 12px; padding: 6px 0; }

/* ---- Tab bar ---- */
.tabs {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 5;
  display: flex;
  justify-content: center;
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding: 6px 8px calc(env(safe-area-inset-bottom) + 6px);
}
.tab {
  flex: 1;
  max-width: 140px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  font-size: 11px;
  color: var(--muted);
  text-decoration: none;
  padding: 4px 0;
}
.tab .glyph { display: flex; height: 24px; }
.tab.on { color: var(--accent); font-weight: 600; }

/* ---- Today ---- */
.hero {
  display: block;
  color: #fff;
  text-decoration: none;
  border-radius: 22px;
  padding: 18px;
  margin: 16px 0 12px;
  box-shadow: var(--shadow);
}
.hero .lbl { color: #f4dcb0; }
.hero-title { display: block; font-family: Georgia, serif; font-size: 24px; line-height: 1.2; margin: 8px 0 6px; }
.hero-text { display: block; font-size: 15px; opacity: .92; }
.pill { display: inline-block; margin-top: 14px; background: #fff; color: #23415a; border-radius: 20px; padding: 7px 16px; font-weight: 600; font-size: 14px; }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tile {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--card);
  border-radius: 16px;
  padding: 12px 14px;
  font-size: 15px;
  text-decoration: none;
  min-height: 108px;
}
.chip { margin-top: auto; align-self: flex-start; font-size: 12px; padding: 2px 9px; border-radius: 10px; background: var(--line); color: var(--muted); }
.panel { background: var(--card); border-radius: 16px; padding: 14px; margin-top: 10px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 8px; }
.stat { display: flex; flex-direction: column; font-size: 12px; line-height: 1.3; }
.num { font-size: 28px; font-weight: 700; color: var(--accent); line-height: 1.1; }

/* ---- Threads ---- */
.tgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tcard {
  display: flex;
  flex-direction: column;
  color: #fff;
  text-decoration: none;
  border-radius: 18px;
  padding: 14px;
  min-height: 112px;
  box-shadow: var(--shadow);
}
.tgrid .tcard:only-child { grid-column: 1 / -1; }
.tcard-title { font-family: Georgia, serif; font-size: 20px; line-height: 1.2; }
.tcard-sub { font-size: 13px; opacity: .85; margin-top: 2px; }
.segments { display: flex; gap: 3px; margin-top: auto; padding-top: 12px; }
.segments i { flex: 1; max-width: 22px; height: 4px; border-radius: 2px; background: rgba(255, 255, 255, .3); }
.segments i.f { background: #fff; }

/* ---- Road ---- */
.road { position: relative; margin: 10px 0 0; }
.road svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.road path { fill: none; stroke: var(--line); stroke-width: 5; stroke-dasharray: 2 10; stroke-linecap: round; }
.node {
  position: absolute;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
  transform: translate(-50%, -50%);
}
.node.done { background: var(--accent); color: #fff; }
.node.now { width: 48px; height: 48px; background: var(--bg); color: var(--accent); border: 3px solid var(--accent); box-shadow: 0 0 0 7px color-mix(in srgb, var(--accent) 18%, transparent); }
.node.next { background: var(--card); color: var(--muted); }
.nlabel { position: absolute; transform: translateY(-50%); font-size: 14px; line-height: 1.25; max-width: 44%; text-decoration: none; }
.peek {
  position: sticky;
  bottom: calc(env(safe-area-inset-bottom) + var(--tabs-h) + 10px);
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--surface);
  border-radius: 18px;
  padding: 14px;
  margin-top: 8px;
  box-shadow: var(--shadow);
}
.peek-title { font-family: Georgia, serif; font-size: 19px; line-height: 1.25; }
.peek .button, .teaser .button { margin-top: 10px; }
.peek .muted, .teaser .muted { font-size: 14px; line-height: 1.4; }
.road { margin-bottom: 24px; }

/* ---- Stop done / thread done ---- */
.win {
  color: #fff;
  text-align: center;
  border-radius: 24px;
  padding: 26px 18px 18px;
  margin: calc(-1 * env(safe-area-inset-top)) 0 0;
}
.win h1 { font-family: Georgia, serif; font-size: 26px; }
.win p { opacity: .9; }
.win-mark { font-size: 44px; line-height: 1; }
.vcard { text-align: left; }
.vcard .verse { background: rgba(255, 255, 255, .14); border: 1px solid rgba(255, 255, 255, .35); color: #fff; }
.vcard .verse .ref, .vcard .verse sup { color: #f4dcb0; }
.vgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 16px 0; text-align: left; }
.vcard.small { background: rgba(255, 255, 255, .14); border: 1px solid rgba(255, 255, 255, .3); border-radius: 12px; padding: 10px; font-family: Georgia, serif; font-size: 13px; line-height: 1.35; }
.vcard.small .r { display: block; font-family: -apple-system, system-ui, sans-serif; font-size: 10px; text-transform: uppercase; letter-spacing: .05em; color: #f4dcb0; margin-bottom: 4px; }
.conn { display: block; font-size: 14px; opacity: .95; margin: 4px 0 12px; text-decoration: none; }
.teaser {
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--surface);
  color: var(--text);
  border-radius: 16px;
  padding: 14px;
  text-align: left;
  margin-top: 12px;
}
.button.light { background: #fff; color: #23415a; }
.link.light { color: #fff; opacity: .85; }

/* ---- Rows, verses, readings ---- */
.row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  text-decoration: none;
}
.row .sub { display: block; font-size: 14px; color: var(--muted); }

.verse {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 19px;
  line-height: 1.55;
  background: var(--card);
  border-radius: 14px;
  padding: 16px;
  margin: 12px 0 16px;
}
.verse .ref { display: block; font-family: -apple-system, system-ui, sans-serif; font-size: 13px; color: var(--accent); margin-bottom: 6px; }
.verse sup { font-size: 11px; color: var(--muted); margin-right: 2px; }

.readings { border: 1px solid var(--line); border-radius: 14px; padding: 4px 16px; margin: 16px 0; }
.readings h3 { font-size: 14px; margin: 12px 0 2px; color: var(--accent); }
.readings p { margin: 0 0 12px; }

/* ---- Buttons and questions ---- */
.button {
  display: block;
  width: 100%;
  border: 0;
  border-radius: 12px;
  background: var(--button);
  color: var(--button-text);
  font: inherit;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  padding: 14px;
  margin-top: 20px;
  cursor: pointer;
}
.link { display: block; text-align: center; color: var(--muted); padding: 12px; font-size: 15px; background: none; border: 0; font-family: inherit; width: 100%; cursor: pointer; text-decoration: none; }

.choice {
  display: block;
  width: 100%;
  text-align: left;
  font: inherit;
  color: inherit;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  margin: 8px 0;
  cursor: pointer;
}
.choice .ref { display: block; font-size: 13px; color: var(--accent); }
.choice .text { font-family: Georgia, serif; }
.choice.right { border-color: var(--good); background: var(--good-bg); }
.choice.wrong { border-color: var(--bad); background: var(--bad-bg); }
.choice:disabled { cursor: default; color: inherit; }
.explain { margin: 12px 0 0; }
.progress { font-size: 13px; color: var(--muted); }
.pair { display: flex; gap: 10px; }
.pair .button { margin-top: 12px; }

/* ---- Reader ---- */
.chapter { font-family: Georgia, "Times New Roman", serif; font-size: 19px; line-height: 1.6; margin: 12px 0 20px; }
.chapter sup { font-size: 11px; color: var(--muted); margin-right: 2px; }
.chapter .hl { background: var(--card); box-shadow: 0 0 0 3px var(--card); border-radius: 4px; }
.chapter-nav { display: flex; justify-content: space-between; }
.link-inline { background: none; border: 0; font: inherit; cursor: pointer; padding: 6px 0; }

/* ---- Forms ---- */
.input {
  display: block;
  width: 100%;
  font: inherit;
  font-size: 17px;
  color: inherit;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  margin-top: 12px;
}
form .button { margin-top: 10px; }
.code { font-family: ui-monospace, Menlo, monospace; font-size: 13px; word-break: break-all; resize: vertical; }

/* ---- Words and the bottom sheet ---- */
.term {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  text-decoration: underline dotted var(--accent);
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
  cursor: pointer;
}
.word { border-bottom: 1px solid var(--line); padding: 4px 0; }
.word summary { cursor: pointer; padding: 10px 0; font-weight: 600; list-style-position: outside; }
.word p { margin: 0 0 8px; }
.word .term { display: inline-block; margin-bottom: 10px; color: var(--accent); }
.seen { color: var(--accent); font-weight: 400; }
#sheet {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .35);
  display: flex;
  align-items: flex-end;
  z-index: 10;
}
#sheet[hidden] { display: none; }
.sheet-card {
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  max-height: 75vh;
  overflow-y: auto;
  background: var(--bg);
  border-radius: 18px 18px 0 0;
  padding: 18px 16px calc(env(safe-area-inset-bottom) + 12px);
}
.sheet-card h3 { margin: 0 0 6px; color: var(--accent); }

/* ---- Sermons, search and memorize ---- */
.tabs .tab { max-width: 112px; }
.recap { margin: 12px 0 0; font-size: 14px; color: var(--muted); }
.row .sub.serif { font-family: Georgia, "Times New Roman", serif; font-size: 15px; line-height: 1.4; color: var(--text); opacity: .85; }
.button.secondary { background: transparent; color: var(--text); border: 1px solid var(--line); }
.verse-actions { display: flex; gap: 18px; margin: -8px 0 14px 4px; font-size: 14px; }
.verse-actions a, .verse-actions .link-inline { color: var(--accent); text-decoration: none; font-size: 14px; padding: 0; }
.mask { color: var(--accent); letter-spacing: .04em; }
.edit { margin-top: 28px; border-top: 1px solid var(--line); padding-top: 8px; }
.edit summary { cursor: pointer; color: var(--muted); padding: 10px 0; }
textarea.input { resize: vertical; line-height: 1.45; }

/* ---- Account and group boards ---- */
.board-card { display: block; text-decoration: none; }
.brow { display: flex; align-items: center; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 16px; }
.brow:last-child { border-bottom: 0; }
.brow.me { font-weight: 700; color: var(--accent); }
.brank { width: 22px; color: var(--muted); font-variant-numeric: tabular-nums; }
.bname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bscore { font-variant-numeric: tabular-nums; font-weight: 700; }
.field { display: block; margin-top: 12px; font-size: 14px; color: var(--muted); }
.check { display: flex; align-items: center; gap: 10px; margin-top: 14px; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }
.code-input { font-size: 24px; letter-spacing: .3em; text-align: center; }
.join-code { font-size: 22px; letter-spacing: .15em; font-variant-numeric: tabular-nums; }
