/* ── CSS custom properties ── */
:root {
  --bg:             #f5f3ef;
  --text:           #1a1f2e;
  --topbar-bg:      #2E4057;
  --topbar-opt-bg:  #2E4057;
  --title-color:    #2E4057;
  --subtitle-color: #888;
  --divider-color:  #2E4057;
  --h1-color:       #2E4057;
  --h1-border:      #c5d0dc;
  --h2-color:       #4A6FA5;
  --h3-color:       #6B8CAE;
  --src-color:      #b0b0b0;
  --bq-color:       #444;
  --bq-border:      #c8d4e0;
  --bq-ref:         #1a1f2e;
  --mark-bg:        #fff176;
  --mark-text:      inherit;
  --mark-cur-bg:    #ff8f00;
  --mark-cur-text:  white;
  --ts-color:       #ccc;
  --ts-border:      #e8e8e8;
  --ref-border:     #8aaac8;
  --ref-hover:      #4A6FA5;
  --topbar-title:   #a8c4e0;
}

[data-theme="dark"] {
  --bg:             #1c1f28;
  --text:           #c8c4ba;
  --topbar-bg:      #141720;
  --topbar-opt-bg:  #1c2030;
  --title-color:    #6a90b8;
  --subtitle-color: #606060;
  --divider-color:  #2a3d52;
  --h1-color:       #6a90b8;
  --h1-border:      #2a3545;
  --h2-color:       #4e7aa0;
  --h3-color:       #4e6a84;
  --src-color:      #505050;
  --bq-color:       #8a8278;
  --bq-border:      #2a3545;
  --bq-ref:         #c8c4ba;
  --mark-bg:        #4a4200;
  --mark-text:      #e8de90;
  --mark-cur-bg:    #7a4800;
  --mark-cur-text:  #ffe0a0;
  --ts-color:       #404040;
  --ts-border:      #252830;
  --ref-border:     #3a5a78;
  --ref-hover:      #6a90b8;
  --topbar-title:   #5a7a98;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 16px;
  line-height: 1.8;
  color: var(--text);
  background: var(--bg);
}
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--topbar-bg);
  color: white;
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  height: 52px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.3);
}
.topbar-title {
  font-family: Arial, sans-serif;
  font-weight: bold;
  font-size: 14px;
  color: var(--topbar-title);
  white-space: nowrap;
  margin-right: 4px;
}
.topbar select {
  height: 32px;
  padding: 0 8px;
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 4px;
  background: rgba(255,255,255,0.1);
  color: white;
  font-size: 13px;
  cursor: pointer;
  outline: none;
  font-family: Arial, sans-serif;
}
.topbar select option { background: var(--topbar-opt-bg); color: white; }
.topbar select:focus { border-color: rgba(255,255,255,0.55); }
.topbar select:disabled { opacity: 0.45; cursor: default; }
.topbar-sep {
  width: 1px;
  height: 26px;
  background: rgba(255,255,255,0.18);
  flex-shrink: 0;
  margin: 0 2px;
}
.search-group {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-left: auto;
}
.search-group input[type=text] {
  height: 32px;
  width: 210px;
  padding: 0 10px;
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 4px;
  background: rgba(255,255,255,0.1);
  color: white;
  font-size: 13px;
  font-family: Arial, sans-serif;
  outline: none;
}
.search-group input[type=text]::placeholder { color: rgba(255,255,255,0.45); }
.search-group input[type=text]:focus { border-color: rgba(255,255,255,0.65); background: rgba(255,255,255,0.16); }
.match-count {
  font-size: 12px;
  font-family: Arial, sans-serif;
  color: rgba(255,255,255,0.65);
  white-space: nowrap;
  min-width: 64px;
  text-align: center;
}
.topbar button {
  height: 28px;
  width: 28px;
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 4px;
  background: rgba(255,255,255,0.09);
  color: white;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s;
  flex-shrink: 0;
}
.topbar button:hover:not(:disabled) { background: rgba(255,255,255,0.2); }
.topbar button:disabled { opacity: 0.3; cursor: default; }
.page {
  max-width: 820px;
  margin: 0 auto;
  padding: 52px 36px 96px 36px;
}
.doc-title {
  font-family: Arial, sans-serif;
  font-size: 26pt;
  font-weight: bold;
  color: var(--title-color);
  text-align: center;
  margin-bottom: 0.15em;
}
.doc-subtitle {
  font-size: 12.5pt;
  color: var(--subtitle-color);
  font-style: italic;
  text-align: center;
  font-family: Arial, sans-serif;
  margin-bottom: 1.1em;
}
hr.divider {
  border: none;
  border-top: 3px solid var(--divider-color);
  margin: 0 0 2.2em 0;
}
h1 {
  font-family: Arial, sans-serif;
  font-size: 19pt;
  color: var(--h1-color);
  margin: 2.2em 0 0.5em 0;
  padding-bottom: 0.25em;
  border-bottom: 1px solid var(--h1-border);
  scroll-margin-top: 68px;
}
h2 {
  font-family: Arial, sans-serif;
  font-size: 13.5pt;
  color: var(--h2-color);
  margin: 1.8em 0 0.5em 0;
  scroll-margin-top: 68px;
}
h3 {
  font-family: Arial, sans-serif;
  font-size: 11pt;
  color: var(--h3-color);
  font-weight: bold;
  margin: 1.5em 0 0.4em 0;
  scroll-margin-top: 68px;
}
p { margin: 0 0 0.85em 0; font-size: 11pt; }
.src { color: var(--src-color); font-style: italic; font-size: 9pt; font-family: Arial, sans-serif; }
.bq {
  margin: 0.4em 2.8em 0.9em 2.8em;
  font-style: italic;
  color: var(--bq-color);
  border-left: 3px solid var(--bq-border);
  padding-left: 1.1em;
  font-size: 10.5pt;
}
.bq .ref { font-style: normal; font-weight: bold; color: var(--bq-ref); }
ol { margin: 0 0 0.9em 0; padding-left: 2.2em; font-size: 11pt; }
li { margin: 0.25em 0; }
mark {
  background: var(--mark-bg);
  color: var(--mark-text);
  border-radius: 2px;
  padding: 0 1px;
}
mark.current {
  background: var(--mark-cur-bg);
  color: var(--mark-cur-text);
  border-radius: 2px;
}
.timestamp {
  font-size: 8.5pt;
  color: var(--ts-color);
  text-align: right;
  margin-top: 4em;
  padding-top: 0.6em;
  border-top: 1px solid var(--ts-border);
  font-family: Arial, sans-serif;
}
/* ── Language toggle ── */
.lang-toggle { display: flex; gap: 4px; align-items: center; }
.lang-btn {
  font-family: Arial, sans-serif;
  font-size: 12px;
  font-weight: bold;
  color: rgba(255,255,255,0.55);
  text-decoration: none;
  padding: 3px 7px;
  border-radius: 3px;
  border: 1px solid rgba(255,255,255,0.18);
  transition: color 0.12s, border-color 0.12s, background 0.12s;
}
.lang-btn:hover { color: white; border-color: rgba(255,255,255,0.5); }
.lang-btn.lang-active {
  color: white;
  background: rgba(255,255,255,0.15);
  border-color: rgba(255,255,255,0.4);
}

/* ── Appendix link ── */
.appendix-link {
  font-family: Arial, sans-serif;
  font-size: 12px;
  color: rgba(255,255,255,0.65);
  text-decoration: none;
  white-space: nowrap;
  transition: color 0.12s;
}
.appendix-link:hover { color: white; text-decoration: underline; }

/* ── Chapter prev/next buttons ── */
.chap-nav {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  z-index: 90;
  background: var(--topbar-bg);
  color: rgba(255,255,255,0.7);
  border: none;
  padding: 18px 7px;
  cursor: pointer;
  font-family: Arial, sans-serif;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  transition: background 0.15s, color 0.15s;
  outline: none;
  box-shadow: 2px 0 8px rgba(0,0,0,0.25);
}
.chap-nav:hover { background: var(--h2-color); color: white; }
.chap-prev { left: 0; border-radius: 0 6px 6px 0; }
.chap-next { right: 0; border-radius: 6px 0 0 6px; }
.chap-arrow { font-size: 20px; line-height: 1; }
.chap-label {
  font-size: 10px;
  writing-mode: vertical-rl;
  text-orientation: mixed;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.chap-prev .chap-label { transform: rotate(180deg); }

/* ── Responsive / mobile ── */
@media (max-width: 620px) {
  .topbar {
    height: auto;
    flex-wrap: wrap;
    padding: 8px 12px;
    gap: 6px;
  }
  .topbar-title { display: none; }
  .topbar-sep   { display: none; }

  /* Row 1: chapter select + verse select */
  #chapterSel { order: 1; flex: 0 0 auto; width: 52px; }
  #verseSel   { order: 1; flex: 1 1 0; min-width: 0; }

  /* Row 2: Bible version select, lang toggle, appendix link */
  #refVersionSel  { order: 2; flex: 0 0 auto; width: 96px; }
  .lang-toggle    { order: 2; flex: 0 0 auto; }
  .appendix-link  { order: 2; flex: 0 0 auto; font-size: 12px; }

  /* Row 3: search */
  .search-group {
    order: 3;
    width: 100%;
    margin-left: 0;
  }
  .search-group input[type=text] {
    flex: 1;
    width: auto;
    min-width: 0;
  }

  h1, h2, h3 { scroll-margin-top: 128px; }
  .page { padding-left: 18px; padding-right: 18px; }
  .bq { margin-left: 1.2em; margin-right: 1.2em; }
  .chap-nav {
    top: auto;
    bottom: 16px;
    transform: none;
    flex-direction: row;
    padding: 10px 14px;
    gap: 6px;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  }
  .chap-prev { left: 12px; border-radius: 6px; }
  .chap-next { right: 12px; border-radius: 6px; }
  .chap-label { writing-mode: horizontal-tb; transform: none; font-size: 12px; }
  .chap-arrow { font-size: 16px; }
}

/* ── BibleGateway reference links ── */
a.bibleref, #content a[href*="biblegateway"] {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px dotted var(--ref-border);
  cursor: help;
  transition: color 0.1s, border-color 0.1s;
}
a.bibleref:hover, #content a[href*="biblegateway"]:hover {
  color: var(--ref-hover);
  border-bottom-color: var(--ref-hover);
}
