/* ====================================================================
   OneRead (๑อ่าน) — Commercial PWA Stylesheet (V5 Black Fullscreen & Deck Slide)
   Zero-Emoji Minimalist UI | Full RTL (ar) | 5 Eye-Care Paper Filters |
   Pure Black (#000000) Fullscreen + Deck-Reveal Swipe Slide Transition
   ==================================================================== */

:root {
  --font-sans: 'Inter', 'Sarabun', 'Noto Sans Thai', 'Noto Sans Arabic', 'Noto Sans JP', 'Noto Sans SC', 'Noto Sans KR', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;

  /* Theme 1: original_clean (Default Free) */
  --bg-app: #F6F7F9;
  --bg-surface: #FFFFFF;
  --bg-elevated: #FFFFFF;
  --bg-subtle: #EEF1F5;
  --bg-shelf-plank: #E5E9F0;
  --bg-reader-stage: #E2E6EC;
  --paper-tint: #FFFFFF;

  --text-primary: #14181F;
  --text-secondary: #4E5869;
  --text-muted: #7B8596;
  --border-color: #DCE1E8;
  --border-strong: #BCC5D3;

  --accent: #1E3A5F;
  --accent-hover: #152B47;
  --accent-contrast: #FFFFFF;
  --accent-soft: rgba(30, 58, 95, 0.10);

  /* Pastel Highlight Colors for Tap-Translate & Live TTS */
  --tap-word-bg: rgba(250, 204, 21, 0.42);
  --tap-word-border: rgba(202, 138, 4, 0.72);
  --tts-sent-bg: rgba(125, 211, 252, 0.34);
  --tts-sent-border: rgba(2, 132, 199, 0.60);
  --search-hit-bg: rgba(167, 243, 208, 0.50);
  --search-current-bg: rgba(251, 146, 60, 0.55);

  --canvas-filter: none;
  --shadow-sm: 0 2px 6px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.10);
  --shadow-lg: 0 18px 42px rgba(15, 23, 42, 0.16);
  --shadow-book: 0 8px 18px rgba(15, 23, 42, 0.14), 0 2px 4px rgba(15, 23, 42, 0.08);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

/* Theme 2: warm_sepia (Free — Eye-care Cream #F6F1E3) */
html[data-theme="warm_sepia"] {
  --bg-app: #EFE8D5;
  --bg-surface: #F6F1E3;
  --bg-elevated: #FAF6EB;
  --bg-subtle: #E6DEC8;
  --bg-shelf-plank: #DDD3B8;
  --bg-reader-stage: #E4DBC4;
  --paper-tint: #F6F1E3;
  --text-primary: #2C241B;
  --text-secondary: #5C4F3E;
  --text-muted: #847561;
  --border-color: #D8CEB6;
  --border-strong: #C2B598;
  --accent: #6E4726;
  --accent-hover: #56361B;
  --accent-contrast: #FFFDF9;
  --accent-soft: rgba(110, 71, 38, 0.12);
  --canvas-filter: sepia(0.24) brightness(0.97) contrast(0.98);
}

/* Theme 3: manga_paper (PRO — Japanese Tankobon Soft Matte) */
html[data-theme="manga_paper"] {
  --bg-app: #E8E5DE;
  --bg-surface: #F2EFE9;
  --bg-elevated: #F7F5F0;
  --bg-subtle: #DFDCD4;
  --bg-shelf-plank: #D2CEC4;
  --bg-reader-stage: #DAD6CC;
  --paper-tint: #EFECE6;
  --text-primary: #1B1B19;
  --text-secondary: #4B4A45;
  --text-muted: #76746D;
  --border-color: #CFCBC1;
  --border-strong: #B6B1A5;
  --accent: #27272A;
  --accent-hover: #18181B;
  --accent-contrast: #FAFAF9;
  --accent-soft: rgba(39, 39, 42, 0.10);
  --canvas-filter: sepia(0.11) brightness(0.955) contrast(1.05);
}

/* Theme 4: eink_crisp (PRO — High-Contrast E-Ink Reader) */
html[data-theme="eink_crisp"] {
  --bg-app: #EDEDEB;
  --bg-surface: #F5F5F3;
  --bg-elevated: #FAFAF8;
  --bg-subtle: #E0E0DD;
  --bg-shelf-plank: #CFCFCC;
  --bg-reader-stage: #DFDFDC;
  --paper-tint: #F4F4F2;
  --text-primary: #0A0A0A;
  --text-secondary: #333333;
  --text-muted: #616161;
  --border-color: #C7C7C4;
  --border-strong: #8F8F8B;
  --accent: #111111;
  --accent-hover: #000000;
  --accent-contrast: #FFFFFF;
  --accent-soft: rgba(17, 17, 17, 0.09);
  --canvas-filter: grayscale(1) contrast(1.22) brightness(0.98);
}

/* Theme 5: night_amoled (PRO — True Dark Eye Relief) */
html[data-theme="night_amoled"] {
  --bg-app: #090B0E;
  --bg-surface: #12151B;
  --bg-elevated: #181C24;
  --bg-subtle: #1F242E;
  --bg-shelf-plank: #1A1F28;
  --bg-reader-stage: #050608;
  --paper-tint: #14171D;
  --text-primary: #E8ECF2;
  --text-secondary: #A5B0C2;
  --text-muted: #6E7A8E;
  --border-color: #252B37;
  --border-strong: #374052;
  --accent: #7AA2F7;
  --accent-hover: #93B4FA;
  --accent-contrast: #090C12;
  --accent-soft: rgba(122, 162, 247, 0.16);
  --tap-word-bg: rgba(250, 204, 21, 0.32);
  --tts-sent-bg: rgba(56, 189, 248, 0.28);
  --canvas-filter: invert(0.90) hue-rotate(180deg) contrast(1.04);
}

/* Ink Contrast Boost Combinators (PRO) */
body.ink-boost-on {
  --ink-extra-filter: contrast(1.28) brightness(0.98);
}

/* Lock page scroll while actively dragging a book cover on shelf */
body.shelf-dragging-active {
  user-select: none;
  -webkit-user-select: none;
  overflow: hidden;
}

/* ====================================================================
   RESET & BASE TYPOGRAPHY
   ==================================================================== */
*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background-color: var(--bg-app);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

button,
input,
select {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

html[dir="rtl"] .rtl-mirror {
  transform: scaleX(-1);
}

/* ====================================================================
   REUSABLE BUTTONS, SELECTS & BADGES (100% ZERO-EMOJI)
   ==================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-weight: 500;
  font-size: 0.88rem;
  line-height: 1.2;
  white-space: nowrap;
  background: transparent;
  transition: background-color 0.16s ease, border-color 0.16s ease, color 0.16s ease, transform 0.1s ease;
  user-select: none;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background-color: var(--accent);
  color: var(--accent-contrast);
  border-color: var(--accent);
}

.btn-primary:hover {
  background-color: var(--accent-hover);
}

/* Clean Gray-Outlined Import Button Matching Language Button */
.btn-import-clean {
  background-color: var(--bg-subtle);
  color: var(--text-primary);
  border: 1.5px solid var(--border-strong);
  font-weight: 600;
}

.btn-import-clean:hover {
  border-color: var(--accent);
  background-color: var(--bg-surface);
}

.btn-accent {
  background-color: var(--bg-subtle);
  color: var(--text-primary);
  border: 1.5px solid var(--border-strong);
  font-weight: 600;
}

.btn-outline {
  background-color: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-outline:hover {
  border-color: var(--border-strong);
  background-color: var(--bg-subtle);
}

.btn-ghost {
  background-color: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover {
  background-color: var(--bg-subtle);
  color: var(--text-primary);
}

.btn-chip {
  background-color: var(--bg-subtle);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  border-radius: 999px;
  padding: 5px 11px;
  font-size: 0.80rem;
}

.btn-chip[aria-pressed="true"],
.btn-chip.active {
  background-color: var(--accent);
  color: var(--accent-contrast);
  border-color: var(--accent);
}

.btn-sm {
  padding: 6px 10px;
  font-size: 0.84rem;
}

.btn-xs {
  padding: 4px 9px;
  font-size: 0.78rem;
}

.btn-lg {
  padding: 12px 20px;
  font-size: 0.98rem;
  font-weight: 600;
}

.link-btn {
  background: none;
  border: none;
  padding: 2px 4px;
  color: var(--accent);
  font-weight: 600;
  font-size: 0.84rem;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.select-clean,
.select-compact,
.input-clean {
  background-color: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  outline: none;
  transition: border-color 0.15s ease;
}

.select-clean:focus,
.select-compact:focus,
.input-clean:focus {
  border-color: var(--accent);
}

.select-compact {
  padding: 4px 8px;
  font-size: 0.80rem;
  border-radius: 999px;
}

.input-sm {
  padding: 6px 10px;
  font-size: 0.84rem;
}

.input-xs {
  padding: 4px 8px;
  font-size: 0.80rem;
}

/* Clean Subtle Gray Outline Badge for both FREE and PRO */
.plan-badge,
.plan-badge.is-pro {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  border: 1.5px solid var(--border-strong);
  color: var(--text-secondary);
  background-color: var(--bg-subtle);
  flex-shrink: 0;
}

.pro-mini-tag {
  display: inline-block;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  border: 1px solid currentColor;
  opacity: 0.85;
}

body.is-pro-unlocked [data-pro-tag] {
  display: none !important;
}

.count-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 19px;
  height: 17px;
  padding-inline: 5px;
  border-radius: 999px;
  font-size: 0.70rem;
  font-weight: 700;
  background-color: var(--accent-soft);
  color: var(--accent);
}

/* Invisible Native Select Overlay for Compact Top Lang & Bottom Tap-Translate Pill */
.overlay-native-select {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  border: none;
  margin: 0;
  padding: 0;
  appearance: none;
  -webkit-appearance: none;
}

/* ====================================================================
   VIEW 1: BOOKSHELF COMPACT HEADER & FRONT-COVER / FOLDER GRID
   ==================================================================== */
.app-view {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

#bookshelfView {
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
}

.shelf-header {
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  padding: 10px calc(16px + var(--safe-right)) 10px calc(16px + var(--safe-left));
  position: sticky;
  top: 0;
  z-index: 30;
}

.shelf-brand-row {
  max-width: 1240px;
  margin-inline: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: nowrap;
}

.brand-identity {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background-color: var(--accent);
  color: var(--accent-contrast);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.brand-name {
  margin: 0;
  font-size: 1.12rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  display: flex;
  align-items: baseline;
  gap: 5px;
  white-space: nowrap;
}

.brand-sub {
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.price-inline {
  font-weight: 700;
}

/* Top-Right Circular Buttons (Paper Theme Swatch + Language Short Code TH) */
.circle-top-btn {
  position: relative;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1.5px solid var(--border-strong);
  background-color: var(--bg-subtle);
  color: var(--text-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
  user-select: none;
  flex-shrink: 0;
  transition: border-color 0.15s ease, transform 0.1s ease;
}

.circle-top-btn:hover {
  border-color: var(--accent);
}

.circle-top-btn:active {
  transform: scale(0.95);
}

.theme-circle-swatch {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--paper-tint) 52%, var(--accent) 52%);
  border: 1px solid rgba(0, 0, 0, 0.18);
  pointer-events: none;
}

/* Clean Single-Row Search & Import Toolbar */
.shelf-toolbar {
  max-width: 1240px;
  width: 100%;
  margin: 12px auto 8px;
  padding-inline: calc(16px + var(--safe-left)) calc(16px + var(--safe-right));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.search-box {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
}

.search-icon {
  position: absolute;
  inset-inline-start: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.search-box input {
  width: 100%;
  padding-inline-start: 32px;
}

.plus-mark {
  font-weight: 700;
  font-size: 1.02rem;
}

/* Free Quota Strip */
.quota-strip {
  max-width: 1208px;
  width: calc(100% - 32px);
  margin: 2px auto 8px;
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  background-color: var(--bg-surface);
  border: 1px dashed var(--border-strong);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 0.80rem;
  color: var(--text-secondary);
}

.quota-items {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.quota-sep {
  color: var(--border-strong);
}

/* Front-Cover Bookshelf Grid */
.bookshelf-stage {
  flex: 1;
  max-width: 1240px;
  width: 100%;
  margin: 6px auto 20px;
  padding-inline: calc(16px + var(--safe-left)) calc(16px + var(--safe-right));
}

.bookshelf-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(154px, 1fr));
  gap: 24px 18px;
}

.book-card,
.folder-card {
  display: flex;
  flex-direction: column;
  position: relative;
  min-width: 0;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.book-cover-wrap,
.folder-cover-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1.414;
  border-radius: 4px 8px 8px 4px;
  background-color: var(--bg-surface);
  box-shadow: var(--shadow-book);
  border: 1px solid var(--border-color);
  overflow: hidden;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  transition: transform 0.2s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.2s ease, border-color 0.2s ease;
}

.book-cover-wrap:hover,
.folder-cover-wrap:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.book-cover-wrap::after {
  content: "";
  position: absolute;
  inset-block: 0;
  inset-inline-start: 0;
  width: 10px;
  background: linear-gradient(to right, rgba(0, 0, 0, 0.18), rgba(255, 255, 255, 0.16) 45%, transparent);
  pointer-events: none;
}

.book-cover-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  background-color: var(--paper-tint);
  pointer-events: none;
  -webkit-user-drag: none;
}

/* ====================================================================
   HOME-SCREEN STYLE FOLDER CARD & LONG-PRESS DRAG VISUALS
   ==================================================================== */
.folder-cover-wrap {
  border-radius: 14px;
  background-color: var(--bg-subtle);
  border: 1.5px solid var(--border-strong);
  padding: 10px;
  display: flex;
  flex-direction: column;
}

.folder-mini-grid {
  flex: 1;
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-template-rows: repeat(2, 1fr);
  gap: 7px;
}

.folder-mini-slot {
  border-radius: 5px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  overflow: hidden;
  box-shadow: 0 2px 5px rgba(15, 23, 42, 0.08);
}

.folder-mini-slot.empty {
  background-color: rgba(148, 163, 184, 0.12);
  border: 1px dashed var(--border-color);
  box-shadow: none;
}

.folder-mini-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
  -webkit-user-drag: none;
}

/* Drag Source & Drop Target Highlighting */
.book-card.dragging-source {
  opacity: 0.34;
  transform: scale(0.95);
}

.book-card.drop-target-active .book-cover-wrap,
.folder-card.drop-target-active .folder-cover-wrap {
  transform: scale(1.06);
  border-color: var(--accent);
  box-shadow: 0 0 0 3.5px var(--accent), var(--shadow-lg);
}

/* Floating Ghost Cover Following Finger / Cursor */
.drag-floating-ghost {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 130;
  pointer-events: none;
  border-radius: 8px;
  overflow: hidden;
  background-color: var(--bg-surface);
  border: 2px solid var(--accent);
  box-shadow: 0 22px 44px rgba(15, 23, 42, 0.34);
  opacity: 0.94;
  will-change: transform;
}

.drag-floating-ghost img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.book-top-badges {
  position: absolute;
  top: 7px;
  inset-inline: 8px;
  display: flex;
  justify-content: space-between;
  gap: 4px;
  pointer-events: none;
  z-index: 2;
}

.book-tag {
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 0.68rem;
  font-weight: 700;
  background-color: rgba(20, 24, 31, 0.82);
  color: #FFFFFF;
  backdrop-filter: blur(4px);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.book-tag.sample-tag,
.book-tag.folder-count-tag {
  background-color: var(--accent);
  color: var(--accent-contrast);
}

.book-shelf-ledge {
  height: 7px;
  margin-inline: -5px;
  background: var(--bg-shelf-plank);
  border-radius: 2px;
  border-bottom: 2px solid var(--border-strong);
  margin-bottom: 7px;
}

.book-meta {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}

.book-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  min-width: 0;
}

/* Single-Line Truncated Title with Ellipsis (...) */
.book-title-btn {
  background: none;
  border: none;
  padding: 0;
  text-align: start;
  font-weight: 600;
  font-size: 0.86rem;
  color: var(--text-primary);
  flex: 1 1 auto;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.35;
}

.book-card-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

.icon-action-btn {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 1px 4px;
  font-size: 0.72rem;
  color: var(--text-muted);
}

.icon-action-btn:hover {
  border-color: var(--border-color);
  background-color: var(--bg-surface);
  color: var(--text-primary);
}

.book-progress-track {
  width: 100%;
  height: 4px;
  border-radius: 999px;
  background-color: var(--bg-subtle);
  overflow: hidden;
}

.book-progress-fill {
  height: 100%;
  background-color: var(--accent);
  border-radius: 999px;
  transition: width 0.25s ease;
}

.book-stats-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.74rem;
  color: var(--text-muted);
}

.empty-state {
  text-align: center;
  padding: 48px 20px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  background-color: var(--bg-surface);
}

.empty-title {
  margin: 0 0 6px;
  font-weight: 600;
  font-size: 1rem;
}

.empty-desc {
  margin: 0;
  font-size: 0.88rem;
  color: var(--text-secondary);
}

/* Single-Row Minimalist Shelf Footer */
.shelf-footer {
  padding: 10px 16px;
  border-top: 1px solid var(--border-color);
  background-color: var(--bg-surface);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.footer-link {
  color: var(--text-secondary);
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ====================================================================
   FOLDER MODAL STYLING (App-Folder Popup Window)
   ==================================================================== */
.modal-folder {
  width: min(780px, 100%);
  max-height: 88dvh;
}

.folder-modal-header {
  gap: 10px;
}

.folder-title-edit-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 auto;
  min-width: 0;
}

.folder-title-input {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 1.02rem;
  font-weight: 700;
  background-color: var(--bg-subtle);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  outline: none;
}

.folder-title-input:focus {
  border-color: var(--accent);
  background-color: var(--bg-surface);
}

.folder-subbar {
  padding: 9px 18px;
  border-bottom: 1px solid var(--border-color);
  background-color: var(--bg-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.folder-count-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.folder-subbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.folder-picker-panel {
  padding: 12px 18px;
  border-bottom: 1px solid var(--border-color);
  background-color: var(--bg-app);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.folder-picker-list {
  max-height: 185px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.folder-picker-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background-color: var(--bg-surface);
  cursor: pointer;
  font-size: 0.85rem;
}

.folder-picker-row input[type="checkbox"] {
  width: 17px;
  height: 17px;
  accent-color: var(--accent);
  flex-shrink: 0;
}

.folder-picker-row span {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.folder-picker-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.folder-books-grid {
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: 20px 14px;
}

/* ====================================================================
   VIEW 2: FULL-SCREEN READER (ALWAYS PURE BLACK #000000 WHEN EXPANDED)
   ==================================================================== */
.reader-view {
  position: fixed;
  inset: 0;
  height: 100dvh;
  width: 100vw;
  background-color: var(--bg-reader-stage);
  overflow: hidden;
  z-index: 50;
  transition: background-color 0.2s ease;
}

/* Regardless of chosen paper filter, fullscreen backdrop is always pure black */
.reader-view.bars-hidden {
  background-color: #000000 !important;
}

.reader-topbar {
  position: absolute;
  top: 0;
  inset-inline: 0;
  padding: calc(7px + var(--safe-top)) calc(10px + var(--safe-right)) 7px calc(10px + var(--safe-left));
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  flex-wrap: wrap;
  z-index: 40;
  transition: transform 0.22s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.22s ease;
}

.reader-view.bars-hidden .reader-topbar {
  transform: translateY(-105%);
  opacity: 0;
  pointer-events: none;
}

.reader-topbar-start {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  flex: 1 1 160px;
}

.reader-doc-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.reader-book-title {
  margin: 0;
  font-size: 0.90rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.subpage-pill {
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.68rem;
  font-weight: 700;
  background-color: var(--accent);
  color: var(--accent-contrast);
  flex-shrink: 0;
}

.reader-topbar-end {
  display: flex;
  align-items: center;
  gap: 4px;
  overflow-x: auto;
  max-width: 100%;
}

/* Sub-bars (In-PDF Search & Scanned Image Notice) */
.reader-subbar,
.scanned-banner {
  position: absolute;
  top: calc(50px + var(--safe-top));
  inset-inline: 12px;
  max-width: 780px;
  margin-inline: auto;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  background-color: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  z-index: 38;
}

.reader-subbar input {
  flex: 1 1 180px;
}

.search-count-label {
  font-size: 0.80rem;
  color: var(--text-secondary);
  min-width: 48px;
  text-align: center;
}

.scanned-msg {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-primary);
}

.scanned-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

/* Main Reader Viewport */
.reader-viewport {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  direction: ltr;
}

.paged-stage {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
}

.paged-stage.swipe-clip {
  overflow: hidden !important;
}

/* Strict 50% Left / 50% Right Page-Flip Tap Zones */
.tap-zone {
  position: fixed;
  top: 52px;
  bottom: 72px;
  z-index: 12;
}

.reader-view.bars-hidden .tap-zone {
  top: 0;
  bottom: 0;
}

.tap-zone-left {
  left: 0;
  width: 50%;
}

.tap-zone-right {
  right: 0;
  width: 50%;
}

body.tap-translate-active .tap-zone {
  pointer-events: none;
}

/* Dedicated Center-Bottom Fullscreen Toggle Button (Subtle Watermark on #000000) */
.fullscreen-toggle-btn {
  position: fixed;
  left: 50%;
  bottom: calc(68px + var(--safe-bottom));
  transform: translateX(-50%);
  z-index: 44;
  width: 44px;
  height: 32px;
  padding: 0;
  border-radius: 9px;
  border: 1.5px solid var(--border-strong);
  background-color: var(--bg-surface);
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
  opacity: 0.88;
  transition: bottom 0.22s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.22s ease, background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease, transform 0.12s ease;
}

.fullscreen-toggle-btn:active {
  transform: translateX(-50%) scale(0.94);
}

.reader-view.bars-hidden .fullscreen-toggle-btn {
  bottom: calc(8px + var(--safe-bottom));
  width: 52px;
  height: 36px;
  background-color: rgba(20, 24, 31, 0.45);
  color: #FFFFFF;
  border-color: rgba(255, 255, 255, 0.42);
  box-shadow: none;
  opacity: 0.28;
}

.reader-view.bars-hidden .fullscreen-toggle-btn:hover,
.reader-view.bars-hidden .fullscreen-toggle-btn:active {
  opacity: 0.82;
  background-color: rgba(20, 24, 31, 0.88);
  color: #FFFFFF;
}

/* ====================================================================
   DECK-REVEAL STACK (Underlay Target Page + Sliding Top Page)
   ==================================================================== */
.canvas-transform-wrap {
  position: relative;
  display: grid;
  place-items: center;
  margin: auto;
  padding: 50px 8px 72px;
  transition: padding 0.2s ease;
}

.reader-view.bars-hidden .canvas-transform-wrap {
  padding: 4px 2px;
}

/* Stationary Target Page Underneath (Uncovered as Top Sheet Slides Away) */
.pdf-underlay-surface {
  grid-area: 1 / 1;
  position: relative;
  z-index: 1;
  background-color: var(--paper-tint);
  box-shadow: var(--shadow-md);
  direction: ltr;
  pointer-events: none;
  will-change: transform, opacity;
}

/* Active Top Page Surface */
.pdf-page-surface {
  grid-area: 1 / 1;
  position: relative;
  z-index: 2;
  background-color: var(--paper-tint);
  box-shadow: var(--shadow-lg);
  direction: ltr;
  transform-origin: center center;
  will-change: transform, opacity;
}

/* 1. Fast Tap Switch (Instant Snappy Turn without Sliding) */
.pdf-page-surface.anim-tap-switch {
  animation: pageTapQuickSwitch 0.11s ease-out;
}

@keyframes pageTapQuickSwitch {
  0% {
    opacity: 0.82;
  }
  100% {
    opacity: 1;
  }
}

/* 2. Interactive Finger Swipe Drag & Smooth Slide-Out Reveal */
.pdf-page-surface.is-swipe-dragging {
  transition: none !important;
  animation: none !important;
  box-shadow: -18px 0 34px rgba(0, 0, 0, 0.36), 18px 0 34px rgba(0, 0, 0, 0.36);
}

.pdf-page-surface.is-swipe-committing {
  transition: transform 0.26s cubic-bezier(0.22, 0.9, 0.32, 1) !important;
  animation: none !important;
  box-shadow: -18px 0 34px rgba(0, 0, 0, 0.32), 18px 0 34px rgba(0, 0, 0, 0.32);
}

.pdf-page-surface.is-swipe-canceling {
  transition: transform 0.20s cubic-bezier(0.22, 1, 0.36, 1) !important;
  animation: none !important;
}

.pdf-canvas {
  display: block;
  filter: var(--canvas-filter) var(--ink-extra-filter, contrast(1));
}

/* Synchronized TTS Highlight & Search Overlay Layer */
.pdf-highlight-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  direction: ltr;
  z-index: 4;
}

.tts-sentence-box {
  position: absolute;
  border-radius: 3px;
  background-color: transparent;
  transition: background-color 0.14s ease;
}

.tts-sentence-box.active {
  background-color: var(--tts-sent-bg);
  outline: 1px solid var(--tts-sent-border);
}

.search-hit-box {
  position: absolute;
  background-color: var(--search-hit-bg);
  border-radius: 2px;
}

.search-hit-box.current {
  background-color: var(--search-current-bg);
  outline: 1.5px solid #EA580C;
}

/* Precision PDF.js Text Layer */
.pdf-text-layer {
  position: absolute;
  inset: 0;
  overflow: hidden;
  line-height: 1;
  text-size-adjust: none;
  forced-color-adjust: none;
  transform-origin: 0 0;
  direction: ltr;
  z-index: 8;
}

.pdf-text-layer span {
  color: transparent;
  position: absolute;
  white-space: pre;
  cursor: text;
  transform-origin: 0% 0%;
}

body.tap-translate-active .pdf-text-layer span {
  cursor: pointer;
}

.pdf-text-layer ::selection {
  background: rgba(59, 130, 246, 0.28);
}

.tapped-word-highlight {
  position: absolute;
  background-color: var(--tap-word-bg);
  border: 1.5px solid var(--tap-word-border);
  border-radius: 4px;
  pointer-events: none;
  z-index: 6;
}

/* Optional Manga Bubble OCR Selection Overlay */
.ocr-selection-overlay {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.18);
  cursor: crosshair;
  z-index: 16;
}

.ocr-crop-box {
  position: absolute;
  border: 2px dashed var(--accent);
  background: rgba(56, 189, 248, 0.18);
  pointer-events: none;
}

/* Vertical Continuous Scroll Stage */
.scroll-stage {
  width: 100%;
  height: 100%;
  overflow-y: auto;
  padding: calc(56px + var(--safe-top)) 12px calc(92px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}

.reader-view.bars-hidden .scroll-stage {
  padding: calc(10px + var(--safe-top)) 6px calc(24px + var(--safe-bottom));
}

.scroll-page-slot {
  position: relative;
  background-color: var(--paper-tint);
  box-shadow: var(--shadow-md);
  direction: ltr;
}

/* Series Next-Volume Banner */
.next-volume-banner {
  position: fixed;
  bottom: calc(108px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  z-index: 45;
  width: min(520px, calc(100% - 28px));
  padding: 12px 16px;
  border-radius: 10px;
  background-color: var(--bg-elevated);
  border: 1.5px solid var(--accent);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.next-vol-info {
  display: flex;
  flex-direction: column;
  font-size: 0.84rem;
}

/* ====================================================================
   FLOATING TRANSLATION POPOVER CARD
   ==================================================================== */
.translation-popover {
  position: fixed;
  z-index: 60;
  width: min(350px, calc(100vw - 24px));
  background-color: var(--bg-elevated);
  color: var(--text-primary);
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 13px 14px;
  direction: initial;
}

.popover-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.popover-word-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.popover-word {
  font-size: 1.06rem;
  font-weight: 700;
  color: var(--text-primary);
  word-break: break-word;
}

.popover-close {
  background: none;
  border: none;
  font-size: 1.25rem;
  line-height: 1;
  color: var(--text-muted);
  padding: 0 4px;
}

.popover-lang-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.engine-badge {
  margin-inline-start: auto;
  font-size: 0.66rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  background-color: var(--bg-subtle);
  color: var(--text-muted);
}

.popover-meaning {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background-color: var(--bg-subtle);
  font-size: 0.96rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 10px;
  min-height: 40px;
  word-break: break-word;
}

.popover-sentence-box {
  padding: 8px 10px;
  margin-bottom: 10px;
  border-inline-start: 3px solid var(--accent);
  background-color: var(--bg-subtle);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 0.82rem;
}

.orig-sentence {
  margin: 0 0 4px;
  color: var(--text-secondary);
}

.translated-sentence {
  margin: 0;
  font-weight: 600;
  color: var(--text-primary);
}

.popover-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.popover-footer .btn {
  flex: 1;
}

.popover-quota-note {
  margin-top: 8px;
  font-size: 0.74rem;
  color: var(--text-muted);
  text-align: center;
}

/* ====================================================================
   LIVE HIGHLIGHTED TTS PANEL & BOTTOM READER BAR
   ==================================================================== */
.tts-bar {
  position: fixed;
  bottom: calc(106px + var(--safe-bottom));
  inset-inline: 12px;
  max-width: 820px;
  margin-inline: auto;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  background-color: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-lg);
  z-index: 46;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.tts-main-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.tts-transport,
.tts-options {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.tts-inline-field {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.sleep-countdown {
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--accent);
}

.tts-live-caption {
  font-size: 0.80rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.reader-bottombar {
  position: absolute;
  bottom: 0;
  inset-inline: 0;
  padding: 7px calc(12px + var(--safe-right)) calc(7px + var(--safe-bottom)) calc(12px + var(--safe-left));
  background-color: var(--bg-surface);
  border-top: 1px solid var(--border-color);
  z-index: 40;
  display: flex;
  flex-direction: column;
  gap: 5px;
  transition: transform 0.22s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.22s ease;
}

.reader-view.bars-hidden .reader-bottombar {
  transform: translateY(105%);
  opacity: 0;
  pointer-events: none;
}

.bottom-tools-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  overflow-x: auto;
}

.quick-mode-pills,
.zoom-controls {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}

/* Combined Bottom Tap-Translate (Language) Pill */
.tap-translate-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  border: 1px solid var(--border-color);
  background-color: var(--bg-subtle);
  color: var(--text-secondary);
  font-size: 0.78rem;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  user-select: none;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.tap-translate-pill.active {
  background-color: var(--accent);
  color: var(--accent-contrast);
  border-color: var(--accent);
}

.tap-pill-toggle {
  border: none;
  background: transparent;
  color: inherit;
  padding: 4px 5px 4px 10px;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
}

.tap-pill-lang {
  position: relative;
  display: inline-flex;
  align-items: center;
  padding: 4px 10px 4px 2px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}

.zoom-val {
  font-size: 0.78rem;
  min-width: 40px;
  text-align: center;
  font-weight: 600;
}

.scrubber-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-inline: 2px;
}

.scrubber-row.manga-rtl-slider {
  direction: rtl;
}

.page-slider {
  flex: 1;
  accent-color: var(--accent);
  cursor: pointer;
  margin: 0;
}

.page-indicator {
  font-size: 0.78rem;
  font-weight: 600;
  min-width: 64px;
  text-align: end;
  direction: ltr;
  color: var(--text-secondary);
}

/* ====================================================================
   MODALS, SHEETS, VOCAB NOTEBOOK & PAYWALL
   ==================================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  background-color: rgba(9, 12, 18, 0.54);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-sheet {
  width: min(560px, 100%);
  max-height: 88dvh;
  background-color: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-lg {
  width: min(760px, 100%);
}

.modal-sm {
  width: min(420px, 100%);
}

.modal-pro {
  width: min(540px, 100%);
}

.modal-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.modal-header h3 {
  margin: 0;
  font-size: 1.02rem;
  font-weight: 700;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.4rem;
  line-height: 1;
  color: var(--text-muted);
  padding: 2px 6px;
}

.modal-body {
  padding: 16px 18px;
  overflow-y: auto;
}

.setting-block {
  margin-bottom: 18px;
}

.setting-block:last-child {
  margin-bottom: 0;
}

.setting-heading {
  display: block;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.segmented-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
  gap: 8px;
}

.segmented-inline {
  display: inline-flex;
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 3px;
  gap: 3px;
}

.seg-btn {
  border: 1px solid var(--border-color);
  background-color: var(--bg-surface);
  color: var(--text-secondary);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.83rem;
  font-weight: 500;
}

.segmented-inline .seg-btn {
  border: none;
  background: transparent;
  padding: 5px 11px;
}

.seg-btn.active {
  background-color: var(--accent);
  color: var(--accent-contrast);
  border-color: var(--accent);
  font-weight: 600;
}

.switch-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background-color: var(--bg-subtle);
  cursor: pointer;
}

.switch-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.switch-info strong {
  font-size: 0.88rem;
}

.switch-info small {
  font-size: 0.77rem;
  color: var(--text-secondary);
}

.switch-ctrl {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.switch-ctrl input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

/* 5 Paper Filter Swatches */
.theme-swatches {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(135px, 1fr));
  gap: 8px;
}

.theme-card {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border-color);
  background-color: var(--bg-surface);
  text-align: start;
  font-size: 0.80rem;
}

.theme-card.active {
  border-color: var(--accent);
  background-color: var(--accent-soft);
  font-weight: 600;
}

.swatch {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.2);
  flex-shrink: 0;
}

.swatch-clean { background: #FFFFFF; }
.swatch-sepia { background: #F6F1E3; }
.swatch-manga { background: #EFECE6; }
.swatch-eink  { background: linear-gradient(135deg, #F5F5F3 50%, #181818 50%); }
.swatch-amoled { background: #0B0D10; border-color: #4B5563; }

.theme-name {
  flex: 1;
  line-height: 1.25;
}

/* Vocabulary Notebook */
.vocab-toolbar {
  padding: 10px 18px;
  border-bottom: 1px solid var(--border-color);
  background-color: var(--bg-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.vocab-toolbar input {
  flex: 1 1 160px;
}

.vocab-export-group {
  display: flex;
  align-items: center;
  gap: 5px;
}

.vocab-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.vocab-item {
  padding: 12px 14px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background-color: var(--bg-subtle);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.vocab-item-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.vocab-pair {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}

.vocab-word {
  font-weight: 700;
  font-size: 0.98rem;
}

.vocab-meaning {
  font-weight: 600;
  color: var(--accent);
}

.vocab-context {
  margin: 0;
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.vocab-item-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Outline & Bookmarks List */
.nav-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.nav-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background-color: var(--bg-subtle);
}

.nav-row-btn {
  background: none;
  border: none;
  padding: 0;
  text-align: start;
  flex: 1;
  font-size: 0.88rem;
  color: var(--text-primary);
}

/* Forms */
.form-stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.form-field label {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}

.helper-note {
  margin: 0;
  font-size: 0.84rem;
  color: var(--text-secondary);
  line-height: 1.55;
}

/* PRO Paywall Styling */
.pro-eyebrow {
  display: block;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--accent);
}

.pro-lead {
  margin: 0 0 14px;
  font-size: 0.90rem;
  color: var(--text-secondary);
}

.pro-feature-list {
  margin: 0 0 18px;
  padding-inline-start: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 0.86rem;
}

.pro-price-card {
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background-color: var(--bg-subtle);
  border: 1.5px solid var(--accent);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.pro-price-meta {
  display: flex;
  flex-direction: column;
}

.pro-sku-label {
  font-size: 0.76rem;
  color: var(--text-secondary);
}

.pro-price-big {
  font-size: 1.45rem;
  font-weight: 800;
  color: var(--text-primary);
}

.pro-restore-row {
  margin-top: 12px;
  text-align: center;
}

/* Loading Overlay & Toasts */
.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 95;
  background-color: rgba(9, 12, 18, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
}

.loading-box {
  background-color: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 18px 24px;
  box-shadow: var(--shadow-lg);
  text-align: center;
  min-width: 220px;
}

.spinner-line {
  width: 32px;
  height: 32px;
  margin: 0 auto 10px;
  border-radius: 50%;
  border: 2.5px solid var(--border-color);
  border-top-color: var(--accent);
  animation: spin 0.75s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.toast-container {
  position: fixed;
  bottom: calc(22px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.toast-item {
  background-color: #14181F;
  color: #FFFFFF;
  padding: 9px 16px;
  border-radius: 999px;
  font-size: 0.84rem;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  max-width: min(440px, calc(100vw - 28px));
  text-align: center;
}

/* Mobile Compact Refinements */
@media (max-width: 720px) {
  .bookshelf-grid {
    grid-template-columns: repeat(auto-fill, minmax(134px, 1fr));
    gap: 18px 14px;
  }

  .folder-books-grid {
    grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
    gap: 16px 12px;
  }

  .brand-sub {
    font-size: 0.82rem;
  }

  .pro-price-card .btn-lg {
    width: 100%;
  }
}