/* ---------- Themes ---------- */

:root {
  color-scheme: light;

  /* Light (default) */
  --bg: #faf7f2;
  --surface: #ffffff;
  --text: #2b2620;
  --text-muted: #8a8175;
  --border: #e4ddd2;
  --accent: #7a5c3e;
  --accent-soft: #f0e8dc;
  --hl-yellow: #fdf0a8;
  --hl-green: #d3efc9;
  --hl-blue: #cfe6f7;
  --hl-pink: #f9d9e5;
  --shadow: 0 4px 18px rgba(60, 45, 25, 0.12);
  --error: #b3452f;

  --reader-font-size: 19px;
  --serif: Georgia, "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

[data-theme="sepia"] {
  --bg: #f4ecd8;
  --surface: #fbf5e6;
  --text: #4a3f2e;
  --text-muted: #93856b;
  --border: #e0d3b4;
  --accent: #8a6236;
  --accent-soft: #ecdfc2;
  --hl-yellow: #f4e08a;
  --hl-green: #d4e6b5;
  --hl-blue: #c9dee0;
  --hl-pink: #f2d3c8;
  --shadow: 0 4px 18px rgba(90, 70, 35, 0.15);
}

[data-theme="dark"] {
  color-scheme: dark;

  --bg: #1e1b17;
  --surface: #27231e;
  --text: #e8e2d8;
  --text-muted: #9a9184;
  --border: #3a342c;
  --accent: #c9a878;
  --accent-soft: #38302a;
  --hl-yellow: #5c5320;
  --hl-green: #2e4a28;
  --hl-blue: #26404f;
  --hl-pink: #4f2c3a;
  --shadow: 0 4px 18px rgba(0, 0, 0, 0.4);
  --error: #e0705a;
}

@media (prefers-color-scheme: dark) {
  [data-theme="auto"] {
    color-scheme: dark;

    --bg: #1e1b17;
    --surface: #27231e;
    --text: #e8e2d8;
    --text-muted: #9a9184;
    --border: #3a342c;
    --accent: #c9a878;
    --accent-soft: #38302a;
    --hl-yellow: #5c5320;
    --hl-green: #2e4a28;
    --hl-blue: #26404f;
    --hl-pink: #4f2c3a;
    --shadow: 0 4px 18px rgba(0, 0, 0, 0.4);
    --error: #e0705a;
  }
}

/* ---------- Base ---------- */

* { box-sizing: border-box; }

/* A generic "force hidden" utility — !important so it always wins over any
   other class setting display on the same element (a plain single-class
   rule here would otherwise lose to a later-declared, equal-specificity
   class like .back-link's `display: inline-flex`, purely by source order). */
.hidden { display: none !important; }

.icon {
  display: inline-block;
  vertical-align: -3px;
  flex-shrink: 0;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--custom-bg, var(--bg));
  color: var(--text);
  font-family: var(--sans);
}

/* Themed scrollbars (Firefox) */
* {
  scrollbar-color: var(--border) var(--bg);
}

/* Themed scrollbars (WebKit/Chromium) */
::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}
::-webkit-scrollbar-track {
  background: var(--bg);
}
::-webkit-scrollbar-thumb {
  background-color: var(--border);
  border-radius: 8px;
  border: 3px solid var(--bg);
}
::-webkit-scrollbar-thumb:hover {
  background-color: var(--accent);
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
body > main { flex: 1 0 auto; width: 100%; }

[data-font="serif"] .chapter-text,
[data-font="serif"] .chapter-title,
[data-font="serif"] .settings-preview { font-family: var(--serif); }
[data-font="sans"] .chapter-text,
[data-font="sans"] .chapter-title,
[data-font="sans"] .settings-preview { font-family: var(--sans); }

/* ---------- Footer ---------- */

.site-footer {
  flex-shrink: 0;
  border-top: 1px solid var(--border);
  padding: 24px 20px;
}

.site-footer-inner {
  max-width: 900px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 24px;
}

.site-footer-brand {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  color: var(--text-muted);
}

.site-footer-nav { display: flex; flex-wrap: wrap; gap: 16px; }
.site-footer-nav a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13px;
}
.site-footer-nav a:hover { color: var(--accent); }

.site-footer-credit {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
  width: 100%;
  text-align: center;
}
.site-footer-credit a { color: var(--text-muted); }
.site-footer-credit a:hover { color: var(--accent); }

/* ---------- Top bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 18px;
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  font-size: 15px;
  white-space: nowrap;
  color: var(--accent);
}
.logo .icon { vertical-align: -2px; }

.site-nav {
  display: flex;
  gap: 4px;
}

.site-nav-link {
  padding: 6px 10px;
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}
.site-nav-link:hover { background: var(--accent-soft); color: var(--text); }
.site-nav-link.active { background: var(--accent-soft); color: var(--accent); }

.topbar-nav {
  display: flex;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.topbar select {
  min-width: 64px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  max-width: 240px;
}

.book-chapter-btn { font-weight: 600; min-width: 140px; justify-content: space-between; }
.translation-btn { max-width: 220px; justify-content: space-between; }
.translation-btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.topbar-right { display: flex; gap: 6px; }

.nav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
}
.nav-btn .icon { vertical-align: -2px; }

.nav-btn:hover:not(:disabled) { background: var(--accent-soft); }
.nav-btn:disabled { opacity: 0.4; cursor: default; }

body.notes-open .notes-toggle { background: var(--accent-soft); border-color: var(--accent); }
.nav-btn.active { background: var(--accent-soft); border-color: var(--accent); }

/* ---------- Floating reader controls ---------- */

.side-nav-btn {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0.55;
  z-index: 15;
  transition: opacity 0.15s, background 0.15s, color 0.15s;
}
.side-nav-btn:hover:not(:disabled) { opacity: 1; background: var(--accent-soft); color: var(--text); }
.side-nav-btn:disabled { opacity: 0.15; cursor: default; }
.side-nav-btn-left { left: 20px; }
.side-nav-btn-right { right: 20px; }

@media (max-width: 1499px) {
  .side-nav-btn { display: none; }
}

.back-to-top {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow);
  z-index: 15;
}
.back-to-top:hover { background: var(--accent-soft); }

/* ---------- Settings panel ---------- */

.settings-panel {
  position: fixed;
  top: 58px;
  right: 16px;
  z-index: 40;
  width: 280px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 16px;
}

.settings-panel h3 { margin: 0 0 12px; font-size: 15px; }

.setting-row { margin-bottom: 14px; }
.setting-row:last-child { margin-bottom: 0; }

.setting-row label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.setting-row input[type="range"] { width: 100%; accent-color: var(--accent); }

.btn-group { display: flex; gap: 6px; flex-wrap: wrap; }

.opt-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
}
.opt-btn:hover { background: var(--accent-soft); }
.opt-btn.active { background: var(--accent-soft); border-color: var(--accent); font-weight: 600; }

.bg-row { display: flex; gap: 8px; align-items: center; }
.bg-row input[type="color"] {
  width: 44px;
  height: 32px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  cursor: pointer;
}

/* ---------- Read-aloud panel ---------- */

.voice-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.voice-play-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}
.voice-play-btn:hover { opacity: 0.9; }
.voice-play-btn .icon { margin-left: 2px; } /* optically center the play triangle */

.voice-autoadvance-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 14px;
  cursor: pointer;
}

#voice-select {
  width: 100%;
  padding: 7px 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 12px;
}

/* ---------- Layout ---------- */

.layout {
  display: flex;
  gap: 24px;
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px 20px 60px;
  align-items: flex-start;
}

.reader { flex: 1; min-width: 0; }

/* ---------- Reader ---------- */

.chapter-title {
  font-size: calc(var(--reader-font-size) * 1.7);
  margin: 8px 0 20px;
}

.chapter-text {
  position: relative; /* anchors the absolutely-positioned .selection-box overlays */
  font-size: var(--reader-font-size);
  line-height: 1.75;
}

.verse {
  margin: 0 0 6px;
  padding: 3px 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s;
}

.verse:hover { background: var(--accent-soft); }

.verse-num {
  color: var(--accent);
  font-weight: 700;
  font-size: 0.65em;
  margin-right: 2px;
}

/* The highlight color sits on the text itself, not the surrounding block,
   so it reads like a highlighter over the words rather than a solid box. */
.verse-text {
  border-radius: 3px;
  padding: 0.15em 0.25em;
  margin: 0 -0.25em;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

.verse-text.hl-yellow { background: var(--hl-yellow); }
.verse-text.hl-green  { background: var(--hl-green); }
.verse-text.hl-blue   { background: var(--hl-blue); }
.verse-text.hl-pink   { background: var(--hl-pink); }

.verse .note-mark {
  display: none;
  font-size: 13px;
  margin-left: 6px;
  opacity: 0.7;
}
.verse.has-note .note-mark { display: inline; }

.verse.flash { outline: 2px solid var(--accent); }

.verse.speaking {
  background: var(--accent-soft);
  border-radius: 6px;
  box-shadow: inset 3px 0 0 0 var(--accent);
}

/* Word-level read-aloud progress, layered on top of the whole-verse
   highlight above. Support for this depends on the browser/voice firing
   boundary events, so it's a bonus on top of the (always-on) verse highlight. */
.word.speaking-word {
  background: var(--accent);
  color: var(--surface);
  border-radius: 3px;
}

/* One box per consecutive run of selected verses (see updateSelectionUI in
   js/app.js), so a multi-verse selection reads as a single growing frame
   instead of separate outlines per paragraph. */
.selection-box {
  position: absolute;
  left: 0;
  right: 0;
  box-sizing: border-box;
  border: 2px solid var(--accent);
  border-radius: 8px;
  pointer-events: none;
  transition: top 0.18s ease, height 0.18s ease;
}

.status-msg { color: var(--text-muted); }
.status-msg.error { color: var(--error); }

.retry-btn {
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-size: 14px;
}

.chapter-footer {
  display: flex;
  justify-content: space-between;
  margin-top: 32px;
}

.chapter-footer-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
}
.chapter-footer-btn:hover:not(:disabled) { background: var(--accent-soft); }
.chapter-footer-btn:disabled { opacity: 0.4; cursor: default; }

.attribution {
  margin-top: 28px;
  font-size: 12px;
  color: var(--text-muted);
}
.attribution a { color: var(--accent); }

/* ---------- Notes panel ---------- */

.notes-panel {
  width: 320px;
  flex-shrink: 0;
  position: sticky;
  top: 76px;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  display: none;
}

body.notes-open .notes-panel { display: block; }

.notes-header h2 { margin: 0 0 12px; font-size: 16px; }
.notes-header span { color: var(--text-muted); font-weight: 400; font-size: 13px; }

.notes-empty { color: var(--text-muted); font-size: 13px; line-height: 1.5; }
.notes-empty a { color: var(--accent); }

.note-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  margin-bottom: 10px;
  background: var(--bg);
}

.note-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.note-ref {
  border: none;
  background: none;
  color: var(--accent);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  padding: 0;
}
.note-ref:hover { text-decoration: underline; }

.note-actions { display: flex; align-items: center; gap: 2px; }

.note-add-to-doc {
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 4px;
}
.note-add-to-doc:hover { color: var(--accent); }

.note-delete {
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 4px;
}
.note-delete:hover { color: var(--error); }

.note-body {
  width: 100%;
  border: none;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  line-height: 1.5;
  resize: none;
  outline: none;
  min-height: 40px;
}

/* ---------- Verse popover ---------- */

.verse-popover {
  position: absolute;
  z-index: 30;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.verse-popover.hidden { visibility: hidden; pointer-events: none; }

.popover-ref {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.popover-swatches { display: flex; gap: 8px; }

.swatch {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1px solid var(--border);
  cursor: pointer;
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.swatch:hover { transform: scale(1.12); }

.swatch-yellow { background: var(--hl-yellow); }
.swatch-green  { background: var(--hl-green); }
.swatch-blue   { background: var(--hl-blue); }
.swatch-pink   { background: var(--hl-pink); }
.swatch-none   { background: var(--surface); }

.popover-action {
  display: flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  padding: 6px 10px;
  font-size: 13px;
  cursor: pointer;
  text-align: left;
}
.popover-action:hover { background: var(--accent-soft); }

/* ---------- Modals ---------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(20, 14, 8, 0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: backdrop-in 0.18s ease;
}

@keyframes backdrop-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(10px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow), 0 24px 60px rgba(20, 14, 8, 0.25);
  padding: 28px;
  width: 100%;
  max-width: 380px;
  max-height: 85vh;
  overflow-y: auto;
  animation: modal-in 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-wide { max-width: 560px; }

.modal h3 { margin: 0 0 8px; font-size: 18px; }

.modal-sub {
  margin: 0 0 16px;
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
}
.modal-close:hover { color: var(--text); }

.modal h3 {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Auth modal: centered header with a circular brand badge (book icon drawn
   with a CSS mask so it follows the theme's accent color). */
#auth-forms::before {
  content: "";
  display: block;
  width: 52px;
  height: 52px;
  margin: 2px auto 14px;
  border-radius: 50%;
  background: var(--accent-soft);
}
#auth-forms {
  position: relative;
}
#auth-forms::after {
  content: "";
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  width: 24px;
  height: 24px;
  background: var(--accent);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2 3h6a4 4 0 0 1 4 4v14a3 3 0 0 0-3-3H2V3z'/%3E%3Cpath d='M22 3h-6a4 4 0 0 0-4 4v14a3 3 0 0 1 3-3h7V3z'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2 3h6a4 4 0 0 1 4 4v14a3 3 0 0 0-3-3H2V3z'/%3E%3Cpath d='M22 3h-6a4 4 0 0 0-4 4v14a3 3 0 0 1 3-3h7V3z'/%3E%3C/svg%3E") center / contain no-repeat;
  pointer-events: none;
}
#auth-forms h3 {
  justify-content: center;
  font-size: 20px;
}
#auth-forms .modal-sub {
  text-align: center;
  max-width: 260px;
  margin-left: auto;
  margin-right: auto;
}

.modal form { display: flex; flex-direction: column; gap: 10px; }

.modal input[type="email"],
.modal input[type="password"],
.modal .password-field input[type="text"],
#auth-form input[type="text"] {
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.modal input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.password-field { position: relative; }
.password-field:has(input.hidden) { display: none; }
.password-field input[type="password"],
.password-field input[type="text"] {
  width: 100%;
  padding-right: 40px;
  box-sizing: border-box;
}
.password-toggle-btn {
  position: absolute;
  top: 50%;
  right: 4px;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  border: none;
  border-radius: 6px;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
}

/* Change-password modal fields share one visibility toggle outside the
   fields, so they don't need the inline icon's reserved padding. */
#password-modal .password-field input[type="password"],
#password-modal .password-field input[type="text"] {
  padding-right: 12px;
}
.password-toggle-btn:hover { color: var(--text); background: var(--accent-soft); }

.recaptcha-widget { margin: 2px 0; }

.primary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: var(--surface);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.primary-btn:hover { opacity: 0.9; }
.primary-btn:disabled { opacity: 0.5; cursor: default; }

.modal .primary-btn {
  padding: 12px 16px;
  border-radius: 10px;
  transition: transform 0.12s ease, box-shadow 0.12s ease, opacity 0.12s ease;
}
.modal .primary-btn:hover:not(:disabled) {
  opacity: 1;
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(20, 14, 8, 0.25);
}
.modal .primary-btn:active:not(:disabled) { transform: translateY(0); box-shadow: none; }

.form-error { color: var(--error); font-size: 13px; margin: 0; }

.modal .form-error,
.modal .form-success {
  padding: 9px 12px;
  border-radius: 8px;
  line-height: 1.45;
}
.modal .form-error {
  background: color-mix(in srgb, var(--error) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--error) 30%, transparent);
}
.modal .form-success {
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
}

.auth-terms-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.4;
  cursor: pointer;
}
.auth-terms-row input { margin-top: 2px; }
.auth-terms-row a { color: var(--accent); }

.auth-switch {
  margin: 18px 0 0;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
}

.link-btn {
  border: none;
  background: none;
  color: var(--accent);
  font-size: 13px;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
}

.summary-body {
  font-size: 14px;
  line-height: 1.7;
  white-space: pre-wrap;
  margin-bottom: 16px;
}
.summary-body.loading { color: var(--text-muted); font-style: italic; }

.summary-body::selection,
.summary-body *::selection { background: var(--hl-yellow); }

.summary-hint { font-size: 12px; margin: 0 0 12px; }

.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }

.bignote-doc-list {
  max-height: 240px;
  overflow-y: auto;
  margin-bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.bignote-doc-row {
  display: block;
  width: 100%;
  text-align: left;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  padding: 8px 10px;
  font-size: 13px;
  cursor: pointer;
}
.bignote-doc-row:hover { background: var(--accent-soft); border-color: var(--accent); }
.bignote-doc-row .doc-row-meta { display: block; color: var(--text-muted); font-size: 11px; margin-top: 2px; }

.bignote-empty { font-size: 13px; color: var(--text-muted); margin: 0 0 14px; }

.bignote-new-form { display: flex; gap: 8px; }
.bignote-new-form input {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
}

.translation-search-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  margin-bottom: 14px;
}

.translation-search-results {
  max-height: 360px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.translation-result {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  width: 100%;
  text-align: left;
  border: 1px solid transparent;
  border-radius: 8px;
  background: none;
  color: var(--text);
  padding: 8px 10px;
  font-size: 13px;
  cursor: pointer;
}
.translation-result:hover { background: var(--accent-soft); border-color: var(--accent); }
.translation-result-name { flex: 1; }
.translation-result-lang { color: var(--text-muted); font-size: 12px; white-space: nowrap; }
.translation-result-active { border-color: var(--accent); color: var(--accent); }
.translation-result-active .icon { flex-shrink: 0; }

.translation-curated-list {
  max-height: 360px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 4px;
}

.translation-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.translation-pagination-label { font-size: 12px; color: var(--text-muted); }

/* ---------- Book / chapter picker ---------- */

.book-grid {
  max-height: 420px;
  overflow-y: auto;
}

.book-grid-heading {
  margin: 16px 0 8px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.book-grid-heading:first-child { margin-top: 0; }

.book-grid-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 6px;
}

.book-grid-btn {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}
.book-grid-btn:hover { background: var(--accent-soft); border-color: var(--accent); }
.book-grid-btn.active { background: var(--accent-soft); border-color: var(--accent); font-weight: 600; }

.chapterpicker-book-name {
  margin: 4px 0 14px;
  font-family: var(--serif);
}

.chapter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(44px, 1fr));
  gap: 8px;
  max-height: 420px;
  overflow-y: auto;
}

.chapter-grid-btn {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
}
.chapter-grid-btn:hover { background: var(--accent-soft); border-color: var(--accent); }
.chapter-grid-btn.active { background: var(--accent); border-color: var(--accent); color: var(--surface); font-weight: 600; }

/* ---------- Sermon Study page ---------- */

.nav-link {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.sermon-layout {
  max-width: 760px;
  margin: 0 auto;
  padding: 24px 20px 80px;
}

.sermon-intro h1 {
  font-size: 28px;
  margin: 8px 0 8px;
}

.sermon-sub {
  color: var(--text-muted);
  font-size: 15px;
  line-height: 1.6;
  margin: 0 0 24px;
}

.sermon-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 24px;
}

.sermon-card h2 {
  margin: 0 0 16px;
  font-size: 15px;
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: 0.02em;
}

.youtube-video-wrap { margin: 16px 0; }

.youtube-video-embed {
  position: relative;
  width: 100%;
  padding-top: 56.25%; /* 16:9 */
  border-radius: 12px;
  overflow: hidden;
  background: var(--bg);
}

.youtube-video-embed iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.or-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px 0;
  color: var(--text-muted);
  font-size: 12px;
}
.or-divider::before,
.or-divider::after {
  content: "";
  flex: 1;
  border-top: 1px solid var(--border);
}

.transcript-input {
  width: 100%;
  min-height: 140px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1.6;
  resize: vertical;
}

.sermon-actions { margin-top: 14px; display: flex; gap: 10px; }

.sermon-title { margin: 0 0 6px; font-size: 20px; }
.sermon-summary {
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.6;
  margin: 0 0 20px;
}

.verse-result {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 14px;
  background: var(--bg);
}

.verse-result-head { margin-bottom: 8px; }

.verse-result-ref {
  color: var(--accent);
  font-weight: 700;
  font-size: 15px;
  text-decoration: none;
}
.verse-result-ref:hover { text-decoration: underline; }

.verse-result-text {
  margin: 0 0 10px;
  padding: 8px 12px;
  border-left: 3px solid var(--accent);
  font-family: var(--serif);
  font-size: 15px;
  line-height: 1.65;
}
.verse-result-text.loading { color: var(--text-muted); font-style: italic; }

.verse-result-point {
  margin: 0 0 8px;
  font-size: 14px;
  line-height: 1.6;
}

.verse-result-quote {
  margin: 0 0 10px;
  font-size: 13px;
  color: var(--text-muted);
  font-style: italic;
  line-height: 1.6;
}

.verse-result-actions { display: flex; gap: 8px; }
.verse-result-actions .opt-btn { text-decoration: none; }
.verse-result-actions .opt-btn:disabled { opacity: 0.6; cursor: default; }

/* ---------- Home page ---------- */

.home-layout {
  max-width: 980px;
  margin: 0 auto;
  padding: 60px 20px 80px;
}

.activity-layout {
  max-width: 980px;
  margin: 0 auto;
  padding: 24px 20px 80px;
}
.activity-layout h1 { font-size: 28px; margin: 8px 0 24px; }

.home-hero { text-align: center; margin-bottom: 48px; }

.home-hero h1 {
  font-family: var(--serif);
  font-size: 40px;
  margin: 0 0 16px;
}

.home-sub {
  color: var(--text-muted);
  font-size: 16px;
  line-height: 1.7;
  max-width: 640px;
  margin: 0 auto;
}

.nav-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
}

.nav-card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  text-decoration: none;
  color: var(--text);
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
}
.nav-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  border-color: var(--accent);
}

.nav-card-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
}
.nav-card-icon .icon { vertical-align: 0; }

.nav-card h2 { margin: 12px 0 8px; font-size: 18px; }

.nav-card p {
  margin: 0 0 16px;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.6;
  flex: 1;
}

.nav-card-cta {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: auto;
  color: var(--accent);
  font-weight: 600;
  font-size: 14px;
}

/* ---------- Home page: today's goals ---------- */

.today-goals-section { margin: 0 auto 40px; max-width: 480px; }

.today-goals-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.today-goals-header h2 { margin: 0; font-size: 20px; }
.today-goals-header .opt-btn { text-decoration: none; }

/* ---------- Home page: verse search ---------- */

.home-search { margin: 0 0 40px; }

.verse-search-wrap {
  position: relative;
  max-width: 560px;
  margin: 0 auto;
}

.verse-search-form {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 6px 6px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: var(--shadow);
  position: relative;
  z-index: 2;
}

.verse-search-icon { color: var(--text-muted); flex-shrink: 0; }

.verse-search-form input {
  flex: 1;
  border: none;
  background: none;
  color: var(--text);
  font-size: 15px;
  padding: 8px 0;
}
.verse-search-form input:focus { outline: none; }

.verse-search-form .primary-btn { border-radius: 999px; padding: 10px 20px; }

.home-search .form-error { text-align: center; margin: 10px 0 0; }

.verse-search-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  z-index: 25;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 14px 16px;
  max-height: 380px;
  overflow-y: auto;
  text-align: left;
}

.search-quickjump {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 10px 12px;
  margin-bottom: 12px;
  border: 1px solid var(--accent);
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.search-quickjump:hover { background: var(--accent); color: var(--surface); }

.verse-search-dropdown .book-grid,
.verse-search-dropdown .chapter-grid { max-height: none; }

/* ---------- Home page: reading-activity calendar ---------- */

.activity-section { margin-top: 8px; }

.activity-header { margin-bottom: 16px; }
.activity-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 4px;
}
.activity-header h2 { margin: 0; font-size: 20px; }
.activity-summary { margin: 0; color: var(--text-muted); font-size: 13px; }

.activity-calendar-wrap {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.activity-daylabels {
  display: grid;
  grid-template-rows: repeat(7, 11px);
  gap: 3px;
  flex-shrink: 0;
  padding-top: 16px;
}
.activity-daylabels span { font-size: 9px; color: var(--text-muted); line-height: 11px; }

.activity-calendar { flex-shrink: 0; }

.activity-months {
  display: grid;
  grid-auto-flow: column;
  gap: 3px;
  height: 14px;
  margin-bottom: 2px;
}
.activity-months span { font-size: 10px; color: var(--text-muted); }

.activity-grid {
  display: grid;
  grid-auto-flow: column;
  gap: 3px;
}

.activity-week {
  display: grid;
  grid-template-rows: repeat(7, 11px);
  gap: 3px;
}

.activity-range-label {
  flex-shrink: 0;
  align-self: center;
  margin-left: 4px;
  padding-left: 12px;
  border-left: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

.activity-day {
  width: 11px;
  height: 11px;
  border-radius: 2px;
  border: none;
  padding: 0;
  background: var(--border);
  cursor: default;
}
.activity-day[data-level] { cursor: default; }
.activity-day[data-level="0"] { background: var(--border); }
.activity-day[data-level="1"] { background: var(--accent); opacity: 0.3; }
.activity-day[data-level="2"] { background: var(--accent); opacity: 0.55; }
.activity-day[data-level="3"] { background: var(--accent); opacity: 0.8; }
.activity-day[data-level="4"] { background: var(--accent); opacity: 1; }
.activity-day[data-level]:not([data-level="0"]) { cursor: pointer; }
.activity-day[data-level]:not([data-level="0"]):hover { outline: 1px solid var(--text); }
.activity-day:disabled { visibility: hidden; }

.activity-legend {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 10px;
  font-size: 11px;
  color: var(--text-muted);
}
.activity-legend-swatch {
  width: 11px;
  height: 11px;
  border-radius: 2px;
  background: var(--accent);
}
.activity-legend-swatch[data-level="0"] { background: var(--border); opacity: 1; }
.activity-legend-swatch[data-level="1"] { opacity: 0.3; }
.activity-legend-swatch[data-level="2"] { opacity: 0.55; }
.activity-legend-swatch[data-level="3"] { opacity: 0.8; }
.activity-legend-swatch[data-level="4"] { opacity: 1; }

.day-detail-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 300px;
  overflow-y: auto;
}
.day-detail-item {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
}
.day-detail-item:hover { background: var(--accent-soft); border-color: var(--accent); }

/* ---------- Study goals calendar ---------- */

.goals-section { margin-top: 40px; }

.goals-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.goals-header h2 { margin: 0; font-size: 20px; }

.goals-month-nav { display: flex; align-items: center; gap: 8px; }
.goals-month-label { font-size: 13px; font-weight: 600; min-width: 110px; text-align: center; }

.goals-body {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 32px;
}

.goals-calendar-wrap { width: 360px; flex-shrink: 0; }

.goals-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-bottom: 4px;
}
.goals-weekdays span {
  font-size: 10px;
  color: var(--text-muted);
  text-align: center;
}

.goals-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.goals-day {
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  padding: 2px;
}
.goals-day:hover { background: var(--accent-soft); }
.goals-day-today { border-color: var(--accent); font-weight: 700; }
.goals-day-num { font-size: 12px; }
.goals-day-marker {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
}
.goals-day-marker-done { background: var(--text-muted); }

.goals-upcoming { flex: 1; min-width: 260px; max-width: 480px; }
.goals-upcoming h3 { margin: 0 0 10px; font-size: 15px; }

.goals-upcoming-list, .goal-existing-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.goal-existing-list { margin-bottom: 16px; }

.goals-upcoming-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.goals-checkbox {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: none;
  cursor: pointer;
  padding: 0;
}
.goals-checkbox-checked { background: var(--accent); border-color: var(--accent); }

.goals-upcoming-link {
  flex: 1;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  text-decoration: none;
  color: var(--text);
  font-size: 13px;
}
.goals-upcoming-link span { color: var(--text-muted); font-size: 12px; }
.goals-goal-done { text-decoration: line-through; color: var(--text-muted); }

.goals-delete-btn {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  border: none;
  border-radius: 6px;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
}
.goals-delete-btn:hover { color: var(--error); background: var(--accent-soft); }

.goal-form-row { display: flex; gap: 8px; margin-bottom: 10px; }
.goal-form-row select {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}
.goal-verse-label {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--text-muted);
}
.goal-verse-label select { width: 100%; }
.goal-verse-status { margin: -4px 0 10px; font-size: 12px; color: var(--text-muted); }

/* ---------- Sermon Study / Verse Finder shared extras ---------- */

.yt-row { display: flex; gap: 8px; }
.yt-row input[type="url"] {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
}

.prompt-input { min-height: 90px; }

.example-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.chip {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg);
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
}
.chip:hover { background: var(--accent-soft); color: var(--text); border-color: var(--accent); }

/* ---------- Profile page ---------- */

.settings-layout {
  max-width: 640px;
  margin: 0 auto;
  padding: 24px 20px 80px;
}

.settings-layout h1 { font-size: 28px; margin: 8px 0 28px; }

.settings-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
  margin-bottom: 20px;
}

.settings-section h2 { margin: 0 0 4px; font-size: 17px; }

.settings-section-sub {
  margin: 0 0 20px;
  font-size: 13px;
  color: var(--text-muted);
}

.settings-preview {
  margin-top: 20px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

.form-success { color: var(--accent); font-size: 13px; margin: 0; }

.settings-signed-out-notice {
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}
.settings-signed-out-notice a { color: var(--accent); }

.profile-avatar-row { display: flex; align-items: center; gap: 14px; }
.profile-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  flex-shrink: 0;
}
.profile-email { margin: 0; font-size: 17px; font-weight: 600; }

.profile-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: 12px;
  margin: 22px 0;
}
.profile-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  text-align: center;
}
.profile-stat-value { font-size: 22px; font-weight: 700; color: var(--accent); }
.profile-stat-label { font-size: 12px; color: var(--text-muted); }

.profile-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.profile-actions .opt-btn { text-decoration: none; }

.profile-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 0;
  border-top: 1px solid var(--border);
}
.profile-row-label { margin: 0; font-size: 13px; color: var(--text-muted); }
.profile-row-value { margin: 2px 0 0; font-size: 15px; letter-spacing: 1px; }

.password-visibility-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  align-self: flex-start;
  color: var(--text-muted);
  text-decoration: none;
}
.password-visibility-toggle:hover { color: var(--text); }
.password-visibility-toggle.active { color: var(--accent); }

/* ---------- Notes page ---------- */

.notes-page-layout {
  max-width: 900px;
  margin: 0 auto;
  padding: 24px 20px 80px;
}

.notes-page-intro h1 { font-size: 28px; margin: 8px 0 8px; }

.new-doc-form {
  display: flex;
  gap: 10px;
  margin: 20px 0 24px;
}
.new-doc-form input {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
}

.doc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}

.doc-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
}

.doc-card-link {
  display: block;
  text-decoration: none;
  color: var(--text);
}

.doc-card h2 {
  margin: 0 20px 8px 0;
  font-size: 16px;
  font-family: var(--serif);
}

.doc-card-snippet {
  margin: 0 0 12px;
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.doc-card-meta {
  margin: 0;
  font-size: 12px;
  color: var(--text-muted);
}

.doc-card-delete {
  position: absolute;
  top: 14px;
  right: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
}
.doc-card-delete:hover { color: var(--error); }

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13px;
  margin-bottom: 16px;
  /* Also used on <button> elements (e.g. chapter/book pickers), which need
     their native chrome reset — <a> usages are unaffected by these. */
  background: none;
  border: none;
  padding: 0;
  font-family: inherit;
  cursor: pointer;
}
.back-link:hover { color: var(--text); }

.doc-title-input {
  width: 100%;
  border: none;
  background: none;
  color: var(--text);
  font-family: var(--serif);
  font-size: 28px;
  font-weight: 700;
  padding: 0;
  margin-bottom: 4px;
}
.doc-title-input:focus { outline: none; }

.doc-meta {
  margin: 0 0 20px;
  font-size: 12px;
  color: var(--text-muted);
}

.doc-body-input {
  width: 100%;
  min-height: 50vh;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  background: var(--surface);
  color: var(--text);
  font-family: var(--serif);
  font-size: 16px;
  line-height: 1.7;
  resize: vertical;
}
.doc-body-input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.doc-editor-actions {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}

.opt-btn-danger:hover { background: var(--error); color: white; border-color: var(--error); }

/* ---------- Responsive ---------- */

@media (max-width: 999px) {
  .layout { flex-direction: column; }

  .notes-panel {
    width: 100%;
    position: static;
    max-height: none;
    order: 2;
  }

  .reader { order: 1; width: 100%; }

  /* Each topbar section gets its own full-width row, explicitly, rather
     than relying on flex-wrap to notice it doesn't fit — .topbar-nav's
     min-width: 0 (needed for its own children to shrink) also tells the
     wrap algorithm it can shrink to nothing, so it never wraps on its own
     and its children overflow instead. */
  .topbar { flex-wrap: wrap; row-gap: 10px; }
  .topbar-left { flex-basis: 100%; flex-wrap: wrap; }
  .topbar-nav { flex-basis: 100%; order: 2; }
  .topbar-right { flex-basis: 100%; order: 3; justify-content: flex-end; }
  .topbar select { max-width: 160px; }
  .chapter-text { font-size: calc(var(--reader-font-size) * 0.92); }
  .nav-cards { grid-template-columns: 1fr; }
  .home-hero h1 { font-size: 30px; }
  .site-nav { order: 3; width: 100%; }
}
