:root {
  --bg: #f6f0e4;
  --bg-raise: #fbf7ee;
  --ink: #2a241c;
  --ink-soft: #5a5044;
  --rule: #d9cbb3;
  --rule-strong: #c4b394;
  --accent: #6b4423;
  --accent-deep: #3b2a1b;
  --gold: #b08d4a;
  --empty: #9a8e7c;
  --header-h: auto;
  --font: "Source Han Serif TC", "Noto Serif CJK TC", "Songti TC", "Songti SC",
    "PMingLiU", "PingFang TC", "Hiragino Mincho ProN", "Times New Roman", Georgia, serif;
  --ui: "PingFang TC", "Noto Sans CJK TC", "Noto Sans TC", "Microsoft JhengHei",
    "Helvetica Neue", sans-serif;
  --body: 21px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--ui);
  min-height: 100vh;
  min-height: 100dvh;
}
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); border: 0;
}
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--accent-deep);
  color: #f6f0e4;
  padding: calc(0.55rem + var(--safe-top)) 0.8rem 0.6rem;
  border-bottom: 3px solid var(--gold);
  display: flex; flex-wrap: wrap; gap: 0.6rem 1rem; align-items: center;
  justify-content: space-between;
}
.brand { display: flex; align-items: center; gap: 0.5rem; }
.brand img { border-radius: 6px; }
.brand h1 {
  font-family: var(--font);
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  margin: 0;
}
.controls { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; }
.controls select, .btn-row button, .search-form button, .search-form input {
  font-family: var(--ui);
  font-size: 0.95rem;
}
.controls select {
  background: #4a3727;
  color: #f6f0e4;
  border: 1px solid #7a6348;
  border-radius: 4px;
  padding: 0.28rem 0.4rem;
  max-width: 11rem;
}
.btn-row { display: flex; flex-wrap: wrap; gap: 0.28rem; }
.btn-row button, .search-form button {
  background: #5a4330;
  color: #f6f0e4;
  border: 1px solid #8a7054;
  border-radius: 4px;
  padding: 0.28rem 0.55rem;
  cursor: pointer;
}
.btn-row button:hover, .search-form button:hover,
.controls select:hover { background: #6b5140; }
.btn-row button:disabled { opacity: 0.4; cursor: default; }

#app { max-width: 1200px; margin: 0 auto; padding: 0.8rem 0.8rem calc(2rem + var(--safe-bottom)); }
.panel h2 {
  font-family: var(--font);
  font-weight: 600;
  font-size: 1.3rem;
  margin: 0.4rem 0 0.8rem;
  color: var(--accent-deep);
}
.chapter-head {
  display: flex; justify-content: space-between; align-items: baseline;
  gap: 1rem; margin: 0.2rem 0 0.8rem;
  border-bottom: 1px solid var(--rule);
  padding-bottom: 0.4rem;
}
.chapter-head h2 { margin: 0; }
.chapter-head .en { color: var(--ink-soft); font-size: 0.95rem; }

/* Wide table */
.verse-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font);
  font-size: var(--body);
  line-height: 1.7;
  background: var(--bg-raise);
  border: 1px solid var(--rule-strong);
}
.verse-table th {
  font-family: var(--ui);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-align: left;
  background: #efe6d3;
  color: var(--accent);
  padding: 0.45rem 0.7rem;
  border-bottom: 1px solid var(--rule-strong);
  border-right: 1px solid var(--rule);
  position: sticky; top: 4.6rem; z-index: 5;
}
.verse-table td, .verse-table th:last-child { border-right: none; }
.verse-table td {
  vertical-align: top;
  padding: 0.55rem 0.7rem;
  border-bottom: 1px solid var(--rule);
  border-right: 1px solid var(--rule);
}
.verse-table tr:last-child td { border-bottom: none; }
.col-n { width: 3.2rem; text-align: center !important; color: var(--accent); font-weight: 600; font-variant-numeric: tabular-nums; }
.col-cuv { width: 32%; }
.col-src { width: 36%; }
.col-dby { width: 30%; font-family: "Iowan Old Style", "Palatino Linotype", Palatino, "Times New Roman", serif; }
.verse-table .empty, .card .empty { color: var(--empty); font-style: italic; font-family: var(--ui); font-size: 0.85em; }
.src-line { letter-spacing: 0.02em; }

/* Phone cards */
.cards { display: flex; flex-direction: column; gap: 0.85rem; }
.card {
  background: var(--bg-raise);
  border: 1px solid var(--rule-strong);
  border-radius: 6px;
  padding: 0.7rem 0.85rem 0.9rem;
  font-family: var(--font);
  font-size: var(--body);
  line-height: 1.7;
}
.card .vn {
  font-family: var(--ui);
  font-weight: 700;
  color: var(--accent);
  font-size: 0.95rem;
  margin-bottom: 0.35rem;
}
.block { margin-top: 0.45rem; }
.block .lab {
  font-family: var(--ui);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  color: var(--accent);
  font-weight: 600;
  margin-bottom: 0.15rem;
  border-bottom: 1px solid var(--rule);
  padding-bottom: 0.1rem;
}
.dby-text { font-family: "Iowan Old Style", "Palatino Linotype", Palatino, "Times New Roman", serif; }

.search-form { display: flex; gap: 0.4rem; margin-bottom: 0.4rem; }
.search-form input {
  flex: 1;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--rule-strong);
  border-radius: 4px;
  background: #fff;
  font-size: 1rem;
  color: var(--ink);
}
.hint { color: var(--ink-soft); font-size: 0.9rem; margin: 0 0 1rem; }
.result {
  padding: 0.65rem 0.2rem;
  border-bottom: 1px solid var(--rule);
  cursor: pointer;
}
.result:hover { background: #efe6d3; }
.result .ref { color: var(--accent); font-weight: 600; margin-bottom: 0.2rem; }
.result .snip { font-family: var(--font); font-size: 1.05rem; line-height: 1.55; }
.about {
  font-size: 1.05rem;
  line-height: 1.75;
  max-width: 42rem;
}
.about h3 { margin: 1.2rem 0 0.4rem; font-size: 1.05rem; color: var(--accent-deep); }
.about a { color: var(--accent); }
.about ul { padding-left: 1.2rem; }
.status {
  position: fixed; left: 50%; bottom: calc(1rem + var(--safe-bottom));
  transform: translateX(-50%);
  background: var(--accent-deep); color: #f6f0e4;
  padding: 0.4rem 0.8rem; border-radius: 4px; font-size: 0.9rem;
}
@media (max-width: 860px) {
  .verse-table { display: none; }
  .chapter-head h2 { font-size: 1.15rem; }
  .controls select { max-width: 9.5rem; }
}
@media (min-width: 861px) {
  .cards { display: none; }
}
