:root {
  color-scheme: light;
  --ink: #252b27;
  --muted: #56625a;
  --paper: #f8f9f6;
  --white: #ffffff;
  --panel: #edf1ea;
  --line: #d9dfd7;
  --accent: #3c5346;
  --focus: #4b765d;
  --radius: 8px;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--paper); color: var(--ink); line-height: 1.55; }
h1, h2, h3, p { margin: 0; }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
.wrap { width: min(1120px, calc(100% - 72px)); margin-inline: auto; }
.sr-only, .skip:not(:focus) { position: absolute; width: 1px; height: 1px; clip-path: inset(50%); overflow: hidden; }
.skip:focus { position: fixed; z-index: 2; left: 12px; top: 12px; background: var(--white); padding: 10px; }

.bar { background: var(--white); border-bottom: 1px solid var(--line); }
.header { min-height: 66px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.brand { font-family: Georgia, 'Times New Roman', serif; font-size: 1.38rem; line-height: 1.2; font-weight: 400; white-space: nowrap; letter-spacing: -.025em; }
nav { display: flex; gap: 24px; align-items: center; font-size: .9rem; }
.nav-link { color: var(--muted); background: none; border: 0; padding: 8px 0; }
.nav-link:hover, .nav-link[aria-pressed=true], .nav-link[aria-expanded=true] { color: var(--ink); text-decoration: underline; text-underline-offset: 4px; }
.button { display: inline-flex; justify-content: center; align-items: center; gap: 6px; border: 1px solid transparent; border-radius: var(--radius); padding: 9px 14px; min-height: 42px; font-size: .9rem; font-weight: 600; line-height: 1.2; text-align: center; }
.outline, .source { border-color: var(--line); background: var(--white); }
.outline:hover, .source:hover { background: var(--panel); }
.dark { background: var(--accent); color: var(--white); }
.dark:hover { background: #2d4337; }

h1, h2, h3 { font-weight: 600; line-height: 1.2; }
h1 { font-size: clamp(1.8rem, 3vw, 2.5rem); letter-spacing: -.035em; }
h2 { font-size: clamp(1.45rem, 2.5vw, 2.1rem); letter-spacing: -.025em; }

.library { display: grid; grid-template-columns: minmax(0, 1fr); padding-block: 26px 52px; scroll-margin-top: 20px; }
.library-grid { display: contents; }
.library-hero { grid-row: 1; justify-self: center; width: min(100%, 540px); margin: 0 0 20px; aspect-ratio: 1; overflow: hidden; border-radius: var(--radius); }
.library-hero img { display: block; width: 100%; height: auto; transform: scale(1.04); }
.library-controls { display: grid; grid-template-columns: minmax(160px, 1fr) minmax(0, 2.4fr); align-items: end; gap: 12px 20px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.library-controls h1 { grid-column: 1 / -1; }
.search { position: relative; display: flex; align-items: center; width: min(100%, 344px); }
.search input { padding: 10px 10px 10px 38px; }
.glass { position: absolute; left: 14px; width: 13px; height: 13px; border: 1.5px solid var(--muted); border-radius: 50%; pointer-events: none; }
.glass::after { content: ""; position: absolute; background: var(--muted); width: 6px; height: 1.5px; transform: rotate(45deg); left: 9px; top: 10px; }
input, select { width: 100%; background: var(--white); border: 1px solid #c9d1c8; border-radius: var(--radius); padding: 9px 11px; }
.filters { display: flex; align-items: end; gap: 12px; }
.filter { display: grid; gap: 5px; flex: 1; min-width: 0; max-width: 240px; font-size: .875rem; font-weight: 600; }
.filter select { appearance: none; font-size: .92rem; font-weight: 400; background: linear-gradient(45deg, transparent 50%, var(--muted) 50%) right 16px center / 5px 5px no-repeat, linear-gradient(135deg, var(--muted) 50%, transparent 50%) right 11px center / 5px 5px no-repeat, var(--white); padding-right: 27px; cursor: pointer; }
.reset { border: 0; background: none; color: var(--accent); text-decoration: underline; text-underline-offset: 3px; padding: 10px 5px; white-space: nowrap; }
.results { font-size: .875rem; color: var(--muted); margin: 13px 0 10px; }

.cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 17px; }
.card { position: relative; display: grid; align-content: start; min-width: 0; background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.card:hover { border-color: #a6b5a7; }
.card-link { display: block; }
.card-link:focus-visible { outline-offset: -3px; }
.visual { display: block; aspect-ratio: 1; background: var(--panel); overflow: hidden; }
.visual img { display: block; width: 100%; height: 100%; object-fit: cover; }
.card:not(:has(.visual)) .card-body { padding-top: 17px; padding-right: 48px; }
.card-body { padding: 13px 14px 15px; }
.chips { display: flex; gap: 4px 7px; flex-wrap: wrap; align-items: center; }
.chip { color: var(--muted); font-size: .8rem; }
.chip + .chip::before { content: "·"; margin-right: 7px; color: #728076; }
.chip:first-child { color: var(--accent); font-weight: 600; }
.card h3 { font-size: 1.1rem; margin: 7px 0 6px; }
.empty p { color: var(--muted); font-size: .94rem; }
.card-time { display: block; font-size: .84rem; color: var(--muted); margin-top: 4px; }
.star {
  --heart-background: rgb(255 255 255 / .60);
  position: absolute;
  top: 6px;
  right: 6px;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: radial-gradient(circle, var(--heart-background) 9px, transparent 10px);
  color: var(--accent);
  font-size: .8125rem;
  line-height: 1;
}
.star:hover, .star:focus-visible { --heart-background: var(--white); }
.star[aria-pressed=true] { color: #7b4050; }
.recipe-select { position: absolute; inset: 0; width: 100%; background: transparent; border: 0; border-radius: inherit; }
.recipe-select:focus-visible { outline-offset: -3px; }
.recipe-select span {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 22px;
  height: 22px;
  border: 1px solid var(--accent);
  border-radius: 5px;
  background: var(--white);
}
.recipe-select[aria-pressed=true] { box-shadow: inset 0 0 0 2px var(--accent); }
.recipe-select[aria-pressed=true] span { background: var(--accent); }
.recipe-select[aria-pressed=true] span::after {
  content: "";
  display: block;
  width: 6px;
  height: 11px;
  margin: 2px 0 0 7px;
  border: solid var(--white);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.selecting-recipes { padding-bottom: 126px; }
.share-bar {
  position: fixed;
  inset: auto 0 0;
  z-index: 1;
  background: var(--white);
  border-top: 1px solid var(--line);
  padding: 10px 0 max(10px, env(safe-area-inset-bottom));
}
.share-content { display: flex; flex-wrap: wrap; gap: 4px 18px; align-items: center; }
.share-summary, .share-actions { display: flex; gap: 8px; align-items: center; }
.share-summary { flex: 1; justify-content: space-between; font-size: .9rem; }
.share-summary .nav-link { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; white-space: nowrap; }
.share-content textarea { width: 100%; font: inherit; }
.share-content .button:disabled, .share-content .button[aria-disabled=true] { opacity: .5; cursor: default; }
.empty { border: 1px dashed #a6b5a7; border-radius: var(--radius); padding: 32px 18px; text-align: center; }
.empty h2 { font-size: 1.3rem; }
.empty p { margin: 6px 0 0; }

dialog { color: var(--ink); background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); width: min(780px, calc(100% - 24px)); max-height: calc(100dvh - 36px); padding: 0; }
dialog::backdrop { background: #202a23a8; }
.detail, .editor { padding: clamp(20px, 5vw, 38px); position: relative; }
.editor h2 { padding-right: 42px; }
.detail-tools { display: flex; justify-content: flex-end; align-items: center; gap: 8px; margin-bottom: 10px; }
.language-switch { font-size: .75rem; line-height: 1; }
.detail-tools .language-switch { min-height: 32px; min-width: 36px; padding: 5px; }
.detail-tools .close { position: static; flex: none; }
.detail-tools .recipe-share-toggle { margin-right: auto; min-height: 32px; padding: 5px 10px; font-size: .8rem; }
.recipe-share-options { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 0 12px; }
.recipe-share-options p { font-size: .875rem; color: var(--muted); }
.recipe-share-options p:empty { position: absolute; }
.recipe-share-options textarea { width: 100%; font: inherit; }
.close { position: absolute; right: 14px; top: 13px; width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 50%; background: var(--paper); font-size: 1.4rem; line-height: 1; }
.detail h2 { margin: 8px 0; }
.detail h3 { font-size: 1.2rem; margin-bottom: 10px; }
.detail-intro { color: var(--muted); }
.detail-image { display: block; width: min(100%, 420px); aspect-ratio: 1; object-fit: cover; border-radius: var(--radius); margin: 17px auto 0; }
.photo-credit { margin-top: 4px; color: var(--muted); font-size: .75rem; text-align: center; }
.detail-columns { display: grid; grid-template-columns: 1fr 1.25fr; gap: 23px; margin-block: 24px; }
.detail ul, .detail ol { padding-left: 21px; margin: 0; }
.detail li + li { margin-top: 8px; }
.recipe-pairing { margin-bottom: 20px; color: var(--muted); }
.recipe-pairing a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.detail-actions { display: flex; gap: 9px; flex-wrap: wrap; }
.trash-note { margin-top: 12px; font-size: .875rem; color: var(--muted); }
.recipe-note { margin-top: 13px; font-size: .875rem; color: var(--muted); }
.recipe-note a { text-decoration: underline; text-underline-offset: 3px; }
.editor { display: grid; gap: 13px; }
.editor label { display: grid; gap: 3px; font-size: .91rem; font-weight: 600; }
.editor input { font-weight: 400; font-size: 1rem; }
.editor .button { justify-self: start; }
.error { color: #943737; }

@media (min-width: 650px) {
  .library-grid:has(.library-hero:not([hidden])) { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); grid-auto-flow: dense; gap: 17px; }
  .library-grid:has(.library-hero:not([hidden])) .cards { display: contents; }
  .library-hero { grid-column: span 2; grid-row: span 2; align-self: start; width: 100%; margin: 0; }
}

@media (min-width: 851px) {
  .library-grid:has(.library-hero:not([hidden])) { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (max-width: 850px) {
  .wrap { width: calc(100% - 48px); }
  .library-controls { grid-template-columns: minmax(0, 1fr); }
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 590px) {
  .wrap { width: calc(100% - 32px); }
  .header { min-height: 60px; gap: 8px; }
  .brand { font-size: clamp(1rem, 4.3vw, 1.25rem); }
  nav { gap: 10px; font-size: .875rem; flex-wrap: wrap; justify-content: flex-end; }
  nav .button { padding-inline: 10px; }
  #language { white-space: nowrap; }
  .library { padding-top: 16px; }
  .library-hero { margin-bottom: 16px; }
  .search { width: 100%; }
  .filters { flex-wrap: wrap; gap: 9px; }
  .filter { flex: 1 1 45%; max-width: none; }
  .cards { gap: 10px; }
  .card-body, .card:not(:has(.visual)) .card-body { padding: 10px 11px; }
  .card h3 { font-size: 1rem; }
  .card .chips, .card .star { display: none; }
  .detail-columns { grid-template-columns: 1fr; gap: 18px; }
  .share-summary { flex-basis: 100%; }
  .share-actions { width: 100%; }
  .share-actions .button { flex: 1; }
}

@media (max-width: 390px) {
  .cards { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}
