/* ═══════════════════════════════════════════════════════════
   ספר מתכונים של סבתא — Premium Edition
   ═══════════════════════════════════════════════════════════ */

:root {
  color-scheme: light;

  /* Core palette */
  --paper: #fffcf7;
  --paper-warm: #f7edd8;
  --paper-edge: #d4b782;
  --ink: #1a1210;
  --ink-soft: #3d2e26;
  --muted: #6b5c52;

  /* Accent tones */
  --burgundy: #6b2030;
  --burgundy-deep: #3d1420;
  --gold: #c4944a;
  --gold-light: #e8c476;
  --gold-dim: rgba(196, 148, 74, 0.18);
  --copper: #a05a32;
  --sage: #4a6038;
  --sage-light: rgba(74, 96, 56, 0.12);

  /* Surfaces */
  --panel-bg: rgba(255, 252, 247, 0.92);
  --panel-border: rgba(100, 72, 42, 0.12);
  --panel-glow: rgba(196, 148, 74, 0.06);

  /* Shadows */
  --shadow-sm: 0 2px 8px rgba(26, 18, 16, 0.06);
  --shadow-md: 0 8px 32px rgba(26, 18, 16, 0.10);
  --shadow-lg: 0 24px 64px rgba(26, 18, 16, 0.16);
  --shadow-book: 0 32px 80px rgba(26, 18, 16, 0.32), 0 8px 24px rgba(26, 18, 16, 0.12);
  --shadow-elevated: 0 12px 40px rgba(26, 18, 16, 0.14), 0 2px 8px rgba(26, 18, 16, 0.06);

  /* Radius */
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;

  /* Transitions */
  --ease-out: cubic-bezier(0.16, 0.72, 0.18, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  overflow-x: hidden;
  direction: ltr;
  background: #f5ede0;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  direction: ltr;
  font-family: "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, sans-serif;
  font-weight: 400;
  color: var(--ink);
  background:
    radial-gradient(ellipse 80% 60% at 20% 10%, rgba(196, 148, 74, 0.06), transparent),
    radial-gradient(ellipse 60% 50% at 80% 90%, rgba(107, 32, 48, 0.04), transparent),
    linear-gradient(175deg, #faf6ee 0%, #f0e6d4 40%, #e4d5ba 100%);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.04;
  background-image:
    url("data:image/svg+xml,%3Csvg width='60' height='60' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M30 0v60M0 30h60' stroke='%23806040' stroke-width='.5' fill='none' opacity='.3'/%3E%3C/svg%3E");
  background-size: 60px 60px;
}

button,
input {
  font: inherit;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.4;
}

/* ───────────── Layout Shell ───────────── */

.app-shell {
  position: relative;
  width: 100%;
  min-height: 100vh;
  padding: 0;
  direction: ltr;
  display: grid;
  place-items: center;
}

.topbar,
.reader-layout,
.drawer,
.reader-meta,
.controls,
.details-card {
  direction: rtl;
}

/* ───────────── Top Bar (hidden) ───────────── */

.topbar {
  display: none;
}

.topbar > div,
.reader-panel,
.reader-layout,
.book-stage {
  min-width: 0;
}

.topbar h1,
.details-header h2,
.drawer-header h2 {
  margin: 0;
  font-family: "Segoe UI Variable", "Segoe UI", system-ui, sans-serif;
  letter-spacing: -0.02em;
}

.topbar h1 {
  font-size: 2.4rem;
  font-weight: 700;
  line-height: 1.1;
  color: var(--burgundy-deep);
  max-width: 100%;
  overflow-wrap: anywhere;
  background: linear-gradient(135deg, var(--burgundy-deep) 20%, var(--burgundy) 80%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--gold);
  letter-spacing: 0.08em;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
}

.topbar-actions,
.reader-meta,
.controls,
.details-header,
.details-actions,
.drawer-header {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ───────────── Reader Layout ───────────── */

.reader-layout {
  width: 100%;
  max-width: 100%;
  margin: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0;
}

.reader-panel {
  position: relative;
  display: grid;
  gap: 0;
}

/* ───────────── Drawer ───────────── */

.drawer {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 20;
  width: min(380px, calc(100vw - 40px));
  max-height: calc(100vh - 40px);
  padding: 18px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--panel-border);
  background: rgba(255, 252, 247, 0.96);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(24px) saturate(1.6);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(-10px) scale(0.98);
  transition:
    transform 260ms var(--ease-out),
    opacity 200ms ease,
    visibility 200ms ease;
}

.drawer.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

.drawer-header {
  padding-bottom: 12px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--panel-border);
}

.drawer-header h2 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--burgundy-deep);
}

.page-list {
  display: grid;
  gap: 6px;
  max-height: calc(100vh - 140px);
  overflow: auto;
  padding-top: 8px;
  scrollbar-width: thin;
  scrollbar-color: var(--gold-dim) transparent;
}

.page-list-button {
  width: 100%;
  display: grid;
  gap: 3px;
  text-align: right;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.6);
  color: var(--ink);
  cursor: pointer;
  transition:
    border-color 200ms ease,
    transform 200ms var(--ease-out),
    background 200ms ease,
    box-shadow 200ms ease;
}

.page-list-button:hover {
  border-color: var(--gold-dim);
  background: rgba(255, 252, 240, 0.9);
  transform: translateX(-2px);
  box-shadow: var(--shadow-sm);
}

.page-list-button.is-active {
  border-color: rgba(196, 148, 74, 0.4);
  background: rgba(255, 248, 230, 0.95);
  box-shadow: inset 3px 0 0 var(--gold), var(--shadow-sm);
}

.page-list-label {
  font-size: 0.72rem;
  color: var(--muted);
  font-weight: 500;
  letter-spacing: 0.02em;
}

.page-list-title {
  font-weight: 700;
  font-size: 0.92rem;
}

/* ───────────── Meta Bar, Controls, Details (hidden) ───────────── */

.reader-meta,
.controls,
.details-card {
  display: none;
}

/* ───────────── Book Stage ───────────── */

.book-stage {
  position: relative;
  width: 100%;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 24px;
  border-radius: 0;
  border: none;
  background: transparent;
  box-shadow: none;
  overflow: hidden;
}

.book-stage::before {
  content: none;
}

/* ───────────── Book Container ───────────── */

.book {
  position: relative;
  width: min(100%, 1120px);
  aspect-ratio: 1.56 / 1;
  perspective: 2600px;
  transform-style: preserve-3d;
  transition: width 280ms var(--ease-out), aspect-ratio 280ms var(--ease-out);
}

.book.is-cover {
  width: min(100%, 420px);
  aspect-ratio: 0.72 / 1;
}

.book.is-single-page:not(.is-cover) {
  width: min(100%, 420px);
  aspect-ratio: 0.72 / 1;
}

.book::before {
  content: "";
  position: absolute;
  inset: auto 5% -18px;
  height: 36px;
  border-radius: 50%;
  background: rgba(26, 18, 16, 0.2);
  filter: blur(16px);
  transform: translateZ(-60px);
}

.book-underlay,
.book-current,
.book-flip {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
}

.book-underlay {
  opacity: 0.2;
  transform: translateY(8px) scale(0.988);
  pointer-events: none;
}

.book.is-cover .book-underlay {
  opacity: 0.14;
  transform: translateX(-20px) translateY(8px) scale(0.92);
}

/* ───────────── Book Spread ───────────── */

.book-spread {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  direction: ltr;
  transform-style: preserve-3d;
  filter: drop-shadow(0 20px 28px rgba(26, 18, 16, 0.15));
}

.book-leaf {
  position: relative;
  min-width: 0;
  transform-style: preserve-3d;
}

.book-leaf-left {
  grid-column: 1;
}

.book-leaf-right {
  grid-column: 2;
}

.book-gutter {
  position: absolute;
  z-index: 3;
  top: 2%;
  bottom: 2%;
  left: calc(50% - 14px);
  width: 28px;
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(60, 44, 28, 0.22), rgba(255, 248, 230, 0.3), rgba(60, 44, 28, 0.22));
  box-shadow:
    inset 6px 0 14px rgba(60, 44, 28, 0.12),
    inset -6px 0 14px rgba(60, 44, 28, 0.12);
  pointer-events: none;
}

.book-single {
  grid-template-columns: minmax(0, 1fr);
}

.book-single .book-leaf-right {
  grid-column: 1;
}

/* ───────────── Page Card ───────────── */

.page-card {
  position: absolute;
  inset: 0;
  direction: rtl;
  padding: 24px 26px;
  border: 1px solid rgba(180, 148, 96, 0.2);
  background:
    radial-gradient(circle at 8% 8%, rgba(255, 255, 255, 0.85), transparent 30%),
    linear-gradient(180deg, #fffef9 0%, var(--paper) 60%, var(--paper-warm) 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.9),
    inset 0 -12px 28px rgba(160, 128, 72, 0.05),
    0 16px 32px rgba(40, 30, 20, 0.12);
  overflow: hidden;
  backface-visibility: hidden;
}

.page-right {
  border-radius: 4px 14px 14px 4px;
  box-shadow:
    inset 10px 0 20px rgba(80, 60, 36, 0.08),
    0 16px 32px rgba(40, 30, 20, 0.12);
}

.page-left {
  border-radius: 14px 4px 4px 14px;
  box-shadow:
    inset -10px 0 20px rgba(80, 60, 36, 0.08),
    0 16px 32px rgba(40, 30, 20, 0.12);
}

.page-blank {
  background:
    repeating-linear-gradient(0deg, rgba(93, 77, 52, 0.02) 0 1px, transparent 1px 14px),
    linear-gradient(180deg, #fffef9, #f4ead6);
}

.page-sheen,
.page-edge {
  position: absolute;
  pointer-events: none;
}

.page-sheen {
  inset: 0;
  background: linear-gradient(120deg, rgba(255, 255, 255, 0.35), transparent 32%, transparent 72%, rgba(196, 148, 74, 0.04));
}

.page-edge {
  top: 0;
  bottom: 0;
  width: 14px;
  background: repeating-linear-gradient(90deg, rgba(160, 128, 72, 0.18) 0 1px, rgba(255, 255, 255, 0.2) 1px 3px);
}

.page-left .page-edge {
  left: 0;
}

.page-right .page-edge {
  right: 0;
}

/* ───────────── Page Chips ───────────── */

.page-chips {
  position: relative;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}

.page-chip,
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 252, 245, 0.85);
  border: 1px solid rgba(196, 148, 74, 0.22);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.badge {
  background: rgba(74, 96, 56, 0.08);
  border-color: rgba(74, 96, 56, 0.2);
  color: var(--sage);
}

/* ───────────── Page Text Frame ───────────── */

.text-frame {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  height: calc(100% - 44px);
  min-height: 0;
}

.text-page-header {
  position: relative;
  padding: 10px 6px 16px;
  border-bottom: 1px solid rgba(180, 148, 96, 0.14);
}

.text-page-header::after {
  content: "";
  position: absolute;
  right: 6px;
  bottom: -1px;
  width: 72px;
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--gold), var(--gold-light), transparent);
}

.text-page-title {
  margin: 0;
  font-family: "Noto Serif Hebrew", "Times New Roman", David, serif;
  font-size: 1.55rem;
  line-height: 1.2;
  font-weight: 700;
  color: var(--burgundy-deep);
}

.text-page-body {
  padding: 14px 6px 4px;
  overflow: auto;
  display: grid;
  align-content: start;
  gap: 6px;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.text-page-body::-webkit-scrollbar {
  width: 0;
  height: 0;
}

.text-line {
  margin: 0;
  font-size: 0.94rem;
  line-height: 1.8;
  white-space: pre-wrap;
  color: var(--ink-soft);
}

.text-line.is-spacer {
  min-height: 0.8rem;
  line-height: 0.8rem;
}

.text-line.is-unclear {
  color: var(--muted);
  font-style: italic;
  opacity: 0.7;
}

/* ───────────── Recipe Layout ───────────── */

.recipe-body {
  padding-block-start: 10px;
}

.recipe-layout {
  display: grid;
  gap: 4px;
}

.recipe-section {
  position: relative;
  padding: 10px 0 12px;
  border-top: 1px solid rgba(180, 148, 96, 0.12);
}

.recipe-section:first-child {
  border-top: 0;
  padding-top: 0;
}

.recipe-section::before {
  content: "";
  position: absolute;
  top: -1px;
  right: 0;
  width: min(64px, 30%);
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(90deg, transparent, var(--gold));
}

.recipe-section:first-child::before {
  display: none;
}

.recipe-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.recipe-section-title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: var(--burgundy-deep);
  font-size: 0.92rem;
  line-height: 1.1;
  font-weight: 800;
}

.recipe-section-title::before {
  content: "";
  width: 16px;
  height: 2px;
  border-radius: 999px;
  background: var(--gold);
}

.recipe-section-method .recipe-section-title::before {
  background: var(--burgundy);
}

.recipe-section-note .recipe-section-title::before,
.recipe-section-intro .recipe-section-title::before {
  background: var(--sage);
}

.recipe-section-count {
  display: none;
}

.recipe-items {
  display: grid;
  gap: 4px;
}

.recipe-section-ingredients .recipe-items {
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 3px 18px;
}

.recipe-item {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.88rem;
  line-height: 1.65;
}

.recipe-item-ingredient {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  gap: 6px;
  padding: 3px 0 4px;
  border-bottom: 1px solid rgba(180, 148, 96, 0.06);
}

.recipe-marker {
  color: var(--gold);
  font-weight: 900;
  line-height: 1.6;
}

.recipe-item-method {
  position: relative;
  padding-right: 28px;
}

.recipe-item-method::before {
  content: var(--step);
  position: absolute;
  top: 0.2rem;
  right: 0;
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: #fff;
  background: var(--burgundy);
  font-size: 0.62rem;
  font-weight: 800;
}

.recipe-item-note {
  padding: 4px 12px 4px 0;
  border-right: 2px solid rgba(74, 96, 56, 0.4);
  border-radius: 0;
  color: var(--sage);
  background: transparent;
  font-style: italic;
}

/* ───────────── Special Page Types ───────────── */

.intro-body {
  align-content: center;
  text-align: center;
  padding-inline: 10%;
}

.intro-body .text-line {
  font-family: "Noto Serif Hebrew", "Times New Roman", David, serif;
  line-height: 2;
  color: var(--ink);
}

.index-body {
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 6px 18px;
}

.index-body .text-line {
  padding: 4px 0;
  border-bottom: 1px solid rgba(180, 148, 96, 0.08);
  font-size: 0.86rem;
}

.page-card.is-verified .page-kind {
  color: #fff;
  background: var(--sage);
  border-color: transparent;
}

/* ───────────── Flip Animations ───────────── */

.book-flip {
  z-index: 8;
  pointer-events: none;
}

.book-flip-forward,
.book-flip-backward {
  top: 0;
  bottom: 0;
  width: 50%;
}

.book-flip-forward {
  left: 0;
  right: auto;
}

.book-flip-backward {
  left: auto;
  right: 0;
}

.book-flip-cover {
  inset: 0;
  width: 100%;
}

.book.is-single-page .book-flip-forward,
.book.is-single-page .book-flip-backward {
  inset: 0;
  width: 100%;
}

.book-flip-reveal,
.book-flip-target-page,
.book-flip-leaf {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
}

.book-flip-reveal {
  z-index: 0;
}

.book-flip-target-page {
  z-index: 1;
  opacity: 0;
  transform: translateX(100%);
}

.book-flip-leaf {
  z-index: 2;
}

.book-flip-forward .book-flip-leaf {
  transform-origin: right center;
}

.book-flip-backward .book-flip-leaf {
  transform-origin: left center;
}

.book.is-flipping-forward .book-flip-forward .book-flip-leaf {
  animation: flip-rtl-forward 780ms var(--ease-out) forwards;
}

.book.is-flipping-forward .book-flip-forward .book-flip-target-page {
  animation: reveal-rtl-forward-target 780ms var(--ease-out) forwards;
}

.book.is-flipping-backward .book-flip-backward .book-flip-leaf {
  animation: flip-rtl-backward 780ms var(--ease-out) forwards;
}

.book-flip .page-card,
.book-flip .cover-card {
  box-shadow: var(--shadow-book);
}

/* ───────────── Controls ───────────── */

.controls {
  justify-content: space-between;
  gap: 16px;
}

.page-slider {
  flex: 1;
  accent-color: var(--burgundy);
  height: 6px;
}

.page-indicator {
  display: grid;
  gap: 2px;
  text-align: left;
  min-width: 112px;
}

.page-indicator #currentPageLabel {
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--ink);
}

.page-indicator #pageCounter {
  font-size: 0.76rem;
  color: var(--muted);
}

/* ───────────── Details Card ───────────── */

.details-card {
  display: grid;
  gap: 14px;
}

.details-header {
  justify-content: space-between;
  align-items: flex-start;
}

.details-header h2 {
  font-size: 1.6rem;
  line-height: 1.15;
  font-weight: 700;
  color: var(--burgundy-deep);
}

.details-preview {
  margin: 0;
  color: var(--muted);
  line-height: 1.75;
  font-size: 0.92rem;
}

.source-panel,
.transcript-panel {
  padding: 14px;
  border-radius: var(--radius-sm);
  background: rgba(255, 252, 247, 0.9);
  border: 1px solid var(--panel-border);
  box-shadow: inset 0 1px 3px rgba(26, 18, 16, 0.04);
  max-height: 380px;
  overflow: auto;
}

.source-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.source-figure {
  margin: 0;
  display: grid;
  gap: 8px;
}

.source-figure img {
  width: 100%;
  max-height: 320px;
  object-fit: contain;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(26, 18, 16, 0.1);
  background: #fff;
}

.source-figure figcaption {
  color: var(--muted);
  font-size: 0.82rem;
}

.transcript-list {
  margin: 0;
  padding-right: 18px;
  line-height: 1.8;
  color: var(--ink-soft);
}

.transcript-page-title {
  margin-top: 12px;
  color: var(--burgundy-deep);
  font-weight: 700;
  font-size: 0.95rem;
}

/* ───────────── Buttons ───────────── */

.primary-button,
.secondary-button,
.icon-button {
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition:
    transform 200ms var(--ease-out),
    box-shadow 200ms ease,
    background 200ms ease;
}

.primary-button,
.secondary-button {
  min-height: 44px;
  padding: 0 18px;
  font-weight: 600;
  font-size: 0.88rem;
}

.primary-button {
  border: none;
  color: #fff;
  background: linear-gradient(180deg, var(--burgundy) 0%, var(--burgundy-deep) 100%);
  box-shadow:
    0 4px 12px rgba(107, 32, 48, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.primary-button:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow:
    0 8px 20px rgba(107, 32, 48, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.primary-button:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: 0 2px 6px rgba(107, 32, 48, 0.3);
}

.secondary-button,
.icon-button {
  color: var(--ink-soft);
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid var(--panel-border);
}

.secondary-button:hover:not(:disabled),
.icon-button:hover:not(:disabled) {
  background: rgba(255, 252, 240, 0.95);
  border-color: rgba(196, 148, 74, 0.3);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.icon-button {
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}

/* ───────────── Cover Card ───────────── */

.cover-card {
  position: absolute;
  inset: 0;
  direction: rtl;
  display: grid;
  gap: 20px;
  align-content: space-between;
  min-height: 100%;
  padding: 36px 32px;
  border-radius: 16px 5px 5px 16px;
  border: 1px solid rgba(196, 148, 74, 0.2);
  background:
    radial-gradient(circle at 15% 15%, rgba(196, 148, 74, 0.12), transparent 35%),
    radial-gradient(circle at 85% 85%, rgba(107, 32, 48, 0.08), transparent 30%),
    linear-gradient(135deg, #1a1014 0%, #2d1620 30%, #4a1828 60%, #6b2030 100%);
  color: #faf6ee;
  box-shadow: var(--shadow-book);
  overflow: hidden;
}

.cover-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.015) 0 1px, transparent 1px 14px);
  pointer-events: none;
}

.cover-spine {
  position: absolute;
  top: 0;
  bottom: 0;
  right: 0;
  width: 36px;
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.2), rgba(196, 148, 74, 0.08)),
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(0, 0, 0, 0.2));
  border-left: 1px solid rgba(196, 148, 74, 0.15);
}

.cover-title {
  margin: 0;
  max-width: 9ch;
  font-family: "Noto Serif Hebrew", "Times New Roman", David, serif;
  font-size: 3rem;
  line-height: 1;
  font-weight: 700;
  color: var(--gold-light);
  text-shadow: 0 2px 16px rgba(0, 0, 0, 0.3);
}

.cover-subtitle {
  margin: 10px 0 0;
  max-width: 24ch;
  color: rgba(250, 246, 238, 0.7);
  line-height: 1.6;
  font-size: 0.92rem;
}

.cover-quote {
  margin: 0;
  padding: 16px 0;
  border-top: 1px solid rgba(196, 148, 74, 0.2);
  border-bottom: 1px solid rgba(196, 148, 74, 0.2);
  line-height: 1.75;
  font-size: 0.9rem;
  color: rgba(250, 246, 238, 0.85);
}

.cover-list {
  display: grid;
  gap: 8px;
}

.cover-list-item {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: rgba(196, 148, 74, 0.08);
  border: 1px solid rgba(196, 148, 74, 0.12);
  font-size: 0.86rem;
  color: rgba(250, 246, 238, 0.8);
}

/* ───────────── Keyframes ───────────── */

@keyframes flip-rtl-forward {
  0% {
    transform: rotateY(0deg) translateZ(2px);
    opacity: 1;
  }
  36% {
    transform: rotateY(70deg) translateZ(6px);
    filter: brightness(0.92);
    opacity: 1;
  }
  54% {
    transform: rotateY(105deg) translateX(4px) translateZ(8px);
    opacity: 0;
  }
  100% {
    transform: rotateY(168deg) translateX(20px) translateZ(8px);
    opacity: 0;
  }
}

@keyframes reveal-rtl-forward-target {
  0%, 46% {
    opacity: 0;
  }
  60% {
    opacity: 0.98;
  }
  100% {
    opacity: 1;
  }
}

@keyframes flip-rtl-backward {
  0% {
    transform: rotateY(0deg) translateZ(1px);
    opacity: 1;
  }
  48% {
    filter: brightness(0.92);
  }
  100% {
    transform: rotateY(-168deg) translateX(-20px) translateZ(8px);
    opacity: 0;
  }
}

/* ───────────── Responsive ───────────── */

@media (max-width: 900px) {
  .book-stage {
    padding: 20px 12px;
  }

  .book {
    width: 100%;
  }

  .page-card {
    padding: 14px;
  }

  .text-page-title {
    font-size: 1.15rem;
  }

  .text-line {
    font-size: 0.84rem;
    line-height: 1.65;
  }

  .page-chip {
    min-height: 24px;
    font-size: 0.68rem;
  }

  .cover-card {
    padding: 24px 20px;
  }

  .cover-title {
    font-size: 2.4rem;
  }
}

/* ═══════════════════════════════════════════════
   Mobile App — hidden on desktop
   ═══════════════════════════════════════════════ */

.mobile-app {
  display: none;
}

@media (max-width: 620px) {
  /* Hide desktop book on mobile */
  .app-shell {
    display: none !important;
  }

  /* Show mobile app */
  .mobile-app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
    background: linear-gradient(180deg, #faf7f0 0%, #f2ead8 100%);
  }

  /* ─── Header ─── */
  .m-header {
    position: sticky;
    top: 0;
    z-index: 10;
    padding: 0 16px;
    background: rgba(250, 247, 240, 0.88);
    backdrop-filter: blur(20px) saturate(1.6);
    -webkit-backdrop-filter: blur(20px) saturate(1.6);
    border-bottom: 1px solid rgba(100, 72, 42, 0.08);
  }

  .m-header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 0 8px;
  }

  .m-eyebrow {
    margin: 0 0 2px;
    color: var(--gold);
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
  }

  .m-title {
    margin: 0;
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--burgundy-deep);
  }

  .m-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
  }

  .m-page-header-side {
    display: flex;
    align-items: center;
    gap: 8px;
  }

  .m-icon-btn {
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    border: 1px solid rgba(100, 72, 42, 0.1);
    background: rgba(255, 255, 255, 0.7);
    color: var(--ink-soft);
    cursor: pointer;
    transition: background 160ms ease;
  }

  .m-icon-btn:active {
    background: rgba(255, 252, 240, 1);
  }

  .m-badge {
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.68rem;
    font-weight: 600;
    background: var(--sage-light);
    color: var(--sage);
    border: 1px solid rgba(74, 96, 56, 0.15);
  }

  .m-page-menu-btn {
    flex-shrink: 0;
  }

  /* ─── Tabs ─── */
  .m-tabs {
    display: flex;
    gap: 4px;
    padding-bottom: 10px;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
  }

  .m-tabs::-webkit-scrollbar { width: 0; height: 0; }

  .m-tab {
    flex-shrink: 0;
    padding: 7px 16px;
    border-radius: 999px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 180ms ease;
    white-space: nowrap;
  }

  .m-tab.is-active {
    background: var(--burgundy-deep);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 2px 8px rgba(61, 20, 32, 0.2);
  }

  .m-tab:not(.is-active):active {
    background: rgba(0, 0, 0, 0.04);
  }

  /* ─── Feed ─── */
  .m-feed {
    flex: 1;
    padding: 12px 14px 80px;
    display: grid;
    gap: 10px;
    align-content: start;
  }

  /* ─── Recipe Drawer ─── */
  .m-recipe-drawer-backdrop {
    position: fixed;
    inset: 0;
    z-index: 35;
    background: rgba(30, 20, 14, 0.28);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    opacity: 0;
    transition: opacity 220ms ease;
  }

  .m-recipe-drawer-backdrop.is-open {
    opacity: 1;
  }

  .m-recipe-drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 36;
    width: min(86vw, 360px);
    display: flex;
    flex-direction: column;
    padding: 12px 14px 18px;
    background:
      linear-gradient(180deg, rgba(255, 252, 247, 0.98), rgba(249, 241, 227, 0.98));
    border-left: 1px solid rgba(100, 72, 42, 0.12);
    box-shadow: -18px 0 48px rgba(26, 18, 16, 0.16);
    transform: translateX(100%);
    transition: transform 260ms var(--ease-out);
  }

  .m-recipe-drawer.is-open {
    transform: translateX(0);
  }

  .m-recipe-drawer-handle {
    align-self: center;
    width: 42px;
    height: 4px;
    margin-bottom: 10px;
    border-radius: 999px;
    background: rgba(100, 72, 42, 0.14);
  }

  .m-recipe-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding-bottom: 12px;
    margin-bottom: 8px;
    border-bottom: 1px solid rgba(100, 72, 42, 0.08);
  }

  .m-recipe-drawer-eyebrow {
    margin: 0 0 4px;
    color: var(--gold);
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
  }

  .m-recipe-drawer-title {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--burgundy-deep);
  }

  .m-recipe-drawer-list {
    display: grid;
    gap: 8px;
    overflow: auto;
    padding-top: 6px;
  }

  .m-recipe-drawer-item {
    width: 100%;
    display: grid;
    gap: 4px;
    text-align: right;
    padding: 12px 14px;
    border: 1px solid rgba(100, 72, 42, 0.08);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.72);
    color: var(--ink);
    cursor: pointer;
    transition: transform 180ms var(--ease-out), background 180ms ease, border-color 180ms ease;
  }

  .m-recipe-drawer-item:active {
    transform: scale(0.98);
  }

  .m-recipe-drawer-item.is-active {
    background: rgba(255, 247, 230, 0.96);
    border-color: rgba(196, 148, 74, 0.24);
    box-shadow: inset 3px 0 0 var(--gold);
  }

  .m-recipe-drawer-item-label {
    font-size: 0.68rem;
    color: var(--muted);
    font-weight: 500;
  }

  .m-recipe-drawer-item-title {
    font-size: 0.9rem;
    font-weight: 700;
    line-height: 1.35;
    color: var(--ink);
  }

  /* ─── Card ─── */
  .m-card {
    display: grid;
    gap: 8px;
    padding: 16px 18px;
    border-radius: 16px;
    border: 1px solid rgba(100, 72, 42, 0.08);
    background: #fff;
    box-shadow:
      0 1px 3px rgba(26, 18, 16, 0.04),
      0 4px 12px rgba(26, 18, 16, 0.03);
    cursor: pointer;
    transition: transform 200ms var(--ease-out), box-shadow 200ms ease;
    -webkit-tap-highlight-color: transparent;
  }

  .m-card:active {
    transform: scale(0.98);
    box-shadow: 0 1px 4px rgba(26, 18, 16, 0.06);
  }

  .m-card-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
  }

  .m-card-kind {
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 0.66rem;
    font-weight: 700;
    letter-spacing: 0.02em;
  }

  .m-card-kind-recipe {
    background: rgba(107, 32, 48, 0.08);
    color: var(--burgundy);
  }

  .m-card-kind-intro {
    background: rgba(74, 96, 56, 0.08);
    color: var(--sage);
  }

  .m-card-kind-index {
    background: rgba(196, 148, 74, 0.12);
    color: var(--copper);
  }

  .m-card-kind-cover {
    background: rgba(61, 20, 32, 0.08);
    color: var(--burgundy-deep);
  }

  .m-card-page {
    font-size: 0.68rem;
    color: var(--muted);
    font-weight: 500;
  }

  .m-card-title {
    margin: 0;
    font-size: 1.08rem;
    font-weight: 700;
    color: var(--ink);
    line-height: 1.3;
  }

  .m-card-preview {
    margin: 0;
    font-size: 0.82rem;
    line-height: 1.55;
    color: var(--muted);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .m-card-sections {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 2px;
  }

  .m-card-section-tag {
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 0.64rem;
    font-weight: 600;
    background: rgba(100, 72, 42, 0.05);
    color: var(--muted);
  }

  .m-card-arrow {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.74rem;
    font-weight: 600;
    color: var(--burgundy);
  }

  .m-card-arrow svg {
    transition: transform 200ms var(--ease-out);
  }

  .m-card:active .m-card-arrow svg {
    transform: translateX(-3px);
  }

  /* ─── Cover Card (special) ─── */
  .m-card-cover {
    padding: 28px 22px;
    background:
      radial-gradient(circle at 15% 15%, rgba(196, 148, 74, 0.1), transparent 40%),
      linear-gradient(135deg, #1a1014, #2d1620 40%, #4a1828 70%, #6b2030);
    border: 1px solid rgba(196, 148, 74, 0.15);
    color: #faf6ee;
    box-shadow: 0 6px 24px rgba(26, 18, 16, 0.16);
  }

  .m-card-cover .m-card-title {
    font-family: "Noto Serif Hebrew", "Times New Roman", David, serif;
    font-size: 1.5rem;
    color: var(--gold-light);
  }

  .m-card-cover .m-card-preview {
    color: rgba(250, 246, 238, 0.7);
    -webkit-line-clamp: 3;
  }

  .m-card-cover .m-card-kind {
    background: rgba(232, 196, 118, 0.15);
    color: var(--gold-light);
  }

  .m-card-cover .m-card-page {
    color: rgba(250, 246, 238, 0.5);
  }

  .m-card-cover .m-card-arrow {
    color: var(--gold-light);
  }

  /* ─── Full Page View ─── */
  .m-page-view {
    position: fixed;
    inset: 0;
    z-index: 30;
    display: flex;
    flex-direction: column;
    background: var(--paper);
    overflow-y: auto;
    animation: m-slide-up 320ms var(--ease-out) forwards;
  }

  .m-page-view[hidden] {
    display: none;
  }

  @keyframes m-slide-up {
    from {
      opacity: 0;
      transform: translateY(40px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }

  .m-page-header {
    position: sticky;
    top: 0;
    z-index: 5;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: rgba(255, 252, 247, 0.9);
    backdrop-filter: blur(16px) saturate(1.4);
    -webkit-backdrop-filter: blur(16px) saturate(1.4);
    border-bottom: 1px solid rgba(100, 72, 42, 0.08);
  }

  .m-back-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px 6px 6px;
    border-radius: 10px;
    border: none;
    background: transparent;
    color: var(--burgundy);
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 150ms ease;
  }

  .m-back-btn:active {
    background: rgba(107, 32, 48, 0.06);
  }

  .m-page-counter {
    font-size: 0.76rem;
    color: var(--muted);
    font-weight: 500;
  }

  .m-page-content-cover {
    background:
      radial-gradient(circle at 14% 16%, rgba(196, 148, 74, 0.08), transparent 28%),
      linear-gradient(180deg, rgba(255, 253, 248, 0.7), rgba(250, 241, 227, 0.8));
  }

  .m-page-content {
    flex: 1;
    padding: 20px 18px 24px;
    direction: rtl;
  }

  /* Page content: Title area */
  .m-page-kind-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 0.68rem;
    font-weight: 700;
    margin-bottom: 10px;
  }

  .m-page-title {
    margin: 0 0 16px;
    font-family: "Noto Serif Hebrew", "Times New Roman", David, serif;
    font-size: 1.6rem;
    font-weight: 700;
    line-height: 1.25;
    color: var(--burgundy-deep);
  }

  .m-page-title::after {
    content: "";
    display: block;
    width: 48px;
    height: 2px;
    margin-top: 12px;
    border-radius: 2px;
    background: linear-gradient(90deg, var(--gold), var(--gold-light));
  }

  .m-page-body {
    display: grid;
    gap: 6px;
  }

  .m-page-text-line {
    margin: 0;
    font-size: 1rem;
    line-height: 1.85;
    color: var(--ink-soft);
    white-space: pre-wrap;
  }

  .m-page-text-line.is-spacer {
    min-height: 0.6rem;
  }

  .m-page-text-line.is-unclear {
    color: var(--muted);
    font-style: italic;
    opacity: 0.7;
  }

  /* Page content: Recipe sections */
  .m-recipe-section {
    position: relative;
    padding: 16px 0;
    border-top: 1px solid rgba(180, 148, 96, 0.1);
  }

  .m-recipe-section:first-child {
    border-top: none;
    padding-top: 0;
  }

  .m-recipe-section-title {
    margin: 0 0 12px;
    font-size: 1rem;
    font-weight: 800;
    color: var(--burgundy-deep);
    display: flex;
    align-items: center;
    gap: 8px;
  }

  .m-recipe-section-title::before {
    content: "";
    width: 14px;
    height: 2.5px;
    border-radius: 999px;
    background: var(--gold);
  }

  .m-section-method .m-recipe-section-title::before {
    background: var(--burgundy);
  }

  .m-section-note .m-recipe-section-title::before,
  .m-section-intro .m-recipe-section-title::before {
    background: var(--sage);
  }

  .m-recipe-items {
    display: grid;
    gap: 4px;
  }

  .m-recipe-item {
    margin: 0;
    font-size: 0.94rem;
    line-height: 1.7;
    color: var(--ink-soft);
  }

  .m-recipe-ingredient {
    display: flex;
    align-items: baseline;
    gap: 8px;
    padding: 5px 0;
    border-bottom: 1px solid rgba(180, 148, 96, 0.06);
  }

  .m-recipe-ingredient::before {
    content: "•";
    color: var(--gold);
    font-weight: 900;
    font-size: 1.1rem;
    flex-shrink: 0;
  }

  .m-recipe-method {
    position: relative;
    padding-right: 32px;
    padding: 4px 32px 4px 0;
  }

  .m-recipe-method::before {
    content: attr(data-step);
    position: absolute;
    top: 0.3rem;
    right: 0;
    width: 22px;
    height: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    color: #fff;
    background: var(--burgundy);
    font-size: 0.66rem;
    font-weight: 800;
  }

  .m-recipe-note {
    padding: 6px 14px 6px 0;
    border-right: 2.5px solid rgba(74, 96, 56, 0.35);
    color: var(--sage);
    font-style: italic;
    font-size: 0.9rem;
  }

  /* Intro page styling */
  .m-page-content-intro .m-page-body {
    text-align: center;
    padding: 12px 8%;
  }

  .m-page-content-intro .m-page-text-line {
    font-family: "Noto Serif Hebrew", "Times New Roman", David, serif;
    line-height: 2.1;
    font-size: 1.05rem;
    color: var(--ink);
  }

  .m-page-content-intro .m-page-title::after {
    margin-inline: auto;
  }

  /* Index page styling */
  .m-page-content-index .m-page-body {
    gap: 0;
  }

  .m-page-content-index .m-page-text-line {
    padding: 8px 0;
    border-bottom: 1px solid rgba(180, 148, 96, 0.08);
    font-size: 0.92rem;
  }

  /* ─── Page Nav ─── */
  .m-page-nav {
    position: sticky;
    bottom: 0;
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
    background: rgba(255, 252, 247, 0.92);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid rgba(100, 72, 42, 0.08);
  }

  .m-nav-btn {
    flex: 1;
    min-height: 46px;
    border-radius: 12px;
    border: 1px solid var(--panel-border);
    background: #fff;
    color: var(--ink-soft);
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 160ms ease;
  }

  .m-nav-btn:active:not(:disabled) {
    background: rgba(255, 252, 240, 1);
    transform: scale(0.97);
  }

  .m-nav-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
  }

  /* ─── Empty state ─── */
  .m-empty {
    padding: 48px 24px;
    text-align: center;
    color: var(--muted);
    font-size: 0.9rem;
    line-height: 1.6;
  }

  body.is-mobile-drawer-open {
    overflow: hidden;
  }
}

/* ───────────── Reduced Motion ───────────── */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
