:root {
  --bg: #14110c;
  --bg2: #1d1913;
  --panel: #242019;
  --line: #3a342a;
  --text: #f2ead9;
  --muted: #a89b84;
  --gold: #f0b429;
  --gold-dim: #8a6d3b;
  --green: #4ade80;
  --red: #f87171;
  --verse-size: 20px;
  --radius: 14px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background:
    radial-gradient(1200px 500px at 50% -10%, #2a2418 0%, transparent 60%),
    var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ---------- header ---------- */
.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px 8px;
  gap: 10px;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.logo {
  width: 42px; height: 42px;
  background: linear-gradient(145deg, #2e2818, #1a160f);
  border: 1px solid var(--gold-dim);
  border-radius: 12px;
  display: grid; place-items: center;
  flex: none;
}
.titles h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.3px;
  white-space: nowrap;
}
.pill {
  display: inline-block;
  margin-top: 3px;
  font-size: 11.5px;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 999px;
  background: #2b2620;
  color: var(--muted);
  border: 1px solid var(--line);
}
.pill.live {
  color: #0e1a10;
  background: var(--green);
  border-color: transparent;
  animation: pulse 1.6s ease-in-out infinite;
}
.pill.warn { color: #2b1d00; background: var(--gold); border-color: transparent; }
@keyframes pulse { 50% { opacity: 0.75; } }

.icon-btn {
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 18px;
  width: 42px; height: 42px;
  border-radius: 12px;
  cursor: pointer;
  flex: none;
}
.icon-btn:active { transform: scale(0.96); }

/* ---------- detection banner ---------- */
.banner {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 4px 14px;
  padding: 12px 14px;
  background: linear-gradient(135deg, #2b2415, #221d12);
  border: 1px solid var(--gold-dim);
  border-radius: var(--radius);
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: none;
  max-height: 0;
  overflow: hidden;
  padding-top: 0; padding-bottom: 0;
  margin-top: 0; margin-bottom: 0;
}
.banner.visible {
  opacity: 1;
  transform: none;
  pointer-events: auto;
  max-height: 90px;
  padding-top: 12px; padding-bottom: 12px;
  margin-top: 4px; margin-bottom: 4px;
}
.banner-icon { font-size: 26px; }
.banner-ref { font-size: 21px; font-weight: 800; color: var(--gold); }
.banner-sub { font-size: 12.5px; color: var(--muted); margin-top: 1px; }

.ref-chips {
  display: none;
  gap: 8px;
  padding: 0 14px;
  overflow-x: auto;
}
.ref-chips.visible { display: flex; }
.ref-chip {
  flex: none;
  background: var(--panel);
  border: 1px solid var(--gold-dim);
  color: var(--gold);
  font-weight: 700;
  font-size: 13px;
  padding: 7px 12px;
  border-radius: 999px;
  cursor: pointer;
}

/* ---------- passage ---------- */
.passage-wrap {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  margin: 6px 14px 0;
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  position: relative;
  overflow: hidden;
}
.passage-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px 6px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #26211a, #201c15);
}
.passage-head h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 20px;
  color: var(--gold);
  letter-spacing: 0.5px;
}
.chap-nav { display: flex; gap: 6px; }
.chap-btn {
  width: 36px; height: 36px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  font-size: 20px;
  cursor: pointer;
  line-height: 1;
}
.chap-btn:disabled { opacity: 0.3; }
.chap-btn:not(:disabled):active { background: var(--gold-dim); }

.passage {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 14px 18px 30px;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}
.verse {
  margin: 0 0 12px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: var(--verse-size);
  line-height: 1.65;
  color: #ece4d2;
  padding: 5px 9px;
  border-radius: 9px;
  transition: background 0.4s;
}
.verse .vnum {
  display: inline-block;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  background: #2c271f;
  border-radius: 6px;
  min-width: 20px;
  text-align: center;
  padding: 2px 4px;
  margin-right: 8px;
  vertical-align: 2px;
}
.verse.quoted {
  background: linear-gradient(90deg, rgba(240, 180, 41, 0.18), rgba(240, 180, 41, 0.07));
  border-left: 3px solid var(--gold);
  color: #fff;
  font-weight: 600;
}
.verse.quoted .vnum {
  background: var(--gold);
  color: #241b05;
}
.empty { color: var(--muted); font-style: italic; text-align: center; margin-top: 40px; }

.loading {
  position: absolute;
  inset: 0;
  display: none;
  place-items: center;
  background: rgba(20, 17, 12, 0.85);
  z-index: 5;
  color: var(--gold);
  font-weight: 700;
  letter-spacing: 0.4px;
}
.loading.visible { display: grid; }

/* ---------- hear row ---------- */
.hear-row {
  padding: 6px 16px 0;
  min-height: 40px;
}
.ghost {
  font-size: 13px;
  color: var(--gold);
  opacity: 0.85;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-height: 17px;
}
.transcript {
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0.75;
  min-height: 15px;
}

/* ---------- error ---------- */
.error-card {
  display: none;
  margin: 6px 14px;
  padding: 12px 14px;
  background: #2b1a17;
  border: 1px solid #7f2f28;
  border-radius: var(--radius);
  gap: 10px;
  align-items: flex-start;
  flex-direction: column;
}
.error-card.visible { display: flex; }
.error-card p { margin: 0; font-size: 13.5px; line-height: 1.5; }

/* ---------- controls ---------- */
.controls {
  padding: 8px 14px calc(12px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: linear-gradient(180deg, transparent, rgba(0,0,0,0.25));
}
.mic {
  align-self: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  width: 96px;
  height: 96px;
  justify-content: center;
  border-radius: 50%;
  border: 3px solid var(--line);
  background: radial-gradient(circle at 35% 30%, #353026, #211d16);
  color: var(--muted);
  cursor: pointer;
  transition: all 0.25s;
  box-shadow: 0 6px 24px rgba(0,0,0,0.4);
}
.mic .mic-label { font-size: 12px; font-weight: 700; letter-spacing: 0.6px; }
.mic.on {
  color: #10240f;
  background: radial-gradient(circle at 35% 30%, #7dff9b, var(--green));
  border-color: #b5f7c8;
  animation: glow 1.8s ease-in-out infinite;
}
.mic:active { transform: scale(0.96); }
.mic:disabled { opacity: 0.45; }
@keyframes glow {
  50% { box-shadow: 0 0 0 12px rgba(74, 222, 128, 0.12), 0 6px 24px rgba(0,0,0,0.4); }
}

.manual-row { display: flex; gap: 8px; }
.manual-row input {
  flex: 1;
  min-width: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 15px;
  outline: none;
}
.manual-row input:focus { border-color: var(--gold-dim); }
.manual-row input::placeholder { color: #7d7361; }

.btn {
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 12px;
  padding: 11px 16px;
  font-size: 14.5px;
  font-weight: 700;
  cursor: pointer;
}
.btn.primary {
  background: linear-gradient(180deg, #f7c948, var(--gold));
  border-color: transparent;
  color: #241b05;
}
.btn:active { transform: scale(0.97); }

.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
  min-height: 34px;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  padding: 7px 12px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
}
.chip:active { border-color: var(--gold); color: var(--gold); }

/* ---------- settings sheet ---------- */
.sheet {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
  z-index: 40;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.sheet.open { opacity: 1; pointer-events: auto; }
.sheet-card {
  width: min(560px, 100%);
  max-height: 88vh;
  overflow-y: auto;
  background: var(--bg2);
  border: 1px solid var(--line);
  border-bottom: none;
  border-radius: 20px 20px 0 0;
  padding: 16px 18px calc(22px + var(--safe-bottom));
  transform: translateY(30px);
  transition: transform 0.25s;
}
.sheet.open .sheet-card { transform: none; }
.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.sheet-head h3 { margin: 0; font-size: 17px; }

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 14px 0;
  font-size: 13.5px;
  color: var(--muted);
}
.field select, .field input[type="range"] {
  width: 100%;
}
.field select {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 12px;
  font-size: 15px;
}
.field.check {
  flex-direction: row;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-size: 14px;
}
.field.check input { width: 20px; height: 20px; accent-color: var(--gold); flex: none; }
.note {
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--muted);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 13px;
}

/* ---------- iframe banner ---------- */
.iframe-banner {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 60;
  padding: 10px 12px;
  background: #2b2415;
  border-bottom: 1px solid var(--gold-dim);
}
.iframe-banner.visible { display: block; }
.iframe-card { display: flex; flex-direction: column; gap: 6px; font-size: 13.5px; }
.iframe-card p { margin: 0; color: var(--muted); line-height: 1.45; }
.iframe-card .btn { align-self: flex-start; padding: 9px 14px; }
body:has(.iframe-banner.visible) { padding-top: 118px; }

/* ---------- toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 180px;
  transform: translate(-50%, 16px);
  background: #000;
  color: #fff;
  border: 1px solid var(--line);
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 13.5px;
  opacity: 0;
  transition: all 0.35s;
  z-index: 80;
  max-width: 86vw;
  text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- scrollbars (desktop) ---------- */
.passage::-webkit-scrollbar { width: 8px; }
.passage::-webkit-scrollbar-thumb { background: #3a342a; border-radius: 8px; }

/* short screens */
@media (max-height: 700px) {
  .mic { width: 78px; height: 78px; }
  .verse { margin-bottom: 9px; }
}
