/* ============================================================
   Riwayti — Reading Interface (Enhanced)
   ============================================================ */

/* ── Layout ───────────────────────────────────────────────── */
.reader-container {
  max-width: 720px;
  margin: 0 auto;
  padding: 24px 20px 120px;
  min-height: calc(100vh - 60px);
}

/* ── Reader Header ────────────────────────────────────────── */
.reader-header {
  position: fixed; top: 60px; left: 0; right: 0;
  background: var(--bg-nav);
  border-bottom: 1px solid var(--border);
  padding: 8px 0; z-index: 200;
  transition: transform .28s cubic-bezier(.4,0,.2,1),
              opacity  .28s cubic-bezier(.4,0,.2,1);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.reader-header.hidden { transform: translateY(-100%); opacity: 0; }
.reader-header.show   { transform: translateY(0);    opacity: 1; }
.reader-header-content {
  max-width: 1200px; margin: 0 auto; padding: 0 16px;
  display: flex; align-items: center; justify-content: space-between;
}
.reader-breadcrumb {
  display: flex; align-items: center; gap: 6px;
  font-size: .8125rem; color: var(--text-muted); max-width: 45%;
}
.reader-breadcrumb a {
  color: var(--text-secondary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 180px;
}
.reader-breadcrumb a:hover { color: var(--orange); }
.reader-breadcrumb i { font-size: .5rem; flex-shrink: 0; }
.reader-controls { display: flex; align-items: center; gap: 6px; }
.reader-control-btn {
  padding: 6px 10px; background: var(--bg-alt);
  border-radius: var(--r-md); color: var(--text-secondary);
  font-size: .8125rem; display: flex; align-items: center; gap: 4px;
  transition: all .15s var(--ease);
  position: relative;
}
.reader-control-btn:hover  { background: var(--orange-light); color: var(--orange); }
.reader-control-btn.active { background: var(--orange); color: #fff; }

/* ── Reader Content Wrapper ──────────────────────────────── */
.reader-content-wrapper { padding-top: 20px; padding-bottom: 40px; }

.reader-book-info {
  text-align: center; margin-bottom: 32px;
  padding-bottom: 24px; border-bottom: 1px solid var(--border-light);
}
.reader-book-cover {
  width: 100px; height: 150px; object-fit: cover;
  border-radius: var(--r-md); box-shadow: var(--shadow-md);
  margin: 0 auto 12px;
}
.reader-book-title  { font-size: 1.125rem; margin-bottom: 4px; }
.reader-book-author { color: var(--text-muted); font-size: .8125rem; }

.reader-chapter-title { text-align: center; margin-bottom: 32px; }
.reader-chapter-number {
  font-size: .6875rem; color: var(--orange); font-weight: 700;
  text-transform: uppercase; letter-spacing: 1.5px; margin-bottom: 6px;
}
.reader-chapter-title h1 {
  font-family: var(--font-serif);
  font-size: clamp(1.5rem, 3vw, 2rem); font-weight: 700;
}

/* ── Reader Content ───────────────────────────────────────── */
.reader-content {
  font-family: var(--font-serif);
  color: var(--text);
  font-size: 18px;
  line-height: 1.9;
  word-wrap: break-word;
  overflow-wrap: break-word;
  overflow: visible;
  transition: font-size .2s, line-height .2s;
}

/* Sepia tint on body */
body.theme-sepia { background: #f5efe6; }
body.theme-sepia .reader-content { color: #3b2e1e; }
body.theme-sepia .reader-header,
body.theme-sepia .reader-progress { background: #ede4d5; border-color: #d4c5a9; }

/* RTL Arabic */
.reader-content.rtl,
.reader-content[dir="rtl"] {
  direction: rtl; text-align: right;
  font-family: 'Noto Naskh Arabic','Amiri','Scheherazade New',
               'Traditional Arabic','Tahoma', var(--font-serif);
  line-height: 2.1; font-size: 20px;
}
.reader-content p { margin-bottom: 1.4em; }

/* ── Highlight on text selection ────────────────────────── */
.reader-content ::selection { background: var(--orange); color: #fff; }

/* ── Reading Settings Sidebar (new — slides from right) ─── */
#reading-settings-panel {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: 300px; max-width: 90vw;
  background: var(--bg); border-left: 1px solid var(--border);
  z-index: 400; overflow-y: auto;
  transform: translateX(100%);
  transition: transform .3s cubic-bezier(.4,0,.2,1);
  box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column;
}
#reading-settings-panel.open { transform: translateX(0); }
.rsp-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.35); z-index: 399;
  backdrop-filter: blur(2px);
}
.rsp-overlay.open { display: block; }

.rsp-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--bg); z-index: 1;
}
.rsp-header h3 { font-size: .9375rem; font-weight: 700; }
.rsp-close {
  width: 30px; height: 30px; display: flex;
  align-items: center; justify-content: center;
  border-radius: var(--r-full); color: var(--text-muted);
  transition: background .15s;
}
.rsp-close:hover { background: var(--bg-alt); color: var(--text); }

.rsp-body { padding: 20px; flex: 1; display: flex; flex-direction: column; gap: 24px; }

.rsp-group label {
  display: block; font-size: .75rem; font-weight: 700;
  color: var(--text-muted); text-transform: uppercase;
  letter-spacing: .8px; margin-bottom: 10px;
}

/* Theme buttons */
.rsp-theme-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 8px; }
.rsp-theme-btn {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 10px 6px; border-radius: var(--r-md);
  border: 2px solid var(--border);
  font-size: .75rem; font-weight: 600; color: var(--text-secondary);
  transition: all .15s; cursor: pointer;
}
.rsp-theme-btn:hover { border-color: var(--orange); }
.rsp-theme-btn.active { border-color: var(--orange); color: var(--orange); }
.rsp-theme-swatch {
  width: 32px; height: 32px; border-radius: var(--r-md);
  border: 1px solid rgba(0,0,0,.1);
}
.swatch-light  { background: #ffffff; }
.swatch-dark   { background: #1a1a2e; }
.swatch-sepia  { background: #f5efe6; }

/* Font size stepper */
.rsp-stepper {
  display: flex; align-items: center; gap: 0;
  background: var(--bg-alt); border-radius: var(--r-md);
  overflow: hidden; border: 1px solid var(--border);
}
.rsp-stepper button {
  width: 40px; height: 40px; display: flex;
  align-items: center; justify-content: center;
  font-size: 1rem; color: var(--text-secondary);
  transition: background .15s;
  flex-shrink: 0;
}
.rsp-stepper button:hover { background: var(--orange-light); color: var(--orange); }
.rsp-stepper span {
  flex: 1; text-align: center; font-weight: 700;
  font-size: .9375rem; pointer-events: none;
}

/* Font family selector */
.rsp-font-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.rsp-font-btn {
  padding: 10px; border-radius: var(--r-md);
  border: 2px solid var(--border);
  font-size: .9375rem; color: var(--text-secondary);
  transition: all .15s; cursor: pointer;
  text-align: center; line-height: 1.3;
}
.rsp-font-btn:hover  { border-color: var(--orange); }
.rsp-font-btn.active { border-color: var(--orange); color: var(--orange); }
.rsp-font-btn[data-font="serif"]     { font-family: Georgia, 'Times New Roman', serif; }
.rsp-font-btn[data-font="sans"]      { font-family: system-ui, sans-serif; }
.rsp-font-btn[data-font="arabic"]    { font-family: 'Noto Naskh Arabic', 'Amiri', serif; }
.rsp-font-btn[data-font="mono"]      { font-family: 'Courier New', monospace; }

/* Line spacing slider */
.rsp-slider-wrap { display: flex; align-items: center; gap: 12px; }
.rsp-slider-wrap input[type=range] {
  flex: 1; accent-color: var(--orange); cursor: pointer;
}
.rsp-slider-val {
  font-weight: 700; font-size: .875rem;
  min-width: 32px; text-align: right;
}

/* Width slider */
.rsp-width-wrap { display: flex; flex-direction: column; gap: 8px; }
.rsp-width-btns { display: flex; gap: 8px; }
.rsp-width-btn {
  flex: 1; padding: 8px; border-radius: var(--r-md);
  border: 2px solid var(--border); font-size: .75rem; font-weight: 600;
  color: var(--text-secondary); transition: all .15s; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.rsp-width-btn:hover  { border-color: var(--orange); }
.rsp-width-btn.active { border-color: var(--orange); color: var(--orange); }
.rsp-width-icon { display: flex; gap: 2px; }
.rsp-width-icon span {
  height: 14px; background: currentColor; border-radius: 2px; opacity: .5;
}

/* Preview */
.rsp-preview {
  background: var(--bg-alt); border-radius: var(--r-md);
  padding: 14px; border: 1px solid var(--border);
  font-family: var(--font-serif); font-size: 15px;
  line-height: 1.8; color: var(--text);
  transition: font-size .2s, line-height .2s, font-family .2s;
  max-height: 100px; overflow: hidden;
}

/* ── Progress Bar ─────────────────────────────────────────── */
.reader-progress {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--bg-nav); border-top: 1px solid var(--border);
  padding: 6px 0; z-index: 200;
  transition: transform .28s cubic-bezier(.4,0,.2,1);
}
.reader-progress.hidden { transform: translateY(100%); }
.reader-progress-content {
  max-width: 720px; margin: 0 auto; padding: 0 16px;
  display: flex; align-items: center; gap: 12px;
}
.reader-progress-bar {
  flex: 1; height: 5px; background: var(--bg-alt);
  border-radius: var(--r-full); overflow: hidden;
}
.reader-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--orange), #e74c3c);
  border-radius: var(--r-full);
  transition: width .25s var(--ease);
}
.reader-progress-text {
  font-size: .6875rem; color: var(--text-muted);
  white-space: nowrap; font-weight: 600;
}

/* Time remaining badge */
#time-remaining {
  font-size: .6875rem; color: var(--text-muted);
  white-space: nowrap; display: none;
}

/* ── Quick Actions (desktop) ────────────────────────────── */
.reader-quick-actions {
  position: fixed; right: 16px; top: 50%;
  transform: translateY(-50%);
  display: flex; flex-direction: column; gap: 6px; z-index: 200;
}
.quick-action-btn {
  width: 42px; height: 42px; display: flex;
  align-items: center; justify-content: center;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--r-full); color: var(--text-secondary);
  font-size: 1rem; box-shadow: var(--shadow-sm);
  transition: all .18s var(--ease);
  position: relative;
}
.quick-action-btn:hover {
  background: var(--orange); border-color: var(--orange);
  color: #fff; transform: scale(1.12);
  box-shadow: 0 4px 12px rgba(230,126,34,.35);
}

/* ── Mobile Bottom Toolbar ──────────────────────────────── */
.reader-mobile-toolbar {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--bg-nav); border-top: 1px solid var(--border);
  z-index: 201; transition: transform .28s cubic-bezier(.4,0,.2,1);
}
.reader-mobile-toolbar.hidden { transform: translateY(100%); }
.rmt-progress {
  height: 3px; background: var(--bg-alt); width: 100%;
}
.rmt-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--orange), #e74c3c);
  transition: width .25s;
}
.rmt-actions {
  display: flex; align-items: center; justify-content: space-around;
  padding: 6px 8px 6px;
  padding-bottom: max(6px, env(safe-area-inset-bottom));
}
.rmt-btn {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 10px; border-radius: var(--r-md);
  color: var(--text-muted); font-size: .625rem; font-weight: 600;
  transition: color .15s, background .15s;
  -webkit-tap-highlight-color: transparent;
  min-width: 52px;
}
.rmt-btn i { font-size: 1.125rem; }
.rmt-btn:active, .rmt-btn:hover { color: var(--orange); background: var(--orange-light); }
.rmt-btn.nav-disabled { opacity: .35; pointer-events: none; }
.rmt-btn.active i { color: var(--orange); }
.rmt-chapter-info {
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  flex: 1; padding: 4px;
}
.rmt-chapter-label { font-size: .5625rem; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: .5px; }
.rmt-chapter-num   { font-size: .875rem; font-weight: 700; color: var(--text); }

/* ── Swipe hint (mobile, first time) ───────────────────── */
.swipe-hint {
  position: fixed; bottom: 72px; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,.75); color: #fff;
  padding: 8px 16px; border-radius: var(--r-full);
  font-size: .75rem; white-space: nowrap; z-index: 300;
  opacity: 0; pointer-events: none;
  transition: opacity .3s;
}
.swipe-hint.show { opacity: 1; }

/* ── Chapter Sidebar ────────────────────────────────────── */
.chapter-sidebar {
  position: fixed; top: 60px; left: 0;
  width: 320px; max-height: calc(100vh - 60px);
  background: var(--bg); border-right: 1px solid var(--border);
  z-index: 300; transform: translateX(-100%);
  transition: transform .3s cubic-bezier(.4,0,.2,1);
  overflow: hidden; display: flex; flex-direction: column;
  box-shadow: var(--shadow-lg);
}
.chapter-sidebar.show { transform: translateX(0); }
.chapter-sidebar-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
}
.chapter-sidebar-title { font-weight: 700; font-size: .9375rem; }
.chapter-sidebar-close {
  width: 28px; height: 28px; display: flex;
  align-items: center; justify-content: center;
  border-radius: var(--r-full); color: var(--text-muted);
}
.chapter-sidebar-close:hover { background: var(--bg-alt); color: var(--text); }
.chapter-sidebar-body { flex: 1; overflow-y: auto; padding: 8px; }

/* Search box inside sidebar */
.chapter-sidebar-search {
  padding: 8px 8px 4px;
}
.chapter-sidebar-search input {
  width: 100%; padding: 8px 12px; border-radius: var(--r-md);
  border: 1px solid var(--border); background: var(--bg-alt);
  color: var(--text); font-size: .8125rem;
  outline: none;
}
.chapter-sidebar-search input:focus { border-color: var(--orange); }

.chapter-sidebar-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: var(--r-md);
  transition: background .1s; color: var(--text);
}
.chapter-sidebar-item:hover  { background: var(--bg-alt); }
.chapter-sidebar-item.active { background: var(--orange-light); color: var(--orange); }
.chapter-sidebar-number {
  width: 28px; height: 28px; display: flex;
  align-items: center; justify-content: center;
  background: var(--bg-alt); border-radius: var(--r-full);
  font-size: .6875rem; font-weight: 700; flex-shrink: 0;
}
.chapter-sidebar-item.active .chapter-sidebar-number { background: var(--orange); color: #fff; }
.chapter-sidebar-info { flex: 1; min-width: 0; }
.chapter-sidebar-item-title {
  font-weight: 600; font-size: .8125rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chapter-sidebar-meta { font-size: .6875rem; color: var(--text-muted); }

/* ── Chapter Navigation ─────────────────────────────────── */
.reader-navigation {
  display: flex; justify-content: space-between; gap: 12px;
  margin-top: 40px; padding-top: 24px;
  border-top: 1px solid var(--border-light);
}
.reader-nav-btn {
  flex: 1; max-width: 280px; display: flex; align-items: center; gap: 12px;
  padding: 14px; background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--r-lg); transition: all .2s var(--ease); color: var(--text);
}
.reader-nav-btn:hover { border-color: var(--orange); box-shadow: var(--shadow-sm); color: var(--text); }
.reader-nav-btn.disabled { opacity: .4; pointer-events: none; }
.reader-nav-btn.next { margin-left: auto; text-align: right; }
.reader-nav-icon {
  width: 40px; height: 40px; display: flex;
  align-items: center; justify-content: center;
  background: var(--bg-alt); border-radius: var(--r-full);
  color: var(--text-secondary); font-size: 1rem;
  transition: all .15s; flex-shrink: 0;
}
.reader-nav-btn:hover .reader-nav-icon { background: var(--orange); color: #fff; }
.reader-nav-info   { flex: 1; min-width: 0; }
.reader-nav-label  { font-size: .6875rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; font-weight: 600; }
.reader-nav-title  { font-weight: 600; font-size: .875rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── Focus Mode ─────────────────────────────────────────── */
.focus-mode .reader-header,
.focus-mode .reader-quick-actions,
.focus-mode .main-header,
.focus-mode .main-footer {
  opacity: 0; pointer-events: none; transition: opacity .3s;
}
.focus-mode .reader-header:hover,
.focus-mode .reader-quick-actions:hover,
.focus-mode .main-header:hover { opacity: 1; pointer-events: auto; }

/* ── Glossary sidebar / modal (unchanged from original) ─── */
.glossary-sidebar-btn {
  display: flex; align-items: center; gap: 8px;
  width: 100%; padding: 10px 16px;
  border-top: 1px solid var(--border);
  font-size: .8125rem; font-weight: 600; color: var(--text);
}
.glossary-sidebar-panel { display: none; }
.glossary-sidebar-panel.open { display: block; }
.gsb-card {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; cursor: pointer; transition: background .1s;
}
.gsb-card:hover { background: var(--bg-alt); }
.gsb-avatar {
  width: 32px; height: 32px; border-radius: var(--r-full);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: .875rem; flex-shrink: 0;
}
.gsb-name { font-weight: 600; font-size: .8125rem; }
.gsb-role { font-size: .6875rem; color: var(--text-muted); }
.gsb-info { flex: 1; min-width: 0; }

/* ── Commentary markers / popovers ─────────────────────── */
.commentary-marker {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: var(--r-full);
  background: var(--orange-light); color: var(--orange);
  font-size: .625rem; margin-left: 6px;
  cursor: pointer; transition: all .15s;
  vertical-align: middle;
}
.commentary-marker:hover { background: var(--orange); color: #fff; transform: scale(1.15); }
.commentary-popover {
  position: fixed; width: 300px; z-index: 500;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.cp-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; background: var(--orange-light);
  border-bottom: 1px solid var(--border);
}
.cp-badge { font-size: .75rem; font-weight: 700; color: var(--orange); display: flex; align-items: center; gap: 5px; }
.cp-close { width: 24px; height: 24px; display: flex; align-items: center; justify-content: center; color: var(--text-muted); border-radius: var(--r-full); }
.cp-close:hover { background: var(--bg-alt); }
.cp-body { padding: 12px 14px; font-size: .875rem; line-height: 1.6; color: var(--text); }

/* ── Toast ──────────────────────────────────────────────── */
.commentary-toast {
  position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 12px 18px;
  font-size: .8125rem; font-weight: 600;
  box-shadow: var(--shadow-lg); z-index: 600;
  display: flex; align-items: center; gap: 8px;
  opacity: 0; transition: all .3s var(--ease); white-space: nowrap;
  max-width: 90vw;
}
.commentary-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.commentary-toast-success i { color: #27ae60; }
.commentary-toast-info    i { color: var(--orange); }
.commentary-toast-error   i { color: #e74c3c; }

/* ── Glossary modal ─────────────────────────────────────── */
.glossary-modal-bg {
  position: fixed; inset: 0; background: rgba(0,0,0,.5);
  z-index: 500; display: none; align-items: center; justify-content: center;
  padding: 20px;
}
.glossary-modal-bg.open .glossary-modal { transform: scale(1); opacity: 1; }
.glossary-modal {
  background: var(--bg-card); border-radius: var(--r-xl);
  width: 100%; max-width: 420px; overflow: hidden;
  box-shadow: var(--shadow-lg);
  transform: scale(.95); opacity: 0;
  transition: all .2s var(--ease);
}
.glossary-modal-header {
  display: flex; align-items: center; gap: 14px;
  padding: 20px; border-bottom: 1px solid var(--border);
}
.glossary-modal-avatar {
  width: 48px; height: 48px; border-radius: var(--r-full);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 1.25rem; font-weight: 700; flex-shrink: 0;
}
.glossary-modal-name  { font-size: 1rem; font-weight: 700; }
.glossary-modal-role  { font-size: .8125rem; color: var(--text-muted); }
.glossary-modal-close {
  margin-left: auto; width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--r-full); color: var(--text-muted);
}
.glossary-modal-close:hover { background: var(--bg-alt); color: var(--text); }
.glossary-modal-body  { padding: 20px; }
.glossary-modal-desc  { font-size: .9375rem; line-height: 1.6; margin: 0; }
.glossary-first-appears { margin-top: 14px; font-size: .8125rem; color: var(--text-muted); display: flex; align-items: center; gap: 4px; }
.glossary-first-appears a { color: var(--orange); }

/* ── Emotion Picker ─────────────────────────────────────── */
.emotion-picker-wrap {
  margin-top: 40px; padding: 24px;
  background: var(--bg-alt); border-radius: var(--r-xl);
  border: 1px solid var(--border-light);
}
.emotion-picker-label { text-align: center; font-weight: 700; margin-bottom: 16px; font-size: .9375rem; }
.emotion-picker-grid  { display: grid; grid-template-columns: repeat(3,1fr); gap: 8px; }
.emotion-btn {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 12px 8px; border-radius: var(--r-md);
  border: 2px solid var(--border); transition: all .15s;
  cursor: pointer;
}
.emotion-btn:hover  { border-color: var(--em-color, var(--orange)); transform: translateY(-2px); }
.emotion-btn.active { border-color: var(--em-color, var(--orange)); background: color-mix(in srgb, var(--em-color, var(--orange)) 12%, transparent); }
.emotion-emoji { font-size: 1.5rem; }
.emotion-label { font-size: .6875rem; font-weight: 600; color: var(--text-secondary); }
.emotion-save-wrap { display: flex; gap: 8px; margin-top: 12px; justify-content: center; }
.emotion-save-btn {
  padding: 8px 20px; background: var(--orange); color: #fff;
  border-radius: var(--r-md); font-size: .875rem; font-weight: 700;
  transition: opacity .15s;
}
.emotion-save-btn:hover { opacity: .88; }
.emotion-clear-btn { padding: 8px 20px; background: var(--bg-alt); border: 1px solid var(--border); border-radius: var(--r-md); font-size: .875rem; font-weight: 600; color: var(--text-secondary); }
.emotion-saved-msg { text-align: center; margin-top: 10px; font-size: .8125rem; color: #27ae60; display: flex; align-items: center; justify-content: center; gap: 5px; }

/* ── Mobile responsive ──────────────────────────────────── */
@media (max-width: 768px) {
  .reader-mobile-toolbar { display: flex; flex-direction: column; }
  .reader-progress       { display: none; }
  .reader-quick-actions  { display: none; }

  .chapter-sidebar {
    width: 100%; max-height: 65vh;
    top: auto; bottom: 0; left: 0; right: 0;
    border-right: none; border-top: 1px solid var(--border);
    transform: translateY(100%);
    border-radius: var(--r-xl) var(--r-xl) 0 0;
  }
  .chapter-sidebar.show { transform: translateY(0); }

  .reader-content       { font-size: 16px; }
  .reader-content.rtl,
  .reader-content[dir="rtl"] { font-size: 18px; }

  .reader-navigation { flex-direction: column; }
  .reader-nav-btn    { max-width: 100%; }
  .reader-nav-btn.next { margin-left: 0; }

  .reader-container { padding-bottom: 80px; }
  #reading-settings-panel { width: 100%; max-width: 100%; top: auto; border-radius: var(--r-xl) var(--r-xl) 0 0; max-height: 85vh; }
}

@media (max-width: 480px) {
  .reader-chapter-title h1 { font-size: 1.375rem; }
  .emotion-picker-grid { grid-template-columns: repeat(3,1fr); }
}

@media (min-width: 769px) {
  /* Desktop: keep original progress bar */
  .reader-mobile-toolbar { display: none !important; }
}

/* ── Dark mode overlay for sidebar ─────────────────────── */
.sidebar-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.4); z-index: 299;
}
.sidebar-overlay.show { display: block; }
