/* Book of recipes: application styles on top of parchment.css (Parchment v2 theme). */

body { min-height: 100vh; }
.page { min-height: 60vh; }
.section--first { padding-top: .25rem; }
.section:last-child { border-bottom: 0; }
.section__heading h1 { margin-block: .5rem .75rem; font-size: clamp(2.25rem, 3.6vw, 3rem); letter-spacing: -.02em; }
.flash:empty { display: none; }
.flash { margin-bottom: 1.5rem; }
.panel__title { font-size: 1rem; font-family: var(--font-ui); font-weight: 600; line-height: 1.4; }

/* Header: the brand leads home, the theme toggle and the user menu sit on the right */
.site-header .nav a[aria-current="page"] { color: var(--accent); }
.site-header__actions { display: flex; align-items: center; gap: .25rem; margin-inline-start: auto; }
.theme-toggle { display: grid; place-items: center; width: 2.75rem; height: 2.75rem; padding: 0; border: 1px solid transparent; border-radius: var(--radius); background: transparent; color: var(--muted); transition: background-color var(--duration), border-color var(--duration), color var(--duration); }
.theme-toggle:hover { background: var(--surface); border-color: var(--border); color: var(--accent); }
.theme-toggle__icon { width: 1.25rem; height: 1.25rem; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
/* The icon shows the theme a click switches to: a moon on light pages, a sun on dark ones. */
.theme-toggle__icon--sun { display: none; }
[data-theme="dark"] .theme-toggle__icon--sun { display: block; }
[data-theme="dark"] .theme-toggle__icon--moon { display: none; }
@media (prefers-color-scheme: dark) {
  [data-theme="system"] .theme-toggle__icon--sun { display: block; }
  [data-theme="system"] .theme-toggle__icon--moon { display: none; }
}
.user-menu { position: relative; }
.user-menu__toggle { display: inline-flex; align-items: center; gap: .5rem; min-height: 2.75rem; padding: .25rem .625rem .25rem .375rem; border: 1px solid transparent; border-radius: var(--radius); color: var(--text); font-size: var(--size-small); list-style: none; user-select: none; transition: background-color var(--duration), border-color var(--duration); }
.user-menu__toggle::-webkit-details-marker { display: none; }
.user-menu__toggle:hover, .user-menu[open] > .user-menu__toggle { background: var(--surface); border-color: var(--border); }
.user-menu__name { max-width: 12rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-menu__caret { color: var(--muted); font-size: .75rem; transition: transform var(--duration); }
.user-menu[open] .user-menu__caret { transform: rotate(180deg); }
.user-menu__panel { position: absolute; z-index: 20; top: calc(100% + .375rem); right: 0; display: grid; min-width: 14rem; padding: .375rem; background-color: var(--surface); background-image: var(--paper-grain); border: 1px solid var(--paper-edge); border-radius: var(--radius); box-shadow: 0 14px 32px -12px var(--paper-shadow); }
.user-menu[open] .user-menu__panel { animation: menu-in 120ms ease-out; }
@keyframes menu-in { from { opacity: 0; transform: translateY(-.25rem); } }
.user-menu__item { display: flex; align-items: center; width: 100%; min-height: 2.5rem; padding: .5rem .75rem; border: 0; border-radius: var(--radius-small); background: transparent; color: var(--text); font-size: var(--size-small); text-align: start; text-decoration: none; }
.user-menu__item:hover { background: var(--accent-soft); color: var(--accent); }
.user-menu__item[aria-current="page"] { color: var(--accent); font-weight: 600; }
.user-menu__logout { margin: .375rem 0 0; padding-top: .375rem; border-top: 1px solid var(--border); }
.user-menu__logout .user-menu__item { color: var(--error); }
.user-menu__logout .user-menu__item:hover { background: var(--error-bg); color: var(--error); }

/* Title search above the category tabs on the recipe list. */
.recipe-search { display: flex; gap: .5rem; margin-bottom: 1.25rem; }
.recipe-search .input { flex: 1; }

/* Tabs between admin sections: page links, the current one is marked with aria-current. */
/* The baseline is an inset shadow, so the active underline sits on it without overflowing (no vertical scrollbar). */
.tabs { display: flex; gap: .25rem; margin-bottom: 1.75rem; overflow: auto hidden; box-shadow: inset 0 -1px 0 var(--border); scrollbar-width: thin; }
.tabs__tab { display: inline-flex; align-items: center; flex: 0 0 auto; min-height: 2.75rem; padding: .5rem 1rem; border-bottom: 2px solid transparent; color: var(--muted); font-size: var(--size-small); font-weight: 500; text-decoration: none; transition: color var(--duration), border-color var(--duration); }
.tabs__tab:hover { color: var(--text); border-bottom-color: var(--control-border); }
.tabs__tab[aria-current="page"] { color: var(--accent); border-bottom-color: var(--accent); }

/* Avatars: the server stores them square; object-fit still crops avatars uploaded before that. */
.avatar { display: inline-grid; place-items: center; flex: 0 0 auto; overflow: hidden; border: 1px solid var(--border); border-radius: 50%; background: var(--accent-soft); color: var(--accent); font: italic 1rem/1 var(--font-reading); }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar--small { width: 2rem; height: 2rem; }
.avatar--large { width: 6rem; height: 6rem; font-size: 2.5rem; outline: 1px solid var(--border); outline-offset: 3px; }
.avatar-preview { display: flex; align-items: center; gap: 1.25rem; }

/* Icons and icon buttons */
.icon { flex: 0 0 auto; width: 1.125rem; height: 1.125rem; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.icon--grip { stroke-width: 3; }
.button--small { min-height: 2.25rem; padding: .3125rem .625rem; font-size: var(--size-small); }
.icon-button { display: inline-grid; place-items: center; flex: 0 0 auto; width: 2.5rem; height: 2.5rem; padding: 0; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--muted); text-decoration: none; transition: background-color var(--duration), border-color var(--duration), color var(--duration); }
.icon-button:not(:disabled):hover { background: var(--surface-hover); border-color: var(--accent); color: var(--accent); }
.icon-button--danger:not(:disabled):hover { background: var(--error-bg); border-color: var(--error); color: var(--error); }
.icon-button:disabled { opacity: .35; cursor: default; }
.icon-button--small { width: 2.25rem; height: 2.25rem; border-color: transparent; background: transparent; }

/* Tags */
.tag-list { display: flex; flex-wrap: wrap; gap: .375rem; margin: 0; padding: 0; list-style: none; }
.tag { display: inline-block; padding: .125rem .5rem; border-radius: var(--radius-small); background: var(--accent-soft); color: var(--accent); font-size: .75rem; font-weight: 500; line-height: 1.5; text-decoration: none; }
a.tag:hover, .tag--selected { background: var(--accent); color: var(--on-accent); }

/* Tag search above the recipe list */
.tag-filter { display: grid; gap: .875rem; margin-bottom: 1rem; padding: 1.25rem 1.5rem; background-color: var(--surface); background-image: var(--paper-grain); border: 1px solid var(--border); border-radius: var(--radius); }
.tag-filter__row { display: flex; flex-wrap: wrap; align-items: baseline; gap: .5rem .75rem; }
.tag-filter__label { color: var(--muted); font-size: var(--size-small); }
.tag-filter__selected, .tag-cloud { display: flex; flex-wrap: wrap; gap: .375rem; margin: 0; padding: 0; list-style: none; }
.tag-filter .tag-chip--link { gap: .5rem; padding: .25rem .5rem .25rem .75rem; border-radius: 1rem; background: var(--accent); color: var(--on-accent); text-decoration: none; }
.tag-filter .tag-chip--link:hover { background: var(--accent-hover); color: var(--on-accent); }
.tag-chip__x { font-size: 1rem; line-height: 1; opacity: .8; }
.tag-filter__reset { color: var(--muted); font-size: var(--size-small); }
.tag-filter__reset:hover { color: var(--accent); }
.tag-cloud__tag { display: inline-flex; align-items: baseline; gap: .375rem; padding: .25rem .625rem; border: 1px solid var(--border); border-radius: 1rem; color: var(--text); font-size: var(--size-small); text-decoration: none; transition: border-color var(--duration), color var(--duration); }
.tag-cloud__tag:hover { border-color: var(--accent); color: var(--accent); }
.tag-cloud__count { color: var(--muted); font-size: .75rem; font-variant-numeric: tabular-nums; }
.tag-cloud__more { padding: .25rem .625rem; border: 1px dashed var(--control-border); border-radius: 1rem; background: transparent; color: var(--muted); font-size: var(--size-small); }
.tag-cloud__more:hover { border-color: var(--accent); color: var(--accent); }

/* Recipe cards: Parchment .card (the title link covers the card, hover lifts it); edit and delete buttons sit above it. */
.recipe-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 17rem), 1fr)); gap: 1rem 1rem; margin: 0; padding: 0; list-style: none; }
.recipe-card__image { display: grid; place-items: center; background-color: var(--surface-subtle); background-image: var(--paper-grain), radial-gradient(ellipse at 50% 40%, var(--paper-glow), transparent 70%), linear-gradient(160deg, transparent 40%, var(--paper-shade)); color: var(--accent); }
.recipe-card__glyph { font: 2.5rem/1 var(--font-reading); opacity: .7; }
.recipe-card__actions { position: absolute; z-index: 2; top: 1.25rem; right: 1.25rem; display: flex; gap: .375rem; }
.recipe-card__actions form { margin: 0; }
.recipe-card__actions .icon-button { background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(4px); box-shadow: 0 2px 8px -3px var(--paper-shadow); }
.feed-more { display: flex; justify-content: center; margin-top: 2.5rem; }
/* Meal plans */
.plan-create { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 1rem; margin-bottom: 2rem; }
.plan-create__name { flex: 1 1 14rem; }
.plans__heading { margin: 2rem 0 .75rem; font-size: 1.5rem; }
.recipe-card__choose { display: flex; justify-content: center; align-self: stretch; margin-top: auto; padding-top: .5rem; }
.recipe-empty { display: grid; justify-items: center; gap: .75rem; }
.recipe-empty h2 { font-size: 1.75rem; }
.recipe-empty__glyph { color: var(--accent); font: 3rem/1 var(--font-reading); opacity: .7; }

/* Recipe page: ingredients beside the steps, like a page of a cookbook */
.recipe__header { display: grid; gap: .875rem; margin-bottom: 1.75rem; }
/* author · tags · actions: the tags sit in the middle */
.recipe__meta { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, auto) minmax(0, 1fr); align-items: center; gap: 1rem; }
.recipe__meta > .tag-list { justify-content: center; }
.recipe__actions { display: flex; gap: .25rem; grid-column: 3; justify-self: end; }
.recipe__actions .icon-button--danger { border-color: var(--error); background: var(--error-bg); color: var(--error); }
.recipe__actions .icon-button--danger:not(:disabled):hover { background: var(--error); color: var(--bg); }
.recipe__header h1 { font-size: clamp(2.25rem, 4.2vw, 3.25rem); letter-spacing: -.02em; text-wrap: balance; overflow-wrap: anywhere; }
.recipe__byline { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.recipe__description { max-width: 46rem; margin: 0 0 2.5rem; color: var(--muted); white-space: pre-line; overflow-wrap: anywhere; }
.recipe__actions form { margin: 0; }
.recipe__photo { margin: 0 0 2.5rem; padding: .75rem; background-color: var(--surface); background-image: var(--paper-grain); border: 1px solid var(--border); border-radius: var(--radius-page); box-shadow: 0 12px 28px -20px var(--paper-shadow); }
.recipe__photo img { display: block; width: 100%; max-height: 36rem; object-fit: cover; border-radius: var(--radius-small); }
.recipe__layout { display: grid; grid-template-columns: minmax(15rem, 1fr) minmax(0, 1.9fr); align-items: start; gap: 3rem; }
.recipe__ingredients { position: sticky; top: 1.5rem; max-height: calc(100dvh - 3rem); overflow-y: auto; padding: 1.5rem 1.5rem 1.75rem; }
.recipe__section-title { margin-bottom: 1rem; font: 400 1.75rem/1.2 var(--font-reading); }
.ingredients__group { margin: 1.5rem 0 .375rem; color: var(--accent); font: italic 1.125rem/1.3 var(--font-reading); }
.ingredients { margin: 0; padding: 0; list-style: none; }
/* name ······ amount: the dotted leader is the ::before, placed between the two by order. */
.ingredient { display: flex; align-items: baseline; gap: .5rem; padding-block: .375rem; font: 1.0625rem/1.45 var(--font-reading); }
.ingredient::before { content: ''; order: 1; flex: 1 1 1rem; min-width: 1rem; border-bottom: 1px dotted var(--control-border); }
.ingredient:not(:has(.ingredient__amount))::before { visibility: hidden; }
.ingredient__name { min-width: 0; overflow-wrap: anywhere; }
.ingredient__amount { order: 2; max-width: 50%; font-variant-numeric: tabular-nums; text-align: end; }
.steps { display: grid; gap: 1.75rem; margin: 0; padding: 0; list-style: none; }
.step { display: grid; grid-template-columns: 2.75rem minmax(0, 1fr); gap: 1.25rem; }
.step__number { display: grid; place-items: center; width: 2.75rem; height: 2.75rem; border: 1px solid var(--accent); border-radius: 50%; color: var(--accent); font: italic 1.25rem/1 var(--font-reading); }
/* Servings calculator of the recipe page */
.recipe__ingredients-heading { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: 1rem; }
.recipe__ingredients-heading .recipe__section-title { margin-bottom: 0; }
.servings { display: flex; }
.servings__stepper { display: inline-flex; align-items: center; border: 1px solid var(--control-border); border-radius: 1.125rem; background: var(--bg); }
.servings__step { display: grid; place-items: center; width: 2.25rem; height: 2.25rem; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--accent); }
.servings__step:not(:disabled):hover { background: var(--accent-soft); }
.servings__step:disabled { color: var(--muted); opacity: .45; cursor: default; }
.servings__count { min-width: 2rem; white-space: nowrap; color: var(--text); font-size: var(--size-small); font-weight: 600; font-variant-numeric: tabular-nums; text-align: center; }
.ingredient__amount.is-scaled, .step-amount.is-scaled { font-weight: 600; }

/* An ingredient amount put into a step with {{Название.amount}} */
.step-amount { color: var(--accent); white-space: nowrap; }
.step__text { max-width: var(--reading-width); padding-top: .3rem; font: var(--size-reading)/var(--leading-reading) var(--font-reading); white-space: pre-line; overflow-wrap: anywhere; }

/* Recipe form */
.recipe-form { display: grid; gap: 1.5rem; max-width: 54rem; }
.recipe-form .panel__header { display: grid; gap: .25rem; }
.recipe-form__errors { max-width: 54rem; margin-bottom: 1.5rem; }
.recipe-form__errors ul { margin: 0; padding-inline-start: 1.1rem; }
.recipe-form code { font: .8125rem var(--font-code); color: var(--text); }
.photo-field__row { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 1.25rem; }
.photo-field__preview { display: grid; place-items: center; flex: 0 0 12rem; aspect-ratio: 4 / 3; overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius-small); background-color: var(--surface-subtle); background-image: var(--paper-grain); }
.photo-field__preview img { width: 100%; height: 100%; object-fit: cover; transition: opacity var(--duration); }
.photo-field__preview.is-removed img { opacity: .25; filter: grayscale(1); }
.photo-field__empty { color: var(--accent); font: 2.5rem/1 var(--font-reading); opacity: .6; }
.photo-field__controls { flex: 1 1 16rem; gap: .5rem; }
.tag-input { display: flex; flex-wrap: wrap; align-items: center; gap: .375rem; min-height: var(--control-height); padding: .3125rem .5rem; border: 1px solid var(--control-border); border-radius: var(--radius); background: var(--bg); cursor: text; }
.tag-input:hover { border-color: var(--accent); }
.tag-input:focus-within { outline: 2px solid var(--accent); outline-offset: 3px; }
.tag-input__chips { display: contents; }
.tag-input__field { flex: 1 1 10rem; min-width: 8rem; min-height: 2rem; padding: .125rem .25rem; border: 0; outline: none; background: transparent; color: var(--text); }
.tag-input__field::placeholder { color: var(--muted); opacity: 1; }
.tag-chip { display: inline-flex; align-items: center; gap: .125rem; padding: .125rem .125rem .125rem .5rem; border-radius: var(--radius-small); background: var(--accent-soft); color: var(--accent); font-size: var(--size-small); font-weight: 500; }
.tag-chip__remove { display: grid; place-items: center; width: 1.5rem; height: 1.5rem; padding: 0; border: 0; border-radius: var(--radius-small); background: transparent; color: inherit; font-size: 1rem; line-height: 1; }
.tag-chip__remove:hover { background: var(--accent); color: var(--on-accent); }
.ingredient-groups { display: grid; gap: 1rem; }
.ingredient-group { display: grid; gap: .5rem; padding: .75rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-subtle); }
.ingredient-group > [data-add] { justify-self: start; }
.ingredient-group__header { display: flex; align-items: center; gap: .5rem; }
.ingredient-group__name { flex: 1 1 auto; font-weight: 600; }
.ingredient-group__name::placeholder { font-weight: 400; }
.ingredient-list, .step-list { display: grid; gap: .5rem; margin: 0; padding: 0; list-style: none; }
.ingredient-row { display: grid; grid-template-columns: auto 6rem 8rem minmax(0, 1fr) auto; grid-template-areas: "handle amount unit name actions"; align-items: center; gap: .5rem; }
.ingredient-row > .drag-handle { grid-area: handle; }
.ingredient-row__amount { grid-area: amount; }
.ingredient-row__unit { grid-area: unit; }
.ingredient-row__name { grid-area: name; }
.ingredient-row > .row-actions { grid-area: actions; }
.step-row { display: grid; grid-template-columns: auto 2.25rem minmax(0, 1fr) auto; grid-template-areas: "handle number text actions"; align-items: start; gap: .5rem; }
.step-row > .drag-handle { grid-area: handle; margin-top: .25rem; }
.step-row__number { grid-area: number; display: grid; place-items: center; width: 2.25rem; height: 2.25rem; margin-top: .25rem; border: 1px solid var(--accent); border-radius: 50%; color: var(--accent); font: italic 1.0625rem/1 var(--font-reading); }
.step-row__text { grid-area: text; min-height: 5.5rem; resize: vertical; field-sizing: content; }
.step-row > .row-actions { grid-area: actions; margin-top: .125rem; }
/* Ingredient cloud of the steps panel: sticks to the top while the steps scroll under it (wide screens only). */
.ingredient-cloud { position: sticky; z-index: 4; top: .5rem; display: grid; gap: .5rem; padding: 1rem 1.5rem; background-color: var(--surface); background-image: var(--paper-grain); border-bottom: 1px solid var(--border); box-shadow: 0 10px 16px -16px var(--paper-shadow); }
.ingredient-cloud__title { font-size: var(--size-small); font-weight: 600; }
.ingredient-cloud__list { display: flex; flex-wrap: wrap; gap: .375rem; }
.ingredient-cloud__list:empty { display: none; }
.ingredient-cloud__empty { color: var(--muted); font-size: var(--size-small); font-style: italic; }
.ingredient-chip { display: inline-flex; align-items: center; min-height: 2rem; padding: .25rem .75rem; border: 1px solid var(--accent); border-radius: 1rem; background: var(--accent-soft); color: var(--accent); font-size: var(--size-small); font-weight: 500; line-height: 1.3; transition: background-color var(--duration), color var(--duration); }
.ingredient-chip:not(:disabled):hover { background: var(--accent); color: var(--on-accent); }
.ingredient-chip:not(:disabled):active { transform: translateY(1px); }
.ingredient-chip:disabled { border-style: dashed; border-color: var(--control-border); background: transparent; color: var(--muted); cursor: not-allowed; }
.step-row.is-insert-target .step-row__text { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.row-actions { display: flex; gap: .125rem; }
.drag-handle { display: grid; place-items: center; width: 1.5rem; height: 2.25rem; color: var(--muted); cursor: grab; }
.drag-handle:hover { color: var(--accent); }
[data-item].is-dragging { opacity: .4; }
.form-actions { position: sticky; z-index: 5; bottom: .75rem; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .75rem; padding: .75rem 1rem; background-color: var(--surface); background-image: var(--paper-grain); border: 1px solid var(--paper-edge); border-radius: var(--radius); box-shadow: 0 10px 28px -12px var(--paper-shadow); }

/* Login */
.login-page .login { display: grid; grid-template-columns: 1fr minmax(0, 26rem); align-items: center; gap: 4rem; width: min(64rem, calc(100% - 3rem)); min-height: 100vh; margin-inline: auto; padding-block: 3rem; }
.login__intro { display: grid; gap: 1.5rem; }
.login__intro h1 { font-size: clamp(3rem, 6vw, 4.5rem); letter-spacing: -.035em; }
.login__intro h1 em { color: var(--accent); }
.login__lead { max-width: 36ch; color: var(--muted); line-height: 1.7; }
.login__card { position: relative; padding: 2.25rem 2.25rem 1.25rem; }
.login__card::before { content: ''; position: absolute; pointer-events: none; top: -1px; right: 1.75rem; width: 1rem; height: 3.125rem; background: var(--accent); clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 83%, 0 100%); }
.login__title { margin-top: .5rem; font-size: 2.25rem; }
.login__submit { width: 100%; }

/* Settings and user administration */
.user-list { margin: 0; padding: 0; list-style: none; }
.user-row { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem 1rem; padding: var(--row-pad) 1.5rem; }
.user-row + .user-row { border-top: 1px solid var(--border); }
.user-row__content { display: grid; flex: 1 1 8rem; min-width: 0; gap: .125rem; }
.user-row__login { font-weight: 500; overflow-wrap: anywhere; }
.user-row__actions { display: flex; gap: .5rem; }
.user-row__actions form { margin: 0; }

/* API tokens in the profile */
.api-tokens { margin-top: var(--space-6); }
.api-tokens__intro { gap: .25rem; max-width: 46rem; }
.api-token-new__value { display: flex; gap: .5rem; }
.api-token-new__input { flex: 1 1 auto; font-family: var(--font-code); font-size: var(--size-small); }
.token-list { margin: 0; padding: 0; list-style: none; border: 1px solid var(--border); border-radius: var(--radius); }
.token-row { display: flex; align-items: center; gap: 1rem; padding: .75rem 1rem; }
.token-row + .token-row { border-top: 1px solid var(--border); }
.token-row__content { display: grid; flex: 1 1 auto; min-width: 0; gap: .125rem; }
.token-row__name { font-weight: 500; overflow-wrap: anywhere; }
.token-row__prefix { font: .8125rem var(--font-code); }
.token-row form { margin: 0; }
.api-tokens .panel__header { align-items: flex-start; }
.api-tokens__intro { flex: 1 1 20rem; }

/* Modal dialogs (native <dialog> opened with showModal) */
.dialog { width: min(30rem, calc(100% - 2rem)); max-height: calc(100dvh - 2rem); padding: 0; overflow: hidden; border: 1px solid var(--paper-edge); border-radius: var(--radius-page); background-color: var(--surface); background-image: var(--paper-grain); color: var(--text); box-shadow: 3px 3px 0 -1px var(--surface), 3px 3px 0 var(--paper-edge), 0 24px 60px -16px rgb(30 18 6 / 45%); }
.dialog::backdrop { background: rgb(33 24 14 / 45%); backdrop-filter: blur(2px); }
.dialog[open] { animation: dialog-in 160ms ease-out; }
.dialog[open]::backdrop { animation: backdrop-in 160ms ease-out; }
@keyframes dialog-in { from { opacity: 0; transform: translateY(.75rem); } }
@keyframes backdrop-in { from { opacity: 0; } }
.dialog__panel { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; max-height: calc(100dvh - 2rem); }
.dialog__header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem 1rem 1rem 1.5rem; border-bottom: 1px solid var(--border); }
.dialog__title { min-width: 0; font: 400 1.5rem/1.25 var(--font-reading); overflow-wrap: anywhere; }
.dialog__close { display: grid; place-items: center; flex: 0 0 auto; width: 2.75rem; height: 2.75rem; padding: 0; border: 1px solid transparent; border-radius: var(--radius); background: transparent; color: var(--muted); font-size: 1.5rem; line-height: 1; transition: background-color var(--duration); }
.dialog__close:hover { background: var(--accent-soft); color: var(--accent); }
.dialog__body { padding: 1.5rem; overflow-y: auto; }
.dialog__footer { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .75rem; padding: 1rem 1.5rem; border-top: 1px solid var(--border); background: var(--surface-subtle); }
.dialog__message { font: var(--size-reading)/1.6 var(--font-reading); }
.dialog__user { display: flex; align-items: center; gap: .75rem; }
.dialog--confirm { width: min(26rem, calc(100% - 2rem)); }

/* Errors */
.error-page { display: grid; justify-items: start; gap: 1rem; }
.error-page h1 { font-size: clamp(2.25rem, 4vw, 3rem); }
.error-page__debug { max-width: 100%; font-size: .75rem; white-space: pre-wrap; }

@media (max-width: 60rem) {
  .login-page .login { grid-template-columns: minmax(0, 1fr); gap: 2rem; min-height: auto; }
  .recipe__layout { grid-template-columns: minmax(0, 1fr); gap: 2.5rem; }
  .recipe__ingredients { position: static; max-height: none; }
}
@media (max-width: 34rem) {
  /* On a phone the brand, the theme toggle and the user menu do not fit on one line;
     the user menu matters more, so only the «Р» mark stays (the login page keeps the name). */
  .site-header__inner:has(.user-menu) .brand__name { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
}
@media (max-width: 44rem) {
  .user-menu__name { max-width: 8rem; }
  .user-row { padding-inline: 1.25rem; }
  .recipe__meta { grid-template-columns: minmax(0, 1fr) auto; }
  .recipe__meta > .tag-list { grid-row: 2; grid-column: 1 / -1; justify-content: flex-start; }
  .recipe__actions { grid-column: 2; }
  .login__card { padding: 1.75rem 1.25rem 1rem; }
  .dialog__body { padding: 1.25rem; }
  .dialog__header { padding-inline-start: 1.25rem; }
  .dialog__footer { padding-inline: 1.25rem; }
  .dialog__footer .button { flex: 1 1 auto; }
  .recipe-card__actions { top: 1.125rem; right: 1.125rem; }
  .tag-filter { padding: 1rem; }
  .step { grid-template-columns: 2.25rem minmax(0, 1fr); gap: 1rem; }
  .step__number { width: 2.25rem; height: 2.25rem; font-size: 1.0625rem; }
  .step__text { padding-top: .1rem; }
  .photo-field__preview { flex-basis: 100%; }
  .recipe-form .panel__body { padding-inline: .75rem; }
  .ingredient-cloud { position: static; padding: .875rem .75rem; }
  .ingredient-group { padding: .5rem; }
  .ingredient-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr) auto; grid-template-areas: "amount unit actions" "name name name"; padding-bottom: .625rem; border-bottom: 1px dashed var(--border); }
  .step-row { grid-template-columns: 2.25rem minmax(0, 1fr) auto; grid-template-areas: "number . actions" "text text text"; }
  .ingredient-row > .drag-handle, .step-row > .drag-handle, .ingredient-group__header > .drag-handle { display: none; }
  .ingredient-row__amount, .ingredient-row__unit { padding-inline: .5rem; }
  .form-actions { flex-wrap: nowrap; padding-inline: .75rem; }
  .form-actions [data-submit] { flex: 1 1 auto; }
}
@media (pointer: coarse) {
  /* Drag and drop needs a mouse; on touch screens rows are moved with the buttons. */
  .drag-handle { display: none; }
  .ingredient-row { grid-template-columns: 6rem 8rem minmax(0, 1fr) auto; grid-template-areas: "amount unit name actions"; }
  .step-row { grid-template-columns: 2.25rem minmax(0, 1fr) auto; grid-template-areas: "number text actions"; }
}
@media (pointer: coarse) and (max-width: 44rem) {
  .ingredient-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr) auto; grid-template-areas: "amount unit actions" "name name name"; }
  .step-row { grid-template-columns: 2.25rem minmax(0, 1fr) auto; grid-template-areas: "number . actions" "text text text"; }
}
@media print {
  .site-header__actions, .tabs, .login__card::before, .recipe-card__actions, .recipe__actions, .servings button { display: none; }
  .servings__stepper { border: 0; }
  .recipe__ingredients { position: static; max-height: none; }
}

/* Date picker (app.js, [data-date-picker]): a Monday-first month grid under the field. */
.date-picker { position: relative; }
.date-picker__toggle { text-align: left; cursor: pointer; }
.date-picker__panel { position: absolute; z-index: 20; top: calc(100% + .25rem); left: 0; width: 17.5rem; padding: .75rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 8px 24px -8px var(--paper-shadow); }
.date-picker__header { display: flex; align-items: center; justify-content: space-between; margin-bottom: .5rem; }
.date-picker__month { font-weight: 600; }
.date-picker__grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: .125rem; }
.date-picker__weekday { padding: .25rem 0; text-align: center; font-size: var(--size-small); color: var(--muted); }
.date-picker__day { aspect-ratio: 1; padding: 0; border: 1px solid transparent; border-radius: var(--radius-small); background: none; color: inherit; font: inherit; cursor: pointer; }
.date-picker__day:hover { border-color: var(--accent); }
.date-picker__day--outside { color: var(--muted); opacity: .6; }
.date-picker__day--today { border-color: var(--border); font-weight: 600; }
.date-picker__day[aria-pressed="true"] { background: var(--accent); color: var(--surface); }
