:root {
  --paper: #f5ecdc; --pale: #fff7e8; --wine: #541021; --orange: #ff8b47;
  --ink: #301d1e; --blue: #284a89; --muted: #674d48; --rule: #ccb5a6;
  --serif: "Instrument Serif", Georgia, serif;
  --sans: "DM Sans", system-ui, sans-serif;
  color: var(--ink); background: var(--paper); font: 400 16px/1.5 var(--sans);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body, h1, h2, h3, p { margin: 0; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .65; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 3px; }
.cover :focus-visible { outline-color: var(--pale); }
h1, h2, h3, legend { font-family: var(--serif); font-weight: 400; line-height: .98; }
.cover {
  position: relative; isolation: isolate; display: grid; place-items: center; min-height: 680px;
  min-height: max(680px, 100svh); color: var(--orange); overflow: hidden;
  background: repeating-linear-gradient(92deg, #ffffff0a 0 1px, #0000 1px 4px),
    radial-gradient(ellipse at 45% 26%, #76203a 0%, var(--wine) 58%, #350914 100%);
  box-shadow: inset 0 0 42px #27061390;
}
.binding {
  position: absolute; inset: 0 auto 0 0; width: clamp(18px, 4.5vw, 68px); pointer-events: none;
  background: linear-gradient(90deg, #300713 4%, #7b2a3a 57%, #ffae8050 62%, #29061080 70%, #0000 91%);
}
.cover::after { content: ""; position: absolute; inset: 11px; pointer-events: none; border: 1px solid #ff9b5e35; z-index: -1; }
.plate { position: absolute; width: min(calc(100% - 38px), 1060px); height: calc(100% - 44px); }
.cover-item {
  position: absolute; left: calc(var(--x) * 100% / 24); top: calc(var(--y) * 100% / 36);
  width: calc(var(--w) * 100% / 24); height: calc(var(--h) * 100% / 36);
}
.cover-title { display: grid; place-items: center; text-align: center; container-type: size; z-index: 2; }
.cover-title h1 {
  max-width: 100%; color: var(--orange); font-size: min(var(--title-size, 18cqi), 78cqh);
  line-height: .86; letter-spacing: -.045em; text-wrap: balance; overflow-wrap: anywhere;
}
.cover-photo {
  border: 1px solid #f3987380; padding: clamp(4px, 1vw, 9px); z-index: 1;
  background: #300812; box-shadow: 1px 12px 28px #21040c85, inset 0 0 6px #0009;
}
.cover-photo img { display: block; width: 100%; height: 100%; object-fit: cover; object-position: 50% 52%; }
.cover-controls { display: grid; place-items: center; container-type: size; z-index: 3; }
.cover-actions {
  display: grid; width: 100%; grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center; gap: clamp(4px, 2cqi, 12px);
  font-size: clamp(.875rem, min(5cqi, 24cqh), 1.25rem);
  --control-height: clamp(44px, 63cqh, 4.2rem);
}
.cover-button, .search {
  border: 1px solid #ffa66a; background: var(--orange); color: #36121a; font-weight: 700;
  border-radius: 3px; min-height: 44px; padding: .45em .75em;
}
.cover-actions .cover-button, .search { min-height: var(--control-height); }
.cover-button:hover { background: #ffab72; }
.cover-button.plus { min-width: var(--control-height); padding: 0; font-size: 1.45em; line-height: 1; }
.cover-button.open { white-space: nowrap; }
.search {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; padding: 0 0 0 .65em;
  align-items: stretch; background: #400b1b; color: var(--pale);
}
.search input { width: 100%; min-width: 0; padding: 0; border: 0; background: transparent; color: inherit; }
.search input::placeholder { color: #ffe4d8; }
.search button { display: grid; place-items: center; background: transparent; color: #ffb78c; border: 0; width: 2.2em; padding: .4em; }
.search svg { width: 1.2em; stroke: currentColor; stroke-width: 2; fill: none; }
.owner-link {
  position: absolute; bottom: 17px; right: clamp(20px, 4vw, 62px);
  z-index: 5; border: 0; background: none; color: #ffcfb5; min-height: 44px;
  font-size: .8rem; text-decoration: underline; text-underline-offset: 4px;
}
.cover-message, .cover-gate { position: absolute; z-index: 4; text-align: center; bottom: 12%; padding-inline: 1rem; color: var(--pale); }
.cover-gate { display: grid; justify-items: center; gap: .8rem; }
.cover-gate .cover-button { padding-inline: 1rem; }
.pages { min-height: 100svh; background: radial-gradient(ellipse at 15% 0, #fff7e8, transparent 42rem), var(--paper); }
.page-header {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr) minmax(0, 1fr); align-items: center;
  gap: .4rem; padding: .8rem clamp(1rem, 5vw, 5rem); border-bottom: 1px solid var(--rule);
}
.page-header > :last-child { justify-self: end; }
.wordmark { border: 0; background: transparent; color: var(--wine); font: 400 clamp(1.5rem, 4vw, 2.3rem)/1 var(--serif); overflow-wrap: anywhere; }
.page-body { width: min(100% - 2.5rem, 58rem); margin-inline: auto; padding-block: clamp(2rem, 6vw, 4.8rem); }
.page-body h1 { color: var(--wine); font-size: clamp(3.3rem, 7.5vw, 6.3rem); letter-spacing: -.03em; margin-bottom: 1.1rem; overflow-wrap: anywhere; }
.chapters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.4rem 3rem; }
.chapter { border-top: 1px solid var(--rule); padding-top: .9rem; }
.chapter h2, .recipe-columns h2 { font-size: clamp(2.2rem, 4vw, 3.05rem); color: var(--wine); margin-bottom: .65rem; }
.chapter ul { list-style: none; margin: 0; padding: 0; }
.chapter button {
  width: 100%; border: 0; border-bottom: 1px solid var(--rule); background: transparent; color: var(--ink);
  text-align: left; min-height: 48px; padding: .55rem .15rem; overflow-wrap: anywhere;
}
.chapter button:hover { color: var(--blue); text-decoration: underline; }
.chapter button span { display: block; color: var(--muted); font-size: .84rem; }
.empty { grid-column: 1 / -1; color: var(--muted); padding-block: .6rem; }
.plain, .close {
  min-height: 44px; padding: .3rem .1rem; border: 0; color: var(--blue); background: transparent;
  text-decoration: underline; text-underline-offset: 4px;
}
.button {
  min-height: 44px; border: 1px solid #a48b7c; border-radius: 3px; padding: .45rem .85rem;
  font-weight: 700; background: var(--paper); color: var(--wine);
}
.button:hover { background: #fff; }
.button.primary { border-color: var(--wine); background: var(--wine); color: var(--pale); }
.button.primary:hover { background: #742039; }
.close { min-width: 44px; font-size: 1.85rem; line-height: 1; text-decoration: none; }
.recipe-page > .plain { margin-bottom: 1.2rem; }
.recipe-header { display: grid; gap: 1.25rem; margin-bottom: 2rem; }
.recipe-header:has(img) { grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); align-items: center; }
.recipe-header img { width: 100%; max-height: 26rem; object-fit: cover; border-radius: 3px; }
.recipe-columns { display: grid; grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr); gap: 2rem; }
.recipe-columns.combined { grid-template-columns: minmax(0, 1fr); }
.recipe-columns ol, .recipe-columns ul { margin: 0; padding-inline-start: 1.3rem; }
.recipe-columns li { padding: .35rem 0 .5rem; }
.tags { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; }
.tag { color: var(--blue); background: #eee4d3; border: 1px solid #405b8a70; border-radius: 2rem; padding: .14rem .6rem; font-size: .82rem; }
button.tag { min-height: 30px; }
.byline, .hint, label small { color: var(--muted); font-size: .85rem; font-weight: 400; }
.byline { margin: .7rem 0; }
.recipe-tools { display: flex; align-items: end; gap: .7rem; flex-wrap: wrap; margin: 0 0 1.7rem; padding: .8rem 0; border-block: 1px solid var(--rule); }
.recipe-tools label { font-size: .85rem; }
.recipe-tools select { min-width: 7rem; }
dialog {
  width: min(100% - 1.5rem, 38rem); max-height: calc(100% - 1.5rem); overflow: auto;
  padding: clamp(1rem, 4vw, 1.6rem); border: 1px solid var(--rule); border-radius: 5px;
  color: var(--ink); background: var(--pale); box-shadow: 0 24px 70px #26101e70;
}
dialog::backdrop { background: #2809119c; }
dialog form { display: grid; gap: .85rem; }
.dialog-heading { display: flex; align-items: center; justify-content: space-between; }
.dialog-heading h2 { color: var(--wine); font-size: clamp(2.6rem, 8vw, 3.5rem); }
label { display: grid; gap: .25rem; font-weight: 600; min-width: 0; }
label.inline { display: flex; align-items: center; }
label.inline input { width: auto; min-height: auto; margin-right: .4rem; }
input, select, textarea {
  width: 100%; min-height: 44px; color: var(--ink); background: #fffaf1; border: 1px solid #a48b7c;
  border-radius: 3px; padding: .52rem .63rem;
}
textarea { resize: vertical; }
fieldset { border: 1px solid var(--rule); border-radius: 3px; padding: .75rem; min-width: 0; margin: 0; }
legend { font-size: 1.85rem; color: var(--wine); }
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; }
.ingredient { display: grid; grid-template-columns: 1.3rem minmax(0, .75fr) minmax(0, 1fr) minmax(0, 1.5fr) 32px; align-items: center; gap: .32rem; margin-top: .55rem; }
.ingredient input { padding: .38rem; }
.ingredient button { min-width: 0; padding: 0; }
.ingredient > span { text-align: center; color: var(--muted); font-size: .85rem; }
.form-actions, .settings-links { display: flex; flex-wrap: wrap; gap: .9rem; }
.error { color: #871c29; font-weight: 600; font-size: .9rem; }
.error:empty { display: none; }
.layout-tools { background: var(--paper); padding: .8rem; border-top: 1px solid var(--rule); position: sticky; bottom: 0; z-index: 6; }
.layout-top, .layout-values { display: flex; flex-wrap: wrap; align-items: end; gap: .55rem; justify-content: center; }
.layout-top p { align-self: center; color: var(--muted); font-size: .8rem; }
.layout-values { margin-top: .55rem; }
.layout-tools label { font-size: .8rem; }
.layout-values input { width: 4.6rem; }
.cover.editing { min-height: max(640px, calc(100svh - 112px)); }
.editing .plate {
  touch-action: none;
  background-image: linear-gradient(to right, #ffd6a93c 1px, transparent 1px), linear-gradient(to bottom, #ffd6a93c 1px, transparent 1px);
  background-size: calc(100% / 24) calc(100% / 36);
}
.editing .cover-item { outline: 1px dashed #ffe5b7; cursor: move; }
.editing .cover-item.selected { outline: 2px solid #ffdc8b; z-index: 4; }
.editing .cover-item > :not(.resize) { pointer-events: none; }
.editing .resize { position: absolute; bottom: -11px; right: -11px; background: #ffdc8b; border: 1px solid var(--wine); width: 25px; height: 25px; cursor: nwse-resize; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
@media (max-width: 640px) {
  .plate { width: calc(100% - 32px); }
  .cover-actions { grid-template-columns: minmax(0, 1fr) auto; gap: 5px; }
  .search { grid-column: 1 / -1; min-height: 44px; }
  .cover-actions .cover-button { min-height: 44px; }
  .cover-actions .plus { min-width: 44px; }
  .recipe-header:has(img), .recipe-columns, .chapters { grid-template-columns: 1fr; }
  .recipe-columns { gap: 1.4rem; }
  .page-header .plain { font-size: .82rem; white-space: nowrap; }
}
