/* ═══════════════════════════════════════════════════════════
   VOXENOR — Design System
   Palette: Calm · Sand · Mink · Forest · Merlot · Noir
   ═══════════════════════════════════════════════════════════ */

/* ── Global Custom Scrollbar ── */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(165, 138, 123, 0.3) transparent;
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(165, 138, 123, 0.3);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(165, 138, 123, 0.5);
}

::-webkit-scrollbar-corner {
  background: transparent;
}

:root {
  /* ── Core Palette ── */
  --calm:    #FEF9EE;
  --sand:    #E5D9C6;
  --mink:    #A58A7B;
  --forest:  #26342B;
  --merlot:  #3F0B0D;
  --noir:    #050605;

  /* ── Semantic Tokens ── */
  --paper:       #FAF4E8;
  --paper-deep:  #F0E6D4;
  --ink:         #1A1210;
  --muted:       rgba(26, 18, 16, 0.58);
  --line:        rgba(165, 138, 123, 0.18);
  --line-strong: rgba(165, 138, 123, 0.32);
  --panel:       rgba(254, 249, 238, 0.82);
  --panel-strong:rgba(254, 249, 238, 0.94);

  /* ── Elevation ── */
  --shadow-xs:  0 1px 3px rgba(5, 6, 5, 0.06);
  --shadow-sm:  0 4px 12px rgba(5, 6, 5, 0.08);
  --shadow-md:  0 12px 32px rgba(5, 6, 5, 0.10);
  --shadow-lg:  0 24px 64px rgba(5, 6, 5, 0.14);
  --shadow-xl:  0 40px 80px rgba(5, 6, 5, 0.18);

  /* ── Radius ── */
  --radius-xs: 8px;
  --radius-sm: 12px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-xl: 32px;
  --radius-2xl: 40px;
  --radius-full: 999px;

  /* ── Type ── */
  --font-display: "Cormorant Garamond", "Iowan Old Style", "Baskerville", "Palatino Linotype", serif;
  --font-body:    "Inter", "Avenir Next", "Helvetica Neue", "Segoe UI", sans-serif;
  --font-reader:  "Georgia", "Iowan Old Style", "Palatino Linotype", "Book Antiqua", serif;
  --reader-font-size: 1.22rem;

  /* ── Transitions ── */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --duration-fast: 150ms;
  --duration-normal: 280ms;
  --duration-slow: 480ms;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  font-weight: 400;
  color: var(--ink);
  background: var(--calm);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

h1, h2, h3, h4 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

p { margin: 0; }

.hidden { display: none !important; }

/* ═══════════════════════════════════════════════════════════
   LANDING PAGE
   ═══════════════════════════════════════════════════════════ */

.landing-page {
  position: relative;
  min-height: 100vh;
  overflow: hidden;
}

.landing-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

.landing-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(100px);
  opacity: 0.4;
}

.landing-orb-1 {
  top: -15%;
  left: -10%;
  width: 40vw;
  height: 40vw;
  background: radial-gradient(circle, rgba(63, 11, 13, 0.2), transparent 70%);
  animation: orb-float 20s ease-in-out infinite;
}

.landing-orb-2 {
  bottom: -10%;
  right: -5%;
  width: 50vw;
  height: 50vw;
  background: radial-gradient(circle, rgba(38, 52, 43, 0.18), transparent 70%);
  animation: orb-float 25s ease-in-out infinite reverse;
}

.landing-orb-3 {
  top: 40%;
  left: 50%;
  width: 30vw;
  height: 30vw;
  background: radial-gradient(circle, rgba(165, 138, 123, 0.15), transparent 70%);
  animation: orb-float 18s ease-in-out 3s infinite;
}

.landing-grain {
  position: absolute;
  inset: 0;
  opacity: 0.025;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 200px 200px;
}

@keyframes orb-float {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(30px, -20px) scale(1.05); }
  66% { transform: translate(-20px, 15px) scale(0.95); }
}

/* ── Landing Nav ── */

.landing-nav {
  position: relative;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem clamp(1.5rem, 5vw, 4rem);
  animation: fade-in-down 800ms var(--ease-out) both;
}

.landing-brand {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.brand-logo {
  width: 7rem;
  height: 7rem;
  border-radius: var(--radius-lg);
  object-fit: cover;
  box-shadow: var(--shadow-lg), inset 0 1px 0 rgba(255,255,255,0.08);
  transition: transform var(--duration-normal) var(--ease-spring);
}

.brand-logo:hover {
  transform: scale(1.05) rotate(-2deg);
}

.brand-logo-footer {
  width: 5rem;
  height: 5rem;
  border-radius: 50%;
}

.brand-mark {
  width: 2.75rem;
  height: 2.75rem;
  display: grid;
  place-items: center;
  border-radius: var(--radius-sm);
  background: linear-gradient(145deg, var(--forest), #1a2620);
  color: var(--calm);
  box-shadow: var(--shadow-md), inset 0 1px 0 rgba(255,255,255,0.08);
  transition: transform var(--duration-normal) var(--ease-spring);
}

.brand-mark:hover {
  transform: scale(1.05) rotate(-2deg);
}

.brand-mark svg {
  width: 1.4rem;
  height: 1.4rem;
}

.brand-mark-sm {
  width: 2.2rem;
  height: 2.2rem;
}

.brand-mark-sm svg {
  width: 1.1rem;
  height: 1.1rem;
}

.brand-wordmark {
  font-family: var(--font-display);
  font-size: 5rem;
  font-weight: 700;
  letter-spacing: -0.05em;
  color: var(--noir);
  line-height: 1;
}

.brand-tagline {
  font-family: var(--font-body);
  font-size: 1.05rem;
  font-weight: 500;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--mink);
}

.landing-nav-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.nav-link {
  appearance: none;
  border: none;
  background: none;
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--mink);
  cursor: pointer;
  padding: 0.65rem 1rem;
  border-radius: var(--radius-full);
  transition: color var(--duration-fast), background var(--duration-fast);
}

.nav-link:hover {
  color: var(--noir);
  background: rgba(165, 138, 123, 0.1);
}

.nav-button {
  appearance: none;
  border: none;
  background: var(--noir);
  color: var(--calm);
  font-size: 0.92rem;
  font-weight: 500;
  padding: 0.65rem 1.35rem;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: transform var(--duration-fast) var(--ease-spring), box-shadow var(--duration-fast);
  box-shadow: var(--shadow-sm);
}

.nav-button:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

/* ── Landing Hero — Two‑column: logo left, copy right ── */

.landing-hero {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: clamp(2.5rem, 5vw, 5rem);
  align-items: center;
  padding: clamp(2rem, 6vh, 5rem) clamp(1.5rem, 5vw, 4rem) clamp(2rem, 4vh, 3rem);
  max-width: 80rem;
  margin: 0 auto;
  animation: fade-in-up 1000ms var(--ease-out) 200ms both;
}

.hero-left {
  display: grid;
  justify-items: center;
  gap: 1.5rem;
}

.hero-logo-frame {
  position: relative;
  width: clamp(14rem, 22vw, 20rem);
  height: clamp(14rem, 22vw, 20rem);
  display: grid;
  place-items: center;
  border-radius: var(--radius-2xl);
  overflow: visible;
}

.hero-logo-glow {
  position: absolute;
  inset: -20%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(63, 11, 13, 0.18) 0%, rgba(38, 52, 43, 0.08) 50%, transparent 70%);
  filter: blur(40px);
  animation: glow-pulse 5s ease-in-out infinite;
  pointer-events: none;
}

@keyframes glow-pulse {
  0%, 100% { opacity: 0.6; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.08); }
}

.hero-logo {
  position: relative;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: var(--radius-xl);
  box-shadow:
    var(--shadow-xl),
    0 0 0 1px rgba(165, 138, 123, 0.2),
    0 0 80px rgba(63, 11, 13, 0.12);
  transition: transform var(--duration-slow) var(--ease-spring);
}

.hero-logo-frame:hover .hero-logo {
  transform: scale(1.02);
}

/* Gold corner ornaments */
.hero-logo-ornament {
  position: absolute;
  width: 2rem;
  height: 2rem;
  border-color: rgba(191, 155, 88, 0.5);
  border-style: solid;
  pointer-events: none;
}
.hero-logo-ornament-tl { top: -6px; left: -6px; border-width: 2px 0 0 2px; border-radius: 4px 0 0 0; }
.hero-logo-ornament-tr { top: -6px; right: -6px; border-width: 2px 2px 0 0; border-radius: 0 4px 0 0; }
.hero-logo-ornament-bl { bottom: -6px; left: -6px; border-width: 0 0 2px 2px; border-radius: 0 0 0 4px; }
.hero-logo-ornament-br { bottom: -6px; right: -6px; border-width: 0 2px 2px 0; border-radius: 0 0 4px 0; }

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 1rem;
  border-radius: var(--radius-full);
  background: rgba(38, 52, 43, 0.06);
  border: 1px solid rgba(38, 52, 43, 0.1);
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--forest);
}

.hero-badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--forest);
  animation: pulse-dot 2s ease infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.8); }
}

.hero-right {
  display: grid;
  gap: 1.5rem;
  align-content: center;
}

.landing-h1 {
  font-size: clamp(2.6rem, 5.5vw, 5rem);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.04em;
  color: var(--noir);
}

.hero-accent {
  background: linear-gradient(135deg, var(--merlot), #6b2023, var(--forest));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.landing-subtitle {
  font-size: clamp(1.05rem, 1.8vw, 1.2rem);
  line-height: 1.7;
  color: var(--muted);
  max-width: 40ch;
}

.hero-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* ── Buttons ── */

.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border: none;
  border-radius: var(--radius-full);
  font-weight: 500;
  font-size: 0.94rem;
  cursor: pointer;
  padding: 0.82rem 1.5rem;
  transition:
    transform var(--duration-fast) var(--ease-spring),
    box-shadow var(--duration-normal) var(--ease-out),
    background var(--duration-fast),
    opacity var(--duration-fast);
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.btn svg {
  width: 1em;
  height: 1em;
  flex-shrink: 0;
  transition: transform var(--duration-fast) var(--ease-spring);
}

.btn:hover svg { transform: translateX(2px); }

.btn-primary {
  background: linear-gradient(145deg, var(--forest), #1a2620);
  color: var(--calm);
  box-shadow: var(--shadow-md), inset 0 1px 0 rgba(255,255,255,0.06);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg), inset 0 1px 0 rgba(255,255,255,0.06);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  background: var(--merlot);
  color: var(--calm);
  box-shadow: var(--shadow-sm);
}

.btn-secondary:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn-ghost {
  background: rgba(5, 6, 5, 0.04);
  color: var(--noir);
  border: 1px solid var(--line);
}

.btn-ghost:hover {
  background: rgba(5, 6, 5, 0.08);
  transform: translateY(-1px);
}

.btn-lg {
  padding: 1rem 2rem;
  font-size: 1rem;
}

.btn-full {
  width: 100%;
  justify-content: center;
}

/* ═══ Bookshelf Showcase ═══ */

.landing-shelf {
  position: relative;
  z-index: 1;
  padding: clamp(2rem, 5vh, 4rem) clamp(1.5rem, 5vw, 4rem) 0;
  max-width: 72rem;
  margin: 0 auto;
  animation: fade-in-up 1000ms var(--ease-out) 400ms both;
}

.shelf-ornament-left,
.shelf-ornament-right {
  position: absolute;
  top: 50%;
  width: 3rem;
  height: 60%;
  transform: translateY(-50%);
  border: 1px solid rgba(191, 155, 88, 0.2);
  pointer-events: none;
}
.shelf-ornament-left  { left: clamp(0.5rem, 3vw, 2rem); border-right: none; border-radius: 6px 0 0 6px; }
.shelf-ornament-right { right: clamp(0.5rem, 3vw, 2rem); border-left: none; border-radius: 0 6px 6px 0; }

.shelf-row {
  display: flex;
  justify-content: center;
  gap: 0.6rem;
  padding: 0 2rem;
  perspective: 800px;
}

.shelf-book {
  position: relative;
  width: clamp(4.5rem, 7vw, 6rem);
  height: 13rem;
  border-radius: 3px 8px 8px 3px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.8rem 0.5rem;
  text-align: center;
  color: rgba(254, 249, 238, 0.9);
  font-family: var(--font-display);
  box-shadow:
    var(--shadow-md),
    inset 0 0 0 1px rgba(255,255,255,0.06),
    inset -3px 0 8px rgba(0,0,0,0.15);
  transition: transform var(--duration-normal) var(--ease-spring);
  cursor: default;
  overflow: hidden;
}

.shelf-book:hover {
  transform: translateY(-10px);
  box-shadow: var(--shadow-lg), inset 0 0 0 1px rgba(255,255,255,0.06), inset -3px 0 8px rgba(0,0,0,0.15);
}

.shelf-book::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 5px;
  background: linear-gradient(180deg, rgba(255,255,255,0.18), rgba(255,255,255,0.04));
  border-radius: 2px 0 0 2px;
}

.shelf-book::after {
  content: "";
  position: absolute;
  inset: 8px;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 2px;
  pointer-events: none;
}

.shelf-book-title {
  font-size: clamp(0.68rem, 1vw, 0.82rem);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0.01em;
}

.shelf-book-author {
  font-size: clamp(0.55rem, 0.75vw, 0.65rem);
  font-weight: 400;
  opacity: 0.7;
  letter-spacing: 0.02em;
}

.shelf-book-1 { background: linear-gradient(180deg, #5c1416, var(--merlot)); }
.shelf-book-2 { background: linear-gradient(180deg, #8b2e2e, #4a1010); }
.shelf-book-3 { background: linear-gradient(180deg, #3d5045, var(--forest)); }
.shelf-book-4 { background: linear-gradient(180deg, #2a1a0e, #4a2e1a); }
.shelf-book-5 { background: linear-gradient(180deg, #7a6b5a, #3a322a); }
.shelf-book-6 { background: linear-gradient(180deg, #1a3a5a, #0e2240); }
.shelf-book-7 { background: linear-gradient(180deg, #4a3060, #2a1840); }
.shelf-book-8 { background: linear-gradient(180deg, #1a2620, #0a120e); }

.shelf-ledge {
  width: 100%;
  height: 12px;
  background: linear-gradient(180deg, #7a6b5a 0%, #544a3f 40%, #3a322a 100%);
  border-radius: 0 0 4px 4px;
  box-shadow: 0 4px 12px rgba(5, 6, 5, 0.15), 0 1px 0 rgba(255,255,255,0.1) inset;
}

.shelf-caption {
  text-align: center;
  font-size: 0.92rem;
  color: var(--muted);
  padding-top: 1.5rem;
  font-style: italic;
  font-family: var(--font-display);
  font-size: 1.05rem;
}

/* ═══ Reader Preview Window ═══ */

.landing-preview {
  position: relative;
  z-index: 1;
  padding: clamp(4rem, 8vh, 6rem) clamp(1.5rem, 5vw, 4rem);
  max-width: 72rem;
  margin: 0 auto;
}

.preview-header {
  text-align: center;
  margin-bottom: clamp(2rem, 4vh, 3rem);
}

.preview-window {
  border-radius: var(--radius-2xl);
  overflow: hidden;
  background: var(--calm);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-xl), 0 0 80px rgba(63, 11, 13, 0.05);
  animation: fade-in-up 1000ms var(--ease-out) 600ms both;
}

.preview-chrome {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1.25rem;
  background: linear-gradient(180deg, rgba(229, 217, 198, 0.5), rgba(229, 217, 198, 0.3));
  border-bottom: 1px solid var(--line);
}

.preview-dots {
  display: flex;
  gap: 5px;
}

.preview-dots span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--sand);
}

.preview-tab {
  font-size: 0.76rem;
  font-weight: 500;
  color: var(--muted);
  padding: 0.25rem 0.75rem;
  border-radius: var(--radius-xs);
  background: rgba(165, 138, 123, 0.1);
}

.preview-body {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 0;
  padding: 2rem 2rem;
  min-height: 14rem;
}

.preview-page {
  padding: 0 1.2rem;
}

.preview-text {
  font-family: var(--font-display);
  font-size: 0.92rem;
  line-height: 1.75;
  color: var(--ink);
  margin: 0 0 0.8rem;
  text-indent: 1.5em;
}

.preview-text:first-child {
  text-indent: 0;
}

.preview-highlight {
  background: linear-gradient(180deg, transparent 55%, rgba(63, 11, 13, 0.15) 55%);
  cursor: pointer;
  border-radius: 2px;
  padding: 0 2px;
  font-weight: 500;
}

.preview-gutter {
  width: 1px;
  background: linear-gradient(180deg, transparent, var(--line-strong), var(--line), transparent);
  margin: 0 0.5rem;
}

.preview-vocab-bar {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  padding: 0.8rem 1.5rem;
  border-top: 1px solid var(--line);
  background: rgba(38, 52, 43, 0.02);
}

.preview-vocab-chip {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.7rem;
  border-radius: var(--radius-full);
  background: rgba(38, 52, 43, 0.06);
  border: 1px solid rgba(38, 52, 43, 0.08);
  font-size: 0.78rem;
}

.preview-vocab-chip strong {
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--forest);
}

.preview-vocab-chip span {
  color: var(--muted);
}

.preview-waveform {
  display: flex;
  align-items: flex-end;
  gap: 0;
  padding: 0.75rem 1.5rem;
  background: rgba(229, 217, 198, 0.3);
  border-top: 1px solid var(--line);
  height: 3.5rem;
}

.preview-wave-bar {
  flex: 1;
  height: var(--h);
  margin: 0 1px;
  border-radius: 2px 2px 0 0;
  background: var(--mink);
  opacity: 0.35;
}

.preview-wave-bar.active {
  background: var(--merlot);
  opacity: 1;
}

@keyframes wave-pulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

/* ── Landing Features ── */

.landing-features {
  position: relative;
  z-index: 1;
  padding: clamp(4rem, 10vh, 8rem) clamp(1.5rem, 5vw, 4rem);
}

.features-header,
.how-header {
  text-align: center;
  margin-bottom: clamp(2.5rem, 5vh, 4rem);
}

.section-eyebrow {
  display: block;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--mink);
  margin-bottom: 0.75rem;
}

.landing-h2 {
  font-size: clamp(2rem, 4vw, 3.5rem);
  font-weight: 700;
  color: var(--noir);
  line-height: 1.1;
}

.features-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  max-width: 72rem;
  margin: 0 auto;
}

.feature-card {
  position: relative;
  padding: 2rem;
  border-radius: var(--radius-xl);
  background: rgba(254, 249, 238, 0.7);
  border: 1px solid var(--line);
  backdrop-filter: blur(12px);
  transition: transform var(--duration-normal) var(--ease-spring), box-shadow var(--duration-normal) var(--ease-out), border-color var(--duration-normal);
  display: grid;
  gap: 0.75rem;
  align-content: start;
}

.feature-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--line-strong);
}

.feature-card-lg {
  background: linear-gradient(165deg, rgba(38, 52, 43, 0.04), rgba(254, 249, 238, 0.8));
}

.feature-icon {
  width: 3rem;
  height: 3rem;
  display: grid;
  place-items: center;
  border-radius: var(--radius-md);
  background: linear-gradient(145deg, var(--forest), #1e2d24);
  color: var(--calm);
  box-shadow: var(--shadow-sm);
  margin-bottom: 0.5rem;
}

.feature-icon svg {
  width: 1.3rem;
  height: 1.3rem;
}

.feature-card h3 {
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--noir);
}

.feature-card p {
  font-size: 0.95rem;
  line-height: 1.7;
  color: var(--muted);
}

/* ── Landing How ── */

.landing-how {
  position: relative;
  z-index: 1;
  padding: clamp(4rem, 10vh, 8rem) clamp(1.5rem, 5vw, 4rem);
}

.how-steps {
  display: grid;
  grid-template-columns: 1fr auto 1fr auto 1fr;
  gap: 1.5rem;
  align-items: start;
  max-width: 64rem;
  margin: 0 auto;
}

.how-step {
  display: grid;
  gap: 0.75rem;
  text-align: center;
  padding: 2rem 1.5rem;
}

.how-step-icon {
  width: 3.5rem;
  height: 3.5rem;
  display: grid;
  place-items: center;
  margin: 0 auto 0.5rem;
  border-radius: var(--radius-lg);
  background: linear-gradient(145deg, var(--merlot), #2a0709);
  color: rgba(254, 249, 238, 0.9);
  box-shadow: var(--shadow-md);
}

.how-step-icon svg {
  width: 1.4rem;
  height: 1.4rem;
}

.how-step-number {
  font-family: var(--font-display);
  font-size: 3.5rem;
  font-weight: 700;
  line-height: 1;
  background: linear-gradient(180deg, var(--merlot), rgba(63, 11, 13, 0.3));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.how-step h3 {
  font-size: 1.3rem;
  color: var(--noir);
}

.how-step p {
  font-size: 0.95rem;
  line-height: 1.7;
  color: var(--muted);
}

.how-step-divider {
  width: 1px;
  height: 100%;
  min-height: 8rem;
  background: linear-gradient(180deg, transparent, var(--line-strong), transparent);
  align-self: center;
}

/* ── Landing CTA ── */

.landing-cta {
  position: relative;
  z-index: 1;
  padding: clamp(2rem, 5vh, 4rem) clamp(1.5rem, 5vw, 4rem) clamp(4rem, 10vh, 8rem);
}

.cta-card {
  max-width: 46rem;
  margin: 0 auto;
  text-align: center;
  display: grid;
  gap: 1.25rem;
  justify-items: center;
  padding: clamp(3rem, 6vh, 5rem) clamp(2rem, 5vw, 4rem);
  border-radius: var(--radius-2xl);
  background: linear-gradient(165deg, var(--noir), #141210);
  color: var(--calm);
  box-shadow: var(--shadow-xl);
  overflow: hidden;
  position: relative;
}

.cta-card::before {
  content: "";
  position: absolute;
  top: -30%;
  left: -20%;
  width: 60%;
  height: 60%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(63, 11, 13, 0.4), transparent 70%);
  filter: blur(60px);
  pointer-events: none;
}

.cta-card::after {
  content: "";
  position: absolute;
  bottom: -20%;
  right: -15%;
  width: 50%;
  height: 50%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(38, 52, 43, 0.3), transparent 70%);
  filter: blur(60px);
  pointer-events: none;
}

.cta-logo {
  width: 16rem;
  height: 16rem;
  border-radius: var(--radius-2xl);
  object-fit: cover;
  box-shadow: 0 0 100px rgba(191, 155, 88, 0.3), var(--shadow-xl);
  position: relative;
  z-index: 1;
}

.cta-card .landing-h2 {
  color: var(--calm);
  position: relative;
  z-index: 1;
}

.cta-card p {
  color: rgba(254, 249, 238, 0.6);
  font-size: 1.05rem;
  position: relative;
  z-index: 1;
}

.cta-card .btn {
  position: relative;
  z-index: 1;
}

.cta-card .btn-primary {
  background: linear-gradient(145deg, var(--calm), var(--sand));
  color: var(--noir);
}

/* ── Landing Footer ── */

.landing-footer {
  position: relative;
  z-index: 1;
  border-top: 1px solid var(--line);
}

.footer-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 2rem clamp(1.5rem, 5vw, 4rem);
  max-width: 72rem;
  margin: 0 auto;
}

.footer-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--noir);
}

.footer-note {
  font-size: 0.85rem;
  color: var(--muted);
}

.footer-links {
  font-size: 0.82rem;
  color: var(--muted);
  margin-top: 0.25rem;
}

.footer-links a {
  color: var(--mink);
  text-decoration: none;
}

.footer-links a:hover {
  text-decoration: underline;
}

.footer-sep {
  margin: 0 0.35rem;
}

/* Plan badge */
.plan-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  vertical-align: middle;
  margin-left: 0.3rem;
}

.plan-badge-free {
  background: var(--sand);
  color: var(--mink);
}

.plan-badge-premium {
  background: linear-gradient(135deg, var(--merlot), #5a1213);
  color: var(--calm);
}

/* Checkbox field */
.field.field-checkbox {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 0.5rem;
  cursor: pointer;
}

.field-checkbox input[type="checkbox"] {
  margin-top: 0.15rem;
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
  accent-color: var(--merlot);
}

.field-checkbox span {
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.4;
}

.field-checkbox a {
  color: var(--merlot);
  text-decoration: none;
}

.field-checkbox a:hover {
  text-decoration: underline;
}

/* ═══════════════════════════════════════════════════════════
   AUTH SHELL — Login / Sign Up
   ═══════════════════════════════════════════════════════════ */

.auth-shell {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}

.auth-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(5, 6, 5, 0.45);
  backdrop-filter: blur(24px) saturate(1.2);
  animation: fade-in var(--duration-normal) var(--ease-out) both;
}

.auth-card {
  position: relative;
  width: min(28rem, 100%);
  display: grid;
  gap: 1.25rem;
  padding: 2rem;
  border-radius: var(--radius-2xl);
  background: linear-gradient(180deg, rgba(254, 249, 238, 0.97), rgba(240, 230, 212, 0.95));
  border: 1px solid rgba(229, 217, 198, 0.5);
  box-shadow: var(--shadow-xl), 0 0 0 1px rgba(255,255,255,0.2) inset;
  animation: auth-enter 500ms var(--ease-out) both;
}

.auth-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 2.25rem;
  height: 2.25rem;
  display: grid;
  place-items: center;
  border: none;
  border-radius: var(--radius-full);
  background: rgba(165, 138, 123, 0.1);
  color: var(--mink);
  cursor: pointer;
  transition: background var(--duration-fast), transform var(--duration-fast) var(--ease-spring);
}

.auth-close:hover {
  background: rgba(165, 138, 123, 0.2);
  transform: scale(1.08);
}

.auth-close svg {
  width: 1rem;
  height: 1rem;
}

.auth-header {
  display: grid;
  gap: 0.5rem;
  text-align: center;
  padding-top: 0.5rem;
}

.auth-header h2 {
  font-size: 1.85rem;
  color: var(--noir);
}

.auth-subtitle {
  color: var(--muted);
  font-size: 0.95rem;
}

/* ── Auth Tabs ── */

.auth-tabs {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-radius: var(--radius-sm);
  background: rgba(165, 138, 123, 0.08);
  padding: 4px;
  gap: 0;
}

.auth-tab {
  appearance: none;
  border: none;
  background: none;
  padding: 0.65rem 1rem;
  border-radius: var(--radius-xs);
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  transition: color var(--duration-fast), background var(--duration-normal) var(--ease-out);
  z-index: 1;
}

.auth-tab.active {
  color: var(--noir);
  background: rgba(254, 249, 238, 0.95);
  box-shadow: var(--shadow-xs);
}

/* ── Auth Body ── */

.auth-body {
  position: relative;
  min-height: 14rem;
}

.auth-pane {
  display: none;
  gap: 1rem;
  animation: pane-in var(--duration-normal) var(--ease-out) both;
}

.auth-pane.active {
  display: grid;
}

@keyframes pane-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.auth-status-text {
  text-align: center;
  font-size: 0.85rem;
  color: var(--muted);
  min-height: 1.2rem;
}

.auth-status-text.is-error {
  color: var(--merlot);
}

/* ── Auth Footer ── */

.auth-footer {
  display: grid;
  gap: 1rem;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 1rem;
  color: var(--muted);
  font-size: 0.82rem;
}

.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

.auth-switch-text {
  text-align: center;
  font-size: 0.88rem;
  color: var(--muted);
}

.link-button {
  appearance: none;
  border: none;
  background: none;
  color: var(--forest);
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
  text-decoration-color: rgba(38, 52, 43, 0.3);
  text-underline-offset: 2px;
  transition: color var(--duration-fast);
}

.link-button:hover {
  color: var(--merlot);
}

@keyframes auth-enter {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ═══════════════════════════════════════════════════════════
   FORM FIELDS (Shared)
   ═══════════════════════════════════════════════════════════ */

.field {
  display: grid;
  gap: 0.4rem;
}

.field span {
  font-size: 0.88rem;
  font-weight: 500;
  color: rgba(26, 18, 16, 0.7);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: rgba(254, 249, 238, 0.6);
  color: var(--ink);
  padding: 0.82rem 1rem;
  outline: none;
  font-size: 0.94rem;
  transition:
    border-color var(--duration-fast),
    box-shadow var(--duration-fast),
    background var(--duration-fast);
}

textarea {
  min-height: 8rem;
  resize: vertical;
  line-height: 1.6;
}

input:focus,
textarea:focus,
select:focus {
  border-color: rgba(38, 52, 43, 0.35);
  background: rgba(254, 249, 238, 0.9);
  box-shadow: 0 0 0 3px rgba(38, 52, 43, 0.08);
}

input::placeholder,
textarea::placeholder {
  color: var(--mink);
  opacity: 0.6;
}

/* ═══════════════════════════════════════════════════════════
   APP SHELL
   ═══════════════════════════════════════════════════════════ */

.app-shell {
  position: relative;
  min-height: 100vh;
  overflow: hidden;
  background:
    radial-gradient(circle at 10% 5%, rgba(63, 11, 13, 0.04), transparent 30%),
    radial-gradient(circle at 90% 15%, rgba(38, 52, 43, 0.04), transparent 30%),
    linear-gradient(180deg, var(--calm) 0%, var(--paper) 50%, var(--paper-deep) 100%);
}

.ambient {
  position: fixed;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.25;
  pointer-events: none;
  z-index: 0;
}

.ambient-one {
  top: -10rem;
  left: -8rem;
  width: 26rem;
  height: 26rem;
  background: rgba(63, 11, 13, 0.15);
}

.ambient-two {
  right: -12rem;
  bottom: 5%;
  width: 30rem;
  height: 30rem;
  background: rgba(38, 52, 43, 0.12);
}

/* ── Topbar ── */

.app-topbar,
.app-main {
  position: relative;
  z-index: 1;
}

.app-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1.5rem;
  padding: 1.25rem clamp(1rem, 3vw, 2.8rem);
  border-bottom: 1px solid var(--line);
  background: rgba(254, 249, 238, 0.92);
  backdrop-filter: blur(16px);
  will-change: transform;
}

.app-brand {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.app-brand-logo {
  width: 3.5rem;
  height: 3.5rem;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: var(--shadow-sm);
}

.app-brand-name {
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 2.5vw, 2rem);
  font-weight: 700;
  color: var(--noir);
  letter-spacing: -0.01em;
  line-height: 1.1;
}

.app-brand-tagline {
  font-size: 0.82rem;
  color: var(--muted);
  letter-spacing: 0.04em;
  margin-top: 0.1rem;
}

h1 {
  font-size: clamp(1.8rem, 3vw, 2.6rem);
  color: var(--noir);
}

h2 {
  font-size: clamp(2.2rem, 4vw, 4rem);
  color: var(--noir);
}

h3 {
  font-size: 1.4rem;
  color: var(--noir);
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--mink);
}

.lede {
  line-height: 1.72;
  color: var(--muted);
}

.compact { font-size: 0.96rem; }
.compact-copy { color: var(--muted); line-height: 1.55; font-size: 0.94rem; }

.topbar-actions,
.section-heading,
.status-row,
.meta-grid,
.progress-label-row {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  align-items: center;
}

.topbar-actions { justify-content: flex-end; gap: 0.6rem; }

.topbar-note {
  color: var(--muted);
  align-self: center;
  font-size: 0.88rem;
}

.app-main { padding: 1.5rem clamp(1rem, 3vw, 2.8rem) 1.5rem; }

.screen { display: grid; gap: 1rem; }

/* ═══════════════════════════════════════════════════════════
   CARDS
   ═══════════════════════════════════════════════════════════ */

.card {
  border-radius: var(--radius-xl);
  border: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(254, 249, 238, 0.9), rgba(240, 230, 212, 0.78)),
    var(--panel);
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(12px);
}

.hero-card {
  display: none; /* legacy — replaced by library-hero */
}

/* ── Library Hero ── */

.library-hero {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1rem;
  flex-wrap: wrap;
  padding-top: 0.75rem;
  margin-bottom: 0.25rem;
}

.library-hero-title {
  font-family: var(--font-display);
  font-size: clamp(2rem, 3.5vw, 2.8rem);
  font-weight: 700;
  color: var(--noir);
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.library-hero-desc {
  max-width: 48ch;
  color: var(--muted);
  line-height: 1.65;
  font-size: 1rem;
  margin-top: 0.35rem;
}

.library-hero-actions {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  flex-wrap: wrap;
}

.import-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.82rem 1.5rem;
  font-size: 0.95rem;
}

/* ── Import Panel ── */

.import-panel {
  padding: clamp(1.2rem, 2vw, 1.8rem);
  animation: fade-in-down 320ms ease;
}

.import-panel-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1.2rem;
}

.import-panel-head-right {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.import-close-btn {
  width: 2.2rem;
  height: 2.2rem;
  padding: 0;
  display: grid;
  place-items: center;
  border-radius: var(--radius-full);
  flex-shrink: 0;
}

.import-form-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(16rem, 0.7fr);
  gap: 1.5rem;
}

.import-form-left,
.import-form-right {
  display: grid;
  gap: 1rem;
  align-content: start;
}

/* ── Library Books ── */

.library-books {
  min-height: 0;
}

/* ── Discover Section ── */

.discover-section {
  display: grid;
  gap: 1.8rem;
  padding-top: 2.5rem;
  margin-top: 1rem;
  border-top: 1px solid var(--line);
}

.discover-header {
  display: grid;
  gap: 1rem;
}

.discover-header .eyebrow {
  font-size: 0.6rem;
  letter-spacing: 0.2em;
  margin-bottom: 0.2rem;
}

.discover-header h3 {
  font-size: clamp(1.5rem, 2.5vw, 2rem);
  font-weight: 700;
  letter-spacing: -0.01em;
}

.discover-controls {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  align-items: center;
  width: 100%;
}

.discover-search-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}

.discover-search-wrap {
  position: relative;
  width: 100%;
  max-width: 36rem;
}

.discover-search-icon {
  position: absolute;
  left: 1.1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--mink);
  pointer-events: none;
}

.discover-search-input {
  width: 100%;
  padding: 0.78rem 2.4rem 0.78rem 3.2rem !important;
  border: 1.5px solid var(--sand);
  border-radius: var(--radius-full);
  background: #fff;
  font-size: 0.95rem;
  color: var(--ink);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
  transition: border-color var(--duration-fast), box-shadow var(--duration-fast);
}

.discover-search-clear {
  position: absolute;
  right: 0.45rem;
  top: 50%;
  transform: translateY(-50%);
  width: 1.4rem;
  height: 1.4rem;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  display: grid;
  place-items: center;
  border-radius: var(--radius-full);
  transition: color var(--duration-fast), background var(--duration-fast);
}
.discover-search-clear:hover {
  color: var(--ink);
  background: rgba(0, 0, 0, 0.06);
}
.discover-search-clear.hidden {
  display: none;
}

.discover-search-input:focus {
  outline: none;
  border-color: var(--mink);
  box-shadow: 0 0 0 3px rgba(165, 138, 123, 0.15);
}

.discover-categories {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 0.4rem;
}

.discover-grid {
  margin-top: 1rem;
}

.discover-cat {
  appearance: none;
  border: 1.5px solid var(--mink);
  border-radius: var(--radius-full);
  padding: 0.4rem 0.85rem;
  background: var(--sand);
  color: var(--forest);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  transition: all var(--duration-fast);
}

.discover-cat:hover {
  background: var(--mink);
  color: #fff;
}

.discover-cat.active {
  background: var(--forest);
  border-color: var(--forest);
  color: var(--calm);
}

.discover-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(10.5rem, 1fr));
  gap: 1.25rem;
  min-height: 14rem;
}

.discover-grid.loading-state {
  display: grid;
  place-items: center;
  grid-template-columns: 1fr;
  min-height: 14rem;
}

.discover-book {
  display: grid;
  gap: 0.5rem;
  cursor: pointer;
  text-align: left;
  animation: card-fade-in 420ms ease both;
}

.discover-book-cover {
  aspect-ratio: 2 / 3;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: linear-gradient(160deg, var(--forest), var(--merlot));
  box-shadow: var(--shadow-sm);
  transition: transform var(--duration-normal) var(--ease-spring), box-shadow var(--duration-normal);
}

.discover-book:hover .discover-book-cover {
  transform: translateY(-4px) scale(1.02);
  box-shadow: var(--shadow-lg);
}

.discover-book-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.discover-book-cover .discover-cover-fallback {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  padding: 0.75rem;
  color: rgba(254, 249, 238, 0.85);
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 600;
  text-align: center;
  line-height: 1.25;
}

.discover-book-title {
  font-family: var(--font-display);
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--noir);
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.discover-book-author {
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ── Load More ── */

.discover-load-more {
  grid-column: 1 / -1;
  display: flex;
  justify-content: center;
  padding: 1.5rem 0 0.5rem;
}

.discover-load-more-btn {
  background: var(--forest);
  color: var(--calm);
  border: none;
  border-radius: 8px;
  padding: 0.7rem 2rem;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}

.discover-load-more-btn:hover {
  opacity: 0.85;
}

.discover-load-more-btn:disabled {
  opacity: 0.6;
  cursor: wait;
}

/* ── Discover Modal ── */

.discover-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}

.discover-modal.hidden {
  display: none;
}

.discover-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(5, 6, 5, 0.55);
  backdrop-filter: blur(8px);
}

.discover-modal-card {
  position: relative;
  width: min(42rem, 100%);
  max-height: 85vh;
  overflow-y: auto;
  padding: clamp(1.5rem, 3vw, 2.2rem);
  border-radius: var(--radius-xl);
  background:
    linear-gradient(180deg, rgba(254, 249, 238, 0.97), rgba(240, 230, 212, 0.95));
  border: 1px solid var(--line);
  box-shadow: var(--shadow-lg), 0 25px 60px rgba(5, 6, 5, 0.2);
  animation: fade-in-up 280ms ease;
}

.discover-modal-close-btn {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  width: 1.8rem;
  height: 1.8rem;
  padding: 0;
  display: grid;
  place-items: center;
  border-radius: var(--radius-full);
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  z-index: 2;
  transition: color var(--duration-fast), background var(--duration-fast);
}
.discover-modal-close-btn:hover {
  color: var(--ink);
  background: rgba(0, 0, 0, 0.06);
  transform: none;
}

.discover-modal-body {
  display: grid;
  grid-template-columns: 11rem minmax(0, 1fr);
  gap: 1.5rem;
  align-items: start;
}

.discover-modal-cover {
  aspect-ratio: 2 / 3;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: linear-gradient(160deg, var(--forest), var(--merlot));
  box-shadow: var(--shadow-md);
}

.discover-modal-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.discover-modal-info {
  display: grid;
  gap: 0.6rem;
}

.discover-modal-info h2 {
  font-size: clamp(1.3rem, 2.5vw, 1.8rem);
  line-height: 1.2;
  letter-spacing: -0.01em;
}

.discover-modal-author {
  font-family: var(--font-display);
  font-size: 1.05rem;
  color: var(--mink);
  font-weight: 500;
}

.discover-modal-meta {
  font-size: 0.85rem;
  color: var(--muted);
}

.discover-modal-desc {
  color: var(--ink);
  font-size: 0.92rem;
  line-height: 1.65;
  max-height: 10rem;
  overflow-y: auto;
}

.discover-modal-actions {
  display: flex;
  gap: 0.65rem;
  flex-wrap: wrap;
  align-items: end;
  padding-top: 0.35rem;
}

.discover-modal-lang-field {
  flex: 1 1 100%;
}
.discover-modal-lang-field span {
  font-size: 0.82rem;
  color: var(--muted);
}
.discover-modal-lang-field select {
  font-size: 0.95rem;
  padding: 0.5rem 0.65rem;
  width: 100%;
}

.discover-modal-no-audio-label {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.72rem;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
  flex: 1 1 100%;
  padding: 0.3rem 0 0.45rem 3px;
}
.discover-modal-no-audio-label input[type="checkbox"] {
  width: 0.82rem;
  height: 0.82rem;
  accent-color: var(--merlot);
  cursor: pointer;
  margin: 0;
}

.discover-modal-actions .primary-button {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  flex: 1 1 100%;
  justify-content: center;
}

/* ── Read-only mode (no audiobook) ── */

.read-only-mode .transport-wing,
.read-only-mode .transport-controls,
.read-only-mode #generate-button,
.read-only-mode .generation-card {
  display: none !important;
}

/* ── Confirm Dialog ── */

.confirm-dialog {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: confirm-fade-in 180ms ease both;
}

.confirm-dialog.hidden {
  display: none;
}

.confirm-dialog-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(5, 6, 5, 0.45);
  backdrop-filter: blur(4px);
}

.confirm-dialog-card {
  position: relative;
  width: min(28rem, 90vw);
  background: var(--calm);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 64px rgba(5, 6, 5, 0.25), 0 8px 20px rgba(5, 6, 5, 0.12);
  padding: 2rem 2rem 1.5rem;
  display: grid;
  gap: 0.6rem;
  animation: confirm-card-in 260ms var(--ease-spring) both;
}

.confirm-dialog-title {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--noir);
  margin: 0;
}

.confirm-dialog-message {
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.55;
  margin: 0 0 0.5rem;
}

.confirm-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.65rem;
  padding-top: 0.5rem;
}

.confirm-dialog-btn {
  border: 0;
  border-radius: var(--radius-full);
  padding: 0.6rem 1.4rem;
  font-size: 0.92rem;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--duration-fast), transform var(--duration-fast) var(--ease-spring);
}

.confirm-dialog-btn.cancel {
  background: var(--sand);
  color: var(--noir);
}

.confirm-dialog-btn.cancel:hover {
  background: var(--line-strong);
}

.confirm-dialog-btn.danger {
  background: var(--merlot);
  color: var(--calm);
}

.confirm-dialog-btn.danger:hover {
  background: rgba(63, 11, 13, 0.92);
  transform: scale(1.03);
}

@keyframes confirm-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes confirm-card-in {
  from { opacity: 0; transform: translateY(12px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── Settings Row ── */

.app-settings-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr));
  gap: 1.2rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--line);
}

/* ═══════════════════════════════════════════════════════════
   LIBRARY
   ═══════════════════════════════════════════════════════════ */

.library-layout {
  display: none; /* legacy — replaced by full-width grid */
}

.library-main, .library-sidebar, .reader-side {
  display: grid;
  gap: 1.2rem;
  align-content: start;
}

.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr));
  gap: 1.25rem;
  min-height: 14rem;
}

.book-card {
  width: 100%;
  min-height: 18rem;
  display: grid;
  grid-template-rows: 1fr auto;
  gap: 0.6rem;
  padding: 0.55rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, rgba(254, 249, 238, 0.95), rgba(240, 230, 212, 0.88));
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  text-align: left;
  transition: box-shadow var(--duration-normal), border-color var(--duration-fast);
}

.book-card:hover,
.book-card:focus-visible {
  box-shadow: var(--shadow-lg);
  border-color: var(--line-strong);
}

.book-card.active {
  border-color: rgba(38, 52, 43, 0.35);
  box-shadow: var(--shadow-lg), 0 0 0 2px rgba(38, 52, 43, 0.1);
}

.book-cover,
.current-book-cover {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-md);
  background: linear-gradient(160deg, var(--forest), var(--merlot));
  color: rgba(254, 249, 238, 0.88);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.book-cover::before,
.current-book-cover::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(255,255,255,0.06) 0, rgba(255,255,255,0) 14%, rgba(255,255,255,0.04) 88%, rgba(255,255,255,0.1) 100%),
    repeating-linear-gradient(145deg, rgba(255,255,255,0.015) 0, rgba(255,255,255,0.015) 7px, rgba(0,0,0,0.03) 7px, rgba(0,0,0,0.03) 14px);
}

.book-cover {
  display: grid;
  place-items: center;
  aspect-ratio: 2 / 3;
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 600;
  letter-spacing: 0.03em;
}

.book-cover img, .current-book-cover img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  position: relative;
  z-index: 1;
}

.book-card-copy { display: grid; gap: 0.3rem; }
.book-card-copy strong { font-family: var(--font-display); font-size: 1.05rem; font-weight: 600; color: var(--noir); line-height: 1.25; }
.book-card-copy small { color: var(--muted); font-size: 0.82rem; }
.book-card-progress { display: grid; gap: 0.4rem; }

.book-card-delete {
  position: absolute;
  z-index: 2;
  top: 1rem;
  right: 1rem;
  border: 0;
  border-radius: var(--radius-full);
  padding: 0.45rem 0.75rem;
  background: rgba(5, 6, 5, 0.75);
  color: var(--calm);
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 500;
  backdrop-filter: blur(8px);
  transition: background var(--duration-fast), transform var(--duration-fast) var(--ease-spring);
}

.book-card-delete:hover { background: rgba(63, 11, 13, 0.92); }
.book-card-delete:disabled { cursor: not-allowed; opacity: 0.65; }

.section-heading {
  justify-content: space-between;
  align-items: flex-start;
}

.meta-pill, .soft-pill {
  display: inline-flex;
  align-items: center;
  border-radius: var(--radius-full);
  padding: 0.48rem 0.78rem;
  font-size: 0.78rem;
  font-weight: 500;
  border: 1px solid var(--line);
}

.meta-pill { background: rgba(254, 249, 238, 0.85); color: rgba(26, 18, 16, 0.72); }
.soft-pill { background: rgba(38, 52, 43, 0.06); color: var(--forest); }

.stack { display: grid; gap: 1rem; }
.compact-gap { gap: 0.8rem; }

/* ── Upload Zone ── */

.upload-zone {
  display: grid;
  gap: 0.5rem;
  padding: 1.4rem;
  border: 1px dashed rgba(165, 138, 123, 0.35);
  border-radius: var(--radius-md);
  background: linear-gradient(180deg, rgba(254, 249, 238, 0.5), rgba(240, 230, 212, 0.3));
  cursor: pointer;
  text-align: center;
  transition: border-color var(--duration-fast), background var(--duration-fast);
}

.upload-zone:hover {
  border-color: rgba(38, 52, 43, 0.4);
  background: linear-gradient(180deg, rgba(254, 249, 238, 0.7), rgba(240, 230, 212, 0.5));
}

.upload-zone input { display: none; }

.upload-zone.has-file {
  border-style: solid;
  border-color: var(--accent);
  background: rgba(75, 106, 65, 0.08);
  font-weight: 500;
  word-break: break-all;
}

.upload-icon {
  display: grid;
  place-items: center;
  justify-self: center;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: var(--radius-full);
  background: rgba(38, 52, 43, 0.06);
  color: var(--forest);
}

.upload-icon svg { width: 1.2rem; height: 1.2rem; }
.upload-title { font-family: var(--font-display); font-size: 1.1rem; font-weight: 600; color: var(--noir); }
.upload-subtitle { color: var(--muted); font-size: 0.88rem; line-height: 1.55; }
.upload-premium-badge { display: none; }

/* Free-plan gating for upload zone */
.free-plan .upload-zone {
  opacity: 0.45;
  pointer-events: none;
  position: relative;
}
.free-plan .upload-premium-badge {
  display: inline-block;
  background: var(--forest);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-full);
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
.free-plan .upload-zone .upload-title::after {
  content: " — Premium";
  color: var(--accent);
  font-weight: 700;
}
.free-plan textarea[disabled] {
  opacity: 0.4;
  pointer-events: none;
}

/* ── Buttons (App Shell Legacy Compat) ── */

.primary-button, .secondary-button, .ghost-button {
  appearance: none;
  border: 0;
  border-radius: var(--radius-full);
  padding: 0.82rem 1.2rem;
  cursor: pointer;
  font-weight: 500;
  font-size: 0.94rem;
  transition: transform var(--duration-fast) var(--ease-spring), box-shadow var(--duration-normal), opacity var(--duration-fast), background var(--duration-fast);
}

.primary-button:disabled, .secondary-button:disabled, .ghost-button:disabled, .page-turn-button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.primary-button {
  background: linear-gradient(145deg, var(--forest), #1a2620);
  color: var(--calm);
  box-shadow: var(--shadow-md);
}

.secondary-button {
  background: var(--merlot);
  color: var(--calm);
  box-shadow: var(--shadow-sm);
}

.ghost-button {
  border: 1px solid var(--line);
  background: rgba(254, 249, 238, 0.7);
  color: var(--ink);
}

.primary-button:hover, .secondary-button:hover, .ghost-button:hover, .page-turn-button:hover {
  transform: translateY(-1px);
}

.danger-button { color: var(--merlot); }

.status-text { color: var(--muted); min-height: 1.4rem; font-size: 0.88rem; }
.status-text.is-error { color: var(--merlot); }

/* ═══════════════════════════════════════════════════════════
   VOICE SETTINGS
   ═══════════════════════════════════════════════════════════ */

.voice-shelf { display: grid; gap: 0.75rem; }

.voice-card {
  width: 100%;
  display: grid;
  gap: 0.2rem;
  padding: 0.9rem 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(254, 249, 238, 0.7);
  cursor: pointer;
  text-align: left;
  transition: border-color var(--duration-fast), background var(--duration-fast), transform var(--duration-fast) var(--ease-spring);
}

.voice-card strong { font-family: var(--font-display); font-size: 1.15rem; font-weight: 600; }
.voice-card small { color: var(--muted); font-size: 0.85rem; }

.voice-card:hover { border-color: var(--line-strong); transform: translateY(-1px); }
.voice-card.active { border-color: rgba(38, 52, 43, 0.3); background: rgba(38, 52, 43, 0.04); }

.catalog-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(254, 249, 238, 0.55);
}

.catalog-panel summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 1rem;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.98rem;
  color: var(--noir);
}

.catalog-panel summary::-webkit-details-marker { display: none; }

.piper-catalog { display: grid; gap: 0.85rem; padding: 0 1rem 1rem; }
.piper-language-group { display: grid; gap: 0.5rem; }
.piper-language-header { display: flex; justify-content: space-between; gap: 0.75rem; color: var(--muted); font-size: 0.85rem; }
.piper-chip-list { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.piper-chip {
  display: inline-grid;
  gap: 0.1rem;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: rgba(254, 249, 238, 0.8);
  font-size: 0.78rem;
}

.piper-chip strong { font-size: 0.82rem; }

.support-card, .support-list { display: grid; gap: 0.75rem; }

.support-item {
  display: grid;
  gap: 0.2rem;
  padding: 0.85rem 1rem;
  border-radius: var(--radius-sm);
  background: rgba(254, 249, 238, 0.75);
  border: 1px solid var(--line);
}

.network-list { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.network-list span {
  padding: 0.42rem 0.7rem;
  border-radius: var(--radius-full);
  background: rgba(254, 249, 238, 0.75);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.78rem;
}

/* ═══════════════════════════════════════════════════════════
   READER
   ═══════════════════════════════════════════════════════════ */

.reader-layout {
  display: grid;
  grid-template-columns: minmax(18rem, 0.9fr) minmax(0, 1.7fr) minmax(18rem, 0.95fr);
  gap: 1.25rem;
  align-items: start;
}

.reader-stage-shell { display: grid; gap: 1rem; }

.reader-stage-status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  padding: 0.45rem 1rem;
  min-height: 2rem;
  color: var(--muted);
  text-align: center;
  font-size: 0.82rem;
}

.stage-spinner {
  width: 0.85rem;
  height: 0.85rem;
  border-radius: 50%;
  border: 2px solid rgba(63, 11, 13, 0.15);
  border-top-color: var(--merlot);
  animation: spin 760ms linear infinite;
}

#reader-stage-spinner.hidden {
  display: block !important;
  visibility: hidden;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Transport Bar ── */

.reader-transport {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  grid-template-rows: auto auto;
  align-items: center;
  gap: 0.25rem 1rem;
  padding: 0.5rem 0;
}

.reader-stage-status {
  grid-column: 1 / -1;
  justify-self: start;
}

.transport-wing {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.transport-wing-left {
  justify-self: end;
}

.transport-wing-right {
  justify-self: start;
}

.transport-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  justify-self: center;
}

/* Volume slider */
.transport-range-label {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--mink);
  cursor: pointer;
}

.transport-range {
  -webkit-appearance: none;
  appearance: none;
  width: 5rem;
  height: 4px;
  border-radius: 2px;
  background: var(--line);
  outline: none;
  cursor: pointer;
}

.transport-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--merlot);
  border: 2px solid var(--calm);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
}

.transport-range::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--merlot);
  border: 2px solid var(--calm);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
}

/* Speed button */
.transport-speed-btn {
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 600;
  min-width: 3rem;
  height: 2.1rem;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  background: rgba(254, 249, 238, 0.8);
  color: var(--ink);
  cursor: pointer;
  transition: background 120ms, box-shadow 120ms;
  padding: 0 0.75rem;
}

.transport-speed-btn:hover {
  background: rgba(254, 249, 238, 1);
  box-shadow: var(--shadow-sm);
}

.transport-btn {
  width: 2.5rem;
  height: 2.5rem;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgba(254, 249, 238, 0.8);
  color: var(--ink);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform 120ms, background 120ms, box-shadow 120ms;
}

.transport-btn:hover:not(:disabled) {
  background: rgba(254, 249, 238, 1);
  box-shadow: var(--shadow-sm);
  transform: scale(1.06);
}

.transport-btn:disabled {
  cursor: not-allowed;
  opacity: 0.35;
}

.transport-btn-main {
  width: 3.2rem;
  height: 3.2rem;
  border: none;
  background: linear-gradient(145deg, var(--merlot), #5a1213);
  color: var(--calm);
  box-shadow: var(--shadow-md), inset 0 1px 0 rgba(255,255,255,0.08);
}

.transport-btn-main:hover:not(:disabled) {
  background: linear-gradient(145deg, #5a1213, var(--merlot));
  box-shadow: var(--shadow-lg);
  transform: scale(1.08);
}

.transport-btn-main .icon-play,
.transport-btn-main .icon-pause { display: block; }
.transport-btn-main .icon-pause.hidden,
.transport-btn-main .icon-play.hidden { display: none; }

.reader-stage {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: stretch;
  gap: 1rem;
}

.page-turn-button {
  align-self: center;
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: rgba(254, 249, 238, 0.8);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: transform 120ms var(--ease-spring), box-shadow 120ms, background 120ms;
}

.page-turn-button:hover:not(:disabled) {
  transform: scale(1.08);
  background: rgba(254, 249, 238, 0.95);
  box-shadow: var(--shadow-md);
}

.page-turn-button:disabled { opacity: 0.3; cursor: not-allowed; }

.page-turn-button svg {
  width: 1.2rem;
  height: 1.2rem;
  stroke: var(--ink);
  stroke-width: 1.8;
  fill: none;
}

/* ── Reader Page (single page, book-like) ── */

.reader-page {
  position: relative;
  height: clamp(32rem, 72vh, 54rem);
  overflow: hidden;
  border-radius: 4px 12px 12px 4px;
  border: 1px solid rgba(185, 170, 150, 0.35);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.18), rgba(255,255,255,0) 20%),
    linear-gradient(90deg, #EDE1CF 0%, #F5EAD8 4%, #FAF0DE 18%, #FBF2E0 50%, #F9EDD9 100%);
  box-shadow:
    -4px 0 12px -4px rgba(130, 110, 90, 0.18),
    inset 0 0 0 1px rgba(255, 250, 240, 0.4),
    0 8px 32px -8px rgba(80, 60, 40, 0.18),
    0 2px 8px rgba(80, 60, 40, 0.06);
  transform-origin: left center;
}

/* Decorative left edge — worn spine/binding strip */
.page-edge-left {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 2.2rem;
  background:
    linear-gradient(90deg,
      rgba(150, 120, 90, 0.14) 0%,
      rgba(170, 140, 110, 0.08) 40%,
      rgba(200, 180, 160, 0.02) 100%);
  border-right: 1px solid rgba(165, 138, 123, 0.1);
  pointer-events: none;
  z-index: 1;
}

.page-edge-left::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 3px;
  background: linear-gradient(180deg,
    rgba(120, 90, 60, 0.22),
    rgba(140, 110, 80, 0.28) 20%,
    rgba(130, 100, 70, 0.25) 80%,
    rgba(120, 90, 60, 0.2));
}

.reader-page-overlay {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background: linear-gradient(180deg, rgba(250, 244, 232, 0.75), rgba(250, 244, 232, 0.55));
  backdrop-filter: blur(6px);
}

.reader-page-overlay-card {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  width: min(22rem, 100%);
  padding: 1rem 1.1rem;
  border-radius: var(--radius-lg);
  background: rgba(254, 249, 238, 0.95);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-md);
}

.reader-page-overlay-card strong { display: block; margin-bottom: 0.15rem; }
.reader-page-overlay-card p { color: var(--muted); line-height: 1.45; font-size: 0.9rem; }

.reader-content.page-enter-forward  { animation: page-enter-forward 320ms ease-out; }
.reader-content.page-enter-backward { animation: page-enter-backward 320ms ease-out; }

.page-grain {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 12% 18%, rgba(255,255,255,0.25), transparent 14%),
    repeating-linear-gradient(0deg, rgba(165, 138, 123, 0.02) 0, rgba(165, 138, 123, 0.02) 1.5px, rgba(255,255,255,0) 1.5px, rgba(255,255,255,0) 7px);
  opacity: 0.6;
  pointer-events: none;
  z-index: 0;
}

.reader-content {
  position: relative;
  z-index: 2;
  height: 100%;
  padding: clamp(2rem, 3.5vw, 3rem) clamp(2.5rem, 5vw, 4rem) 3.5rem clamp(3rem, 5vw, 4.5rem);
  overflow-y: auto;
  overflow-x: hidden;
}

.reader-content.empty-state {
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--muted);
  font-size: 1rem;
}

.reader-article {
  font-family: var(--font-reader);
  font-size: var(--reader-font-size);
  line-height: 1.85;
  letter-spacing: 0.005em;
  color: var(--noir);
}

.reader-article p {
  margin: 0 0 1.1rem;
  break-inside: avoid;
  text-align: justify;
  text-justify: inter-word;
  hyphens: auto;
}

.token {
  border-radius: 0.25rem;
  padding: 0.02rem 0.04rem;
  transition: background 100ms, box-shadow 100ms;
  cursor: pointer;
}

.token:hover { background: rgba(63, 11, 13, 0.07); }
.token.active { background: rgba(63, 11, 13, 0.18); box-shadow: 0 0 0 2px rgba(63, 11, 13, 0.1); border-radius: 0.2rem; }
.token.is-saved { background: rgba(38, 52, 43, 0.12); box-shadow: inset 0 -2px 0 rgba(38, 52, 43, 0.25); }
.token.is-looked-up { background: rgba(165, 138, 123, 0.2); }

/* ── Word Tooltip ── */
.word-tooltip {
  position: fixed;
  z-index: 9999;
  display: none;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.75rem;
  background: var(--forest);
  color: var(--calm);
  font-size: 0.88rem;
  font-family: var(--font-body);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  pointer-events: none;
  white-space: nowrap;
  max-width: 90vw;
  overflow: hidden;
  text-overflow: ellipsis;
  animation: wordTipIn 120ms var(--ease-spring);
}
.word-tooltip.visible { display: flex; }
.word-tooltip-source { font-weight: 600; }
.word-tooltip-sep { opacity: 0.55; font-size: 0.8em; }
.word-tooltip-result { font-style: italic; }
@keyframes wordTipIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

.page-footer {
  position: absolute;
  left: 0; right: 0; bottom: 0.8rem;
  display: flex;
  justify-content: center;
  z-index: 2;
  pointer-events: none;
}

#page-footer-number {
  font-family: var(--font-display);
  font-size: 0.85rem;
  color: var(--muted);
  opacity: 0.7;
  letter-spacing: 0.02em;
}

/* ── Book Summary ── */

.current-book-head {
  display: grid;
  grid-template-columns: 6.5rem minmax(0, 1fr);
  gap: 0.85rem;
  align-items: start;
}

.current-book-cover {
  min-height: 9rem;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 600;
  border-radius: var(--radius-md);
}

.current-book-copy { display: grid; gap: 0.45rem; }

.progress-block { display: grid; gap: 0.5rem; }

.progress-track {
  height: 0.65rem;
  border-radius: var(--radius-full);
  overflow: hidden;
  background: rgba(165, 138, 123, 0.1);
}

.progress-fill {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--merlot), var(--mink) 50%, var(--forest));
  transition: width 280ms var(--ease-out);
}

.goto-form { display: grid; gap: 0.75rem; }

.generation-card, .book-summary-card, .lookup-card,
.saved-words-card, .settings-card, .profile-card, .import-card {
  padding: 1.2rem;
  display: grid;
  gap: 1rem;
}

.generation-status { display: grid; gap: 0.7rem; }

.log-surface {
  display: grid;
  gap: 0.4rem;
  max-height: 12rem;
  overflow: auto;
  padding: 0.85rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: rgba(254, 249, 238, 0.65);
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.55;
}

/* ── Lookup & Vocabulary ── */

.lookup-output, .saved-words-list { display: grid; gap: 0.8rem; }

.lookup-output {
  min-height: 8rem;
  padding: 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: rgba(254, 249, 238, 0.7);
}

.lookup-output.empty-state,
.book-grid.empty-state,
.saved-words-list.empty-state,
.piper-catalog.empty-state {
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--muted);
  border-style: dashed;
  font-size: 0.92rem;
}

.book-grid.empty-state {
  grid-template-columns: 1fr;
  min-height: 6rem;
  padding: 2rem;
  border: 1px dashed var(--line);
  border-radius: var(--radius-lg);
}

.book-grid.loading-state {
  display: grid;
  place-items: center;
  min-height: 14rem;
  border: 1px dashed var(--line);
  border-radius: var(--radius-lg);
}

.library-loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.85rem;
  color: var(--muted);
  font-size: 1.05rem;
  padding: 3rem 0;
  width: 100%;
  grid-column: 1 / -1;
}

.library-loader .stage-spinner {
  width: 2.2rem;
  height: 2.2rem;
}

.book-card-shell {
  position: relative;
  animation: card-fade-in 420ms ease both;
  transition: transform var(--duration-normal) var(--ease-spring);
}
.book-card-shell:hover {
  transform: translateY(-4px);
}

@keyframes card-fade-in {
  from { opacity: 0; transform: translateY(12px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.lookup-source { font-family: var(--font-display); font-size: 1.25rem; font-weight: 600; }
.lookup-result { color: var(--muted); line-height: 1.65; }
.lookup-meta { color: rgba(26, 18, 16, 0.5); font-size: 0.82rem; }

.saved-word-item {
  display: grid;
  gap: 0.5rem;
  padding: 0.9rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: rgba(254, 249, 238, 0.78);
}

.saved-word-head {
  display: flex;
  justify-content: space-between;
  gap: 0.8rem;
  align-items: start;
}

.saved-word-head strong { font-family: var(--font-display); font-size: 1.1rem; font-weight: 600; }

.saved-word-delete {
  border: 0;
  background: none;
  color: rgba(63, 11, 13, 0.55);
  cursor: pointer;
  padding: 0;
  transition: color var(--duration-fast);
}

.saved-word-delete:hover { color: var(--merlot); }

.saved-word-translation { color: var(--muted); line-height: 1.55; }
.saved-word-context { color: rgba(26, 18, 16, 0.5); font-size: 0.85rem; line-height: 1.5; }

.back-button {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.is-loading { opacity: 0.65; }

/* ═══════════════════════════════════════════════════════════
   ANIMATIONS
   ═══════════════════════════════════════════════════════════ */

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes fade-in-up {
  from { opacity: 0; transform: translateY(24px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fade-in-down {
  from { opacity: 0; transform: translateY(-16px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes page-enter-forward {
  from { opacity: 0; transform: translateX(24px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes page-enter-backward {
  from { opacity: 0; transform: translateX(-24px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ═══════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════ */

@media (max-width: 1200px) {
  .reader-layout {
    grid-template-columns: minmax(18rem, 0.95fr) minmax(0, 1.5fr);
  }
  .reader-side.right {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
  }
  .features-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .feature-card-lg {
    grid-column: span 1;
  }
}

@media (max-width: 1024px) {
  .hero-card,
  .library-layout,
  .reader-layout {
    grid-template-columns: 1fr;
  }
  .import-form-grid { grid-template-columns: 1fr; }
  .reader-stage { grid-template-columns: 1fr; }
  .page-turn-button { width: 100%; height: auto; min-height: 3rem; border-radius: var(--radius-md); }
  .page-turn-left { order: 2; }
  .page-turn-right { order: 3; }
  .reader-page { order: 1; }
  .reader-side.right { grid-template-columns: 1fr; }
  .landing-hero { grid-template-columns: 1fr; justify-items: center; text-align: center; gap: 2rem; }
  .hero-right { justify-items: center; text-align: center; }
  .hero-actions { justify-content: center; }
  .hero-logo-frame { width: clamp(12rem, 40vw, 16rem); height: clamp(12rem, 40vw, 16rem); }
  .preview-body { grid-template-columns: 1fr; }
  .preview-gutter { display: none; }
  .preview-page-right { display: none; }
  .how-steps { grid-template-columns: 1fr; gap: 0; }
  .how-step-divider { width: 100%; height: 1px; min-height: auto; }
  .shelf-book { width: clamp(2.5rem, 4vw, 3.5rem); height: 10rem; }
}

@media (max-width: 820px) {
  .app-topbar { flex-direction: column; }
  .current-book-head { grid-template-columns: 1fr; }
  .features-grid { grid-template-columns: 1fr; }
  .feature-card-lg { grid-column: span 1; }
  .shelf-ornament-left, .shelf-ornament-right { display: none; }
  .discover-modal-body { grid-template-columns: 8rem minmax(0, 1fr); }
  .discover-header { flex-direction: column; }
  .discover-controls { align-items: stretch; }
}

@media (max-width: 640px) {
  .app-main, .app-topbar { padding-left: 0.85rem; padding-right: 0.85rem; }
  .hero-copy h2 { max-width: 100%; }
  .book-grid { grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr)); }
  .library-hero { flex-direction: column; align-items: stretch; }
  .app-settings-row { grid-template-columns: 1fr; }
  .discover-grid { grid-template-columns: repeat(auto-fill, minmax(8rem, 1fr)); }
  .discover-search-input { width: 100%; }
  .discover-modal-body { grid-template-columns: 1fr; justify-items: center; text-align: center; }
  .discover-modal-actions { justify-content: center; }
  .reader-content { padding: 1.2rem 1rem 3.5rem; }
  .landing-nav { padding: 1rem 1.25rem; }
  .landing-hero { padding-left: 1.25rem; padding-right: 1.25rem; }
  .landing-features, .landing-how, .landing-cta { padding-left: 1.25rem; padding-right: 1.25rem; }
  .landing-shelf { padding-left: 1.25rem; padding-right: 1.25rem; }
  .landing-preview { padding-left: 1.25rem; padding-right: 1.25rem; }
  .footer-inner { flex-direction: column; gap: 0.75rem; text-align: center; }
  .shelf-row { gap: 0.4rem; padding: 0 0.5rem; }
  .shelf-book { width: clamp(2.5rem, 12vw, 3.5rem); height: 9rem; }
  .shelf-book-title { font-size: 0.55rem; }
  .shelf-book-author { font-size: 0.45rem; }
}

/* ═══════════════════════════════════════════════════════════
   PROFILE / SETTINGS MODAL
   ═══════════════════════════════════════════════════════════ */

.profile-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}
.profile-modal.hidden { display: none; }

.profile-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(5, 6, 5, 0.55);
  backdrop-filter: blur(12px);
  animation: fade-in var(--duration-normal) var(--ease-out) both;
}

.profile-modal-card {
  position: relative;
  width: min(36rem, 100%);
  max-height: 88vh;
  overflow-y: auto;
  padding: clamp(1.5rem, 3vw, 2.5rem);
  border-radius: var(--radius-xl);
  background: linear-gradient(180deg, rgba(254, 249, 238, 0.98), rgba(240, 230, 212, 0.96));
  border: 1px solid var(--line);
  box-shadow: var(--shadow-xl), 0 25px 60px rgba(5, 6, 5, 0.2);
  animation: fade-in-up 280ms ease both;
  display: grid;
  gap: 1.6rem;
}

.profile-modal-close-btn {
  position: absolute;
  top: 0.85rem;
  right: 0.85rem;
  width: 2rem;
  height: 2rem;
  padding: 0;
  display: grid;
  place-items: center;
  border-radius: var(--radius-full);
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  z-index: 2;
  transition: color var(--duration-fast), background var(--duration-fast);
}
.profile-modal-close-btn:hover {
  color: var(--ink);
  background: rgba(0, 0, 0, 0.06);
}

/* Header with avatar */
.profile-modal-header {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.profile-avatar {
  width: 3.2rem;
  height: 3.2rem;
  border-radius: var(--radius-full);
  background: linear-gradient(145deg, var(--forest), #1e2d23);
  color: var(--calm);
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.35rem;
  letter-spacing: 0;
  flex-shrink: 0;
}

.profile-modal-title {
  font-size: 1.35rem;
  letter-spacing: -0.02em;
}
.profile-modal-subtitle {
  font-size: 0.88rem;
  color: var(--muted);
  margin-top: 0.1rem;
}

/* Section groups */
.profile-section {
  display: grid;
  gap: 0.8rem;
}
.profile-section-title {
  font-family: var(--font-display);
  font-size: 0.88rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--mink);
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--line);
}

/* Form rows */
.profile-form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.8rem;
}
.profile-form-row-3 {
  grid-template-columns: 1fr 1fr 1fr;
}
.profile-save-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.profile-save-status {
  font-size: 0.82rem;
  color: var(--muted);
  transition: opacity var(--duration-normal);
}
.profile-save-status.is-error { color: var(--merlot); }
.profile-save-status.is-ok { color: var(--forest); }

.profile-save-row-bottom {
  border-top: 1px solid var(--line);
  padding-top: 1.2rem;
}

.btn-sm {
  padding: 0.55rem 1.1rem;
  font-size: 0.85rem;
  border-radius: var(--radius-full);
}

/* Plan cards */
.plan-cards {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.75rem;
}

.plan-card {
  position: relative;
  padding: 1.2rem 1rem;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--line);
  background: rgba(254, 249, 238, 0.6);
  display: grid;
  gap: 0.5rem;
  text-align: center;
  transition: border-color var(--duration-normal), box-shadow var(--duration-normal);
}
.plan-card.plan-card-active {
  border-color: var(--forest);
  background: rgba(38, 52, 43, 0.07);
  box-shadow: 0 0 0 2px var(--forest), var(--shadow-md);
  transform: scale(1.03);
}
.plan-card.plan-card-recommended {
  border-color: #c9963b;
  box-shadow: 0 0 0 1.5px #c9963b, var(--shadow-md);
  background: rgba(201, 150, 59, 0.06);
}

.plan-card-badge {
  position: absolute;
  top: -0.55rem;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.15rem 0.55rem;
  border-radius: var(--radius-full);
  white-space: nowrap;
}
.plan-card-badge-current {
  background: var(--forest);
  color: var(--calm);
}
.plan-card-badge-best {
  background: linear-gradient(135deg, #c9963b, #a67518);
  color: #fff;
  font-size: 0.66rem;
  padding: 0.2rem 0.7rem;
  box-shadow: 0 2px 8px rgba(201, 150, 59, 0.45);
}

.plan-card-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: -0.01em;
}
.plan-card-price {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1;
}
.plan-card-price small {
  font-size: 0.72rem;
  font-weight: 400;
  color: var(--muted);
}
.plan-card-desc {
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.45;
}
.plan-card-action {
  margin-top: 0.25rem;
}
.plan-card-action .btn {
  width: 100%;
  font-size: 0.82rem;
  padding: 0.55rem 0.8rem;
}
.plan-card-action .btn-outline {
  background: transparent;
  border: 1.5px solid var(--line-strong);
  color: var(--ink);
}
.plan-card-action .btn-outline:hover {
  background: rgba(0,0,0,0.03);
}

/* First-login welcome modal */
.welcome-modal {
  position: fixed;
  inset: 0;
  z-index: 250;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}
.welcome-modal.hidden { display: none; }
.welcome-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(5, 6, 5, 0.55);
  backdrop-filter: blur(12px);
  animation: fade-in var(--duration-normal) var(--ease-out) both;
}
.welcome-modal-card {
  position: relative;
  width: min(28rem, 100%);
  padding: clamp(1.5rem, 3vw, 2.5rem);
  border-radius: var(--radius-xl);
  background: linear-gradient(180deg, rgba(254, 249, 238, 0.98), rgba(240, 230, 212, 0.96));
  border: 1px solid var(--line);
  box-shadow: var(--shadow-xl), 0 25px 60px rgba(5, 6, 5, 0.2);
  animation: fade-in-up 280ms ease both;
  display: grid;
  gap: 1.2rem;
  text-align: center;
}
.welcome-modal-card h2 {
  font-size: 1.5rem;
}
.welcome-modal-card .welcome-subtitle {
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.5;
}
.welcome-modal-card .profile-form-row {
  text-align: left;
}
.welcome-modal-card .profile-form-row-3 {
  text-align: left;
}

/* Topbar user name clickable */
.topbar-profile-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-full);
  padding: 0.82rem 1.2rem;
  background: rgba(254, 249, 238, 0.7);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 0.94rem;
  font-weight: 500;
  cursor: pointer;
  transition: transform var(--duration-fast) var(--ease-spring), box-shadow var(--duration-normal), background var(--duration-fast);
}
.topbar-profile-btn:hover {
  transform: translateY(-1px);
}
.topbar-profile-btn svg {
  color: var(--mink);
  flex-shrink: 0;
}
.topbar-profile-label {
  white-space: nowrap;
}

/* Responsive */
@media (max-width: 700px) {
  .profile-form-row { grid-template-columns: 1fr; }
  .profile-form-row-3 { grid-template-columns: 1fr; }
  .plan-cards { grid-template-columns: 1fr; }
}

/* ── Legal Page Overlay ── */

.legal-overlay {
  position: fixed;
  inset: 0;
  z-index: 9500;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: confirm-fade-in 180ms ease both;
}

.legal-overlay.hidden {
  display: none;
}

.legal-overlay-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(5, 6, 5, 0.5);
  backdrop-filter: blur(6px);
}

.legal-overlay-card {
  position: relative;
  width: min(44rem, 92vw);
  max-height: 85vh;
  background: var(--calm);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 64px rgba(5, 6, 5, 0.25), 0 8px 20px rgba(5, 6, 5, 0.12);
  overflow-y: auto;
  animation: confirm-card-in 260ms var(--ease-spring) both;
}

.legal-overlay-close {
  position: sticky;
  top: 0.75rem;
  float: right;
  margin: 0.75rem 0.75rem 0 0;
  width: 2.2rem;
  height: 2.2rem;
  border: none;
  border-radius: 50%;
  background: var(--sand);
  color: var(--noir);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
  transition: background var(--duration-fast);
}

.legal-overlay-close:hover {
  background: var(--line-strong);
}

.legal-overlay-content {
  padding: 2rem 2.5rem 2.5rem;
}

.legal-overlay-content h1 {
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 600;
  color: var(--merlot);
  margin: 0 0 0.3rem;
}

.legal-overlay-content .updated {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 1.5rem;
}

.legal-overlay-content h2 {
  font-size: 1.05rem;
  font-weight: 600;
  margin: 1.6rem 0 0.4rem;
}

.legal-overlay-content p,
.legal-overlay-content ul {
  margin-bottom: 0.85rem;
  font-size: 0.92rem;
  line-height: 1.65;
}

.legal-overlay-content ul {
  padding-left: 1.4rem;
}

.legal-overlay-content li {
  margin-bottom: 0.3rem;
}

.legal-overlay-content a {
  color: var(--merlot);
}

@media (max-width: 600px) {
  .legal-overlay-card {
    width: 100vw;
    max-height: 100vh;
    border-radius: 0;
  }
  .legal-overlay-content {
    padding: 1.5rem 1.25rem 2rem;
  }
}

/* ── Cookie consent banner ─────────────────────────────────── */

.cookie-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.2rem;
  padding: 1rem 2rem;
  background: var(--forest);
  color: var(--calm);
  font-size: 0.88rem;
  line-height: 1.5;
  box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.25);
}

.cookie-banner.hidden {
  display: none;
}

.cookie-banner p {
  margin: 0;
  flex: 1;
  max-width: 48rem;
}

.cookie-banner a {
  color: var(--sand);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.cookie-accept-btn {
  flex-shrink: 0;
  padding: 0.5rem 1.4rem;
  border: 1px solid var(--sand);
  border-radius: 0.5rem;
  background: transparent;
  color: var(--calm);
  font-family: var(--font-body);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 120ms, color 120ms;
}

.cookie-accept-btn:hover {
  background: var(--calm);
  color: var(--forest);
}

@media (max-width: 600px) {
  .cookie-banner {
    flex-direction: column;
    text-align: center;
    padding: 1rem 1.25rem;
    gap: 0.75rem;
  }
}

/* ── Upgrade Modal ──────────────────────────────────────── */
.upgrade-modal {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}
.upgrade-modal.hidden { display: none; }
.upgrade-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(5, 6, 5, 0.6);
  backdrop-filter: blur(14px);
  animation: fade-in var(--duration-normal) var(--ease-out) both;
}
.upgrade-modal-card {
  position: relative;
  width: min(26rem, 100%);
  padding: clamp(2rem, 4vw, 3rem) clamp(1.5rem, 3vw, 2.5rem);
  border-radius: var(--radius-xl);
  background: linear-gradient(170deg, rgba(254, 249, 238, 0.99), rgba(240, 230, 212, 0.97));
  border: 1px solid var(--line);
  box-shadow: var(--shadow-xl), 0 30px 80px rgba(63, 11, 13, 0.18);
  text-align: center;
  animation: slide-up var(--duration-normal) var(--ease-spring) both;
}
.upgrade-modal-close-btn {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  width: 2rem;
  height: 2rem;
  display: grid;
  place-items: center;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  border-radius: var(--radius-full);
  transition: background var(--duration-fast), color var(--duration-fast);
}
.upgrade-modal-close-btn:hover {
  background: rgba(0,0,0,0.06);
  color: var(--ink);
}
.upgrade-modal-icon {
  color: var(--merlot);
  margin-bottom: 0.75rem;
}
.upgrade-modal-title {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--noir);
  margin-bottom: 0.5rem;
  letter-spacing: -0.01em;
}
.upgrade-modal-desc {
  font-size: 0.92rem;
  line-height: 1.55;
  color: var(--muted);
  margin-bottom: 1.5rem;
}
.upgrade-modal-desc strong {
  color: var(--ink);
}
.upgrade-modal-plans {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.upgrade-modal-plan {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  padding: 1.2rem 0.75rem;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--line-strong);
  background: rgba(255,255,255, 0.6);
  cursor: pointer;
  transition: border-color var(--duration-fast), box-shadow var(--duration-fast), transform var(--duration-fast);
}
.upgrade-modal-plan:hover {
  border-color: var(--forest);
  box-shadow: 0 0 0 2px var(--forest);
  transform: translateY(-2px);
}
.upgrade-modal-plan-best {
  border-color: var(--merlot);
  background: rgba(63, 11, 13, 0.04);
}
.upgrade-modal-plan-best:hover {
  border-color: var(--merlot);
  box-shadow: 0 0 0 2px var(--merlot);
}
.upgrade-modal-plan-badge {
  position: absolute;
  top: -0.5rem;
  right: -0.3rem;
  font-size: 0.58rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.12rem 0.5rem;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--merlot), #5a1213);
  color: var(--calm);
  white-space: nowrap;
}
.upgrade-modal-plan-name {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--ink);
}
.upgrade-modal-plan-price {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--noir);
}
.upgrade-modal-plan-price small {
  font-size: 0.68rem;
  font-weight: 400;
  color: var(--muted);
}
.upgrade-modal-note {
  font-size: 0.72rem;
  color: var(--muted);
  opacity: 0.75;
}

/* ── Profile cancel row ──────────────────────────────── */
.profile-cancel-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--line);
}
.profile-cancel-row.hidden { display: none; }
.danger-link {
  color: var(--merlot);
  font-size: 0.82rem;
}
.danger-link:hover {
  text-decoration: underline;
}
.profile-contact-text {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.6rem;
  line-height: 1.5;
}

@media (max-width: 600px) {
  .upgrade-modal-plans {
    grid-template-columns: 1fr;
  }
}