:root {
  --bg: #111111;
  --bg-elev: #161616;
  --bg-elev-2: #1c1c1c;
  --text: #ecebe4;
  --muted: #a0a0a0;
  --line: #2a2a2a;
  --accent: #00e385;
  --accent-soft: #0f2a1e;
  --danger: #d89d9d;
  --radius-sm: 6px;
  --radius-md: 12px;
  --verse-size: 18px;
  --verse-num-size: 14px;
  --menu-text-size: 16px;
  --ts: 0.1s;
}

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

::selection {
  background: rgba(0, 227, 133, 0.3);
  color: #fff;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background-color: #0a0a0a;
  color: var(--text);
  font-family: "Georgia", "Times New Roman", serif;
}

body {
  padding: 18px;
}

.preload-hide {
  opacity: 0;
  visibility: hidden;
}

@keyframes skeletonPulse {
  0% {
    background-color: #1c1c1c;
  }
  50% {
    background-color: #242424;
  }
  100% {
    background-color: #1c1c1c;
  }
}

.skeleton-loader {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.skeleton-verse {
  height: 18px;
  background: var(--bg-elev-2);
  border-radius: 4px;
  animation: skeletonPulse 1.5s ease-in-out infinite;
}

.skeleton-verse:nth-child(even) {
  width: 95%;
}

.skeleton-verse:nth-child(3n) {
  width: 85%;
}

.skeleton-verse:nth-child(4n) {
  width: 90%;
}

.reader-shell {
  width: min(1200px, 100%);
  margin: 0 auto;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition:
    opacity var(--ts) ease,
    visibility var(--ts) ease;
}

.reader-header {
  padding: 0;
  border-bottom: 1px solid var(--line);
  background: var(--bg-elev);
}

.header-main {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  padding: 24px;
  height: 100px;
}

.header-meta {
  padding: 14px;
  border-top: 1px solid var(--line);
  background: var(--bg-elev-2);
}

.header-brand {
  min-width: 0;
}

.reader-header h1 {
  margin: 0;
  font-size: clamp(40px, 5vw, 50px);
  letter-spacing: -0.02em;
  font-weight: bold;
  color: var(--text);
  text-decoration: underline 4px;
}

.auth-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 15px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg-elev-2);
  color: var(--text);
  font: inherit;
  font-size: 15px;
  font-weight: bold;
  text-decoration: none;
  cursor: pointer;
  transition:
    border-color var(--ts) ease,
    background-color var(--ts) ease,
    color var(--ts) ease;
  white-space: nowrap;
  flex-shrink: 0;
}

.auth-btn:hover {
  border-color: var(--accent);
  background: rgba(0, 227, 133, 0.08);
  color: #fff;
}

.auth-btn:focus-visible {
  outline: none;
  border-color: var(--accent);
}

.auth-avatar {
  width: 40px;
  height: 40px;
  margin-left: -5px;
  border-radius: 50%;
  display: block;
  flex-shrink: 0;
}

.header-description {
  margin: 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.5;
  font-weight: bold;
  text-align: center;
}

.control-panel {
  padding: 16px;
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(4, minmax(0, 1fr)) auto;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}

.control-group {
  display: grid;
  gap: 6px;
  position: relative;
}

.control-group span {
  color: var(--muted);
  font-size: 15px;
  font-weight: bold;
}

select,
button,
.custom-select-trigger {
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--bg-elev-2);
  color: var(--text);
  padding: 10px 12px;
  font: inherit;
  font-size: 16px;
  font-weight: bold;
  transition:
    border-color var(--ts) ease,
    background-color var(--ts) ease,
    color var(--ts) ease,
    transform var(--ts) ease;
}

select {
  appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a0a0a0' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
  padding-right: 35px;
  cursor: pointer;
}

select option {
  background-color: #161616;
  color: var(--text);
}

button,
.custom-select-trigger {
  cursor: pointer;
}

button:hover,
.custom-select-trigger:hover,
select:hover {
  border-color: #3a3a3a;
  background-color: #242424;
}

button:focus-visible,
.custom-select-trigger:focus-visible,
select:focus-visible {
  outline: none;
  border-color: var(--accent);
}

button:disabled,
select:disabled,
.custom-select.is-disabled .custom-select-trigger {
  opacity: 0.62;
  cursor: not-allowed;
  pointer-events: none;
}

select.native-select--hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.custom-select {
  position: relative;
}

.custom-select-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  text-align: left;
  box-shadow: none;
}

.custom-select-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.custom-select-caret {
  color: var(--muted);
  font-size: 14px;
  transition:
    transform var(--ts) ease,
    color var(--ts) ease;
}

.custom-select[data-open="true"] .custom-select-caret {
  transform: rotate(180deg);
  color: var(--accent);
}

@keyframes dropdownSlide {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.custom-select-menu {
  position: absolute;
  top: calc(100% + 5px);
  left: 0;
  right: 0;
  z-index: 30;
  max-height: 336px;
  overflow-y: auto;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-elev-2);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.42);
  transform-origin: top center;
}

.custom-select[data-open="true"] .custom-select-menu {
  animation: dropdownSlide 0.2s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.custom-select-option {
  width: 100%;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text);
  text-align: left;
  padding: 8px 10px;
  font: inherit;
  font-size: 15px;
  font-weight: bold;
  line-height: 1.32;
}

.custom-select-option:hover {
  background: rgba(0, 227, 133, 0.11);
  color: #fff;
}

.custom-select-option[aria-selected="true"] {
  background: rgba(0, 227, 133, 0.2);
  color: #fff;
}

.custom-select-option:focus-visible {
  outline: none;
  background: rgba(0, 227, 133, 0.16);
}

.custom-select-option[aria-disabled="true"] {
  opacity: 0.55;
  pointer-events: none;
}

.nav-actions {
  align-self: end;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  min-width: 220px;
}

.text-size-group {
  align-self: end;
}

.text-size-options {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
}

.text-size-options button {
  padding: 10px 12px;
  font-size: 15px;
  min-width: 0;
  border-radius: var(--radius-sm);
  width: 100%;
}

.text-size-options button.is-active {
  border-color: var(--accent);
  background: rgba(0, 227, 133, 0.12);
  color: #fff;
}

.status-bar {
  min-height: 34px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 16px;
  font-weight: bold;
  text-align: center;
}

.status-bar[data-state="error"] {
  color: var(--danger);
}

.status-bar[data-state="ok"] {
  color: var(--accent);
}

.passage-head {
  padding: 16px;
}

.passage-head h2 {
  margin: 0;
  font-size: clamp(20px, 2.4vw, 26px);
  letter-spacing: 0.01em;
}

.passage-head p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 16px;
  font-weight: bold;
}

.content-pane {
  margin: 0 16px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-elev-2);
  padding: 14px 20px 14px 20px;
  line-height: 1.55;
  height: auto;
  overflow-y: visible;
  content-visibility: auto;
  contain-intrinsic-size: auto 500px;
}

.chapter-note {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 15px;
  font-weight: bold;
}

.verse:hover,
.nt-verse:hover {
  background: rgba(0, 227, 133, 0.08);
  color: var(--accent);
  border-radius: 6px;
}

.verse,
.nt-verse {
  margin: 0 -4px 0;
  padding: 3px 6px;
  font-size: var(--verse-size);
  line-height: 1.3;
  text-wrap: balance;
  cursor: pointer;
}

.verse:not(:last-child),
.nt-verse:not(:last-child) {
  margin-bottom: 4px;
}

.verse-num {
  color: var(--accent);
  font-size: var(--verse-num-size);
  font-weight: bold;
  display: inline;
  min-width: 0;
  margin-right: 4px;
  vertical-align: baseline;
}

.empty {
  color: var(--muted);
}

.bottom-nav {
  margin: 0 16px 16px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-elev-2);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.bottom-nav button {
  min-width: 110px;
  font-size: 16px;
}

.bottom-chapter-display {
  font-weight: bold;
  color: var(--accent);
  font-size: 17px;
  text-align: center;
}

.reader-footer {
  padding: 16px;
  border-top: 1px solid var(--line);
  background: var(--bg-elev);
  display: grid;
  gap: 14px;
}

.footer-credits {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
}

.credits-text {
  font-size: 18px;
  margin-left: 8px;
  font-weight: bold;
  letter-spacing: 0.01em;
  color: var(--text);
}

.pizza-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 18px;
  min-height: 38px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--accent);
  background: rgba(0, 227, 133, 0.12);
  color: var(--accent);
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: bold;
  font-size: 14px;
  transition:
    background-color var(--ts) ease,
    border-color var(--ts) ease,
    color var(--ts) ease;
}

.pizza-btn:hover {
  border-color: var(--accent);
  background: rgba(0, 227, 133, 0.2);
  color: #fff;
}

.pizza-btn:focus-visible {
  outline: none;
  border-color: var(--accent);
}

@media (max-width: 1124px) and (min-width: 769px) {
  .control-panel {
    grid-template-columns: 1fr 1fr;
  }

  .nav-actions {
    grid-column: 1 / -1;
  }
}

@media (max-width: 768px) {
  body {
    padding: 8px;
  }

  .reader-shell {
    border-radius: 10px;
  }

  .header-main {
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 14px;
    padding: 20px;
    height: 160px;
  }

  .header-meta {
    padding: 12px;
  }

  .header-brand {
    align-items: center;
  }

  .control-panel,
  .status-bar,
  .passage-head {
    padding-left: 12px;
    padding-right: 12px;
  }

  .control-panel {
    grid-template-columns: 1fr;
    text-align: left;
    padding: 12px;
    gap: 12px;
  }

  .nav-actions,
  .text-size-group {
    grid-column: 1 / -1;
    min-width: 0;
  }

  .content-pane {
    margin: 0 12px 12px;
    padding: 10px 14px 10px 14px;
    text-align: left;
  }

  .bottom-nav {
    margin: 0 12px 12px;
    padding: 12px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }

  .bottom-nav button {
    width: 100%;
    min-width: 0;
  }

  .bottom-chapter-display {
    grid-column: 1 / -1;
    grid-row: 1;
    margin-bottom: 4px;
  }

  .reader-footer {
    padding: 14px;
    gap: 12px;
  }

  .footer-credits {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }

  .pizza-btn {
    width: 100%;
  }
}

/* ===========================
   Scrollbar (Custom)
   =========================== */
::-webkit-scrollbar {
  width: 5px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: #00000000;
}

::-webkit-scrollbar-thumb {
  background: var(--accent);
  border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--accent);
}

/* ===========================
   Verse Menu (Bottom Sheet)
   =========================== */

.vm-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(0, 0, 0, 0.55);
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 0.22s cubic-bezier(0.4, 0, 0.2, 1),
    visibility 0s 0.22s;
  pointer-events: none;
}

.vm-overlay.is-active {
  opacity: 1;
  visibility: visible;
  transition-delay: 0s, 0s;
  pointer-events: auto;
}

.verse-menu {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 60;
  height: 92vh;
  height: 92dvh;
  max-width: 780px;
  margin: 0 auto;
  border-radius: 18px 18px 0 0;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-bottom: 0;
  box-shadow: 0 -6px 32px rgba(0, 0, 0, 0.48);
  transform: translateY(100%);
  will-change: transform;
  transition: transform 0.28s cubic-bezier(0.32, 0.72, 0, 1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.verse-menu[data-mode="actions"] {
  transform: translateY(calc(100% - 152px));
}

.verse-menu[data-mode="comments"] {
  transform: translateY(8px);
}

.vm-actions-view {
  flex-shrink: 0;
  padding: 12px 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  border-bottom: 1px solid var(--line);
}

.verse-menu[data-mode="comments"] .vm-actions-view {
  display: none;
}

.vm-actions-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.vm-ref {
  font-weight: bold;
  font-size: var(--menu-text-size);
  color: var(--muted);
  user-select: none;
}

.vm-actions-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.vm-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 13px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-elev-2);
  color: var(--text);
  font: inherit;
  font-size: var(--menu-text-size);
  font-weight: bold;
  cursor: pointer;
  transition:
    border-color var(--ts) ease,
    background-color var(--ts) ease;
  white-space: nowrap;
}

.vm-btn:hover {
  border-color: var(--accent);
  background: rgba(0, 227, 133, 0.07);
}

.vm-btn-accent {
  border-color: var(--accent);
  background: rgba(0, 227, 133, 0.12);
  color: var(--accent);
}

.vm-btn-accent:hover {
  background: rgba(0, 227, 133, 0.2);
  color: #fff;
}

.vm-btn-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.vm-close-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-elev-2);
  color: var(--muted);
  cursor: pointer;
  transition:
    border-color var(--ts) ease,
    color var(--ts) ease,
    background-color var(--ts) ease;
  flex-shrink: 0;
  padding: 0;
}

.vm-close-btn svg {
  width: 18px;
  height: 18px;
}

.vm-close-btn:hover {
  border-color: var(--danger);
  color: var(--danger);
  background: rgba(216, 157, 157, 0.08);
}

.vm-back-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-elev-2);
  color: var(--muted);
  cursor: pointer;
  transition:
    border-color var(--ts) ease,
    color var(--ts) ease,
    background-color var(--ts) ease;
  flex-shrink: 0;
  padding: 0;
}

.vm-back-btn svg {
  width: 18px;
  height: 18px;
}

.vm-back-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(0, 227, 133, 0.08);
}

.vm-comments-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.verse-menu[data-mode="actions"] .vm-comments-view,
.verse-menu[data-mode="hidden"] .vm-comments-view {
  display: none;
}

.vm-comments-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-elev);
}

.vm-comments-title {
  flex: 1;
  font-weight: bold;
  font-size: calc(var(--menu-text-size) + 4px);
  color: var(--text);
  text-align: center;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.vm-comments-body {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 14px 20px 28px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.vm-comment-card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-elev-2);
  content-visibility: auto;
  contain-intrinsic-size: auto 120px;
}

.vm-comment-author {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 6px;
}

.vm-comment-author-name {
  font-weight: bold;
  font-size: calc(var(--menu-text-size) + 3px);
  color: var(--accent);
}

.vm-comment-author-year {
  font-size: calc(var(--menu-text-size) + 1px);
  color: var(--muted);
  font-weight: bold;
}

.vm-comment-work {
  font-size: calc(var(--menu-text-size) + 1px);
  color: var(--muted);
  font-weight: bold;
  margin-bottom: 10px;
  font-style: italic;
}

.vm-comment-quote {
  font-size: var(--verse-size);
  line-height: 1.55;
  color: var(--text);
  quotes: "\201C" "\201D" "\2018" "\2019";
}

.vm-comment-quote::before {
  content: open-quote;
  color: var(--accent);
  font-size: calc(var(--verse-size) + 4px);
  line-height: 0;
  vertical-align: -4px;
}

.vm-comment-quote::after {
  content: close-quote;
  color: var(--accent);
  font-size: calc(var(--verse-size) + 4px);
  line-height: 0;
  vertical-align: -4px;
}

.vm-comment-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 10px;
  font-size: var(--verse-size);
  color: var(--accent);
  text-decoration: none;
  font-weight: bold;
  border-bottom: 1px solid transparent;
  transition: border-color var(--ts) ease;
}

.vm-comment-link:hover {
  border-bottom-color: var(--accent);
}

.vm-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 50px 20px;
  text-align: center;
  gap: 14px;
}

.vm-empty-icon {
  color: var(--muted);
  opacity: 0.4;
}

.vm-empty-icon svg {
  width: 48px;
  height: 48px;
}

.vm-empty-text {
  color: var(--muted);
  font-size: var(--menu-text-size);
  font-weight: bold;
}

.vm-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 50px 20px;
  gap: 10px;
  color: var(--muted);
  font-size: var(--menu-text-size);
  font-weight: bold;
}

.vm-loading-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: vmSpin 0.7s linear infinite;
}

@keyframes vmSpin {
  to { transform: rotate(360deg); }
}

.verse.verse-tap-active,
.nt-verse.verse-tap-active {
  background: rgba(0, 227, 133, 0.14);
  border-radius: 6px;
  transition: background 0.08s ease;
}

@media (max-width: 768px) {
  .verse-menu {
    max-width: none;
    border-radius: 16px 16px 0 0;
    height: 100vh;
    height: 100dvh;
  }

  .verse-menu[data-mode="actions"] {
    transform: translateY(calc(100% - 146px));
  }

  .verse-menu[data-mode="comments"] {
    transform: translateY(48px);
  }

  .vm-actions-view {
    padding: 12px 14px 14px;
  }

  .vm-comments-body {
    padding: 12px 14px 24px;
  }
}
