/* 和合本投影 — projector-first */
:root {
  color-scheme: dark;
  --bg: #0a0a0c;
  --bg-elev: #14141a;
  --fg: #f4f1ea;
  --fg-dim: #a8a29a;
  --accent: #e8c878;
  --accent-dim: #9a7b3c;
  --border: #2a2a32;
  --danger: #f07178;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  --font: "Noto Sans TC", "PingFang TC", "Hiragino Sans CNS", "Microsoft JhengHei",
    "Heiti TC", "Source Han Sans TC", "Noto Sans CJK TC", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --verse-size: 56px;
  --ref-size: calc(var(--verse-size) * 0.42);
  --chrome-h: auto;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --measure: min(38em, 92vw);
}

html[data-theme="light"] {
  color-scheme: light;
  --bg: #f7f4ee;
  --bg-elev: #ffffff;
  --fg: #1a1714;
  --fg-dim: #6b645c;
  --accent: #8a6a1f;
  --accent-dim: #c4a35a;
  --border: #ddd5c8;
  --shadow: 0 12px 40px rgba(40, 30, 10, 0.12);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.skip {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--accent);
  color: #111;
  padding: 0.5rem 1rem;
  z-index: 100;
}
.skip:focus {
  left: 0.5rem;
  top: 0.5rem;
}

/* —— Chrome —— */
.chrome {
  flex: 0 0 auto;
  background: color-mix(in srgb, var(--bg-elev) 92%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  padding: calc(0.55rem + var(--safe-t)) 0.85rem 0.65rem;
  transition: transform 0.28s ease, opacity 0.28s ease;
  z-index: 20;
}

body.chrome-hidden .chrome {
  transform: translateY(-110%);
  opacity: 0;
  pointer-events: none;
  position: absolute;
  width: 100%;
}

body.chrome-hidden .stage {
  padding-top: 1.5rem;
}

.chrome-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem 0.65rem;
  max-width: 1400px;
  margin: 0 auto;
}

.chrome-brand {
  margin-bottom: 0.35rem;
}

.brand {
  font-size: 1.05rem;
  letter-spacing: 0.04em;
  color: var(--accent);
}

.brand-sub {
  color: var(--fg-dim);
  font-size: 0.85rem;
}

.chrome-nav {
  margin-bottom: 0.4rem;
}

.chrome-tools {
  justify-content: space-between;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 7rem;
}

.field-sm {
  min-width: 4.5rem;
}

.field-jump {
  flex: 1 1 14rem;
  min-width: 12rem;
}

.lab {
  font-size: 0.7rem;
  color: var(--fg-dim);
  letter-spacing: 0.06em;
}

select,
input[type="search"] {
  appearance: none;
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 0.45rem;
  padding: 0.45rem 0.6rem;
  font: inherit;
  font-size: 0.95rem;
  min-height: 2.35rem;
}

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

.btn,
.icon-btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--fg);
  border-radius: 0.45rem;
  padding: 0.45rem 0.75rem;
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  min-height: 2.35rem;
  line-height: 1.2;
}

.btn:hover,
.icon-btn:hover {
  border-color: var(--accent-dim);
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn.primary {
  background: var(--accent);
  color: #1a1408;
  border-color: transparent;
  font-weight: 600;
}

.btn.ghost {
  background: transparent;
}

.icon-btn {
  margin-left: auto;
  width: 2.2rem;
  padding: 0;
  border-radius: 999px;
  color: var(--fg-dim);
}

.tool-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

/* —— Stage —— */
.stage {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5rem clamp(1rem, 4vw, 3rem) calc(1.5rem + var(--safe-b));
  overflow: auto;
  text-align: center;
  cursor: default;
  -webkit-tap-highlight-color: transparent;
}

.ref-line {
  font-size: var(--ref-size);
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.06em;
  margin-bottom: 0.85em;
  line-height: 1.25;
  max-width: var(--measure);
}

.verse-text {
  font-size: var(--verse-size);
  font-weight: 500;
  line-height: 1.55;
  max-width: var(--measure);
  letter-spacing: 0.02em;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.meta-line {
  margin-top: 1.25rem;
  font-size: max(0.85rem, calc(var(--verse-size) * 0.22));
  color: var(--fg-dim);
  max-width: var(--measure);
}

.verse-text .vnum {
  color: var(--accent-dim);
  font-size: 0.72em;
  font-weight: 600;
  margin-right: 0.25em;
  vertical-align: 0.1em;
}

.verse-text .range-block + .range-block {
  margin-top: 0.85em;
}

/* —— Toast / Help —— */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(1.25rem + var(--safe-b));
  transform: translateX(-50%);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  color: var(--fg);
  padding: 0.55rem 1rem;
  border-radius: 999px;
  box-shadow: var(--shadow);
  z-index: 40;
  font-size: 0.9rem;
}

.help {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: grid;
  place-items: center;
  z-index: 50;
  padding: 1rem;
}

.help[hidden],
.toast[hidden],
.meta-line[hidden] {
  display: none !important;
}

.help-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 1.25rem 1.4rem;
  max-width: 32rem;
  width: 100%;
  box-shadow: var(--shadow);
  text-align: left;
}

.help-card h2 {
  margin: 0 0 0.75rem;
  font-size: 1.2rem;
  color: var(--accent);
}

.help-card ul {
  margin: 0 0 0.75rem;
  padding-left: 1.1rem;
  line-height: 1.7;
  color: var(--fg);
}

.help-card p {
  color: var(--fg-dim);
  line-height: 1.55;
  font-size: 0.92rem;
}

kbd,
code {
  font-family: var(--mono);
  font-size: 0.85em;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 0.3rem;
  padding: 0.05em 0.35em;
}

/* —— Responsive —— */
@media (max-width: 720px) {
  :root {
    --verse-size: 36px;
  }
  .chrome-tools {
    flex-direction: column;
    align-items: stretch;
  }
  .tool-group {
    width: 100%;
  }
  .tool-group .btn {
    flex: 1 1 auto;
  }
}

@media (min-width: 1280px) {
  :root {
    --verse-size: 64px;
  }
}

/* 4:3 projectors often shorter */
@media (max-aspect-ratio: 5/4) {
  :root {
    --verse-size: 48px;
    --measure: min(34em, 90vw);
  }
}

@media (min-aspect-ratio: 16/9) and (min-height: 700px) {
  :root {
    --verse-size: 68px;
  }
}

/* When presenting / fullscreen, nudge larger */
body.is-fullscreen :root,
:fullscreen :root {
  --verse-size: max(var(--verse-size), 64px);
}

body.presenting .chrome {
  opacity: 0.92;
}

/* —— Fullscreen prev/next (stay visible when chrome hides) —— */
.fs-nav {
  display: none;
}
body.is-fullscreen .fs-nav,
body.chrome-hidden .fs-nav,
:fullscreen .fs-nav {
  display: block;
}
.fs-nav-btn {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  z-index: 30;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  min-width: 4.2rem;
  min-height: 6.4rem;
  padding: 0.7rem 0.55rem;
  border: 1px solid color-mix(in srgb, var(--fg) 22%, transparent);
  border-radius: 0.85rem;
  background: color-mix(in srgb, var(--bg-elev) 78%, transparent);
  backdrop-filter: blur(8px);
  color: var(--fg);
  cursor: pointer;
  opacity: 0.72;
  transition: opacity 0.2s ease, background 0.2s ease;
}
.fs-nav-btn:hover,
.fs-nav-btn:focus-visible {
  opacity: 1;
  background: color-mix(in srgb, var(--bg-elev) 92%, transparent);
  outline: none;
}
.fs-nav-btn:disabled {
  opacity: 0.28;
  cursor: default;
}
.fs-nav-prev { left: max(0.5rem, var(--safe-l, 0px)); }
.fs-nav-next { right: max(0.5rem, var(--safe-r, 0px)); }
.fs-nav-arrow {
  font-size: 2.6rem;
  line-height: 0.9;
  font-weight: 500;
}
.fs-nav-label {
  font-size: 0.85rem;
  letter-spacing: 0.04em;
}
@media (max-width: 720px) {
  .fs-nav-btn {
    min-width: 3.2rem;
    min-height: 4.8rem;
    padding: 0.45rem 0.3rem;
  }
  .fs-nav-arrow { font-size: 2rem; }
  .fs-nav-label { font-size: 0.72rem; }
}
