/* ── Reset & Variables ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #f5f4f0;
  --surface: #ffffff;
  --surface2: #f0ede8;
  --border: #ddd8d0;
  /* --input-border: separate from decorative --border; meets WCAG 1.4.11 3:1 on all surfaces */
  /* #706c68 on #fff=5.21, on --bg=4.73, on --surface2=4.46 — all ✅ */
  --input-border: #706c68;
  --text: #1a1814;
  --text2: #5a5650;
  /* #6e6b66 on #f5f4f0=4.82, on --surface=5.31, on --surface2=4.54 — all ✅ */
  --text3: #6e6b66;
  --accent: #ff5206;
  --accent-hover: #e04800;
  --accent-light: #fff0eb;
  /* --on-accent: text on accent buttons (bold 15px+, 3:1 min for large/bold text) */
  --on-accent: #ffffff;
  --danger: #c0392b;
  --danger-light: #fdf0ee;
  --reading: #fff3cd;
  /* #8c7000 on #fff3cd = 4.28:1 ✅ */
  --reading-border: #8c7000;
  --bar-bg: #e8e4de;
  --bar-fill: #ff5206;
  --focus-ring: #ff5206;
  --font-title: 'Playfair Display', Georgia, 'Times New Roman', serif;
  --font-body: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --radius: 8px;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
}

/* Sistema en dark Y sin override manual a light */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141417;
    --surface: #1e1e22;
    --surface2: #28282d;
    --border: #35353b;
    --input-border: #7e7870;
    --text: #f0ede8;
    --text2: #c0b8a8;
    --text3: #969490;
    --accent: #ff5206;
    --accent-hover: #ff7340;
    --accent-light: #2a1200;
    --on-accent: #ffffff;
    --danger: #d42e22;
    --danger-light: #3a1a18;
    --reading: #3a3010;
    --reading-border: #c8a020;
    --bar-bg: #3a3630;
    --bar-fill: #ff5206;
    --focus-ring: #ff7340;
    --shadow: 0 2px 8px rgba(0,0,0,0.3);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.4);
  }
}

/* Toggle manual: forzar dark aunque el sistema sea light */
:root[data-theme="dark"] {
  --bg: #141417;
  --surface: #1e1e22;
  --surface2: #28282d;
  --border: #35353b;
  --input-border: #7e7870;
  --text: #f0ede8;
  --text2: #c0b8a8;
  --text3: #969490;
  --accent: #ff5206;
  --accent-hover: #ff7340;
  --accent-light: #2a1200;
  --on-accent: #ffffff;
  --danger: #d42e22;
  --danger-light: #3a1a18;
  --reading: #3a3010;
  --reading-border: #c8a020;
  --bar-bg: #3a3630;
  --bar-fill: #ff5206;
  --focus-ring: #ff7340;
  --shadow: 0 2px 8px rgba(0,0,0,0.3);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.4);
}

/* Toggle manual: forzar light aunque el sistema sea dark */
:root[data-theme="light"] {
  --bg: #f5f4f0;
  --surface: #ffffff;
  --surface2: #f0ede8;
  --border: #ddd8d0;
  --input-border: #706c68;
  --text: #1a1814;
  --text2: #5a5650;
  --text3: #6e6b66;
  --accent: #ff5206;
  --accent-hover: #e04800;
  --accent-light: #fff0eb;
  --on-accent: #ffffff;
  --danger: #c0392b;
  --danger-light: #fdf0ee;
  --reading: #fff3cd;
  --reading-border: #8c7000;
  --bar-bg: #e8e4de;
  --bar-fill: #ff5206;
  --focus-ring: #ff5206;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
}

/* ── Skip link (WCAG 2.4.1) ──────────────────────────────────────────────── */
.skip-link {
  position: absolute;
  top: -100px;
  left: 16px;
  z-index: 9999;
  background: var(--accent);
  color: var(--on-accent); /* 8.51:1 light, 8.44:1 dark ✅ */
  padding: 8px 16px;
  border-radius: 0 0 8px 8px;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  transition: top 0.15s;
}
.skip-link:focus { top: 0; outline: 3px solid var(--focus-ring); outline-offset: 2px; }

/* ── Placeholder text — force opacity:1 so browser doesn't dim to ~54% (WCAG 1.4.3) ── */
::placeholder { color: var(--text3); opacity: 1; }

/* ── Screen-reader only (visually hidden) ────────────────────────────────── */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* ── Global focus styles (WCAG 2.4.7) ───────────────────────────────────── */
:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
  border-radius: 4px;
}

html {
  overflow-x: clip;  /* clip: no afecta position:fixed (a diferencia de hidden) */
  max-width: 100vw;
}
html, body {
  height: 100%;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
}

/* Serif headings */
h1, h2, h3, .auth-brand span, .lib-header h1, .reader-book-title {
  font-family: var(--font-title);
  letter-spacing: -0.01em;
}

/* ── Layout ──────────────────────────────────────────────────────────────── */
#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* main must be a flex item so child views can fill the remaining height */
main#main-content {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ── Top Nav ─────────────────────────────────────────────────────────────── */
#top-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 10;
  /* Contener el ancho exactamente al viewport */
  width: 100%;
  box-sizing: border-box;
  min-width: 0;
}

#top-nav .nav-brand {
  font-family: var(--font-title);
  font-weight: 700;
  font-size: 18px;
  color: var(--accent);
  margin-right: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  letter-spacing: -0.01em;
}

.nav-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: var(--radius);
  border: none;
  background: transparent;
  color: var(--text2);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s;
}
.nav-tab:hover { background: var(--surface2); color: var(--text); }
.nav-tab.active { background: var(--accent-light); color: var(--accent); font-weight: 600; }
.nav-tab i { font-size: 17px; }

.nav-spacer { flex: 1; }

/* ── Views ───────────────────────────────────────────────────────────────── */
.view { flex: 1; overflow: hidden; display: flex; flex-direction: column; }
.view.hidden { display: none !important; }

/* ── Library ─────────────────────────────────────────────────────────────── */
#view-library {
  padding: 20px;
  overflow-y: auto;
  overflow-x: hidden;
}

.lib-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
}
.lib-header h1 {
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
  flex: 1;
}

/* Search bar */
.lib-searchbar-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
}
.lib-searchbar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--input-border); /* 3:1+ on all surfaces ✅ */
  border-radius: 24px;
  padding: 0 16px;
  height: 48px;
  flex: 1;
}
.lib-searchbar i { font-size: 18px; color: var(--text3); flex-shrink: 0; }
.lib-searchbar input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 14px;
  color: var(--text);
  outline: none;
}
.lib-searchbar input::placeholder { color: var(--text3); }

/* Add book button (56×56 orange, in library view) */
.btn-add-book {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: 16px;
  border: none;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s;
}
.btn-add-book i { font-size: 26px; }
.btn-add-book:hover { background: var(--accent-hover); }

/* Book limit progress bar */
.lib-storage-bar {
  margin-top: 24px;
  padding: 0 4px;
}
.lib-storage-inner {
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.lib-storage-row {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.lib-storage-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--text3);
  margin-bottom: 6px;
}
.lib-storage-warn {
  font-weight: 600;
  color: var(--error, #c0392b);
}
.lib-storage-track {
  height: 6px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
}
.lib-storage-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 99px;
  transition: width 0.4s ease;
}
.lib-storage-fill.lib-storage-full {
  background: var(--error, #c0392b);
}
.lib-storage-tip {
  margin-top: 5px;
  font-size: 11px;
  color: var(--error, #c0392b);
  text-align: center;
}

/* Search result highlight */
mark {
  background: var(--reading);
  color: var(--text);
  border-radius: 2px;
  padding: 0 1px;
}

/* Drop zone as a grid card */
.drop-card {
  cursor: pointer;
}
.drop-cover {
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px dashed var(--border);
  border-radius: 6px;
  background: var(--surface2);
  transition: all 0.2s;
  color: var(--text3);
  font-size: 28px;
}
.drop-card:hover .drop-cover,
.drop-card.drag-over .drop-cover {
  border-color: var(--accent);
  background: var(--accent-light);
  color: var(--accent);
}

/* Book grid */
#lib-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 20px;
}

#lib-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text3);
  padding: 60px 20px;
}
#lib-empty i { font-size: 48px; }
#lib-empty p { font-size: 15px; }

/* Book card */
.book-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  cursor: default;
}

.book-cover {
  position: relative;
  cursor: pointer;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: var(--shadow);
  aspect-ratio: 2/3;
  background: var(--surface2);
  transition: transform 0.15s, box-shadow 0.15s;
}
.book-cover:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }

.book-cover-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.book-cover-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  color: var(--text3);
}

.book-fmt-badge {
  position: absolute;
  bottom: 5px;
  right: 5px;
  background: rgba(0,0,0,0.55);
  color: #fff;
  border-radius: 4px;
  padding: 2px 4px;
  font-size: 11px;
  line-height: 1;
}

.book-info { display: flex; flex-direction: column; gap: 3px; }
.book-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.book-author { font-size: 11px; color: var(--text3); }

.book-progress-bar {
  height: 3px;
  background: var(--bar-bg);
  border-radius: 2px;
  overflow: hidden;
}
.book-progress-fill {
  height: 100%;
  background: var(--bar-fill);
  border-radius: 2px;
  transition: width 0.3s;
}

.book-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text3);
}

/* Drag handle (visible on hover) */
.book-drag-handle {
  position: absolute;
  top: 6px;
  left: 6px;
  width: 24px;
  height: 24px;
  border-radius: 4px;
  background: rgba(0,0,0,0.45);
  color: rgba(255,255,255,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  opacity: 0;
  transition: opacity 0.15s;
  cursor: grab;
  z-index: 2;
}
.book-card:hover .book-drag-handle { opacity: 1; }
.book-card.dragging { opacity: 0.4; transform: scale(0.97); }
.book-card.drop-before { border-left: 3px solid var(--accent); margin-left: -3px; border-radius: 0 6px 6px 0; }
.book-card.drop-after  { border-right: 3px solid var(--accent); margin-right: -3px; border-radius: 6px 0 0 6px; }

/* ── Reader ──────────────────────────────────────────────────────────────── */
#view-reader {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.reader-topbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.reader-topbar .book-title-bar {
  flex: 1;
  font-weight: 600;
  font-size: 15px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.reader-topbar .book-author-bar { font-size: 12px; color: var(--text3); }

#reader-progress-fill {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 2px;
  background: var(--accent);
  transition: width 0.4s;
}
.reader-topbar { position: relative; }

/* Main area: content + sidebar */
.reader-main {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* E-reader content */
#reader-content-wrap {
  flex: 1;
  overflow-y: auto;
  padding: 32px 20px;
  background: var(--bg);
}

#reader-content {
  max-width: 680px;
  margin: 0 auto;
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 17px;
  line-height: 1.8;
  color: var(--text);
}

/* Divisor visual de página — solo visual, aria-hidden para TTS */
.page-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 20px 0 16px;
  user-select: none;
  pointer-events: none;
}
.page-divider::before,
.page-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}
.page-divider-label {
  font-size: 10px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text3);
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--bg);
  white-space: nowrap;
}

.reader-para {
  text-align: justify;
  text-indent: 1.5em;
  margin-bottom: 0.4em;
  cursor: pointer;
  border-radius: 4px;
  padding: 2px 6px;
  transition: background 0.15s;
}
.reader-para:hover { background: var(--surface2); }
.reader-para.reading {
  background: var(--reading);
  border-left: 3px solid var(--reading-border);
  text-indent: calc(1.5em - 3px);
  padding-left: 9px;
}

/* Sidebar */
#reader-sidebar {
  width: 260px;
  border-left: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
}

.sidebar-section {
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.sidebar-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text3);
  padding: 10px 14px 6px;
}
/* Row that holds a section title + action button */
.sidebar-section-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-right: 6px;
}
.sidebar-section-title-row .sidebar-section-title { padding-right: 0; }

/* TTS controls */
#tts-controls {
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.tts-btns {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.tts-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.tts-row label { font-size: 12px; color: var(--text3); white-space: nowrap; }
.tts-row select, .tts-row input[type=range] { flex: 1; }
/* Fila de checkbox — label ocupa el espacio disponible */
.tts-row-check { justify-content: space-between; }
.tts-row-check label { flex: 1; cursor: pointer; }
.tts-row-check input[type=checkbox] {
  width: 16px; height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
}

select {
  background: var(--surface2);
  border: 1px solid var(--input-border); /* WCAG 1.4.11: 3:1+ on all surfaces ✅ */
  border-radius: 6px;
  color: var(--text);
  font-size: 13px;
  padding: 4px 8px;
  width: 100%;
}
select:focus { outline: 2px solid var(--accent); }

input[type=range] {
  accent-color: var(--accent);
}

/* Translation panel */
#translation-panel {
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.tr-row { display: flex; gap: 6px; align-items: center; }
.tr-row label { font-size: 12px; color: var(--text3); }
.tr-langs { display: flex; gap: 6px; }
.tr-langs select { flex: 1; }
.tr-modes {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.tr-mode-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
  width: 100%;
  text-align: left;
}
.tr-mode-btn:hover { background: var(--accent-light); border-color: var(--accent); color: var(--accent); }
.tr-mode-btn i { font-size: 16px; flex-shrink: 0; }

.tr-progress-bar {
  height: 4px;
  background: var(--bar-bg);
  border-radius: 2px;
  overflow: hidden;
  display: none;
}
.tr-progress-bar.active { display: block; }
.tr-progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.3s;
  width: 0%;
}
#tr-progress-info { font-size: 11px; color: var(--text3); }

/* Bookmark list */
#bookmark-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.bm-empty { font-size: 13px; color: var(--text3); padding: 10px 0; }

.bm-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
  border-radius: 6px;
  overflow: hidden;
}
.bm-bar-wrap {
  height: 2px;
  background: var(--bar-bg);
  border-radius: 2px;
}
.bm-bar-fill {
  height: 100%;
  background: var(--bar-fill);
  border-radius: 2px;
}
.bm-row {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 6px;
  background: var(--surface2);
  border-radius: 0 0 6px 6px;
}
.bm-name {
  flex: 1;
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bm-name:hover { color: var(--accent); }
.bm-actions { display: flex; gap: 2px; }

/* Bottom bar — outer wrapper is full-width surface, no border here */
.reader-bottombar {
  background: var(--surface);
  font-size: 13px;
  color: var(--text3);
  flex-shrink: 0;
  padding: 0 20px 6px;   /* matches reader-content-wrap horizontal padding */
}

/* Inner wrapper constrained to text width — the border-top appears only here */
.reader-bottombar-inner {
  max-width: 680px;       /* matches #reader-content max-width */
  margin: 0 auto;
  border-top: 1px solid var(--border);
  padding-top: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

#reader-page { font-size: 13px; color: var(--text3); white-space: nowrap; padding: 0 4px; }
#reader-page.page-hidden { visibility: hidden; } /* preserve space when hidden */

.reader-save-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text3);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.reader-save-btn:hover { background: var(--surface2); color: var(--text); border-color: var(--input-border); }
.reader-save-btn.saved { color: var(--accent); border-color: var(--accent); background: var(--accent-light); }
.reader-save-btn i { font-size: 15px; }

.page-nav { display: flex; align-items: center; gap: 4px; }
.page-nav input {
  width: 52px;
  text-align: center;
  background: var(--surface2);
  border: 1px solid var(--input-border); /* WCAG 1.4.11 ✅ */
  border-radius: 6px;
  color: var(--text);
  font-size: 13px;
  padding: 3px 6px;
}

/* ── Text Tab ────────────────────────────────────────────────────────────── */
#view-text {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.text-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  flex-shrink: 0;
}

/* Outer scroll container — centers reading area */
.text-tts-area {
  flex: 1;
  display: flex;
  justify-content: center;
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--bg);
  padding: 24px 40px 24px 24px; /* right padding for resize handle */
}

/* Reading area — constrained width, resizable */
.text-reading-area {
  position: relative;
  display: flex;
  flex-direction: column;
  width: var(--reading-width, 65ch);
  min-width: 280px;
  max-width: 100%;
  flex-shrink: 0;
}

/* Resize handle — vertical bar on the right edge */
.text-resize-handle {
  position: absolute;
  right: -20px;
  top: 0;
  bottom: 0;
  width: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: col-resize;
  opacity: 0;
  transition: opacity 0.2s;
  user-select: none;
  z-index: 10;
}
.text-reading-area:hover .text-resize-handle,
.text-resize-handle.active { opacity: 1; }

.text-resize-grip {
  width: 4px;
  height: 48px;
  border-radius: 2px;
  background: var(--border);
  transition: background 0.15s, width 0.15s;
}
.text-resize-handle:hover .text-resize-grip,
.text-resize-handle.active .text-resize-grip {
  width: 5px;
  background: var(--accent);
}

/* Input and preview fill their reading area */
#text-input-wrap, #text-preview-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

#text-input {
  flex: 1;
  min-height: 0; /* let flex:1 control height, not a fixed minimum */
  background: var(--surface);
  border: 1px solid var(--input-border); /* WCAG 1.4.11 ✅ */
  border-radius: 8px;
  color: var(--text);
  font-size: 16px;
  line-height: 1.75;
  padding: 20px 24px;
  resize: none;
  font-family: Georgia, 'Times New Roman', serif;
}
#text-input:focus { outline: 2px solid var(--accent); }

#text-preview {
  flex: 1;
  min-height: 0; /* let flex:1 control height */
  overflow-y: auto;
  padding: 20px 24px;
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 16px;
  line-height: 1.8;
}
#text-preview h1, #text-preview h2, #text-preview h3 {
  font-family: inherit;
  margin: 1em 0 0.4em;
  color: var(--text);
}
#text-preview p { margin-bottom: 0.8em; }
#text-preview code {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 0.9em;
  font-family: monospace;
}
#text-preview pre code {
  display: block;
  padding: 12px;
  overflow-x: auto;
  border-radius: 6px;
}

/* Mobile: full width, no resize */
@media (max-width: 700px) {
  .text-tts-area { padding: 12px; }
  .text-reading-area { width: 100% !important; }
  .text-resize-handle { display: none; }
}

.text-bottom {
  border-top: 1px solid var(--border);
  padding: 10px 14px;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
}
.text-bottom-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.text-bottom-row label { font-size: 12px; color: var(--text3); white-space: nowrap; }
.text-bottom-row select { max-width: 180px; }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 20px;
  height: 48px;
  border-radius: 24px;
  border: none;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.btn-primary { background: var(--accent); color: var(--on-accent); height: 56px; border-radius: 32px; padding: 0 28px; font-size: 15px; } /* 8.51:1 light, 8.44:1 dark ✅ */
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-ghost { background: transparent; color: var(--text2); border: 1px solid transparent; }
.btn-ghost:hover { background: var(--surface2); border-color: var(--border); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(1.1); }
.btn-upgrade {
  background: linear-gradient(135deg, #ff9a3c, #ff5206);
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  gap: 5px;
  padding: 6px 12px;
}
.btn-upgrade:hover { filter: brightness(1.08); }
.btn-upgrade i { font-size: 14px; }

/* Premium crown badge in nav (shown instead of upgrade btn for premium users) */
.nav-premium-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px; height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ff9a3c, #ff5206);
  color: #fff;
  font-size: 14px;
  flex-shrink: 0;
  title: "CatsReading Premium";
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--text2);
  cursor: pointer;
  transition: all 0.15s;
  font-size: 0; /* hide any extra text */
}
.btn-icon i { font-size: 18px; }
.btn-icon:hover { background: var(--surface2); color: var(--text); }
.btn-icon.btn-danger-ghost:hover { background: var(--danger-light); color: var(--danger); }
.btn-icon.lg { width: 40px; height: 40px; }
.btn-icon.lg i { font-size: 22px; }
.btn-icon.primary { background: var(--accent); color: var(--on-accent); } /* 8.51:1 light, 8.44:1 dark ✅ */
.btn-icon.primary:hover { background: var(--accent-hover); }

.mode-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text2);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}
.mode-btn.active { background: var(--accent-light); color: var(--accent); border-color: var(--accent); }
.mode-btn:hover { background: var(--surface2); }

/* ── Modals ──────────────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}
.modal-backdrop.open { display: flex; }

.modal {
  background: var(--surface);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  padding: 24px;
  max-width: 480px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.modal h2 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}
.modal p { font-size: 14px; color: var(--text2); }
.modal-snippet {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 13px;
  color: var(--text2);
  font-family: Georgia, serif;
  max-height: 160px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.fm-para {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.fm-page-tag {
  font-size: 10px;
  font-family: -apple-system, sans-serif;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
  background: var(--accent-light);
  border-radius: 3px;
  padding: 1px 5px;
  display: inline-block;
  width: fit-content;
}
.modal-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.modal-row label { font-size: 13px; color: var(--text2); white-space: nowrap; }
.modal-row input[type=number] {
  width: 72px;
  background: var(--surface2);
  border: 1px solid var(--input-border); /* WCAG 1.4.11 ✅ */
  border-radius: 6px;
  color: var(--text);
  font-size: 14px;
  padding: 5px 8px;
  text-align: center;
}
.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

/* Export modal option cards */
.export-options { display: flex; gap: 12px; flex-wrap: wrap; }
.export-option {
  flex: 1;
  min-width: 160px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface2);
  cursor: pointer;
  transition: all 0.15s;
  text-align: left;
}
.export-option:hover { border-color: var(--accent); background: var(--accent-light); }
.export-option i { font-size: 24px; color: var(--accent); }
.export-option strong { font-size: 14px; font-weight: 600; color: var(--text); }
.export-option span { font-size: 12px; color: var(--text2); }

/* Translation result modal */
#tr-result-preview {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px;
  font-size: 13px;
  font-family: Georgia, serif;
  white-space: pre-wrap;
  max-height: 180px;
  overflow-y: auto;
  color: var(--text2);
}

/* ── Toast ───────────────────────────────────────────────────────────────── */
#toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--text);
  color: var(--bg);
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  opacity: 0;
  transition: all 0.25s;
  pointer-events: none;
  z-index: 200;
  white-space: nowrap;
  max-width: 90vw;
}
#toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
#toast.toast-error { background: var(--danger); color: #fff; }
#toast.toast-success { background: #2d7a3a; color: #fff; }
#toast.toast-info { background: var(--accent); color: #fff; }

/* ── Hidden file input ───────────────────────────────────────────────────── */
#lib-file-input { display: none; }

/* ── Scrollbars ──────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text3); }

/* ── Mobile-only / desktop-only helpers ──────────────────────────────────── */
.mobile-only  { display: none; }
.desktop-only { display: flex; }

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 700px) {
  .mobile-only  { display: flex; }
  .desktop-only { display: none !important; }

  #reader-sidebar { display: none; }
  #lib-grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }

  /* Minimum 44×44px touch targets (WCAG 2.5.5) */
  .btn-icon { width: 44px; height: 44px; }
  .btn-icon.lg { width: 48px; height: 48px; }
  .nav-tab { padding: 10px 14px; min-height: 44px; }
  .btn { min-height: 44px; }
  .tr-mode-btn { min-height: 44px; }

  /* Nav compacto en móvil */
  .nav-tab span:not([data-i18n="nav.brand"]) { display: none; }
  #top-nav { gap: 2px; padding: 6px 8px; }
  /* Forzar que todos los hijos del nav puedan encogerse */
  #top-nav > * { min-width: 0; flex-shrink: 1; }
  /* Excepciones: brand y menu-wrap no se encogen */
  #top-nav .nav-brand { flex-shrink: 0; }
  #nav-menu-wrap { flex-shrink: 0; }
  /* Sobreescribir el margin-right del nav-brand (misma especificidad, última regla gana) */
  #top-nav .nav-brand { margin-right: 2px; }
  .nav-brand span { display: none; }
  .nav-spacer { min-width: 0; }

  /* Auth card sin padding excesivo */
  .auth-card { padding: 28px 20px; border-radius: 12px; }

  /* iPhone safe area: evitar que el contenido quede detrás del home bar */
  #top-nav {
    padding-left: max(8px, env(safe-area-inset-left));
    padding-right: max(8px, env(safe-area-inset-right));
  }
  #view-library, #view-text {
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
  }
  .feedback-float-btn {
    bottom: max(24px, calc(env(safe-area-inset-bottom) + 12px));
    right: max(16px, env(safe-area-inset-right));
  }

  /* Dropdown: en móvil usar fixed para evitar recorte por overflow */
  .nav-dropdown {
    position: fixed;
    top: 56px;   /* altura aproximada del nav */
    right: 8px;
    left: auto;
    max-height: calc(100vh - 72px);
    overflow-y: auto;
  }

  /* Plan cards: columna en lugar de fila en pantallas pequeñas */
  .settings-plans-grid {
    grid-template-columns: 1fr;
    gap: 6px;
  }
  .settings-plan-card {
    flex-direction: row;
    align-items: center;
    gap: 12px;
    text-align: left;
  }
  .settings-plan-card-features {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 4px;
  }
}

/* ── Mobile Bottom Sheet ─────────────────────────────────────────────────── */
.mobile-sheet-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 200;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  opacity: 0;
  transition: opacity 0.25s ease;
}
.mobile-sheet-backdrop.open {
  display: block;
  opacity: 1;
}

.mobile-sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 201;
  background: var(--surface);
  border-top: 1px solid var(--border);
  border-radius: 18px 18px 0 0;
  padding-bottom: env(safe-area-inset-bottom, 16px);
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
  max-height: 85vh;
  display: flex;
  flex-direction: column;
}
.mobile-sheet.open {
  transform: translateY(0);
}

.mobile-sheet-handle {
  width: 40px;
  height: 4px;
  background: var(--border);
  border-radius: 99px;
  margin: 12px auto 0;
  cursor: grab;
  flex-shrink: 0;
}

.mobile-sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px 10px;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
}
.mobile-sheet-title {
  font-weight: 600;
  font-size: 16px;
}

.mobile-sheet-body {
  overflow-y: auto;
  padding: 16px 20px;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* ── Reduced motion (WCAG 2.3.3) ────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ── Inert backdrop dimming for modals ───────────────────────────────────── */
#app[inert] { pointer-events: none; }
.modal-backdrop[aria-hidden="false"] { display: flex; }
.modal-backdrop[aria-hidden="true"]  { display: none; }

/* ── Auth screen ─────────────────────────────────────────────────────────── */
#view-auth {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 1000;
}

.auth-card {
  background: transparent;
  border: none;
  border-radius: 16px;
  box-shadow: none;
  padding: 36px 32px;
  width: 100%;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 22px;
  font-weight: 700;
  color: var(--accent);
}
.auth-brand i { font-size: 28px; }

/* Logo images */
.nav-logo  { width: 28px; height: 28px; object-fit: contain; }
.auth-logo { width: 48px; height: 48px; object-fit: contain; }

.auth-subtitle {
  font-size: 14px;
  color: var(--text3);
  margin-top: -12px;
}

.auth-tabs {
  display: flex;
  border-bottom: 2px solid var(--border);
  gap: 0;
}
.auth-tab {
  flex: 1;
  background: none;
  border: none;
  padding: 10px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text3);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.15s;
}
.auth-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
}
.auth-tab:hover:not(.active) { color: var(--text); }

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.auth-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.auth-field label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text2);
}
.auth-field input {
  background: var(--surface2);
  border: 1px solid var(--input-border);
  border-radius: 24px;
  color: var(--text);
  font-size: 15px;
  padding: 0 16px;
  height: 48px;
  width: 100%;
  transition: border-color 0.15s;
}
.auth-field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 15%, transparent);
}

.auth-btn {
  width: 100%;
  justify-content: center;
  font-size: 15px;
  margin-top: 4px;
}

.auth-error {
  background: var(--danger-light);
  color: var(--danger);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  border: 1px solid color-mix(in srgb, var(--danger) 20%, transparent);
}

.auth-info {
  background: var(--accent-light);
  color: var(--accent);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  border: 1px solid color-mix(in srgb, var(--accent) 20%, transparent);
}

.auth-switch {
  font-size: 13px;
  color: var(--text3);
  text-align: center;
}
.auth-switch a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}

/* Privacy disclaimer (shown only in signup mode) */
.auth-disclaimer {
  font-size: 11px;
  line-height: 1.55;
  color: var(--text3);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  margin: 0;
}

/* Smooth appear for signup extras */
#auth-signup-extras {
  display: flex;
  flex-direction: column;
  gap: 12px;
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.auth-switch a:hover { text-decoration: underline; }

/* ── Banner modo invitado ───────────────────────────────────────────────── */
.guest-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: var(--accent-light);
  border-bottom: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
  font-size: 13px;
  color: var(--text2);
  flex-shrink: 0;
}
.guest-banner i { color: var(--accent); font-size: 16px; flex-shrink: 0; }
.guest-banner span { flex: 1; }
.btn-sm { padding: 5px 12px; font-size: 12px; white-space: nowrap; }

/* ── Auth divider ────────────────────────────────────────────────────────── */
.auth-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text3);
  font-size: 12px;
}
.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}
.auth-guest-btn {
  border: 1px solid var(--input-border);
  color: var(--text2);
}
.auth-guest-btn:hover { background: var(--surface2); }

/* Botón de Google OAuth */
.btn-google {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--input-border);
  display: flex; align-items: center; justify-content: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 500;
}
.btn-google:hover { background: var(--surface2); }

/* ── Usuario en el nav (ahora es un botón clicable) ─────────────────────── */
.nav-user {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text2);
  padding: 4px 8px;
  border-radius: 6px;
  background: var(--surface2);
  border: none;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.nav-user:hover { background: var(--accent-light); color: var(--accent); }
.nav-user i { font-size: 18px; color: var(--text3); }

/* ── TTS engine download progress ───────────────────────────────────────── */
#tts-engine-progress {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 300;
  display: none;
}
.tts-prog-inner {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 40px;
  padding: 10px 18px;
  box-shadow: var(--shadow-lg);
  white-space: nowrap;
  min-width: 260px;
}
.tts-prog-inner i {
  font-size: 18px;
  color: var(--accent);
  flex-shrink: 0;
}
.tts-prog-msg {
  font-size: 13px;
  color: var(--text2);
  flex: 1;
}
.tts-prog-track {
  width: 80px;
  height: 4px;
  background: var(--bar-bg);
  border-radius: 2px;
  overflow: hidden;
  flex-shrink: 0;
}
.tts-prog-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.3s ease;
  width: 0%;
}

/* ── Library free plan legend ───────────────────────────────────────────── */
.lib-free-legend {
  font-size: 12px;
  color: var(--text3);
  margin-top: 8px;
  margin-bottom: 16px;
  display: block;
  width: 100%;
}
.lib-free-legend strong {
  color: var(--accent);
}

/* ── Drop zone add button (inside drop card) ─────────────────────────────── */
.drop-add-btn {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  transition: background 0.15s, transform 0.15s;
  pointer-events: none;
}
.drop-card:hover .drop-add-btn,
.drop-card.drag-over .drop-add-btn {
  background: var(--accent-hover);
  transform: scale(1.08);
}

/* ── Plan cards in Configuración ─────────────────────────────────────────── */
.settings-plans-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.settings-plan-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 10px;
  border-radius: 12px;
  border: 2px solid var(--border);
  background: var(--surface2);
  text-align: center;
}
.settings-plan-card--active {
  border-color: var(--accent);
  background: var(--accent-light);
}

.settings-plan-card-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
}
.settings-plan-card-price {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 4px;
}
.settings-plan-card-features {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 11px;
  color: var(--text3);
  text-align: left;
  padding: 0;
  flex: 1;
}
.settings-plan-card-features li::before {
  content: '· ';
  color: var(--text3);
}
.settings-plan-card-current {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  margin-top: 6px;
}
.settings-plan-card-btn {
  margin-top: 6px;
  padding: 5px 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text2);
  font-size: 11px;
  cursor: pointer;
  transition: all 0.15s;
}
.settings-plan-card-btn:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ── Cloud-only book card ────────────────────────────────────────────────── */
.book-cloud-badge {
  position: absolute;
  bottom: 6px;
  left: 6px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.25);
  pointer-events: none;
}
.book-card--cloud .book-cover { opacity: 0.75; }
.book-card--cloud:hover .book-cover { opacity: 1; }
.book-card--cloud .book-cover-placeholder {
  border: 2px dashed var(--accent);
  color: var(--accent);
}

/* ── TTS Audio badge en la tarjeta de libro ─────────────────────────────── */
.book-tts-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  height: 22px;
  min-width: 22px;
  padding: 0 5px;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  pointer-events: none;
  white-space: nowrap;
  box-shadow: 0 1px 4px rgba(0,0,0,0.30);
  line-height: 1;
}
.book-tts-badge--ready {
  background: rgba(30,200,80,0.88);
  color: #fff;
  font-size: 13px;
}
.book-tts-badge--pending {
  background: rgba(255,200,30,0.88);
  color: #333;
  font-size: 12px;
}
.book-tts-badge--processing {
  background: rgba(80,160,255,0.88);
  color: #fff;
  font-size: 10px;
  gap: 3px;
}
.book-tts-badge--error {
  background: rgba(255,80,60,0.88);
  color: #fff;
  font-size: 12px;
}

/* (Voice preset picker eliminado — selector reemplazado por select de
    voces neurales del navegador en reader-voice-select.) */
/* (Reader TTS status chip eliminado junto con cloud TTS.) */

/* ── Nav Menu Dropdown ───────────────────────────────────────────────────── */
#nav-menu-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.nav-menu-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  border-radius: 50%;
  transition: background 0.15s;
}
.nav-menu-btn:hover { background: var(--surface2); }

.nav-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}

.nav-crown {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 18px;
  height: 18px;
  background: var(--accent);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: #fff;
  border: 2px solid var(--surface);
  z-index: 1;
}
.nav-crown i { font-size: 9px; }

.nav-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 200px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  padding: 8px;
  z-index: 500;
}

.nav-dd-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text3);
  padding: 4px 8px 6px;
}

.nav-dd-mode {
  display: flex;
  gap: 4px;
  padding: 0 0 4px;
}

.nav-dd-mode-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text2);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}
.nav-dd-mode-btn:hover { background: var(--surface2); color: var(--text); }
.nav-dd-mode-btn.active {
  background: var(--accent-light);
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 30%, transparent);
  font-weight: 600;
}

.nav-dd-divider {
  height: 1px;
  background: var(--border);
  margin: 6px 0;
}

.nav-dd-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--text2);
  font-size: 14px;
  text-align: left;
  cursor: pointer;
  transition: all 0.15s;
}
.nav-dd-item:hover { background: var(--surface2); color: var(--text); }
.nav-dd-item i { font-size: 16px; flex-shrink: 0; }

.nav-dd-item--danger { color: var(--danger); }
.nav-dd-item--danger:hover { background: var(--danger-light); color: var(--danger); }

/* ── Floating Feedback Button ────────────────────────────────────────────── */
.feedback-float-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 99px;
  color: var(--text2);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  box-shadow: var(--shadow-lg);
  z-index: 400;
  transition: all 0.15s;
}
.feedback-float-btn:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  transform: translateY(-2px);
}
.feedback-float-btn i { font-size: 16px; }

/* ── Modal Card (for nav-menu modals) ────────────────────────────────────── */
.modal-card {
  background: var(--surface);
  border-radius: 20px;
  padding: 24px;
  width: 100%;
  max-width: 480px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 0;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.modal-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

.modal-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text3);
  margin-bottom: 10px;
}

/* ── Settings Modal ──────────────────────────────────────────────────────── */
.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.settings-select {
  background: var(--surface2);
  border: 1px solid var(--input-border);
  border-radius: 10px;
  color: var(--text);
  font-size: 13px;
  padding: 6px 12px;
  cursor: pointer;
}

.settings-plan-active {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--accent-light);
  border-radius: 12px;
  border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
}
.settings-plan-active i { font-size: 22px; }
.settings-plan-active div {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.settings-plan-active strong { font-size: 14px; color: var(--text); }
.settings-plan-active span { font-size: 12px; color: var(--text2); }

.settings-plan-free {
  padding: 10px 12px;
  background: var(--surface2);
  border-radius: 10px;
  font-size: 13px;
  color: var(--text3);
}

/* ── Billing Modal ───────────────────────────────────────────────────────── */
.billing-summary-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text2);
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}
.billing-summary-row:last-child { border-bottom: none; }
.billing-summary-row strong { color: var(--text); }

.billing-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  color: var(--text);
}
.billing-table th {
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text3);
  padding: 0 8px 10px;
  border-bottom: 1px solid var(--border);
}
.billing-table td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--border);
  color: var(--text2);
  vertical-align: middle;
}
.billing-table tbody tr:last-child td { border-bottom: none; }

.billing-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
  background: var(--surface2);
  color: var(--text3);
}
.billing-badge--paid {
  background: color-mix(in srgb, #2d7a3a 15%, transparent);
  color: #2d7a3a;
}
[data-theme="dark"] .billing-badge--paid {
  background: color-mix(in srgb, #4caf50 15%, transparent);
  color: #4caf50;
}

.billing-link {
  color: var(--accent);
  text-decoration: none;
  font-size: 16px;
  display: inline-flex;
  align-items: center;
}
.billing-link:hover { color: var(--accent-hover); }

/* ── Feedback Faces ──────────────────────────────────────────────────────── */
.feedback-faces {
  display: flex;
  justify-content: center;
  gap: 10px;
  padding: 8px 0;
}

.feedback-face {
  font-size: 28px;
  padding: 8px;
  border-radius: 12px;
  border: 2px solid transparent;
  background: var(--surface2);
  cursor: pointer;
  transition: all 0.15s;
  line-height: 1;
}
.feedback-face:hover {
  background: var(--accent-light);
  border-color: color-mix(in srgb, var(--accent) 30%, transparent);
  transform: scale(1.1);
}
.feedback-face.selected {
  background: var(--accent-light);
  border-color: var(--accent);
  transform: scale(1.15);
}
