:root {
  --bg: #0e091d;
  --fg: #e7f6f2;
  --accent: #be3f50;
  --reading: #e7f6f2;
  --muted: #9eb0ad;
  --surface: #171226;
  --surface-2: #241c34;
  --line: #3c334c;
  --on-accent: #fff;
  --reading-size: 21px;
  --font: "Noto Serif", "Liberation Serif", Palatino, serif;
  --ui: "Adwaita Sans", "Noto Sans", "Liberation Sans", sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--ui);
  font-size: 15px;
  line-height: 1.45;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

::selection {
  background: color-mix(in srgb, var(--accent) 55%, white);
  color: #1a1214;
}

button, input, select, textarea { font: inherit; color: inherit; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.site-back {
  /* 6611ministry.com: slim strip (32px) above the app bar; scrolls away, the bar below stays sticky. */
  height: 32px;
  display: flex;
  align-items: center;
  padding: 0 0.8rem;
  font-size: 14px;
  font-weight: 700;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  overflow: hidden;
}

.site-back a {
  color: color-mix(in srgb, var(--fg) 72%, var(--bg));
  text-decoration: none;
}

.site-back a:hover,
.site-back a:focus-visible { color: var(--fg); text-decoration: underline; }

.nav {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  height: 52px;
  padding: 0 0.8rem;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--fg);
  text-decoration: none;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.mark { width: 22px; height: 22px; display: block; }

.tabs { display: flex; gap: 0.15rem; }

.tabs a {
  color: var(--muted);
  text-decoration: none;
  font-weight: 650;
  padding: 0.32rem 0.62rem;
  border-radius: 999px;
}

.tabs a[aria-current="page"] {
  color: var(--on-accent);
  background: var(--accent);
}

#theme-btn {
  margin-left: auto;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.32rem 0.75rem;
  cursor: pointer;
}

main { min-height: calc(100vh - 52px); }

.loading, .empty {
  width: min(40rem, calc(100% - 2rem));
  margin: 3rem auto;
  color: var(--muted);
}

.reader {
  width: min(44rem, calc(100% - 1.5rem));
  margin: 0 auto;
  padding: 1rem 0 2.5rem;
}

body.has-sheet .reader { padding-bottom: 9.5rem; }

.chapter-bar {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 0.55rem;
  align-items: center;
  margin-bottom: 0.8rem;
}

.goto-btn {
  display: flex;
  align-items: baseline;
  gap: 0.35rem;
  max-width: 100%;
  margin: 0;
  padding: 0.05rem 0.25rem 0.05rem 0;
  border: 0;
  border-radius: 8px;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
  text-align: left;
}

.goto-btn:hover, .goto-btn:focus-visible {
  background: color-mix(in srgb, var(--fg) 8%, transparent);
}

.goto-name {
  font-family: var(--font);
  font-size: 1.55rem;
  font-weight: 650;
  letter-spacing: 0.01em;
}

.goto-chevron {
  color: var(--accent);
  font-size: 0.9rem;
  line-height: 1;
}

.goto-form {
  display: grid;
  grid-template-columns: 1.5fr 0.55fr 0.55fr;
  gap: 0.5rem;
  align-items: end;
  margin-top: 0.85rem;
}

.goto-form label {
  display: grid;
  gap: 0.25rem;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.goto-form .primary { grid-column: 1 / -1; }

.dialog.goto { width: min(28rem, 100%); }

.chapter-title p {
  margin: 0.1rem 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.icon-btn, .text-btn, .go, .primary, .ghost {
  border-radius: 10px;
  cursor: pointer;
  border: 1px solid var(--line);
  background: var(--surface-2);
}

.icon-btn {
  width: 2.3rem;
  height: 2.3rem;
  font-size: 1.15rem;
}

.icon-btn:disabled { opacity: 0.35; cursor: default; }

.version select, .field input, .field select, .note, .ref-input, .goto-form select {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.4rem 0.55rem;
}

.hint {
  display: flex;
  justify-content: space-between;
  gap: 0.8rem;
  align-items: center;
  color: var(--muted);
  font-size: 0.85rem;
  margin: 0 0 0.7rem;
}

.hint button {
  background: none;
  border: 0;
  color: var(--accent);
  cursor: pointer;
  padding: 0;
}

.verses {
  list-style: none;
  margin: 0;
  padding: 0;
}

.verse {
  display: grid;
  grid-template-columns: 2.5rem 1fr;
  grid-template-rows: auto auto;
  column-gap: 0.45rem;
  padding: 0.28rem 0.35rem;
  border-radius: 8px;
  scroll-margin: 72px 0 140px;
}

.note-icon {
  grid-column: 1;
  grid-row: 1;
  justify-self: end;
  width: 1.15rem;
  height: 1.15rem;
  margin: 0 0.12rem 0.05rem 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  display: grid;
  place-items: center;
}

.note-icon svg { width: 1rem; height: 1rem; display: block; }

.verse.target {
  background: color-mix(in srgb, var(--accent) 18%, transparent);
}

.verse.marked {
  background: color-mix(in srgb, var(--mark, #e2b657) 30%, transparent);
  box-shadow: inset 3px 0 0 var(--mark, #e2b657);
}

.verse-num {
  grid-column: 1;
  grid-row: 2;
  appearance: none;
  border: 0;
  background: none;
  color: var(--accent);
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  padding: 0.15rem 0 0;
  text-align: right;
  border-radius: 6px;
}

.verse-text {
  grid-column: 2;
  grid-row: 2;
  margin: 0;
  font-family: var(--font);
  font-size: var(--reading-size);
  line-height: 1.65;
  color: var(--reading);
}

.word { border-radius: 3px; cursor: context-menu; }
.word:hover { background: color-mix(in srgb, var(--fg) 12%, transparent); }

.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 15;
  background: var(--surface);
  border-top: 1px solid var(--line);
  box-shadow: 0 -10px 36px rgba(0, 0, 0, 0.28);
  padding: 0.7rem 0.9rem 0.85rem;
}

.sheet-inner {
  width: min(44rem, 100%);
  margin: 0 auto;
  display: grid;
  gap: 0.5rem;
}

.sheet-top, .row, .swatches, .actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}

.sheet-top strong { font-family: var(--font); font-weight: 650; }
.sheet-top span { color: var(--muted); }
.sheet-verses { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.verse-chip { font-variant-numeric: tabular-nums; }

.swatch, .bg-swatch {
  width: 1.35rem;
  height: 1.35rem;
  border-radius: 999px;
  border: 2px solid transparent;
  padding: 0;
  cursor: pointer;
}

.swatch[aria-pressed="true"], .bg-swatch[aria-pressed="true"] {
  border-color: var(--fg);
}

.text-btn, .primary, .ghost, .go {
  padding: 0.42rem 0.7rem;
}

.primary, .go {
  background: var(--accent);
  color: var(--on-accent);
  border-color: transparent;
  font-weight: 700;
}

.ghost { background: transparent; }

.backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(6, 4, 12, 0.58);
  display: grid;
  place-items: center;
  padding: 1rem;
}

.dialog {
  width: min(40rem, 100%);
  max-height: min(86vh, 780px);
  overflow: auto;
  background: var(--surface);
  color: var(--fg);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.4);
  padding: 0.9rem 1rem 1rem;
}

.dialog.wide {
  width: min(40rem, 100%);
  display: flex;
  flex-direction: column;
}

.dialog-head {
  display: flex;
  justify-content: space-between;
  gap: 0.8rem;
  align-items: flex-start;
}

.dialog-head h2, .dialog-head h3 {
  margin: 0;
  font-family: var(--font);
  font-weight: 650;
}

.tab-row {
  display: flex;
  gap: 0.2rem;
  border-bottom: 1px solid var(--line);
  margin: 0.7rem 0 0.8rem;
}

.tab-row button, .tab-row a {
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  padding: 0.4rem 0.55rem;
  cursor: pointer;
  text-decoration: none;
}

.tab-row button[aria-selected="true"], .tab-row a[aria-selected="true"] {
  color: var(--fg);
  border-bottom-color: var(--accent);
}

.note {
  width: 100%;
  min-height: 12rem;
  resize: vertical;
  font-family: var(--font);
  font-size: 1.02rem;
  line-height: 1.55;
  color: var(--reading);
}

.link-form, .home-form, .field { display: grid; gap: 0.35rem; }
.link-form { grid-template-columns: 1.4fr 0.6fr 0.6fr auto; align-items: end; }
.ref-line { display: flex; gap: 0.4rem; margin-top: 0.6rem; }
.ref-input { flex: 1; }

.links { list-style: none; margin: 0.8rem 0 0; padding: 0; display: grid; gap: 0.45rem; }
.link-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.4rem;
  align-items: center;
  padding: 0.45rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
}
.link-jump {
  background: none;
  border: 0;
  padding: 0;
  text-align: left;
  cursor: pointer;
  color: var(--accent);
}
.link-jump small { display: block; color: var(--muted); margin-top: 0.15rem; }

.popover {
  position: fixed;
  z-index: 40;
  width: min(22.5rem, calc(100vw - 1rem));
  max-height: min(26rem, calc(100vh - 1rem));
  overflow: auto;
  background: var(--surface);
  color: var(--fg);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.38);
  padding: 0.85rem 0.95rem 1rem;
}

.popover h3 { margin: 0; font-family: var(--font); font-size: 1.35rem; }
.phonetic { margin: 0.15rem 0 0; color: var(--muted); }
.kicker {
  margin: 0.85rem 0 0.2rem;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}
.def-pos { margin: 0.35rem 0 0; font-weight: 700; text-transform: lowercase; }
.def-line { margin: 0.2rem 0 0; }

.graphic-frame {
  display: flex;
  justify-content: center;
  margin: 0.45rem 0 0.2rem;
  min-height: 0;
}

.graphic-canvas {
  display: block;
  width: auto;
  max-width: 100%;
  max-height: 40vh;
  height: auto;
  border-radius: 12px;
  background: #111;
}

.bg-swatch { width: 1.6rem; height: 1.6rem; }

.search-wrap, .options, .landing, .home-frame { min-height: calc(100vh - 52px); }

.search-wrap {
  display: grid;
  grid-template-rows: auto 1fr auto;
  height: calc(100vh - 52px);
  padding: 0.75rem;
  gap: 0.7rem;
}

.search-wrap.words-search {
  display: block;
  height: auto;
  width: min(42rem, calc(100% - 1.5rem));
  margin: 0.4rem auto 0;
}

.word-form { display: grid; gap: 0.45rem; }
.keyword-input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.55rem 0.65rem;
}

.match-list {
  list-style: none;
  margin: 0.2rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.35rem;
  max-height: min(58vh, 28rem);
  overflow: auto;
}

.match-hit {
  display: grid;
  gap: 0.15rem;
  width: 100%;
  text-align: left;
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.5rem 0.65rem;
  cursor: pointer;
}

.match-hit strong { color: var(--accent); }
.match-text { color: var(--reading); font-family: var(--font); line-height: 1.45; }
.match-hit mark {
  background: color-mix(in srgb, var(--accent) 35%, transparent);
  color: inherit;
  border-radius: 3px;
  padding: 0 0.12rem;
}

.search-layout {
  display: grid;
  grid-template-columns: minmax(180px, 1.15fr) minmax(150px, 0.8fr) minmax(150px, 0.9fr);
  gap: 0.7rem;
  min-height: 0;
}

.col {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: auto;
  padding: 0.55rem;
  min-height: 0;
}

.col h2 {
  margin: 0.2rem 0.3rem 0.45rem;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
}

#book-filter {
  width: 100%;
  margin-bottom: 0.4rem;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.4rem 0.5rem;
}

.book-list { display: grid; gap: 0.12rem; }

.pick {
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: 8px;
  padding: 0.38rem 0.5rem;
  cursor: pointer;
  color: var(--fg);
}

.pick[aria-pressed="true"] {
  background: var(--accent);
  color: var(--on-accent);
}

.num-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(2.4rem, 1fr));
  gap: 0.28rem;
}

.num-grid .lede { grid-column: 1 / -1; }

.num-grid .pick { text-align: center; padding: 0.4rem 0; }

.search-bar {
  display: flex;
  justify-content: space-between;
  gap: 0.8rem;
  align-items: center;
}

.options, .landing {
  width: min(42rem, calc(100% - 1.5rem));
  margin: 0 auto;
  padding: 1.1rem 0 2.5rem;
}

.landing { padding-top: 8vh; }
.landing h1, .options h1 { font-family: var(--font); font-weight: 650; margin: 0.2rem 0 0.4rem; }
.lede { color: var(--muted); margin-top: 0; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.9rem 1rem 1rem;
  margin-top: 0.8rem;
}

.card h2 { margin: 0 0 0.35rem; font-size: 1.05rem; }
.card p { margin: 0.25rem 0 0.7rem; color: var(--muted); }

.segment {
  display: flex;
  width: fit-content;
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
}

.segment button {
  background: transparent;
  border: 0;
  padding: 0.4rem 0.8rem;
  cursor: pointer;
}

.segment button[aria-pressed="true"] {
  background: var(--accent);
  color: var(--on-accent);
}

.controls { display: grid; gap: 0.7rem; }
.control { display: grid; gap: 0.3rem; }
.sample {
  margin: 0.8rem 0 0;
  font-family: var(--font);
  font-size: var(--reading-size);
  color: var(--reading);
  line-height: 1.55;
}

.version-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.4rem 0.7rem;
  align-items: center;
  padding: 0.55rem 0;
  border-top: 1px solid var(--line);
}
.version-row:first-of-type { border-top: 0; }
.version-row small { display: block; color: var(--muted); }

.home-frame { display: flex; flex-direction: column; height: calc(100vh - 52px); }
.home-toolbar {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  padding: 0.4rem 0.7rem;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.home-toolbar .url { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.home-frame iframe { flex: 1; width: 100%; border: 0; background: white; }

#toast {
  position: fixed;
  left: 50%;
  bottom: 1rem;
  transform: translateX(-50%);
  z-index: 60;
  background: var(--fg);
  color: var(--bg);
  border-radius: 999px;
  padding: 0.5rem 0.8rem;
  max-width: min(36rem, calc(100% - 2rem));
}

body.has-sheet #toast { bottom: 8.2rem; }

@media (max-width: 800px) {
  .search-layout { grid-template-columns: 1fr; }
  .search-wrap { height: auto; }
  .link-form { grid-template-columns: 1fr 1fr; }
  .chapter-bar { grid-template-columns: auto 1fr auto; }
  .version { grid-column: 1 / -1; }
  .goto-form { grid-template-columns: 1fr 1fr; }
  .goto-form label:first-child { grid-column: 1 / -1; }
  .nav { gap: 0.3rem; padding: 0 0.45rem; }
  .brand span { display: none; }
}

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

/* 6611ministry.com: full-height views leave room for the 32px back strip as well as the 52px bar. */
main, .search-wrap, .options, .landing, .home-frame { min-height: calc(100vh - 84px); }
.home-frame { height: calc(100vh - 84px); }
@media (min-width: 801px) {
  .search-wrap { height: calc(100vh - 84px); }
}
