/* ==========================================================================
   CSS VARIABLES & THEME SYSTEM
   ========================================================================== */
:root {
  /* Common Geometry */
  --header-height: 60px;
  --max-content-width: 780px;
  --wide-content-width: 960px;
  --border-radius-sm: 6px;
  --border-radius-md: 12px;
  --border-radius-lg: 20px;
  --transition-fast: 0.15s ease;
  --transition-smooth: 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  --book-font-size: 19px;
  --book-line-height: 1.82;
}

/* Theme 1: Sepia (Sıcak Kitap Kağıdı / Parşömen) */
[data-theme="sepia"] {
  --bg-app: #f6eedb;
  --bg-card: #fdf8ee;
  --bg-page: #fefbf4;
  --bg-header: rgba(246, 238, 219, 0.94);
  --bg-surface: #ede2c9;
  --bg-input: #f5edd7;
  --text-main: #2d261e;
  --text-muted: #736453;
  --text-light: #9c8a77;
  --border-color: #e5d7ba;
  --border-subtle: #ebdcc0;
  --accent-gold: #ab7a28;
  --accent-gold-bg: rgba(171, 122, 40, 0.12);
  --accent-hover: #c48f35;
  --book-spine-shadow: linear-gradient(to right, rgba(0,0,0,0.12) 0%, rgba(0,0,0,0.02) 15%, rgba(0,0,0,0) 100%);
  --book-edge-shadow: 0 16px 48px -12px rgba(92, 70, 39, 0.25);
  --shadow-popup: 0 20px 40px rgba(74, 56, 31, 0.18);
  --dropcap-color: #99691b;
}

/* Theme 2: Light (Mat Kağıt Beyazı) */
[data-theme="light"] {
  --bg-app: #f9fafb;
  --bg-card: #ffffff;
  --bg-page: #ffffff;
  --bg-header: rgba(249, 250, 251, 0.95);
  --bg-surface: #f1f3f5;
  --bg-input: #eef1f4;
  --text-main: #191c21;
  --text-muted: #5c6470;
  --text-light: #8b95a5;
  --border-color: #e2e6eb;
  --border-subtle: #edf0f3;
  --accent-gold: #9e6c1e;
  --accent-gold-bg: rgba(158, 108, 30, 0.1);
  --accent-hover: #b87f25;
  --book-spine-shadow: linear-gradient(to right, rgba(0,0,0,0.08) 0%, rgba(0,0,0,0.01) 15%, rgba(0,0,0,0) 100%);
  --book-edge-shadow: 0 16px 40px -10px rgba(0, 0, 0, 0.12);
  --shadow-popup: 0 20px 40px rgba(0, 0, 0, 0.14);
  --dropcap-color: #9e6c1e;
}

/* Theme 3: Dark (Obsidyen Gece) */
[data-theme="dark"] {
  --bg-app: #121316;
  --bg-card: #1a1c21;
  --bg-page: #17181c;
  --bg-header: rgba(18, 19, 22, 0.95);
  --bg-surface: #24272e;
  --bg-input: #1f2228;
  --text-main: #e6e8ec;
  --text-muted: #a1a7b5;
  --text-light: #6a7182;
  --border-color: #2e333d;
  --border-subtle: #242832;
  --accent-gold: #dfa84a;
  --accent-gold-bg: rgba(223, 168, 74, 0.14);
  --accent-hover: #f1bf68;
  --book-spine-shadow: linear-gradient(to right, rgba(0,0,0,0.4) 0%, rgba(0,0,0,0.05) 15%, rgba(0,0,0,0) 100%);
  --book-edge-shadow: 0 20px 50px -12px rgba(0, 0, 0, 0.6);
  --shadow-popup: 0 20px 40px rgba(0, 0, 0, 0.5);
  --dropcap-color: #dfa84a;
}

/* Theme 4: Forest (Zümrüt Gece) */
[data-theme="forest"] {
  --bg-app: #0e1a17;
  --bg-card: #152521;
  --bg-page: #12201d;
  --bg-header: rgba(14, 26, 23, 0.95);
  --bg-surface: #1e332e;
  --bg-input: #192d28;
  --text-main: #dceeda;
  --text-muted: #8ea89e;
  --text-light: #5d756d;
  --border-color: #27423b;
  --border-subtle: #1c332d;
  --accent-gold: #cfa856;
  --accent-gold-bg: rgba(207, 168, 86, 0.14);
  --accent-hover: #e6c174;
  --book-spine-shadow: linear-gradient(to right, rgba(0,0,0,0.45) 0%, rgba(0,0,0,0.05) 15%, rgba(0,0,0,0) 100%);
  --book-edge-shadow: 0 20px 50px -12px rgba(0, 0, 0, 0.6);
  --shadow-popup: 0 20px 40px rgba(0, 0, 0, 0.5);
  --dropcap-color: #cfa856;
}

/* Font Family Selection */
[data-font="newsreader"] {
  --font-body: 'Newsreader', serif;
  --font-heading: 'Cinzel', serif;
  --font-ui: 'Plus Jakarta Sans', sans-serif;
}
[data-font="garamond"] {
  --font-body: 'EB Garamond', serif;
  --font-heading: 'EB Garamond', serif;
  --font-ui: 'Plus Jakarta Sans', sans-serif;
}
[data-font="merriweather"] {
  --font-body: 'Merriweather', serif;
  --font-heading: 'Merriweather', serif;
  --font-ui: 'Plus Jakarta Sans', sans-serif;
}
[data-font="sans"] {
  --font-body: 'Plus Jakarta Sans', sans-serif;
  --font-heading: 'Plus Jakarta Sans', sans-serif;
  --font-ui: 'Plus Jakarta Sans', sans-serif;
}

/* Font Size Scales */
[data-size="small"] { --book-font-size: 16.5px; --book-line-height: 1.75; }
[data-size="medium"] { --book-font-size: 19px; --book-line-height: 1.82; }
[data-size="large"] { --book-font-size: 21.5px; --book-line-height: 1.86; }
[data-size="xlarge"] { --book-font-size: 24px; --book-line-height: 1.9; }

/* Page Width */
[data-width="wide"] { --max-content-width: var(--wide-content-width); }

/* ==========================================================================
   BASE & RESET
   ========================================================================== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  min-height: 100%;
  background-color: var(--bg-app);
  color: var(--text-main);
  font-family: var(--font-body);
  font-size: var(--book-font-size);
  line-height: var(--book-line-height);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color var(--transition-smooth), color var(--transition-smooth);
}

button {
  font-family: var(--font-ui);
  cursor: pointer;
  border: none;
  background: transparent;
  color: inherit;
  outline: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

a {
  color: inherit;
  text-decoration: none;
}

.hidden {
  display: none !important;
}

/* ==========================================================================
   READING PROGRESS BAR
   ========================================================================== */
.progress-bar-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: transparent;
  z-index: 1000;
}

.progress-bar-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--accent-gold), var(--accent-hover));
  transition: width 0.1s linear;
}

/* ==========================================================================
   APP HEADER
   ========================================================================== */
.app-header {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: var(--header-height);
  background-color: var(--bg-header);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 900;
  font-family: var(--font-ui);
}

.header-left, .header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  cursor: pointer;
  user-select: none;
  max-width: 45%;
}

.active-chapter-indicator {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.book-mini-title {
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.icon-btn {
  padding: 8px 12px;
  border-radius: var(--border-radius-sm);
  color: var(--text-muted);
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
}

.icon-btn:hover {
  background-color: var(--bg-surface);
  color: var(--text-main);
}

.btn-label {
  font-size: 13px;
}

.mode-text {
  font-size: 11px;
  background-color: var(--accent-gold-bg);
  color: var(--accent-gold);
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 600;
  margin-left: 2px;
}

/* ==========================================================================
   COVER HERO VIEW
   ========================================================================== */
.cover-view {
  min-height: 100vh;
  padding-top: calc(var(--header-height) + 40px);
  padding-bottom: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cover-canvas {
  max-width: 1100px;
  width: 92%;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 60px;
  align-items: center;
}

/* 3D Realistic Hardcover Book Mockup */
.book-3d-wrapper {
  perspective: 1200px;
  display: flex;
  justify-content: center;
}

.book-hardcover {
  width: 320px;
  height: 470px;
  background: linear-gradient(135deg, #1b262c 0%, #0f1419 100%);
  border-radius: 6px 14px 14px 6px;
  position: relative;
  box-shadow: 
    -12px 14px 28px rgba(0, 0, 0, 0.4),
    -2px 0 6px rgba(0, 0, 0, 0.3),
    inset 4px 0 8px rgba(255, 255, 255, 0.08),
    inset -4px 0 12px rgba(0, 0, 0, 0.6);
  transform: rotateY(-18deg) rotateX(6deg);
  transition: transform var(--transition-smooth), box-shadow var(--transition-smooth);
  cursor: pointer;
  padding: 20px;
  color: #e5d3b3;
}

.book-hardcover:hover {
  transform: rotateY(-8deg) rotateX(2deg) translateY(-8px);
  box-shadow: 
    -18px 24px 38px rgba(0, 0, 0, 0.5),
    -2px 0 8px rgba(0, 0, 0, 0.4);
}

.book-spine {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 16px;
  background: linear-gradient(to right, rgba(0,0,0,0.5), rgba(255,255,255,0.06), rgba(0,0,0,0.3));
  border-radius: 6px 0 0 6px;
}

.book-front-cover {
  width: 100%;
  height: 100%;
  border: 1px solid rgba(212, 175, 55, 0.4);
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  text-align: center;
  position: relative;
  background: radial-gradient(circle at 50% 30%, rgba(212, 175, 55, 0.08) 0%, transparent 70%);
}

.cover-border-ornament {
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
}

.cover-header-tag {
  font-family: var(--font-ui);
  font-size: 9px;
  letter-spacing: 2.5px;
  color: #c9ab76;
  text-transform: uppercase;
}

.cover-gold-divider {
  width: 50px;
  height: 1px;
  background: linear-gradient(90deg, transparent, #d4af37, transparent);
  margin: 10px 0;
}

.cover-main-title {
  font-family: 'Cinzel', serif;
  font-size: 23px;
  font-weight: 700;
  letter-spacing: 1.5px;
  line-height: 1.35;
  color: #f7e6c4;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.6);
  margin-top: 10px;
}

.cover-main-subtitle {
  font-family: 'Newsreader', serif;
  font-size: 13px;
  font-style: italic;
  color: #bfa886;
  line-height: 1.4;
  margin-top: 8px;
  padding: 0 8px;
}

.cover-emblem {
  margin: 16px 0;
  color: #d4af37;
  opacity: 0.85;
}

.cover-footer-author {
  font-family: var(--font-ui);
  font-size: 11px;
  letter-spacing: 2px;
  color: #d8c3a5;
  text-transform: uppercase;
}

.cover-year {
  font-family: var(--font-ui);
  font-size: 9px;
  color: #8c785f;
  margin-top: 4px;
}

/* Cover Text Info & Actions */
.cover-details {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.cover-badge {
  display: inline-flex;
  align-self: flex-start;
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--accent-gold);
  background-color: var(--accent-gold-bg);
  padding: 6px 12px;
  border-radius: 20px;
}

.cover-intro-heading {
  font-family: var(--font-heading);
  font-size: 28px;
  line-height: 1.35;
  color: var(--text-main);
  font-weight: 700;
}

.cover-intro-text {
  font-size: 18px;
  color: var(--text-muted);
  line-height: 1.65;
}

.cover-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 8px;
}

.btn-primary-read {
  background-color: var(--accent-gold);
  color: #ffffff;
  padding: 14px 28px;
  border-radius: var(--border-radius-md);
  font-weight: 600;
  font-size: 16px;
  gap: 10px;
  box-shadow: 0 4px 14px rgba(171, 122, 40, 0.35);
}

.btn-primary-read:hover {
  background-color: var(--accent-hover);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(171, 122, 40, 0.45);
}

.btn-secondary-resume {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 14px 24px;
  border-radius: var(--border-radius-md);
  font-weight: 600;
  font-size: 15px;
  gap: 8px;
}

.btn-secondary-resume:hover {
  background-color: var(--border-color);
}

/* Cover Overview Grid */
.cover-chapters-overview {
  margin-top: 20px;
  border-top: 1px solid var(--border-color);
  padding-top: 20px;
}

.overview-title {
  font-family: var(--font-ui);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.overview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 8px;
}

.overview-card {
  padding: 10px 12px;
  background-color: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--border-radius-sm);
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.overview-card:hover {
  border-color: var(--accent-gold);
  background-color: var(--bg-surface);
  transform: translateX(3px);
}

.overview-card-roman {
  font-family: var(--font-heading);
  font-size: 13px;
  font-weight: 700;
  color: var(--accent-gold);
  width: 24px;
}

.overview-card-title {
  font-family: var(--font-ui);
  font-size: 13px;
  color: var(--text-main);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ==========================================================================
   STREAM READER VIEW (Akıcı Okuma Modu)
   ========================================================================== */
.reader-view {
  min-height: 100vh;
  padding-top: calc(var(--header-height) + 30px);
  padding-bottom: 80px;
}

.reader-container {
  max-width: var(--max-content-width);
  margin: 0 auto;
  padding: 0 24px;
}

.chapter-article {
  background-color: var(--bg-page);
  padding: 50px 60px;
  border-radius: var(--border-radius-lg);
  box-shadow: var(--book-edge-shadow);
  border: 1px solid var(--border-color);
  margin-bottom: 40px;
}

.chapter-badge-roman {
  font-family: var(--font-heading);
  font-size: 14px;
  letter-spacing: 2px;
  color: var(--accent-gold);
  text-transform: uppercase;
  margin-bottom: 8px;
  display: block;
}

.chapter-main-title {
  font-family: var(--font-heading);
  font-size: 36px;
  line-height: 1.25;
  color: var(--text-main);
  margin-bottom: 12px;
  font-weight: 700;
}

.chapter-subtitle {
  font-size: 18px;
  color: var(--text-muted);
  font-style: italic;
  margin-bottom: 30px;
}

.chapter-decorative-rule {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 40px;
  color: var(--accent-gold);
}

.chapter-decorative-rule::before,
.chapter-decorative-rule::after {
  content: "";
  height: 1px;
  flex: 1;
  background: linear-gradient(to right, transparent, var(--border-color), transparent);
}

/* Paragraph styling */
.book-paragraph {
  margin-bottom: 1.6em;
  text-align: justify;
  text-justify: inter-word;
  position: relative;
  transition: background-color var(--transition-fast);
}

.book-paragraph:hover .copy-quote-btn {
  opacity: 1;
  pointer-events: auto;
}

/* Dropcap for 1st paragraph */
.book-paragraph.first-paragraph::first-letter {
  font-family: var(--font-heading);
  float: left;
  font-size: 4.2em;
  line-height: 0.82;
  margin-right: 0.12em;
  margin-top: 0.05em;
  color: var(--dropcap-color);
  font-weight: 700;
}

/* Highlighted Callout / Quote Box */
.chapter-quote-box {
  margin: 2.2em 0;
  padding: 20px 28px;
  background-color: var(--bg-surface);
  border-left: 3px solid var(--accent-gold);
  border-radius: 0 var(--border-radius-sm) var(--border-radius-sm) 0;
  font-style: italic;
  font-size: 1.08em;
  color: var(--text-main);
  line-height: 1.65;
}

/* Copy Quote Button */
.copy-quote-btn {
  position: absolute;
  right: -36px;
  top: 4px;
  opacity: 0;
  pointer-events: none;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 4px;
  color: var(--text-muted);
  transition: opacity var(--transition-fast);
}

.copy-quote-btn:hover {
  color: var(--accent-gold);
  border-color: var(--accent-gold);
}

/* Chapter Bottom Navigation */
.chapter-footer-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  font-family: var(--font-ui);
}

.nav-ch-btn {
  flex: 1;
  padding: 16px 20px;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-md);
  color: var(--text-main);
  gap: 14px;
}

.nav-ch-btn:hover {
  border-color: var(--accent-gold);
  background-color: var(--bg-surface);
}

.nav-btn-text {
  display: flex;
  flex-direction: column;
  text-align: left;
}

.nav-ch-btn.next-btn .nav-btn-text {
  text-align: right;
}

.nav-sub {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.nav-main {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-main);
}

.center-btn {
  flex: 0 0 auto;
  padding: 16px 20px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
}

/* ==========================================================================
   BOOK SPREAD VIEW (Ciltli Çift Sayfa Modu)
   ========================================================================== */
.book-page-mode .book-stage {
  max-width: 1140px;
  margin: 0 auto;
  padding: 0 20px;
}

.open-book-spread {
  display: grid;
  grid-template-columns: 1fr 14px 1fr;
  min-height: 650px;
  background-color: var(--bg-page);
  border-radius: var(--border-radius-md);
  box-shadow: var(--book-edge-shadow);
  border: 1px solid var(--border-color);
  position: relative;
  overflow: hidden;
}

.book-page {
  padding: 45px 50px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
}

.book-page.left-page {
  box-shadow: inset -15px 0 25px -15px rgba(0,0,0,0.12);
}

.book-page.right-page {
  box-shadow: inset 15px 0 25px -15px rgba(0,0,0,0.12);
}

.book-middle-spine {
  background: var(--bg-surface);
  border-left: 1px solid var(--border-subtle);
  border-right: 1px solid var(--border-subtle);
  position: relative;
}

.page-inner {
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--font-ui);
  font-size: 12px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 10px;
  margin-bottom: 24px;
}

.page-body {
  flex: 1;
  overflow-y: auto;
  padding-right: 8px;
}

.page-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-ui);
  font-size: 12px;
  color: var(--text-muted);
  border-top: 1px solid var(--border-subtle);
  padding-top: 10px;
  margin-top: 20px;
}

.book-controls-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 24px;
  font-family: var(--font-ui);
}

.book-nav-arrow {
  padding: 12px 24px;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-md);
  color: var(--text-main);
  gap: 10px;
  font-size: 14px;
  font-weight: 600;
}

.book-nav-arrow:hover {
  background-color: var(--accent-gold);
  color: #fff;
  border-color: var(--accent-gold);
}

.book-page-indicator {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
}

/* ==========================================================================
   TOC DRAWER (İçindekiler)
   ========================================================================== */
.drawer-overlay, .modal-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(4px);
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-smooth);
}

.drawer-overlay.active, .modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.toc-drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 360px;
  max-width: 85vw;
  background-color: var(--bg-card);
  border-right: 1px solid var(--border-color);
  box-shadow: var(--shadow-popup);
  z-index: 1100;
  display: flex;
  flex-direction: column;
  transform: translateX(-100%);
  transition: transform var(--transition-smooth);
}

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

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

.toc-badge {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--accent-gold);
  font-weight: 600;
}

.toc-header h2 {
  font-family: var(--font-heading);
  font-size: 20px;
  color: var(--text-main);
}

.toc-book-meta {
  padding: 16px 20px;
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
}

.toc-book-meta h3 {
  font-family: var(--font-heading);
  font-size: 15px;
  margin-bottom: 4px;
}

.toc-book-meta p {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.toc-stats {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-ui);
  font-size: 11px;
  color: var(--accent-gold);
  font-weight: 600;
}

.toc-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px 0;
}

.toc-item {
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: all var(--transition-fast);
}

.toc-item:hover {
  background-color: var(--bg-surface);
}

.toc-item.active {
  background-color: var(--accent-gold-bg);
  border-left-color: var(--accent-gold);
}

.toc-num {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 14px;
  color: var(--accent-gold);
  width: 24px;
  text-align: center;
}

.toc-info {
  flex: 1;
}

.toc-item-title {
  font-family: var(--font-ui);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-main);
  line-height: 1.35;
}

.toc-item-sub {
  font-family: var(--font-ui);
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ==========================================================================
   SETTINGS MODAL
   ========================================================================== */
.settings-modal {
  position: fixed;
  top: calc(var(--header-height) + 12px);
  right: 20px;
  width: 320px;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-md);
  box-shadow: var(--shadow-popup);
  padding: 20px;
  z-index: 1100;
  font-family: var(--font-ui);
  opacity: 0;
  pointer-events: none;
  transform: translateY(-8px);
  transition: all var(--transition-fast);
}

.settings-modal.open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

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

.settings-header h3 {
  font-size: 15px;
  font-weight: 600;
}

.setting-group {
  margin-bottom: 18px;
}

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

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

.theme-btn {
  flex-direction: column;
  gap: 6px;
  padding: 8px 4px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--border-radius-sm);
  font-size: 11px;
  color: var(--text-muted);
}

.theme-btn.active {
  border-color: var(--accent-gold);
  color: var(--text-main);
  font-weight: 600;
}

.theme-swatch {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.1);
}

.swatch-sepia { background-color: #f6eedb; }
.swatch-light { background-color: #ffffff; }
.swatch-dark { background-color: #121316; }
.swatch-forest { background-color: #0e1a17; }

.font-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.font-btn {
  flex-direction: column;
  align-items: flex-start;
  padding: 8px 10px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--border-radius-sm);
  background-color: var(--bg-surface);
}

.font-btn.active {
  border-color: var(--accent-gold);
  background-color: var(--accent-gold-bg);
}

.font-preview {
  font-size: 14px;
  color: var(--text-main);
  font-weight: 600;
}

.font-desc {
  font-size: 10px;
  color: var(--text-muted);
}

.font-newsreader { font-family: 'Newsreader', serif; }
.font-garamond { font-family: 'EB Garamond', serif; }
.font-merriweather { font-family: 'Merriweather', serif; }
.font-sans { font-family: 'Plus Jakarta Sans', sans-serif; }

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

.size-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}

.size-step-btn {
  width: 30px;
  height: 30px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  font-weight: 600;
}

.width-controls {
  display: flex;
  gap: 6px;
}

.width-btn {
  padding: 5px 12px;
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  font-size: 12px;
}

.width-btn.active {
  background-color: var(--accent-gold);
  color: #fff;
  border-color: var(--accent-gold);
}

/* ==========================================================================
   SEARCH MODAL
   ========================================================================== */
.search-modal {
  position: fixed;
  top: 15%;
  left: 50%;
  transform: translateX(-50%) translateY(-10px);
  width: 580px;
  max-width: 92vw;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-md);
  box-shadow: var(--shadow-popup);
  z-index: 1100;
  opacity: 0;
  pointer-events: none;
  transition: all var(--transition-fast);
  overflow: hidden;
}

.search-modal.open {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}

.search-input-wrapper {
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-muted);
}

.search-input-wrapper input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font-family: var(--font-ui);
  font-size: 16px;
  color: var(--text-main);
}

.search-results {
  max-height: 360px;
  overflow-y: auto;
  padding: 8px;
}

.search-empty-state {
  padding: 30px;
  text-align: center;
  font-family: var(--font-ui);
  font-size: 13px;
  color: var(--text-muted);
}

.search-result-item {
  padding: 12px 16px;
  border-radius: var(--border-radius-sm);
  cursor: pointer;
  transition: background-color var(--transition-fast);
}

.search-result-item:hover {
  background-color: var(--bg-surface);
}

.search-result-header {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-ui);
  font-size: 12px;
  color: var(--accent-gold);
  font-weight: 600;
  margin-bottom: 4px;
}

.search-result-snippet {
  font-size: 13.5px;
  color: var(--text-main);
  line-height: 1.5;
}

.search-result-snippet mark {
  background-color: var(--accent-gold-bg);
  color: var(--accent-gold);
  font-weight: 700;
  padding: 1px 3px;
  border-radius: 3px;
}

/* Paragraph Spoken Highlight (Audiobook tracker) */
.book-paragraph.audio-active-paragraph {
  background-color: var(--accent-gold-bg);
  border-radius: 6px;
  box-shadow: 0 0 0 8px var(--accent-gold-bg);
  transition: all 0.3s ease;
}

/* ==========================================================================
   AUDIO FLOATING BAR (Advanced Natural Audiobook Mode)
   ========================================================================== */
.audio-floating-bar {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  box-shadow: var(--shadow-popup);
  padding: 10px 18px;
  display: flex;
  align-items: center;
  gap: 18px;
  z-index: 850;
  font-family: var(--font-ui);
  max-width: 94vw;
}

.audio-bar-left {
  display: flex;
  align-items: center;
}

.audio-status {
  display: flex;
  align-items: center;
  gap: 12px;
}

.audio-waves {
  display: flex;
  align-items: flex-end;
  gap: 2.5px;
  height: 16px;
}

.audio-waves span {
  width: 3px;
  background-color: var(--accent-gold);
  border-radius: 2px;
  animation: wave 1s ease-in-out infinite;
}
.audio-waves span:nth-child(1) { height: 6px; animation-delay: 0.1s; }
.audio-waves span:nth-child(2) { height: 16px; animation-delay: 0.3s; }
.audio-waves span:nth-child(3) { height: 10px; animation-delay: 0.2s; }
.audio-waves span:nth-child(4) { height: 13px; animation-delay: 0.4s; }

@keyframes wave {
  0%, 100% { transform: scaleY(0.35); }
  50% { transform: scaleY(1); }
}

.audio-info {
  display: flex;
  flex-direction: column;
}

.audio-label-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.audio-label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.audio-badge {
  font-size: 9.5px;
  background-color: var(--accent-gold-bg);
  color: var(--accent-gold);
  padding: 1px 5px;
  border-radius: 4px;
  font-weight: 700;
}

.audio-ch-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Audio Voice & Speed Selectors */
.audio-settings-row {
  display: flex;
  align-items: center;
  gap: 10px;
  border-left: 1px solid var(--border-subtle);
  border-right: 1px solid var(--border-subtle);
  padding: 0 14px;
}

.audio-select {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 4px 8px;
  border-radius: 6px;
  font-family: var(--font-ui);
  font-size: 12px;
  outline: none;
  max-width: 170px;
}

.audio-speed-group {
  display: flex;
  gap: 4px;
}

.audio-speed-btn {
  padding: 3px 7px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 4px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
}

.audio-speed-btn.active {
  background-color: var(--accent-gold);
  color: #ffffff;
  border-color: var(--accent-gold);
}

.audio-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.audio-action-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background-color: var(--bg-surface);
  color: var(--text-main);
  border: 1px solid var(--border-subtle);
}

.audio-action-btn:hover {
  background-color: var(--accent-gold);
  color: #fff;
  border-color: var(--accent-gold);
}

.audio-action-btn.play-pause-main {
  width: 36px;
  height: 36px;
  background-color: var(--accent-gold);
  color: #ffffff;
  border: none;
}

.audio-action-btn.play-pause-main:hover {
  background-color: var(--accent-hover);
  transform: scale(1.05);
}

.audio-action-btn.stop-btn {
  color: var(--text-muted);
}

@media (max-width: 768px) {
  .audio-floating-bar {
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    border-radius: 16px;
    padding: 8px 12px;
  }
  .audio-settings-row {
    border: none;
    padding: 0;
  }
}

/* ==========================================================================
   TOAST NOTIFICATION
   ========================================================================== */
.toast-notification {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background-color: var(--bg-card);
  border: 1px solid var(--accent-gold);
  color: var(--text-main);
  padding: 10px 18px;
  border-radius: var(--border-radius-sm);
  box-shadow: var(--shadow-popup);
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 500;
  z-index: 1200;
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   RESPONSIVE DESIGN (Mobil & Tablet)
   ========================================================================== */
@media (max-width: 900px) {
  .cover-canvas {
    grid-template-columns: 1fr;
    gap: 40px;
    text-align: center;
  }
  .book-3d-wrapper {
    margin-bottom: 20px;
  }
  .cover-badge {
    align-self: center;
  }
  .cover-actions {
    justify-content: center;
  }
  .chapter-article {
    padding: 30px 24px;
  }
  .chapter-main-title {
    font-size: 28px;
  }
  .open-book-spread {
    grid-template-columns: 1fr;
  }
  .book-middle-spine {
    display: none;
  }
  .book-page.left-page {
    border-bottom: 1px solid var(--border-subtle);
  }
}

@media (max-width: 600px) {
  .app-header {
    padding: 0 12px;
  }
  .btn-label, .book-mini-title {
    display: none;
  }
  .chapter-article {
    padding: 24px 16px;
  }
  .chapter-footer-nav {
    flex-direction: column;
  }
  .nav-ch-btn {
    width: 100%;
  }
}
