/* Homemade Apple, Apache License 2.0, siehe fonts/LICENSE.txt */
@font-face {
  font-family: "Homemade Apple";
  src: url("fonts/homemade-apple-latin-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: light dark;
  --paper: #f6efe0;
  --surface: #fffbf2;
  --ink: #2c241b;
  --muted: #6f6253;
  --line: #e2d6bf;
  --accent: #a8431f;
  --on-accent: #fffbf2;
  --accent-soft: #f0dccb;
  --herb: #55683a;
  --required: #c62828;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Noto Serif", "Book Antiqua", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --hand: "Homemade Apple", var(--serif);
  --tick: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fffbf2' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 13l4.5 4.5L19 7'/%3E%3C/svg%3E");
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #1f1a15;
    --surface: #2a231c;
    --ink: #f1e8d9;
    --muted: #b5a793;
    --line: #40362b;
    --accent: #e59068;
    --on-accent: #2a1609;
    --accent-soft: #4a2e20;
    --herb: #a5ba80;
    --required: #ff8a80;
    --tick: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%231f1a15' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 13l4.5 4.5L19 7'/%3E%3C/svg%3E");
  }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { font-size: 112.5%; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  line-height: 1.5;
}

h1, h2, h3 { font-family: var(--serif); line-height: 1.2; font-weight: 600; margin: 0; }
h1 { font-size: 1.9rem; margin-bottom: .75rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.1rem; }
p { margin: 0 0 .75rem; }
a { color: var(--accent); }

:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; padding: 0;
}

.page { max-width: 44rem; margin-inline: auto; padding-inline: 1rem; }
main.page { padding-block: .5rem 7rem; }
main.page-narrow { max-width: 26rem; padding-block: 3rem; }
.stack { display: flex; flex-direction: column; gap: .75rem; }
.form-narrow { max-width: 24rem; }
.muted { color: var(--muted); }

/* Kopfzeile */
.topbar {
  max-width: 44rem; margin-inline: auto;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(.6rem + env(safe-area-inset-top)) 1rem .4rem;
}
.brand { font-family: var(--hand); font-size: 1.15rem; font-weight: 400; line-height: 1.8; color: var(--ink); text-decoration: none; }
.topbar-left { display: flex; align-items: center; gap: .6rem; }
.menu { position: relative; }
.menu summary { list-style: none; }
.menu summary::-webkit-details-marker { display: none; }
.menu[open] .menu-btn { border-color: var(--accent); }
.menu-user { margin: 0 0 .25rem; padding: .5rem .7rem; color: var(--muted); font-size: .9rem; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.menu-panel {
  position: absolute; right: 0; top: calc(100% + .3rem); z-index: 20; min-width: 13rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: .35rem;
  box-shadow: 0 8px 24px rgb(44 36 27 / .18);
}
.menu-panel a, .menu-panel button {
  display: block; width: 100%; padding: .6rem .7rem; text-align: left;
  background: none; border: 0; font: inherit; color: var(--ink); text-decoration: none; cursor: pointer; border-radius: 6px;
}
.menu-panel a:hover, .menu-panel button:hover { background: var(--accent-soft); }

/* Formulare und Knöpfe */
.field { display: block; font-size: .9rem; color: var(--muted); }
.field input, .field textarea { margin-top: .25rem; }
.required { color: var(--required); font-weight: 700; }
input[type="text"], input[type="url"], input[type="password"], input[type="search"], input[type="date"], input[type="number"], textarea, select {
  width: 100%; font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 8px; padding: .6rem .7rem; min-height: 2.75rem;
}
textarea { resize: vertical; field-sizing: content; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 2.75rem; padding: .4rem 1rem;
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
  color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
}
.btn:hover { border-color: var(--accent); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary:disabled { opacity: .6; cursor: default; }
.btn-quiet { background: none; border-color: transparent; color: var(--muted); font-weight: 400; }
.btn-wide { width: 100%; }
.back-btn, .menu-btn { width: 2.75rem; padding: 0; flex: none; }
.back-btn svg, .menu-btn svg { width: 1.3rem; height: 1.3rem; }
.link-btn { background: none; border: 0; padding: .4rem 0; font: inherit; font-size: .9rem; color: var(--accent); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.icon-btn { width: 2.75rem; height: 2.75rem; flex: none; background: none; border: 0; font-size: 1.5rem; line-height: 1; color: var(--muted); cursor: pointer; }
.icon-btn:hover { color: var(--accent); }

.check-line { display: flex; align-items: center; gap: .6rem; min-height: 2.75rem; }
.check-line input { width: 1.4rem; height: 1.4rem; accent-color: var(--accent); }

.alert { color: var(--accent); font-weight: 600; }
.flash { margin-block: .25rem .5rem; color: var(--herb); font-weight: 600; }

.stepper { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); overflow: hidden; }
.stepper-btn { width: 2.75rem; height: 2.75rem; border: 0; background: none; font-size: 1.4rem; color: var(--accent); cursor: pointer; }
.stepper input, .stepper output {
  width: 3rem; min-height: 0; border: 0; padding: 0; text-align: center; background: none; font-weight: 600;
  appearance: textfield; font-family: var(--serif); font-size: 1.2rem;
}
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { appearance: none; margin: 0; }

/* Boxen */
.box, .recipe { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.box { padding: .8rem; }
.box + .box { margin-top: .9rem; }

.tag { display: inline-block; padding: .05rem .55rem; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: .8rem; font-weight: 600; }

/* Anmeldung */
.login { max-width: 22rem; margin: 12vh auto 0; }
.login-title { font-family: var(--hand); font-size: 2.3rem; font-weight: 400; line-height: 1.8; margin-bottom: 1.5rem; }

/* Liste */
.list-head { margin-bottom: .6rem; }
.pills { display: flex; gap: .4rem; overflow-x: auto; margin-inline: -1rem; padding: .2rem 1rem .6rem; scrollbar-width: none; }
.pills::-webkit-scrollbar { display: none; }
.pill {
  flex: none; min-height: 2.5rem; padding: .3rem .9rem; font: inherit; font-size: .9rem; cursor: pointer;
  color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 999px;
}
.pill[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }

.recipes { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .9rem; }
.recipe a { display: flex; gap: .85rem; padding: .8rem; color: inherit; text-decoration: none; }
.thumb { width: 4.5rem; height: 4.5rem; flex: none; border-radius: 8px; object-fit: cover; }
.thumb-empty {
  display: grid; place-items: center; background: var(--accent-soft); color: var(--accent);
  font-family: var(--serif); font-size: 2.2rem; line-height: 1;
}
.recipe-text { min-width: 0; display: flex; flex-direction: column; gap: .1rem; }
.recipe-title { font-family: var(--serif); font-size: 1.2rem; font-weight: 600; line-height: 1.25; }
.recipe-meta { display: flex; flex-wrap: wrap; align-items: center; gap: .2rem .6rem; font-size: .85rem; color: var(--muted); }
.recipe-info { font-size: .92rem; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.empty-state, .empty-filter { padding-block: 2.5rem; color: var(--muted); }
.fab {
  position: fixed; z-index: 10;
  right: max(1rem, calc((100vw - 44rem) / 2 + 1rem));
  bottom: calc(1rem + env(safe-area-inset-bottom));
  padding: .8rem 1.3rem; border-radius: 999px; font-weight: 600; text-decoration: none;
  background: var(--accent); color: var(--on-accent); box-shadow: 0 6px 18px rgb(44 36 27 / .3);
}

/* Maske */
.editor-section { padding-block: 1rem; border-top: 1px solid var(--line); }
.editor-section:first-of-type { border-top: 0; padding-top: 0; }
.editor-section h2 { margin-bottom: .6rem; }
.image-picker { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; }
.image-picker img { width: 4.5rem; height: 4.5rem; border-radius: 8px; object-fit: cover; }
.image-picker label:focus-within { outline: 3px solid var(--accent); outline-offset: 2px; }

.steps { list-style: none; margin: 0 0 .75rem; padding: 0; display: flex; flex-direction: column; gap: .9rem; }
.step { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: .4rem .8rem .9rem; }
.step-head { display: flex; align-items: center; gap: .25rem; }
.step-head h3 { flex: 1; }
.steps.is-sorting .step-body { display: none; }
.steps.is-sorting .step { padding-bottom: .4rem; }

.handle {
  width: 2.75rem; height: 2.75rem; flex: none; border: 0; cursor: grab; touch-action: none;
  background: radial-gradient(circle, var(--muted) 1.6px, transparent 2px) center / 8px 8px no-repeat;
  background-size: 8px 8px; background-repeat: repeat; background-origin: content-box; background-clip: content-box;
  padding: .85rem .95rem;
}
.is-dragging { position: relative; z-index: 15; opacity: .95; box-shadow: 0 8px 22px rgb(44 36 27 / .28); background-color: var(--surface); border-radius: 8px; }
.is-dragging .handle { cursor: grabbing; }

.ing-edit-list { list-style: none; margin: .25rem 0; padding: 0; }
.ing-edit { display: flex; align-items: center; border-bottom: 1px solid var(--line); }
.ing-edit .handle { margin-left: -.6rem; }
.ing-edit .ing-text-input { border: 0; background: none; padding-inline: .2rem; }
.ing-add { display: flex; gap: .4rem; margin-top: .4rem; }
.ing-add-btn, .list-open { width: 2.75rem; padding: 0; flex: none; }
.ing-add-btn { font-size: 1.4rem; }
.list-open svg { width: 1.3rem; height: 1.3rem; }
.step-text-label { margin-top: .5rem; }
/* field-sizing: content ignoriert rows, deshalb die Mindesthöhe in Zeilen plus Innenabstand und Rand */
.step-text { min-height: calc(3lh + 1.2rem + 2px); }
#list-text { min-height: calc(10lh + 1.2rem + 2px); max-height: 60dvh; }

.save-bar {
  position: fixed; z-index: 30; left: 0; right: 0; bottom: 0;
  background: var(--paper); border-top: 1px solid var(--line);
  padding: .6rem 1rem calc(.6rem + env(safe-area-inset-bottom));
}
.save-buttons { max-width: 42rem; margin-inline: auto; display: grid; }
.save-error { max-width: 42rem; margin: 0 auto .4rem; color: var(--accent); font-weight: 600; font-size: .92rem; }

/* Detailansicht */
.detail-head { margin-bottom: .75rem; }
.detail-image { display: block; width: calc(100% + 2rem); max-width: none; margin: .25rem -1rem .9rem; max-height: 22rem; object-fit: cover; }
.detail-category { margin: 0 0 .3rem; }
.detail-head h1 { font-size: 2.2rem; margin-bottom: .4rem; }
.detail-info { font-size: 1.05rem; }
.detail-owner { color: var(--muted); font-size: .92rem; }
.detail-actions { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: 1.1rem; }

.portions-row { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .6rem; margin-bottom: .75rem; }
.portions-main { display: flex; align-items: center; gap: .45rem; min-width: 0; font-size: .9rem; }
.portions-main .stepper { flex: none; }
.portions-main .stepper-btn { width: 2.5rem; }
.portions-main .stepper output { width: 2rem; }
#reset-checks { margin-left: auto; white-space: nowrap; }

.tabs { display: flex; border-bottom: 2px solid var(--line); margin-bottom: .9rem; }
.tabs button {
  flex: 1; min-height: 3rem; font-family: var(--serif); font-size: 1.2rem; font-weight: 600; cursor: pointer;
  background: none; border: 0; border-bottom: 3px solid transparent; margin-bottom: -2px; color: var(--muted);
}
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }

.segment { display: inline-flex; margin-bottom: .6rem; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.segment button { min-height: 2.5rem; padding: .2rem .9rem; font: inherit; font-size: .9rem; background: var(--surface); color: var(--ink); border: 0; cursor: pointer; }
.segment button[aria-pressed="true"] { background: var(--accent-soft); font-weight: 600; }

.ing-group { font-size: 1.05rem; color: var(--accent); }
.ing-list { list-style: none; margin: 0; padding: 0; }
.ing { display: flex; align-items: flex-start; gap: .75rem; padding: .55rem 0; cursor: pointer; font-size: 1.08rem; line-height: 1.4; }
.ing input {
  appearance: none; flex: none; width: 1.55rem; height: 1.55rem; margin: 0; cursor: pointer;
  border: 2px solid var(--muted); border-radius: 6px; background: var(--surface);
}
.ing input:checked { background: var(--herb) var(--tick) center / 85% no-repeat; border-color: var(--herb); }
.ing-text {
  background: linear-gradient(currentColor, currentColor) no-repeat 0 58% / 0 1.5px;
  -webkit-box-decoration-break: clone; box-decoration-break: clone;
  transition: background-size .28s ease-out, color .28s;
}
.ing input:checked + .ing-text { background-size: 100% 1.5px; color: var(--muted); }

.step-views { list-style: none; margin: 0; padding: 0; }
.step-view { display: grid; grid-template-columns: 3rem 1fr; }
.step-numeral { font-family: var(--serif); font-size: 3rem; line-height: .95; color: var(--accent); }
.step-content { min-width: 0; }
.step-content .ing-list { margin-bottom: .6rem; }
.instructions { font-family: var(--serif); font-size: 1.15rem; line-height: 1.55; max-width: 34em; margin: 0; }

.kitchen-log { margin-top: .9rem; }
.kitchen-log h2 { margin-bottom: .5rem; }
.cooked-form { display: flex; gap: .4rem; }
.cooked-form input { flex: 1; min-width: 0; }
.cooked-list { list-style: none; margin: .4rem 0 0; padding: 0; }
.cooked-list li { display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.cooked-list li:last-child { border-bottom: 0; }
#notes { min-height: calc(4lh + 1.2rem + 2px); }
.note-status { min-height: 1.3em; margin: .2rem 0 0; font-size: .85rem; color: var(--muted); }

.user-list { list-style: none; margin: 0 0 1.5rem; padding: 0; }
.user-list li { border-bottom: 1px solid var(--line); padding-block: .6rem; }
.user-list summary { cursor: pointer; }
.user-list form { margin-top: .6rem; }

.dialog { width: min(26rem, calc(100vw - 2rem)); border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--ink); padding: 1.1rem; }
.dialog::backdrop { background: rgb(31 26 21 / .5); }
.dialog-buttons { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .4rem; margin-top: .4rem; }

@media (min-width: 48rem) {
  .detail-image { width: 100%; margin-inline: 0; border-radius: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}
