/* ========================================================
   Zongheng Web Novel Reader - Dark Xianxia Stylesheet
   Inspirado no leitor oficial do Zongheng (纵横中文网)
   ======================================================== */

:root {
  --color-gold: #d4af37;
  --color-gold-hover: #b89628;
  --color-cinnabar: #dc2626;
  --font-serif: 'Noto Serif', Georgia, serif;
  --font-sans: 'Inter', -apple-system, sans-serif;
  --font-title: 'Cinzel', 'Noto Serif', serif;
  
  /* Tamanho de fonte padrão */
  --reader-font-size: 19px;
  --reader-line-height: 1.85;
}

/* 1. Temas de Leitura */
body.theme-obsidian {
  --bg-main: #0c0f16;
  --bg-surface: #141824;
  --bg-card: #181e2c;
  --border-subtle: #242c3e;
  --text-body: #d5dce6;
  --text-muted: #8b9bb4;
  --text-bright: #ffffff;
}

body.theme-midnight {
  --bg-main: #000000;
  --bg-surface: #0a0a0a;
  --bg-card: #121212;
  --border-subtle: #262626;
  --text-body: #a3a3a3;
  --text-muted: #737373;
  --text-bright: #e5e5e5;
}

body.theme-sepia {
  --bg-main: #181410;
  --bg-surface: #221c17;
  --bg-card: #2b241e;
  --border-subtle: #3d332a;
  --text-body: #e4d3be;
  --text-muted: #a8947f;
  --text-bright: #f5ebe0;
}

body.theme-forest {
  --bg-main: #08120e;
  --bg-surface: #0f1f1a;
  --bg-card: #162a23;
  --border-subtle: #213d33;
  --text-body: #c1ded3;
  --text-muted: #7ea395;
  --text-bright: #e2f1ec;
}

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

body {
  background-color: var(--bg-main);
  color: var(--text-body);
  transition: background-color 0.25s ease, color 0.25s ease;
  min-height: 100vh;
}

/* Tipografia */
body.font-serif .chapter-text-body { font-family: var(--font-serif); }
body.font-sans .chapter-text-body { font-family: var(--font-sans); }

/* Espaçamento */
body.lh-compact .chapter-text-body { line-height: 1.6; }
body.lh-normal .chapter-text-body { line-height: 1.85; }
body.lh-spacious .chapter-text-body { line-height: 2.15; }

/* Barra de Progresso no Topo */
.reading-progress-rail {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: transparent;
  z-index: 1000;
}

.reading-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--color-gold) 0%, #f59e0b 100%);
  box-shadow: 0 0 8px rgba(212, 175, 55, 0.6);
  transition: width 0.1s;
}

/* ==========================================
   2. CABEÇALHO SUPERIOR (ZONGHENG TOPBAR)
   ========================================== */
.zongheng-header {
  position: sticky;
  top: 0;
  z-index: 90;
  background: rgba(12, 15, 22, 0.9);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
  padding: 10px 18px;
}

.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.zh-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
}

.seal-character {
  background: linear-gradient(135deg, #1c2333, #0f131d);
  color: var(--color-gold);
  border: 1px solid var(--color-gold);
  font-family: var(--font-sans);
  font-weight: 800;
  font-size: 0.85rem;
  letter-spacing: 0.5px;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.zh-brand-name {
  font-family: var(--font-title);
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-bright);
  letter-spacing: -0.5px;
}

.zh-brand-name span { color: var(--color-gold); }

.breadcrumb-trail {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.breadcrumb-trail a {
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.15s;
}

.breadcrumb-trail a:hover { color: var(--color-gold); }
.breadcrumb-trail .sep { color: var(--border-subtle); }
.breadcrumb-trail .current-cap { color: var(--color-gold); font-weight: 700; }

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.read-percent-chip {
  font-size: 0.75rem;
  color: var(--color-gold);
  background: rgba(212, 175, 55, 0.1);
  border: 1px solid rgba(212, 175, 55, 0.25);
  padding: 3px 8px;
  border-radius: 4px;
  font-weight: 700;
}

.header-btn {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-body);
  padding: 6px 12px;
  border-radius: 6px;
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s;
}

.header-btn:hover {
  background: var(--bg-card);
  border-color: var(--color-gold);
}

.header-btn.btn-highlight {
  background: var(--color-gold);
  color: #000000;
  border-color: var(--color-gold);
  font-weight: 800;
}

.header-btn.btn-highlight:hover {
  background: var(--color-gold-hover);
}

/* ==========================================
   3. ÁREA DE LEITURA (CANVAS IMERSIVO)
   ========================================== */
.reading-canvas {
  margin: 0 auto;
  padding: 40px 20px 80px 20px;
  transition: max-width 0.2s ease;
}

body.width-narrow .reading-canvas { max-width: 760px; }
body.width-medium .reading-canvas { max-width: 900px; }
body.width-wide .reading-canvas { max-width: 1100px; }

/* Cartão do Título da Obra */
.novel-title-card {
  text-align: center;
  margin-bottom: 30px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border-subtle);
}

.seal-stamp-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 12px;
}

.novel-badge-tag {
  background: rgba(229, 169, 59, 0.12);
  color: var(--color-gold);
  border: 1px solid rgba(229, 169, 59, 0.35);
  border-radius: 4px;
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 1.5px;
  padding: 4px 12px;
  text-transform: uppercase;
}

.novel-heading {
  font-family: var(--font-title);
  font-size: 1.8rem;
  font-weight: 900;
  color: var(--text-bright);
  margin-bottom: 8px;
}

.novel-meta-ribbon {
  display: flex;
  justify-content: center;
  gap: 12px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.novel-meta-ribbon b { color: var(--color-gold); }

/* Barra Rápida Superior de Capítulos */
.quick-nav-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 8px 14px;
  margin-bottom: 30px;
}

.nav-arrow-btn {
  background: transparent;
  border: none;
  color: var(--text-body);
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: color 0.15s;
}

.nav-arrow-btn:hover:not(:disabled):not(.disabled) { color: var(--color-gold); }
.nav-arrow-btn.disabled { opacity: 0.35; cursor: not-allowed; pointer-events: none; }

.nav-center-btn {
  background: transparent;
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  padding: 4px 12px;
  border-radius: 4px;
  font-size: 0.76rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.nav-center-btn:hover { color: var(--color-gold); border-color: var(--color-gold); }

/* Artigo do Capítulo */
.chapter-article {
  margin-bottom: 40px;
}

.chapter-header-box {
  margin-bottom: 32px;
}

.chapter-tag-indicator {
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--color-gold);
  letter-spacing: 1px;
}

.chapter-main-title {
  font-family: var(--font-title);
  font-size: 2rem;
  font-weight: 800;
  color: var(--text-bright);
  margin: 6px 0 10px 0;
  line-height: 1.25;
}

.chapter-sub-meta {
  display: flex;
  gap: 12px;
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* Corpo do Texto de Web Novel */
.chapter-text-body p {
  font-size: var(--reader-font-size);
  text-indent: 2em;
  margin-bottom: 1.6em;
  text-align: justify;
  letter-spacing: 0.2px;
  word-break: break-word;
}

.chapter-text-body em {
  color: var(--color-gold);
  font-style: italic;
}

/* Navegação Inferior */
.chapter-end-nav {
  display: flex;
  gap: 12px;
  margin: 50px 0 40px 0;
}

.end-nav-btn {
  flex: 1;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-body);
  padding: 14px 18px;
  border-radius: 8px;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s;
}

.end-nav-btn:hover:not(:disabled):not(.disabled) {
  border-color: var(--color-gold);
  color: var(--color-gold);
}

.end-nav-btn.btn-next {
  background: var(--color-gold);
  color: #000000;
  border-color: var(--color-gold);
  font-weight: 800;
}

.end-nav-btn.btn-next:hover { background: var(--color-gold-hover); }
.end-nav-btn.disabled { opacity: 0.35; cursor: not-allowed; pointer-events: none; }

/* Caixa de Interação */
.reader-interaction-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 24px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.stamp-icon { font-size: 1.8rem; }

.interaction-top h4 {
  font-family: var(--font-title);
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--text-bright);
}

.interaction-top p {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.interaction-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

.interact-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-body);
  padding: 9px 16px;
  border-radius: 20px;
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s;
}

.interact-btn:hover { border-color: var(--color-gold); }
.interact-btn.highlight-reward {
  background: rgba(220, 38, 38, 0.15);
  color: #ef4444;
  border-color: rgba(220, 38, 38, 0.4);
}

/* ==========================================
   4. DOCK LATERAL FLUTUANTE (ZONGHENG TOOLBAR)
   ========================================== */
.floating-dock {
  position: fixed;
  right: 24px;
  bottom: 60px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 30px;
  padding: 8px 6px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
  z-index: 80;
}

.dock-action-btn {
  background: transparent;
  border: none;
  color: var(--text-body);
  width: 42px;
  height: 42px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  position: relative;
  transition: background 0.15s, color 0.15s;
}

.dock-action-btn:hover {
  background: var(--bg-card);
  color: var(--color-gold);
}

.dock-tooltip {
  position: absolute;
  right: 52px;
  background: #000000;
  color: #ffffff;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 4px;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s;
  pointer-events: none;
}

.dock-action-btn:hover .dock-tooltip {
  opacity: 1;
  visibility: visible;
}

/* ==========================================
   5. GAVETA DE ÍNDICE DE CAPÍTULOS (TOC DRAWER)
   ========================================== */
.toc-drawer {
  position: fixed;
  top: 0;
  left: 0;
  width: 380px;
  max-width: 85vw;
  height: 100vh;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
  z-index: 200;
  transform: translateX(-100%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
}

.toc-drawer.open { transform: translateX(0); }

.drawer-mask {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 199;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s;
}

.drawer-mask.active { opacity: 1; visibility: visible; }

.toc-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  border-bottom: 1px solid var(--border-subtle);
}

.toc-title-box h3 {
  font-family: var(--font-title);
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text-bright);
}

.total-caps {
  font-size: 0.72rem;
  color: var(--color-gold);
}

.toc-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.3rem;
  cursor: pointer;
}

.toc-search-box {
  padding: 12px 18px;
  border-bottom: 1px solid var(--border-subtle);
}

.toc-search-box input {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 8px 12px;
  color: var(--text-bright);
  font-family: var(--font-sans);
  font-size: 0.82rem;
  outline: none;
}

.toc-scrollable-list {
  padding: 12px 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.volume-header {
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--color-gold);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 12px 6px 4px 6px;
}

.toc-chapter-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 6px;
  text-decoration: none;
  color: var(--text-body);
  font-size: 0.85rem;
  transition: all 0.15s;
}

.toc-chapter-item:hover,
.toc-chapter-item.active {
  background: var(--bg-card);
  color: var(--color-gold);
}

.chap-num {
  font-weight: 800;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.chap-name {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chap-badge {
  background: rgba(212, 175, 55, 0.15);
  color: var(--color-gold);
  font-size: 0.62rem;
  padding: 2px 5px;
  border-radius: 3px;
}

/* ==========================================
   6. PAINEL DE CONFIGURAÇÕES DE LEITURA
   ========================================== */
.settings-floating-panel {
  position: fixed;
  top: 60px;
  right: 20px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  padding: 20px;
  width: 320px;
  max-width: 90vw;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.7);
  z-index: 150;
  display: none;
  flex-direction: column;
  gap: 16px;
}

.settings-floating-panel.active { display: flex; }

.settings-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.settings-head h4 {
  font-family: var(--font-title);
  font-size: 0.95rem;
  font-weight: 800;
}

.settings-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.1rem;
}

.setting-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.setting-label {
  font-size: 0.76rem;
  color: var(--text-muted);
  font-weight: 700;
}

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

.theme-circle {
  padding: 8px 4px;
  border-radius: 6px;
  border: 2px solid transparent;
  font-family: var(--font-sans);
  font-size: 0.7rem;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
}

.theme-btn-obsidian { background: #141824; color: #d5dce6; }
.theme-btn-midnight { background: #000000; color: #a3a3a3; }
.theme-btn-sepia { background: #221c17; color: #e4d3be; }
.theme-btn-forest { background: #0f1f1a; color: #c1ded3; }

.theme-circle.active { border-color: var(--color-gold); }

.btn-group-segmented {
  display: flex;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 2px;
}

.seg-btn, .width-btn, .line-btn {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 6px;
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 700;
  border-radius: 4px;
  cursor: pointer;
}

.seg-btn.active, .width-btn.active, .line-btn.active {
  background: var(--bg-surface);
  color: var(--color-gold);
}

.font-size-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 4px 10px;
}

.ctrl-btn {
  background: transparent;
  border: none;
  color: var(--text-body);
  font-size: 0.9rem;
  font-weight: 800;
  cursor: pointer;
  padding: 4px 10px;
}

.font-size-val {
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--color-gold);
}

/* Rodapé */
.zongheng-footer {
  text-align: center;
  padding: 30px;
  border-top: 1px solid var(--border-subtle);
  font-size: 0.74rem;
  color: var(--text-muted);
}

@media (max-width: 800px) {
  .desktop-only { display: none !important; }
}
