/* =========================================================
   Franzi's Rezeptbuch – Stylesheet für das 3D-Kochbuch
   - Harmonisches Quer-/Kochbuch-Format auf Desktop (bis 1220px)
   - Mobil: exakte Seitenaufteilung & Buchmaße aus dem Live-Editor
   - Register-Tabs am Buchrand auf Desktop und Mobil
   - "Rezept teilen"- / "Rezept ausdrucken"-Buttons + eigene Druckansicht pro Rezept
   - Zweispaltige Zutatenliste (inkl. 2-Spalten-Unterstützung auf schmalen Displays)
   - Buchfalz-Schatten & Print-Styling
   ========================================================= */

.book-stage-section {
  padding: 44px 0 80px;
  overflow-x: hidden;
}

.book-intro {
  text-align: center;
  max-width: 720px;
  margin: 0 auto 28px;
}

.book-intro h1 {
  margin-bottom: 10px;
}

/* ---------- Toolbar & Utility-Leiste ---------- */
.book-toolbar {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-bottom: 26px;
}

.book-utility-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

/* Live-Suche */
.book-search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.book-search-box .search-icon {
  position: absolute;
  left: 11px;
  font-size: 0.82rem;
  pointer-events: none;
  opacity: 0.75;
}

.book-search-box input {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  color: var(--text-light);
  padding: 6px 14px 6px 32px;
  border-radius: 999px;
  font-size: 0.83rem;
  font-family: var(--font-sans);
  width: 235px;
  transition: border-color 0.2s ease, width 0.25s ease;
}

.book-search-box input:focus {
  outline: none;
  border-color: var(--accent);
  width: 270px;
}

.book-search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  width: 310px;
  max-height: 290px;
  overflow-y: auto;
  background: #241f1b;
  border: 1px solid var(--accent);
  border-radius: 10px;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.65);
  z-index: 1200;
  display: none;
}

.book-search-results.open {
  display: block;
}

.search-result-item {
  padding: 9px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  transition: background 0.15s ease;
}

.search-result-item:last-child {
  border-bottom: none;
}

.search-result-item:hover {
  background: rgba(201, 149, 90, 0.16);
}

.search-result-item strong {
  display: block;
  font-size: 0.86rem;
  color: var(--text-light);
}

.search-result-item small {
  font-size: 0.74rem;
  color: var(--text-muted);
}

.search-result-page {
  font-size: 0.74rem;
  color: var(--accent);
  white-space: nowrap;
  font-weight: 600;
}

.utility-toggle {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  color: var(--text-light);
  padding: 6px 13px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-family: var(--font-sans);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.utility-toggle:hover,
.utility-toggle.is-active {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(201, 149, 90, 0.12);
}

/* ---------- 3D Buch-Bühne (Großzügiges Quer-/Kochbuchformat) ---------- */
.book-scene {
  perspective: 2800px;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 16px 26px 28px;
  user-select: none;
}

.book-wrapper {
  --book-width: min(1220px, 92vw);
  position: relative;
  width: var(--book-width);
  height: 680px;
  transform-style: preserve-3d;
  will-change: transform;
  transition: transform 0.85s cubic-bezier(0.4, 0.0, 0.2, 1);
}

.book-wrapper.is-closed {
  transform: translateX(calc(var(--book-width) * -0.25));
}

.book-wrapper.is-end {
  transform: translateX(calc(var(--book-width) * 0.25));
}

/* Buchrücken & Seitenstapel */
.book-spine {
  position: absolute;
  left: calc(50% - 15px);
  top: -6px;
  width: 30px;
  height: calc(100% + 12px);
  background: linear-gradient(90deg, #1b110b, #3a2417 50%, #1b110b);
  border-radius: 4px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.75);
  z-index: 0;
  opacity: 1;
  transition: opacity 0.3s ease 0.55s;
}

.book-wrapper.is-closed .book-spine,
.book-wrapper.is-end .book-spine {
  opacity: 0;
  transition: opacity 0.12s ease 0s;
}

.book-pages-stack {
  position: absolute;
  top: 6px;
  width: 14px;
  height: calc(100% - 12px);
  background: repeating-linear-gradient(
    90deg,
    #efe8d8 0px,
    #dfd5c0 1px,
    #f7f2e7 2px
  );
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.55);
  z-index: 1;
  opacity: 1;
  transition: opacity 0.3s ease 0.55s;
}

.book-pages-stack.left {
  left: -10px;
  border-radius: 4px 0 0 4px;
}

.book-pages-stack.right {
  right: -10px;
  border-radius: 0 4px 4px 0;
}

.book-wrapper.is-closed .book-pages-stack.left,
.book-wrapper.is-end .book-pages-stack.right {
  opacity: 0;
  transition: opacity 0.12s ease 0s;
}

/* Lesezeichenbändchen */
.book-ribbon {
  position: absolute;
  bottom: -24px;
  left: 51.5%;
  width: 16px;
  height: 36px;
  background: linear-gradient(180deg, #8e2d24, #631b15);
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 80%, 0 100%);
  z-index: 2;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
  opacity: 1;
  transition: opacity 0.3s ease 0.55s;
}

.book-wrapper.is-closed .book-ribbon,
.book-wrapper.is-end .book-ribbon {
  opacity: 0;
  transition: opacity 0.12s ease 0s;
}

/* ---------- Register-Tabs am rechten Buchrand ---------- */
.book-edge-tabs {
  position: absolute;
  top: 38px;
  right: -32px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 3;
  transition: opacity 0.25s ease;
}

.book-wrapper.is-closed .book-edge-tabs,
.book-wrapper.is-end .book-edge-tabs {
  opacity: 0;
  pointer-events: none;
}

.edge-tab-btn {
  writing-mode: vertical-rl;
  text-orientation: mixed;
  background: linear-gradient(90deg, #e7dac3, #f5eedf);
  color: #4a3520;
  border: 1px solid #cbb799;
  border-left: none;
  border-radius: 0 7px 7px 0;
  padding: 11px 6px;
  font-family: var(--font-sans);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.8px;
  max-height: 115px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: 3px 4px 10px rgba(0, 0, 0, 0.35);
  transition: transform 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.edge-tab-btn:hover,
.edge-tab-btn.active {
  background: linear-gradient(90deg, #c9955a, #dfa86b);
  color: #1a1613;
  border-color: #c9955a;
  transform: translateX(4px);
}

/* ---------- Blätter (Sheets) ---------- */
.book-sheets {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
}

.sheet {
  position: absolute;
  top: 0;
  right: 0;
  width: 50%;
  height: 100%;
  transform-origin: left center;
  transform-style: preserve-3d;
  will-change: transform;
  transition: transform 0.85s cubic-bezier(0.4, 0.0, 0.2, 1);
}

.sheet.flipped {
  transform: rotateY(-180deg);
}

.sheet.is-turning {
  z-index: 999 !important;
}

.page-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Helle Elfenbein-Papierseiten inkl. realistischem Buchfalz-Schatten */
.page-front {
  background-color: #faf6ed;
  background-image:
    radial-gradient(rgba(138, 106, 68, 0.06) 1px, transparent 0),
    linear-gradient(90deg, rgba(36, 25, 17, 0.2) 0%, rgba(36, 25, 17, 0.06) 3.5%, transparent 11%);
  background-size: 18px 18px, 100% 100%;
  color: #2b2118;
  border-radius: 2px 10px 10px 2px;
  box-shadow:
    inset 26px 0 32px -20px rgba(36, 25, 17, 0.22),
    inset -4px 0 12px rgba(42, 29, 18, 0.07),
    4px 10px 22px rgba(0, 0, 0, 0.35);
  border: 1px solid #e2d7c3;
}

.page-back {
  transform: rotateY(180deg);
  background-color: #faf6ed;
  background-image:
    radial-gradient(rgba(138, 106, 68, 0.06) 1px, transparent 0),
    linear-gradient(270deg, rgba(36, 25, 17, 0.2) 0%, rgba(36, 25, 17, 0.06) 3.5%, transparent 11%);
  background-size: 18px 18px, 100% 100%;
  color: #2b2118;
  border-radius: 10px 2px 2px 10px;
  box-shadow:
    inset -26px 0 32px -20px rgba(36, 25, 17, 0.22),
    inset 4px 0 12px rgba(42, 29, 18, 0.07),
    -4px 10px 22px rgba(0, 0, 0, 0.35);
  border: 1px solid #e2d7c3;
}

/* ---------- Hardcover Einband (Vorder- & Rückseite) ---------- */
.cover-front {
  background:
    radial-gradient(circle at 30% 25%, rgba(201, 149, 90, 0.18), transparent 60%),
    linear-gradient(145deg, #2b1d14 0%, #1a110b 100%);
  color: var(--text-light);
  border: 2px solid #8a6a44;
  border-radius: 4px 14px 14px 4px;
  padding: 36px;
  justify-content: space-between;
  align-items: center;
  text-align: center;
  box-shadow: inset 12px 0 22px rgba(0, 0, 0, 0.65), 10px 16px 35px rgba(0, 0, 0, 0.55);
}

.cover-frame {
  width: 100%;
  height: 100%;
  border: 1.5px solid rgba(201, 149, 90, 0.55);
  border-radius: 8px;
  padding: 32px 24px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  position: relative;
}

.cover-frame::before {
  content: '';
  position: absolute;
  inset: 6px;
  border: 1px solid rgba(201, 149, 90, 0.25);
  border-radius: 5px;
  pointer-events: none;
}

.cover-emblem {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  border: 1.5px solid var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  background: rgba(201, 149, 90, 0.08);
}

.cover-title {
  font-family: var(--font-serif);
  font-size: 2.85rem;
  font-style: italic;
  color: var(--accent);
  line-height: 1.1;
  margin: 12px 0 8px;
}

.cover-subtitle {
  font-size: 0.85rem;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: #d6c5b3;
}

.cover-cta {
  background: var(--accent);
  color: #1a1613;
  border: none;
  padding: 12px 26px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: transform 0.2s ease, background-color 0.2s ease;
  z-index: 5;
}

.cover-cta:hover {
  background: var(--accent-hover);
  transform: scale(1.04);
}

/* ---------- Buchinnenseiten Layout (abgestimmt auf Live-Editor) ---------- */
.page-inner {
  padding: 22px 26px 16px;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 8px;
}

.page-header-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 1.6px;
  color: #8a6a44;
  border-bottom: 1px solid rgba(138, 106, 68, 0.25);
  padding-bottom: 5px;
  margin-bottom: 6px;
  flex-shrink: 0;
}

.toc-jump-link {
  cursor: pointer;
  transition: color 0.15s ease;
}

.toc-jump-link:hover {
  color: #241911;
}

.page-footer-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 6px 8px;
  font-size: 0.74rem;
  color: #7d6b59;
  border-top: 1px solid rgba(138, 106, 68, 0.2);
  padding-top: 7px;
  margin-top: auto;
  flex-shrink: 0;
}

.recipe-back-links {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  align-items: center;
}

.recipe-back-btn {
  background: rgba(138, 106, 68, 0.12);
  border: 1px solid rgba(138, 106, 68, 0.35);
  color: #5c4328;
  font-family: var(--font-sans);
  font-size: 0.7rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 5px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.recipe-back-btn:hover {
  background: #8a5a2b;
  border-color: #8a5a2b;
  color: #faf6ed;
}

.page-number {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 0.96rem;
  color: #5c4328;
  flex-shrink: 0;
}

/* Blätterecken */
.corner-flip {
  position: absolute;
  bottom: 0;
  width: 48px;
  height: 48px;
  cursor: pointer;
  z-index: 15;
  transition: width 0.25s ease, height 0.25s ease;
}

.corner-flip.next {
  right: 0;
  background: linear-gradient(135deg, transparent 50%, rgba(138, 106, 68, 0.16) 52%, #e6dcc8 100%);
  border-top-left-radius: 8px;
}

.corner-flip.prev {
  left: 0;
  background: linear-gradient(225deg, transparent 50%, rgba(138, 106, 68, 0.16) 52%, #e6dcc8 100%);
  border-top-right-radius: 8px;
}

.corner-flip:hover {
  width: 62px;
  height: 62px;
}

/* ---------- Rezept-Typografie auf hellem Papier ---------- */
.recipe-category-badge {
  display: inline-block;
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 1.8px;
  color: #8a5a2b;
  background: rgba(201, 149, 90, 0.2);
  padding: 2px 8px;
  border-radius: 4px;
  margin-bottom: 3px;
  font-weight: 700;
}

.recipe-title {
  font-family: var(--font-serif);
  font-size: 1.75rem;
  color: #241911;
  line-height: 1.12;
  margin-bottom: 5px;
}

.recipe-desc {
  font-size: 0.85rem;
  color: #5a4a3c;
  line-height: 1.44;
  margin-bottom: 8px;
}

.recipe-desc:empty {
  display: none;
}

/* Portionsrechner */
.portion-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.portion-bar span {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 1.08rem;
  color: #241911;
}

.portion-buttons {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.portion-btn {
  background: #efe8d8;
  border: 1px solid #cbbba0;
  color: #3d2e20;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.74rem;
  font-weight: 600;
  cursor: pointer;
}

.portion-btn.active {
  background: #8a5a2b;
  color: #faf6ed;
  border-color: #8a5a2b;
}

/* Abhakbare Zutatenliste (ein- oder zweispaltig je nach Einstellung im Editor) */
.ingredients-list {
  list-style: none;
  margin-left: 0;
  padding-left: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ingredients-list.two-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  column-gap: 12px;
  row-gap: 3px;
}

.ingredient-item {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  font-size: 0.82rem;
  line-height: 1.32;
  color: #2b2118;
  padding: 2px 4px;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.ingredient-item:hover {
  background: rgba(138, 106, 68, 0.08);
}

.ingredient-item.checked {
  text-decoration: line-through;
  color: #968574;
}

.ingredient-check {
  width: 14px;
  height: 14px;
  margin-top: 2px;
  border: 1.5px solid #8a6a44;
  border-radius: 3px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  color: #faf6ed;
  flex-shrink: 0;
}

.ingredient-item.checked .ingredient-check {
  background: #8a5a2b;
  border-color: #8a5a2b;
}

/* Zubereitungsschritte */
.steps-heading {
  font-family: var(--font-serif);
  font-size: 1.28rem;
  color: #241911;
  margin-bottom: 8px;
}

.steps-list {
  list-style: none;
  margin-left: 0;
  padding-left: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
}

.step-item {
  display: flex;
  gap: 9px;
  font-size: 0.84rem;
  line-height: 1.46;
  color: #2b2118;
}

.step-num {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #8a5a2b;
  color: #faf6ed;
  font-size: 0.72rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
}

/* Gewürz-Empfehlungsbox auf der Buchseite (1:1 wie im Live-Editor) */
.spice-box {
  background: linear-gradient(135deg, #f1e7d4 0%, #e7d8be 100%);
  border: 1px solid #c9a679;
  border-radius: 7px;
  padding: 9px 12px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 5px 10px;
  margin-top: auto;
  margin-bottom: 4px;
}

.spice-box-info {
  min-width: 0;
  flex: 1 1 60%;
}

.spice-box-info small {
  display: block;
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 1.1px;
  color: #8a5a2b;
  font-weight: 700;
  line-height: 1.2;
}

.spice-box-info strong {
  display: block;
  font-family: var(--font-serif);
  font-size: 1.06rem;
  color: #241911;
  line-height: 1.15;
}

.spice-box-info p,
.spice-box-info span {
  display: block;
  font-size: 0.74rem;
  line-height: 1.38;
  color: #5a4a3c;
  margin-top: 3px;
}

.spice-box-link {
  background: #241911;
  color: #c9955a !important;
  padding: 6px 11px;
  border-radius: 5px;
  font-size: 0.74rem;
  font-weight: 600;
  white-space: nowrap;
  flex: 0 0 auto;
  border: 1px solid #8a6a44;
  transition: all 0.2s ease;
}

.spice-box-link:hover {
  background: #8a5a2b;
  color: #faf6ed !important;
}

/* Inhaltsverzeichnis & Kategorien */
.toc-list {
  list-style: none;
  margin-left: 0;
  padding-left: 0;
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-top: 6px;
}

.toc-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 10px;
  border-radius: 5px;
  background: rgba(138, 106, 68, 0.08);
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
}

.toc-item:hover {
  background: rgba(201, 149, 90, 0.22);
  transform: translateX(4px);
}

.toc-category-item {
  border-left: 3px solid #8a5a2b;
  background: rgba(201, 149, 90, 0.12);
}

.toc-item strong {
  font-family: var(--font-serif);
  font-size: 1.08rem;
  color: #241911;
}

.toc-item span {
  font-size: 0.78rem;
  color: #7d6b59;
  white-space: nowrap;
  margin-left: 10px;
}

/* Steuerleiste unten */
.book-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  margin-top: 10px;
}

.page-indicator {
  font-family: var(--font-serif);
  font-size: 1.1rem;
  color: var(--accent);
  min-width: 140px;
  text-align: center;
}

.book-controls button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* ---------- Rezeptfoto & Zusatzseiten-Foto (Edler Kartenrahmen) ---------- */
.recipe-photo,
.info-page-photo {
  width: 100%;
  border-radius: 7px;
  padding: 4px;
  background: #fffdf9;
  border: 1px solid #d5c5ab;
  box-shadow: 0 3px 10px rgba(42, 29, 18, 0.14);
  margin: 4px 0 8px;
}

.recipe-photo {
  height: 155px;
}

.info-page-photo {
  height: 210px;
}

.photo-inner-clip {
  width: 100%;
  height: 100%;
  border-radius: 4px;
  overflow: hidden;
}

.photo-inner-clip img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* ---------- Mobile Wisch-Hinweis ---------- */
.mobile-swipe-hint {
  display: none;
  text-align: center;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 10px;
  letter-spacing: 0.5px;
}

/* ---------- Aktionen pro Rezeptseite: Teilen & Drucken ---------- */
.recipe-actions {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 5px;
  align-items: center;
  margin-left: auto;
}

.recipe-action-btn {
  background: rgba(138, 106, 68, 0.12);
  border: 1px solid rgba(138, 106, 68, 0.35);
  color: #5c4328;
  font-family: var(--font-sans);
  font-size: 0.69rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 5px;
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.15s ease;
}

.recipe-action-btn:hover,
.recipe-action-btn:focus-visible {
  background: #8a5a2b;
  border-color: #8a5a2b;
  color: #faf6ed;
  outline: none;
}

/* Hinweis-Toast (z. B. "Link kopiert") */
.book-toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 20px);
  background: #241911;
  color: #f5eedf;
  border: 1px solid #c9955a;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 0.86rem;
  max-width: 90vw;
  opacity: 0;
  pointer-events: none;
  z-index: 5000;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.book-toast.visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* Titel der mobilen Rezeptseiten */
.mobile-recipe-title {
  font-size: 1.48rem;
}

.mobile-recipe-title.is-compact {
  font-size: 1.25rem;
  margin-bottom: 8px;
}

/* Unsichtbare Messfläche für die dynamische Seitenaufteilung (nur Mobil, kurzzeitig im DOM) */
.mobile-measure-face {
  position: absolute;
  left: 0;
  top: 0;
  visibility: hidden;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  border: 1px solid transparent;
  box-sizing: border-box;
}

/* Druckvorlage für ein einzelnes Rezept (nur im Druck sichtbar) */
#printSheet {
  display: none;
}

/* ---------- Responsive (Mobilgeräte: 1:1 Buchmaße & Layout aus dem Live-Editor) ---------- */
@media (max-width: 1080px) {
  .mobile-swipe-hint {
    display: block !important;
  }

  .book-scene {
    perspective: 1400px !important;
    touch-action: pan-y;
    /* rechts Platz für das Register, damit die Tabs neben dem Buch sitzen */
    padding: 8px 34px 18px 10px !important;
  }

  .book-wrapper,
  .book-wrapper.is-closed,
  .book-wrapper.is-end {
    width: 100% !important;
    max-width: var(--mobile-book-width, 420px) !important;
    height: var(--mobile-book-height, 620px);
    transform: none !important;
  }

  .book-spine,
  .book-pages-stack,
  .book-ribbon {
    display: none !important;
  }

  /* Register-Tabs rechts neben dem Buch (1:1 wie am Desktop und im Editor) */
  .book-edge-tabs {
    display: flex !important;
    top: 22px;
    right: -30px;
    gap: 6px;
    z-index: 20;
    max-height: calc(100% - 30px);
  }

  .edge-tab-btn {
    padding: 9px 4px;
    font-size: 0.64rem;
    letter-spacing: 0.4px;
    max-height: 120px;
    box-shadow: 2px 3px 7px rgba(0, 0, 0, 0.35);
  }

  .edge-tab-btn:hover,
  .edge-tab-btn.active {
    transform: translateX(2px);
  }

  .book-sheets {
    position: relative !important;
    width: 100% !important;
    height: 100% !important;
    transform-style: flat !important;
  }

  .sheet {
    position: static !important;
    width: 100% !important;
    height: 100% !important;
    transform: none !important;
    display: contents !important;
  }

  .page-face {
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    backface-visibility: visible !important;
    border-radius: 12px !important;
    display: flex !important;
    flex-direction: column !important;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateX(18px) !important;
    transition: opacity 0.26s ease, transform 0.28s cubic-bezier(0.25, 0.8, 0.25, 1), visibility 0s linear 0.28s;
    will-change: opacity, transform;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    -webkit-overflow-scrolling: touch;
  }

  .page-face.mobile-anim-prev {
    transform: translateX(-18px) !important;
  }

  .page-face.mobile-page-active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateX(0) !important;
    transition: opacity 0.26s ease, transform 0.28s cubic-bezier(0.25, 0.8, 0.25, 1), visibility 0s linear 0s;
    z-index: 5;
  }

  .page-inner {
    padding: 16px 16px 12px !important;
    min-height: 100%;
    height: auto !important;
    flex: 1 0 auto;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
  }

  .recipe-title {
    font-size: 1.48rem;
  }

  .cover-front {
    padding: 20px !important;
  }

  .cover-frame {
    flex: 1;
    height: 100%;
  }

  .cover-title {
    font-size: 2.2rem !important;
  }

  .info-page-photo {
    max-height: 210px !important;
  }

  /* Gewürz-Box bleibt auch mobil kompakt mit Titel links + Button rechts in einer Zeile */
  .spice-box {
    flex-direction: row !important;
    flex-wrap: wrap !important;
    align-items: center !important;
    justify-content: space-between !important;
    padding: 9px 12px !important;
  }

  .spice-box-link {
    width: auto !important;
    flex: 0 0 auto !important;
  }

  .page-inner .spice-box {
    margin-top: auto;
  }

  /* Zweispaltige Zutatenlisten bleiben auch auf schmalen Handys 2-spaltig,
     wenn dies im Editor oder automatisch (ab 8 Zutaten) gewählt wurde */
  .ingredients-list.two-columns,
  .ingredients-list.two-columns.ing-compact {
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: 8px;
    row-gap: 3px;
  }

  .ing-compact .ingredient-item {
    font-size: 0.8rem;
    gap: 6px;
  }

  .ingredients-list {
    gap: 2px;
  }

  .ingredient-item {
    padding: 2px 4px;
  }

  .steps-list {
    gap: 8px;
    margin-bottom: 10px;
  }

  .steps-heading {
    margin-bottom: 8px;
  }

  /* Fußzeile: Teilen/Drucken-Buttons in eigener Zeile oben drüber, darunter Navigation + Seitenzahl */
  .page-footer-meta {
    flex-wrap: wrap;
    row-gap: 6px;
  }

  .page-footer-meta .recipe-actions {
    order: -1;
    width: 100%;
    margin-left: 0;
    justify-content: space-between;
    padding-bottom: 5px;
    border-bottom: 1px dashed rgba(138, 106, 68, 0.22);
  }

  .page-footer-meta .recipe-action-btn {
    flex: 1;
    justify-content: center;
    padding: 4px 6px;
    font-size: 0.7rem;
  }
}

@media (max-width: 520px) {
  .book-search-box input,
  .book-search-box input:focus {
    width: 210px;
  }

  .book-search-results {
    width: 280px;
    left: -20px;
  }
}

/* ---------- Saubere Druckansicht (Strg + P druckt aktuelles Rezept auf A4 quer) ---------- */
@media print {
  @page {
    size: A4 landscape;
    margin: 12mm;
  }

  body {
    background: #ffffff !important;
    color: #000000 !important;
  }

  #header-placeholder,
  #footer-placeholder,
  .book-intro,
  .book-toolbar,
  .book-controls,
  .mobile-swipe-hint,
  .book-spine,
  .book-pages-stack,
  .book-ribbon,
  .book-edge-tabs,
  .corner-flip,
  .recipe-back-links,
  .recipe-actions,
  .book-toast,
  .spice-box-link {
    display: none !important;
  }

  .book-stage-section {
    padding: 0 !important;
  }

  .book-scene {
    perspective: none !important;
    padding: 0 !important;
  }

  .book-wrapper {
    width: 100% !important;
    height: auto !important;
    transform: none !important;
  }

  .book-sheets {
    display: flex !important;
    gap: 16px !important;
  }

  .sheet {
    display: contents !important;
  }

  .page-face {
    display: none !important;
    position: static !important;
    width: 50% !important;
    height: auto !important;
    transform: none !important;
    box-shadow: none !important;
    border: 1px solid #cbbba0 !important;
    background: #faf6ed !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .page-face.print-active-page {
    display: flex !important;
  }
}

/* ---------- Einzelnes Rezept drucken (Button "Rezept ausdrucken") ---------- */
@media print {
  @page recipe {
    size: A4 portrait;
    margin: 12mm;
  }

  /* Alles ausblenden außer der Druckvorlage */
  body.print-recipe-mode > *:not(#printSheet) {
    display: none !important;
  }

  body.print-recipe-mode #printSheet {
    display: block !important;
    page: recipe;
    color: #000;
    background: #fff;
    font-family: var(--font-sans, Arial, sans-serif);
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .pr-kicker {
    font-size: 9pt;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: #8a5a2b;
    margin-bottom: 4pt;
  }

  .pr-title {
    font-family: var(--font-serif, Georgia, serif);
    font-size: 26pt;
    line-height: 1.1;
    color: #000;
    margin: 0 0 4pt;
  }

  .pr-meta {
    font-size: 10pt;
    color: #5a4a3c;
    margin-bottom: 10pt;
  }

  .pr-photo {
    height: 50mm;
    overflow: hidden;
    border-radius: 3mm;
    margin-bottom: 10pt;
  }

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

  .pr-desc {
    font-size: 10.5pt;
    line-height: 1.5;
    color: #2b2118;
    margin: 0 0 12pt;
  }

  .pr-columns {
    display: grid;
    grid-template-columns: 38% 1fr;
    column-gap: 10mm;
    align-items: start;
  }

  .pr-columns h2 {
    font-family: var(--font-serif, Georgia, serif);
    font-size: 15pt;
    color: #000;
    border-bottom: 1px solid #8a5a2b;
    padding-bottom: 3pt;
    margin: 0 0 8pt;
  }

  .pr-ing .ingredient-item,
  .pr-steps .step-item {
    break-inside: avoid;
    font-size: 10.5pt;
    line-height: 1.4;
    color: #000;
  }

  .pr-ing .ingredients-list {
    gap: 3pt;
  }

  .pr-ing .ingredient-item {
    padding: 0;
  }

  .pr-ing .ingredient-check {
    background: transparent !important;
    color: transparent !important;
    border: 1px solid #5c4328;
  }

  .pr-steps .steps-list {
    gap: 8pt;
  }

  .pr-spice {
    margin-top: 16pt;
    padding: 8pt 10pt;
    border: 1px solid #c9a679;
    border-radius: 2mm;
    background: #f6efe0;
    font-size: 10pt;
    break-inside: avoid;
  }

  .pr-spice small {
    display: block;
    font-size: 8pt;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: #8a5a2b;
    font-weight: 600;
  }

  .pr-footer {
    margin-top: 14pt;
    padding-top: 6pt;
    border-top: 1px solid #cbbba0;
    font-size: 8pt;
    color: #7d6b59;
    word-break: break-all;
  }
}