:root {
  --gold: #b89347;
  --gold-soft: #d6b97d;
  --green-deep: #123a2b;
  --green-cover: #194d39;
  --parchment: #efe0be;
  --ink: #18120f;
  --shadow: rgba(0, 0, 0, 0.3);
  --scroll-track: #dbc79d;
  --scroll-thumb: #8b6f42;
  --scroll-thumb-hover: #6f5733;
}

* {
  box-sizing: border-box;
}

* {
  scrollbar-width: thin;
  scrollbar-color: var(--scroll-thumb) var(--scroll-track);
}

*::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}

*::-webkit-scrollbar-track {
  background: linear-gradient(180deg, #e8d7b4, #cfb784);
  border-radius: 20px;
  border: 1px solid rgba(110, 83, 42, 0.35);
}

*::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #9b7a45, var(--scroll-thumb));
  border-radius: 20px;
  border: 2px solid #d7c293;
}

*::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, #876634, var(--scroll-thumb-hover));
}

body {
  margin: 0;
  color: var(--ink);
  font-family: 'Marcellus', serif;
  min-height: 100vh;
  background: radial-gradient(circle at top, #2d1f15 0%, #15100b 65%, #0d0906 100%);
}

.scene {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.book {
  width: min(1100px, 95vw);
  height: min(760px, 92vh);
  perspective: 2200px;
}

.cover,
.pages {
  border-radius: 12px;
  box-shadow: 0 26px 45px var(--shadow);
}

.cover {
  position: relative;
  background: linear-gradient(130deg, #0c281d, var(--green-cover) 35%, #0f3023 100%);
  color: #f3ebd4;
  border: 2px solid var(--gold);
  overflow: hidden;
  transform-origin: left center;
  transform-style: preserve-3d;
  height: 100%;
  display: grid;
  place-items: center;
  transition: transform 1.3s ease, filter 0.8s ease;
}

.book.is-open .cover {
  transform: rotateY(-165deg);
  filter: brightness(0.7);
  pointer-events: none;
}

.ornament-frame {
  position: absolute;
  inset: 18px;
  border: 2px solid var(--gold);
  border-radius: 8px;
  background:
    linear-gradient(45deg, transparent 15px, rgba(0, 0, 0, 0.17) 17px),
    linear-gradient(-45deg, transparent 15px, rgba(0, 0, 0, 0.17) 17px);
}

.ornament-frame::before,
.ornament-frame::after {
  content: '❦';
  position: absolute;
  color: var(--gold-soft);
  font-size: 2.2rem;
}

.ornament-frame::before {
  top: 10px;
  left: 16px;
}

.ornament-frame::after {
  right: 16px;
  bottom: 8px;
  transform: rotate(180deg);
}

.cover-content {
  text-align: center;
  padding: 38px 24px;
  width: min(520px, 90%);
  z-index: 1;
}

.seal {
  margin: 0;
  letter-spacing: 0.25rem;
  font-size: 0.9rem;
  color: var(--gold-soft);
}

.cover h1 {
  margin: 8px 0;
  font-family: 'Cinzel', serif;
  font-size: clamp(2rem, 4vw, 3.2rem);
  line-height: 1.1;
}

.subtitle {
  margin: 0 0 24px;
  font-family: 'Parisienne', cursive;
  font-size: 1.7rem;
}

.lock-form {
  display: grid;
  gap: 10px;
  text-align: left;
}

.lock-form label {
  font-size: 0.95rem;
  color: #f3e4bf;
}

.lock-form input,
.lock-form button,
textarea,
.recipe-panel input {
  border-radius: 7px;
  border: 1px solid #7f6a45;
  padding: 10px 12px;
  font-family: inherit;
}

.lock-form button,
#recipeForm button {
  cursor: pointer;
  background: linear-gradient(180deg, #d6b97d, #ae8a45);
  color: #1e140a;
  border: none;
  font-weight: 700;
}

#authMessage {
  min-height: 1.1rem;
  margin: 0;
}

.logo-area {
  position: absolute;
  right: 24px;
  bottom: 18px;
  text-align: right;
  z-index: 1;
}

.logo-area img {
  width: 76px;
  height: auto;
  object-fit: contain;
  opacity: 0.86;
  display: block;
}

#logoFallback {
  display: none;
  color: var(--gold-soft);
  font-size: 0.85rem;
}

.pages {
  position: absolute;
  inset: 0;
  background: #d2b184;
  padding: 28px;
  display: grid;
  grid-template-columns: minmax(240px, 320px) 1fr;
  gap: 20px;
  overflow: hidden;
  opacity: 0;
  transform: scale(0.98);
  pointer-events: none;
  transition: opacity 0.55s ease 0.25s, transform 0.7s ease;
}

.book.is-open .pages {
  opacity: 1;
  transform: scale(1);
  pointer-events: auto;
}

.parchment {
  background:
    linear-gradient(rgba(255, 255, 255, 0.06), rgba(0, 0, 0, 0.04)),
    repeating-linear-gradient(
      0deg,
      rgba(0, 0, 0, 0.02),
      rgba(0, 0, 0, 0.02) 1px,
      transparent 1px,
      transparent 30px
    ),
    var(--parchment);
  border: 1px solid #8b6f42;
  border-radius: 8px;
  padding: 16px;
  box-shadow: inset 0 0 70px rgba(99, 66, 31, 0.18);
}

.index-panel h2,
.recipe-panel h2,
.register-area h3 {
  font-family: 'Cinzel', serif;
  margin-top: 0;
}

.index-panel,
.recipe-panel {
  min-height: 0;
}

.index-panel {
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 12px;
}

.index-scroll {
  overflow-y: auto;
  min-height: 0;
  padding-right: 8px;
}

#indexList {
  padding-left: 20px;
  display: grid;
  gap: 8px;
}

#indexList button {
  border: none;
  background: none;
  text-align: left;
  padding: 0;
  cursor: pointer;
  color: #1e1812;
  font-family: inherit;
}

#indexList button:hover {
  text-decoration: underline;
}

.index-actions button,
.recipe-controls button,
.form-actions button {
  cursor: pointer;
  background: linear-gradient(180deg, #d6b97d, #ae8a45);
  color: #1e140a;
  border: none;
  font-weight: 700;
  border-radius: 7px;
  padding: 9px 12px;
  font-family: inherit;
}

.lock-button {
  background: linear-gradient(180deg, #8b6f42, #6e5531) !important;
  color: #f7ecd1 !important;
}

#indexList li.is-active button {
  font-weight: 700;
  text-decoration: underline;
}

.recipe-panel {
  display: grid;
  grid-template-rows: auto minmax(180px, 1fr) auto;
  gap: 12px;
  overflow: hidden;
}

.recipe-header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
}

.recipe-controls {
  display: flex;
  gap: 8px;
}

.recipe-content {
  border: 1px solid #917954;
  border-radius: 8px;
  padding: 18px;
  min-height: 0;
  overflow-y: auto;
}

.recipe-photo {
  width: 110px;
  height: 145px;
  border: 2px solid #8b6f42;
  border-radius: 6px;
  background: #e8d6ad;
  margin: 0 auto 14px;
  position: relative;
  overflow: hidden;
  box-shadow: inset 0 0 30px rgba(99, 66, 31, 0.15);
}

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

.recipe-photo-placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #7f6a45;
  font-size: 2rem;
}

.recipe-content h4 {
  margin: 12px 0 4px;
  font-family: 'Cinzel', serif;
}

.register-area {
  margin-top: 4px;
  border-top: 1px solid rgba(139, 111, 66, 0.5);
  padding-top: 10px;
  overflow-y: auto;
}

.register-area.is-hidden {
  display: none;
}

.form-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.form-actions .secondary,
.recipe-controls #deleteRecipeButton {
  background: #744a35;
  color: #f5ebd3;
}

.form-row {
  display: grid;
  gap: 6px;
  margin-bottom: 10px;
}

@media (max-width: 900px) {
  .pages {
    grid-template-columns: 1fr;
  }

  .recipe-panel {
    grid-template-rows: auto minmax(180px, 1fr) auto;
  }
}

#recipeForm {
  display: grid;
  gap: 10px;
}

@media (max-width: 980px) {
  .pages {
    position: static;
    grid-template-columns: 1fr;
    margin-top: 16px;
  }

  .book {
    height: auto;
  }

  .cover {
    min-height: 80vh;
    height: auto;
  }
}
