/* ==========================================================================
   Библиотека GlowSoft (lib.glowsoft.ru) — Editorial & Web Reader Design System
   Desktop Workstation + Mobile Responsive · 4 Reading Themes · Print-Grade Type
   ========================================================================== */

:root,
[data-theme="paper"] {
  --bg: #faf7f2;
  --bg-elev: #ffffff;
  --bg-subtle: #f2ece2;
  --bg-glass: rgba(250, 247, 242, 0.90);
  --border: #e4ddd0;
  --border-strong: #cfc4b2;
  --ink: #1c1916;
  --ink-secondary: #5a534a;
  --ink-muted: #847b6f;
  --accent: #8b2318;
  --accent-hover: #6e1a11;
  --accent-soft: rgba(139, 35, 24, 0.09);
  --gold: #a67c32;
  --gold-soft: rgba(166, 124, 50, 0.14);
  --highlight: #fbe9b7;
  --shadow-sm: 0 2px 8px rgba(28, 25, 22, 0.05);
  --shadow-md: 0 10px 30px rgba(28, 25, 22, 0.09);
  --shadow-lg: 0 22px 54px rgba(28, 25, 22, 0.16);
  color-scheme: light;
}

[data-theme="sepia"] {
  --bg: #f3e9d7;
  --bg-elev: #faf2e3;
  --bg-subtle: #e9dcc5;
  --bg-glass: rgba(243, 233, 215, 0.92);
  --border: #dccbb0;
  --border-strong: #c5b08e;
  --ink: #292117;
  --ink-secondary: #5f513e;
  --ink-muted: #84735c;
  --accent: #7f1f14;
  --accent-hover: #63160d;
  --accent-soft: rgba(127, 31, 20, 0.10);
  --gold: #9a7026;
  --gold-soft: rgba(154, 112, 38, 0.16);
  --highlight: #f4da93;
  --shadow-sm: 0 2px 8px rgba(41, 33, 23, 0.06);
  --shadow-md: 0 10px 30px rgba(41, 33, 23, 0.11);
  --shadow-lg: 0 22px 54px rgba(41, 33, 23, 0.18);
  color-scheme: light;
}

[data-theme="dusk"] {
  --bg: #181a1f;
  --bg-elev: #21242b;
  --bg-subtle: #272b34;
  --bg-glass: rgba(24, 26, 31, 0.90);
  --border: #2f3440;
  --border-strong: #414858;
  --ink: #e8e4dc;
  --ink-secondary: #a8a298;
  --ink-muted: #78736a;
  --accent: #e06d5b;
  --accent-hover: #ea8373;
  --accent-soft: rgba(224, 109, 91, 0.14);
  --gold: #d5ab5c;
  --gold-soft: rgba(213, 171, 92, 0.16);
  --highlight: rgba(213, 171, 92, 0.28);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.28);
  --shadow-md: 0 12px 32px rgba(0, 0, 0, 0.42);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.58);
  color-scheme: dark;
}

[data-theme="oled"] {
  --bg: #070709;
  --bg-elev: #121317;
  --bg-subtle: #191b21;
  --bg-glass: rgba(7, 7, 9, 0.92);
  --border: #22252d;
  --border-strong: #343844;
  --ink: #dcd8cf;
  --ink-secondary: #989389;
  --ink-muted: #69655d;
  --accent: #da6856;
  --accent-hover: #e57e6e;
  --accent-soft: rgba(218, 104, 86, 0.15);
  --gold: #cca152;
  --gold-soft: rgba(204, 161, 82, 0.16);
  --highlight: rgba(204, 161, 82, 0.30);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.5);
  --shadow-md: 0 12px 32px rgba(0, 0, 0, 0.7);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.85);
  color-scheme: dark;
}

:root {
  --font-serif: "Literata", "PT Serif", "Charter", Georgia, "Times New Roman", serif;
  --font-display: "Cormorant Garamond", "Literata", Georgia, serif;
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  --reader-font: var(--font-serif);
  --reader-size: 19px;
  --reader-lh: 1.68;
  --reader-measure: 66ch;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
}

*, *::before, *::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background-color 0.2s ease, color 0.2s ease;
}

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

button, input, select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

img {
  max-width: 100%;
  display: block;
}

/* ==========================================================================
   Site Header & Container
   ========================================================================== */
.container {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 clamp(16px, 4vw, 36px);
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 60;
  background: var(--bg-glass);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}

.site-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 64px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: linear-gradient(145deg, var(--accent), #59140d);
  color: #f8eed8;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  box-shadow: inset 0 0 0 1px rgba(255, 232, 185, 0.28);
  flex-shrink: 0;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.brand-title {
  font-family: var(--font-serif);
  font-size: 16px;
  font-weight: 700;
}

.brand-sub {
  font-size: 11.5px;
  color: var(--ink-muted);
  letter-spacing: 0.02em;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-right: 8px;
  font-size: 14px;
  color: var(--ink-secondary);
}

.nav-links a:hover {
  color: var(--ink);
}

/* ==========================================================================
   Buttons & Pills
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.16s ease;
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent);
  color: #fffaf3;
  box-shadow: 0 2px 10px rgba(139, 35, 24, 0.22);
}

.btn-primary:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg-elev);
  border-color: var(--border-strong);
  color: var(--ink);
}

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

.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--ink-secondary);
  padding: 7px 12px;
  min-height: 38px;
  font-size: 13.5px;
}

.btn-ghost:hover {
  color: var(--ink);
  background: var(--bg-subtle);
  border-color: var(--border-strong);
}

.btn-marker {
  background: var(--gold-soft);
  border: 1px solid rgba(166, 124, 50, 0.36);
  color: var(--ink);
  min-height: 38px;
  padding: 6px 13px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

.btn-marker:hover {
  background: rgba(166, 124, 50, 0.24);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  background: var(--bg-subtle);
  color: var(--ink-secondary);
  border: 1px solid var(--border);
}

.badge-accent {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: rgba(139, 35, 24, 0.2);
}

.badge-gold {
  background: var(--gold-soft);
  color: var(--gold);
  border-color: rgba(166, 124, 50, 0.28);
}

/* ==========================================================================
   Resume Reading Banner
   ========================================================================== */
.resume-banner {
  margin: 22px 0 0;
  padding: 16px 20px;
  border-radius: var(--radius-md);
  background: var(--bg-elev);
  border: 1px solid var(--gold);
  box-shadow: var(--shadow-sm);
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.resume-banner.visible {
  display: flex;
}

.resume-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.resume-eyebrow {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--gold);
}

.resume-title {
  font-family: var(--font-serif);
  font-size: 16px;
  font-weight: 600;
}

.resume-meta {
  font-size: 13px;
  color: var(--ink-secondary);
}

.resume-marker-chip {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 6px;
  background: var(--gold-soft);
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink);
}

/* ==========================================================================
   Library Home Hero & Featured Showcase
   ========================================================================== */
.library-intro {
  padding: 38px 0 26px;
  border-bottom: 1px solid var(--border);
}

.library-kicker {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent);
  font-weight: 700;
  margin-bottom: 10px;
}

.library-h1 {
  font-family: var(--font-serif);
  font-size: clamp(28px, 4.2vw, 44px);
  line-height: 1.15;
  margin: 0 0 12px;
  letter-spacing: -0.02em;
}

.library-lead {
  max-width: 720px;
  font-size: clamp(15.5px, 1.8vw, 18px);
  color: var(--ink-secondary);
  margin: 0;
}

.featured-card {
  margin: 32px 0 42px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: clamp(20px, 3.5vw, 38px);
  box-shadow: var(--shadow-md);
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: clamp(24px, 4vw, 44px);
  align-items: center;
}

.cover-frame {
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 18px 40px rgba(15, 12, 9, 0.28), 0 2px 6px rgba(15, 12, 9, 0.16);
  aspect-ratio: 1749 / 2481;
  background: #1a1410;
}

.cover-frame::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(255,255,255,0.14) 0%, rgba(255,255,255,0) 7%, rgba(0,0,0,0.12) 100%);
  pointer-events: none;
}

.cover-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.featured-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.featured-author {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-secondary);
  margin-bottom: 6px;
}

.featured-title {
  font-family: var(--font-serif);
  font-size: clamp(26px, 3.5vw, 38px);
  line-height: 1.15;
  margin: 0 0 6px;
}

.featured-orig {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 16px;
  color: var(--ink-muted);
  margin: 0 0 16px;
}

.featured-desc {
  color: var(--ink-secondary);
  font-size: 15.5px;
  line-height: 1.62;
  margin: 0 0 20px;
  max-width: 68ch;
}

.stats-row {
  display: flex;
  flex-wrap: wrap;
  gap: 18px 26px;
  padding: 14px 0;
  margin-bottom: 22px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
}

.stat-item strong {
  display: block;
  font-size: 16px;
  font-family: var(--font-serif);
  color: var(--ink);
}

.stat-item span {
  color: var(--ink-muted);
}

.cta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

/* ==========================================================================
   Catalog Toolbar & Shelf Grid
   ========================================================================== */
.catalog-section {
  padding: 10px 0 56px;
}

.catalog-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}

.filter-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.filter-tab {
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--ink-secondary);
  font-size: 13.5px;
  font-weight: 500;
  min-height: 36px;
}

.filter-tab.active,
.filter-tab:hover {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}

.search-input-wrap {
  position: relative;
  min-width: 250px;
  flex: 0 1 320px;
}

.search-input {
  width: 100%;
  min-height: 40px;
  padding: 8px 14px 8px 36px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--bg-elev);
  font-size: 14px;
}

.search-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.search-icon {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-muted);
  pointer-events: none;
  font-size: 14px;
}

.catalog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 20px;
}

.catalog-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 22px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 16px;
  transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}

.catalog-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
}

.card-type {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 8px;
}

.card-title {
  font-family: var(--font-serif);
  font-size: 19px;
  line-height: 1.3;
  margin: 0 0 8px;
}

.card-desc {
  font-size: 14px;
  color: var(--ink-secondary);
  margin: 0;
  line-height: 1.55;
}

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--ink-muted);
}

.card-link {
  font-weight: 600;
  color: var(--accent);
}

/* ==========================================================================
   Book Hub Page: Downloads & Audiobook Studio Player
   ========================================================================== */
.breadcrumb {
  padding: 18px 0 0;
  font-size: 13.5px;
  color: var(--ink-muted);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.breadcrumb a:hover {
  color: var(--ink);
  text-decoration: underline;
}

.section-block {
  margin: 40px 0;
}

.section-heading {
  font-family: var(--font-serif);
  font-size: clamp(22px, 2.8vw, 28px);
  margin: 0 0 8px;
}

.section-sub {
  color: var(--ink-secondary);
  font-size: 15px;
  margin: 0 0 20px;
  max-width: 72ch;
}

.downloads-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 16px;
}

.download-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 14px;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.download-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-sm);
}

.format-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 10px;
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 700;
  background: var(--accent-soft);
  color: var(--accent);
}

.download-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.download-size {
  font-size: 13px;
  color: var(--ink-muted);
  font-family: var(--font-mono);
}

.download-title {
  font-weight: 600;
  font-size: 16px;
  margin: 0 0 6px;
}

.download-desc {
  font-size: 13.5px;
  color: var(--ink-secondary);
  margin: 0;
}

/* Audiobook Studio Box */
.audio-studio {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-md);
}

.audio-editions-bar {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-bottom: 1px solid var(--border);
  background: var(--bg-subtle);
}

.edition-tab {
  padding: 16px 20px;
  border: none;
  background: transparent;
  text-align: left;
  border-bottom: 3px solid transparent;
  transition: all 0.15s ease;
}

.edition-tab.active {
  background: var(--bg-elev);
  border-bottom-color: var(--accent);
}

.edition-tab-title {
  font-family: var(--font-serif);
  font-size: 16.5px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.edition-tab-sub {
  font-size: 13px;
  color: var(--ink-secondary);
}

.audio-player-core {
  padding: 22px 24px;
  border-bottom: 1px solid var(--border);
}

.now-playing-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.np-chapter {
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 600;
  margin: 4px 0;
}

.np-voices {
  font-size: 13px;
  color: var(--ink-secondary);
}

.scrubber-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.time-label {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--ink-muted);
  min-width: 48px;
}

.range-slider {
  flex: 1;
  accent-color: var(--accent);
  height: 6px;
  cursor: pointer;
}

.player-controls-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.transport-btns {
  display: flex;
  align-items: center;
  gap: 8px;
}

.play-btn-lg {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(139, 35, 24, 0.28);
}

.play-btn-lg:hover {
  background: var(--accent-hover);
}

.ctrl-chip {
  padding: 7px 11px;
  min-height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg);
  font-size: 13px;
  font-weight: 600;
}

.ctrl-chip:hover {
  border-color: var(--accent);
}

.m4b-downloads-strip {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  padding: 16px 24px;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border);
}

.m4b-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.m4b-box-info strong {
  display: block;
  font-size: 14px;
}

.m4b-box-info span {
  font-size: 12.5px;
  color: var(--ink-muted);
}

.tracklist {
  max-height: 380px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.track-item {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 24px;
  border: none;
  border-bottom: 1px solid var(--border);
  background: transparent;
  text-align: left;
  transition: background 0.12s ease;
}

.track-item:hover {
  background: var(--bg-subtle);
}

.track-item.active {
  background: var(--accent-soft);
}

.track-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1;
}

.track-num {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-muted);
  width: 24px;
  flex-shrink: 0;
}

.track-title {
  font-size: 14px;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.track-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.voice-pill {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--bg-subtle);
  color: var(--ink-secondary);
  border: 1px solid var(--border);
}

.voice-pill.commentary {
  background: var(--gold-soft);
  color: var(--gold);
  border-color: rgba(166, 124, 50, 0.25);
}

.track-dur {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-muted);
}

/* TOC Preview on Book Page */
.toc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 8px 18px;
}

.toc-link-card {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-elev);
  font-size: 14px;
  transition: border-color 0.14s ease, background 0.14s ease;
}

.toc-link-card:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.toc-link-num {
  font-family: var(--font-serif);
  font-weight: 700;
  color: var(--accent);
  white-space: nowrap;
  font-size: 13px;
}

/* ==========================================================================
   WEB READER (/books/machiavelli-knyaz/read/)
   ========================================================================== */
.reader-body {
  min-height: 100vh;
  padding-bottom: 90px;
}

.reader-topbar {
  position: sticky;
  top: 0;
  z-index: 70;
  background: var(--bg-glass);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  transition: transform 0.24s ease;
}

.reader-topbar.bar-hidden {
  transform: translateY(-102%);
}

.reader-progress-track {
  height: 3px;
  width: 100%;
  background: var(--border);
  overflow: hidden;
}

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

.reader-topbar-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 8px clamp(12px, 3vw, 28px);
  min-height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

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

.reader-chap-indicator {
  font-family: var(--font-serif);
  font-size: 14px;
  color: var(--ink-secondary);
  max-width: 340px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 38px;
  padding: 6px 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-elev);
  font-size: 13.5px;
  font-weight: 500;
  color: var(--ink);
  white-space: nowrap;
}

html.hydrating-jump #reader-stage {
  opacity: 0;
}

body.modal-lock {
  overflow: hidden;
}

.meta-term {
  font-family: var(--font-serif);
  font-size: 0.95em;
  background: var(--bg-subtle);
  padding: 1px 5px;
  border-radius: 4px;
}

.parallel-notice {
  margin: 0 0 22px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  background: var(--gold-soft);
  border: 1px solid rgba(166, 124, 50, 0.3);
  font-family: var(--font-sans);
  font-size: 13.5px;
  color: var(--ink-secondary);
}

.mobile-lang-tabs {
  display: none;
  margin-bottom: 18px;
  gap: 6px;
  font-family: var(--font-sans);
}

.icon-btn:hover, .icon-btn.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

/* Reader Main Canvas */
.reader-stage {
  max-width: var(--reader-measure);
  margin: 0 auto;
  padding: clamp(26px, 5vw, 54px) clamp(18px, 5vw, 32px) 48px;
  font-family: var(--reader-font);
  font-size: var(--reader-size);
  line-height: var(--reader-lh);
  color: var(--ink);
}

.reader-body.parallel-on .reader-stage {
  max-width: 1120px;
}

.chapter-header {
  margin-bottom: 32px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--border);
}

.chapter-eyebrow {
  font-family: var(--font-sans);
  font-size: 12.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
  margin-bottom: 8px;
}

.chapter-h1 {
  font-family: var(--font-serif);
  font-size: clamp(24px, 3.6vw, 34px);
  line-height: 1.22;
  margin: 0 0 10px;
  font-weight: 700;
}

.chapter-lat {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 0.88em;
  color: var(--ink-muted);
  margin: 0 0 18px;
}

.chapter-audio-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
  font-family: var(--font-sans);
}

.chap-audio-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 13px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--bg-elev);
  font-size: 13px;
  font-weight: 500;
  min-height: 36px;
}

.chap-audio-btn:hover, .chap-audio-btn.playing {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

/* Prose Typography */
.reader-prose p {
  margin: 0 0 1.18em;
  text-align: left;
  hyphens: auto;
  -webkit-hyphens: auto;
  position: relative;
}

.reader-prose h3 {
  font-family: var(--font-serif);
  font-size: 1.24em;
  line-height: 1.32;
  margin: 1.9em 0 0.75em;
  color: var(--ink);
}

.reader-prose ol.maxim-list {
  list-style: none;
  padding: 0;
  margin: 0 0 1.4em;
}

.reader-prose ol.maxim-list li {
  margin: 0 0 1.15em;
  padding-left: 0;
  position: relative;
}

.maxim-num {
  font-family: var(--font-sans);
  font-weight: 700;
  color: var(--accent);
  margin-right: 6px;
}

.verse-block {
  margin: 1.4em 0;
  padding: 14px 22px;
  border-left: 3px solid var(--gold);
  background: var(--bg-subtle);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.glossary-entry {
  padding: 14px 18px;
  margin: 0 0 14px;
  border-radius: var(--radius-sm);
  background: var(--bg-elev);
  border: 1px solid var(--border);
}

/* Philological [stato] Original Markers */
.orig-term {
  color: var(--ink-secondary);
  font-size: 0.93em;
}

.orig-bracket {
  opacity: 0.55;
}

.reader-body.hide-orig-terms .orig-term {
  display: none;
}

/* Inline Footnote Superscript */
.fn-ref {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-sans);
  font-size: 0.70em;
  font-weight: 700;
  line-height: 1;
  min-width: 1.55em;
  height: 1.55em;
  padding: 0 0.35em;
  margin: 0 0.12em;
  vertical-align: super;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid rgba(139, 35, 24, 0.22);
  cursor: pointer;
  position: relative;
  user-select: none;
  scroll-margin-top: 96px;
  transition: all 0.14s ease;
}

/* Generous invisible touch target on mobile */
.fn-ref::after {
  content: "";
  position: absolute;
  inset: -8px;
}

.fn-ref:hover, .fn-ref:focus-visible {
  background: var(--accent);
  color: #fff;
}

/* Locus Milestones & Cross-Device Highlights */
.locus-mark {
  scroll-margin-top: 96px;
}

.locus-chip-inline {
  display: none;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  padding: 1px 6px;
  margin-right: 6px;
  border-radius: 4px;
  background: var(--gold-soft);
  color: var(--gold);
  vertical-align: middle;
  cursor: pointer;
  user-select: none;
}

.reader-body.show-inline-markers .locus-chip-inline {
  display: inline-block;
}

@keyframes locusPulse {
  0% { background-color: var(--highlight); box-shadow: 0 0 0 6px var(--highlight); }
  75% { background-color: var(--highlight); box-shadow: 0 0 0 3px var(--highlight); }
  100% { background-color: transparent; box-shadow: none; }
}

.locus-arrived {
  border-radius: 4px;
  animation: locusPulse 3.4s ease forwards;
}

/* Parallel 1513 Italian View */
.parallel-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px;
  align-items: start;
}

.italian-pane {
  padding: 20px 22px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 0.93em;
  color: var(--ink-secondary);
}

.italian-pane-title {
  font-family: var(--font-sans);
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gold);
  margin-bottom: 12px;
}

/* End-of-Chapter Notes */
.chapter-notes {
  margin-top: 44px;
  padding-top: 26px;
  border-top: 1px solid var(--border);
  font-size: 0.88em;
  line-height: 1.58;
  color: var(--ink-secondary);
}

.chapter-notes h2 {
  font-family: var(--font-serif);
  font-size: 1.2em;
  color: var(--ink);
  margin: 0 0 16px;
}

.note-item {
  margin-bottom: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  scroll-margin-top: 90px;
}

.note-item:target, .note-item.note-highlight {
  background: var(--gold-soft);
}

.note-num {
  font-family: var(--font-sans);
  font-weight: 700;
  color: var(--accent);
  margin-right: 6px;
}

.note-back {
  margin-left: 6px;
  color: var(--accent);
  font-family: var(--font-sans);
  font-weight: 600;
}

/* Prev / Next Chapter Navigation */
.chapter-pager {
  margin-top: 44px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  font-family: var(--font-sans);
}

.pager-card {
  padding: 16px 18px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-elev);
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: left;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.pager-card.next {
  text-align: right;
}

.pager-card:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.pager-dir {
  font-size: 12px;
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}

.pager-title {
  font-family: var(--font-serif);
  font-size: 15.5px;
  font-weight: 600;
  color: var(--ink);
}

/* Sticky Bottom Reader Bar (Mobile + Quick Marker Status) */
.reader-bottombar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 65;
  background: var(--bg-glass);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
  padding: 8px clamp(12px, 3vw, 24px) calc(8px + env(safe-area-inset-bottom, 0px));
  transition: transform 0.24s ease;
}

.reader-bottombar.bar-hidden {
  transform: translateY(105%);
}

.reader-bottombar-inner {
  max-width: 960px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-family: var(--font-sans);
  font-size: 13px;
}

.mini-audio-dock {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  max-width: 420px;
}

.mini-audio-dock.active {
  display: inline-flex;
}

/* ==========================================================================
   Drawers, Modals & Footnote Popover / Bottom Sheet
   ========================================================================== */
.backdrop {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(10, 10, 12, 0.48);
  backdrop-filter: blur(2px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
}

.backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-sheet {
  position: fixed;
  z-index: 100;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -46%) scale(0.97);
  width: min(560px, calc(100vw - 24px));
  max-height: min(86vh, 720px);
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
  font-family: var(--font-sans);
}

.modal-sheet.open {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, -50%) scale(1);
}

.drawer-panel {
  position: fixed;
  z-index: 100;
  top: 0;
  bottom: 0;
  left: 0;
  width: min(400px, 90vw);
  background: var(--bg-elev);
  border-right: 1px solid var(--border-strong);
  box-shadow: var(--shadow-lg);
  transform: translateX(-102%);
  transition: transform 0.22s ease;
  display: flex;
  flex-direction: column;
  font-family: var(--font-sans);
}

.drawer-panel.right {
  left: auto;
  right: 0;
  border-right: none;
  border-left: 1px solid var(--border-strong);
  transform: translateX(102%);
}

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

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

.drawer-body {
  padding: 16px 20px;
  overflow-y: auto;
  overscroll-behavior: contain;
  flex: 1;
}

.toc-drawer-item {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  text-align: left;
  font-size: 14px;
  color: var(--ink);
}

.toc-drawer-item:hover {
  background: var(--bg-subtle);
}

.toc-drawer-item.current {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

/* Settings Controls */
.setting-group {
  margin-bottom: 20px;
}

.setting-label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-muted);
  margin-bottom: 8px;
}

.segmented-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(70px, 1fr));
  gap: 6px;
}

.seg-btn {
  padding: 8px 10px;
  min-height: 38px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg);
  font-size: 13px;
  font-weight: 500;
}

.seg-btn.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
}

.toggle-row strong {
  display: block;
  font-size: 14px;
}

.toggle-row span {
  font-size: 12.5px;
  color: var(--ink-secondary);
}

/* Marker Sync Card inside Modal */
.marker-showcase {
  background: var(--bg-subtle);
  border: 1px solid var(--gold);
  border-radius: var(--radius-md);
  padding: 18px;
  text-align: center;
  margin-bottom: 18px;
}

.marker-pair {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin: 8px 0 10px;
  flex-wrap: wrap;
}

.marker-big-num {
  font-family: var(--font-mono);
  font-size: 30px;
  font-weight: 800;
  color: var(--accent);
  background: var(--bg-elev);
  padding: 6px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
}

.marker-big-word {
  font-family: var(--font-serif);
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--ink);
  background: var(--bg-elev);
  padding: 6px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
}

.marker-jump-form {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.marker-jump-input {
  flex: 1;
  min-height: 44px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg);
  font-size: 16px; /* >=16px prevents iOS Safari auto-zoom on focus! */
}

.marker-jump-input:focus {
  outline: none;
  border-color: var(--accent);
}

.marker-suggestions {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 210px;
  overflow-y: auto;
}

.marker-sug-btn {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
  text-align: left;
}

.marker-sug-btn:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

/* Footnote Popover / Mobile Sheet */
.fn-popover {
  position: fixed;
  z-index: 110;
  width: min(460px, calc(100vw - 24px));
  max-height: 55vh;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  box-shadow: var(--shadow-lg);
  font-family: var(--font-serif);
  font-size: 15.5px;
  line-height: 1.58;
  display: none;
}

.fn-popover.open {
  display: block;
}

.fn-pop-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.btn-print-order {
  background: linear-gradient(145deg, #2a2118, #19140f);
  color: #f7ebd2;
  border: 1px solid rgba(204, 161, 82, 0.55);
  box-shadow: 0 3px 12px rgba(24, 19, 14, 0.2);
}

.btn-print-order:hover {
  border-color: var(--gold);
  transform: translateY(-1px);
  filter: brightness(1.08);
}

[data-theme="dusk"] .btn-print-order,
[data-theme="oled"] .btn-print-order {
  background: linear-gradient(145deg, #33291d, #211a12);
  border-color: rgba(213, 171, 92, 0.6);
}

.print-edition-banner {
  background: var(--bg-elev);
  border: 1px solid var(--gold);
  border-radius: var(--radius-lg);
  padding: clamp(20px, 3vw, 30px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
  flex-wrap: wrap;
  box-shadow: var(--shadow-sm);
}

.order-field {
  margin-bottom: 14px;
}

.order-field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 5px;
  color: var(--ink);
}

.order-input {
  width: 100%;
  min-height: 44px;
  padding: 10px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg);
  font-size: 16px; /* >=16px avoids mobile auto-zoom */
}

.order-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.copies-stepper {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg);
  overflow: hidden;
}

.copies-stepper button {
  width: 44px;
  height: 44px;
  border: none;
  background: var(--bg-subtle);
  font-size: 18px;
  font-weight: 700;
}

.copies-stepper input {
  width: 76px;
  height: 44px;
  border: none;
  background: transparent;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 700;
}

.order-success-box {
  padding: 18px;
  border-radius: var(--radius-md);
  background: var(--gold-soft);
  border: 1px solid var(--gold);
  text-align: center;
}

/* Site Footer */
.site-footer {
  margin-top: 64px;
  padding: 32px 0 44px;
  border-top: 1px solid var(--border);
  color: var(--ink-muted);
  font-size: 13.5px;
}

.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

/* ==========================================================================
   Responsive Mobile Adaptations (<= 768px)
   ========================================================================== */
@media (max-width: 820px) {
  .featured-card {
    grid-template-columns: 1fr;
  }
  .cover-frame {
    max-width: 210px;
    margin: 0 auto;
  }
  .audio-editions-bar,
  .m4b-downloads-strip,
  .parallel-grid,
  .chapter-pager {
    grid-template-columns: 1fr;
  }
  .mobile-lang-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
  .parallel-grid[data-mobile-tab="ru"] .italian-pane {
    display: none;
  }
  .parallel-grid[data-mobile-tab="it"] .reader-prose {
    display: none;
  }
  .track-item {
    padding: 10px 14px;
    gap: 8px;
  }
  .audio-player-core {
    padding: 18px 16px;
  }
  .m4b-downloads-strip {
    padding: 14px 16px;
  }
  .pager-card.next {
    text-align: left;
  }
  .nav-links {
    display: none;
  }
  .reader-chap-indicator {
    display: none;
  }
  /* Footnote becomes a comfortable bottom sheet on mobile */
  .fn-popover {
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    top: auto !important;
    width: 100%;
    max-height: 68vh;
    border-radius: 18px 18px 0 0;
    padding: 20px 20px calc(22px + env(safe-area-inset-bottom, 0px));
  }
  .modal-sheet {
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    max-height: 88vh;
    border-radius: 20px 20px 0 0;
    transform: translateY(20px);
    padding: 22px 18px calc(24px + env(safe-area-inset-bottom, 0px));
  }
  .modal-sheet.open {
    transform: translateY(0);
  }
}

@media (max-width: 600px) {
  .hide-xs {
    display: none !important;
  }
  .icon-btn {
    padding: 6px 9px;
  }
  .btn-marker {
    padding: 5px 10px;
    font-size: 12.5px;
  }
}

@media (max-width: 440px) {
  .brand-sub {
    display: none;
  }
}
