:root {
  color-scheme: light;
  --bg: #fafaf8;
  --surface: #ffffff;
  --surface-hover: #f5f5f3;
  --border: rgba(17, 17, 17, 0.1);
  --border-strong: rgba(17, 17, 17, 0.24);
  --text-primary: #111111;
  --text-secondary: #5c5c5c;
  --text-tertiary: #767676;
  --accent: #ff4a17;
  --accent-contrast: #ffffff;
  --accent-text: color-mix(in srgb, var(--accent) 80%, black); /* orange text, readable on --surface */
  --danger: #c23b1e;
  --pill-bg: #ececea;
  --pill-bg-hover: #e2e2df;
  --switch-off: #d9d9d5;
  --overlay: rgba(17, 17, 17, 0.45);
  --shadow: 0 20px 50px -20px rgba(0, 0, 0, 0.35);
}

/* Dark theme: chosen with the toggle (data-theme), or following the system until then. */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #141414;
  --surface: #1e1e1d;
  --surface-hover: #282827;
  --border: rgba(255, 255, 255, 0.1);
  --border-strong: rgba(255, 255, 255, 0.24);
  --text-primary: #f3f3f1;
  --text-secondary: #b8b8b4;
  --text-tertiary: #8f8f8b;
  --accent-text: color-mix(in srgb, var(--accent) 72%, white);
  --danger: #ff6b4f;
  --pill-bg: #2a2a29;
  --pill-bg-hover: #353534;
  --switch-off: #4a4a48;
  --overlay: rgba(0, 0, 0, 0.6);
  --shadow: 0 20px 50px -20px rgba(0, 0, 0, 0.8);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #141414;
    --surface: #1e1e1d;
    --surface-hover: #282827;
    --border: rgba(255, 255, 255, 0.1);
    --border-strong: rgba(255, 255, 255, 0.24);
    --text-primary: #f3f3f1;
    --text-secondary: #b8b8b4;
    --text-tertiary: #8f8f8b;
    --accent-text: color-mix(in srgb, var(--accent) 72%, white);
    --danger: #ff6b4f;
    --pill-bg: #2a2a29;
    --pill-bg-hover: #353534;
    --switch-off: #4a4a48;
    --overlay: rgba(0, 0, 0, 0.6);
    --shadow: 0 20px 50px -20px rgba(0, 0, 0, 0.8);
  }
}

* {
  box-sizing: border-box;
}

/* `hidden` always wins over a component's own display value. */
[hidden] {
  display: none !important;
}

/* The page itself (the viewport) is the only scroller. A fixed height or overflow:hidden
   on html/body turns body into a second scroll box, which makes iOS stop short of the
   top/bottom. `clip` on body propagates to the viewport without creating a scroll box. */
body {
  margin: 0;
  max-width: 100%;
  overflow-x: clip;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text-primary);
  background: var(--bg);
}

.page {
  max-width: 1180px;
  margin: 0 auto;
  padding: clamp(1.25rem, 4vw, 3rem) clamp(1rem, 3vw, 2rem);
  /* svh = height with the iOS toolbars shown, so short pages don't scroll needlessly. */
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
}

.page--narrow {
  max-width: 760px;
}

.app-header {
  margin-bottom: clamp(1.75rem, 4vw, 2.75rem);
}

.cookbook-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: clamp(1.75rem, 4vw, 2.5rem);
}

/* ---------- Generic card (settings) ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: clamp(1rem, 2.5vw, 1.5rem);
}

.card__header {
  margin-bottom: 1rem;
}

.card__header h2 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
}

.card__text {
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.5;
  color: var(--text-secondary);
}

/* ---------- Login / password setup (settings) ---------- */
.auth-block {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.75rem;
}

.auth-block .text-form {
  margin-bottom: 0;
}

.auth-block > .btn {
  align-self: flex-start;
}

.auth-block__actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

.form-error {
  margin: 0;
  font-size: 0.85rem;
  color: var(--danger);
}

.link-btn {
  align-self: flex-start;
  border: none;
  background: none;
  padding: 0;
  font: inherit;
  font-size: 0.82rem;
  color: var(--text-tertiary);
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

.link-btn:hover {
  color: var(--text-primary);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------- Form fields ---------- */
.recipe-form {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.recipe-form input[type="text"],
.recipe-form textarea,
.text-input {
  font-family: inherit;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem 0.75rem;
  font-size: 1rem;
  color: var(--text-primary);
  width: 100%;
  resize: vertical;
}

.recipe-form input::placeholder,
.recipe-form textarea::placeholder,
.text-input::placeholder {
  color: var(--text-tertiary);
}

.recipe-form input:focus,
.recipe-form textarea:focus,
.text-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}

.text-form {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.text-form .text-input {
  flex: 1;
  min-width: 0;
}

/* ---------- Stepper (− value +) ---------- */
.stepper {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.stepper:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}

.stepper__btn {
  width: 2.4rem;
  height: 2.4rem;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s ease, background-color 0.15s ease;
}

.stepper__btn:hover:not(:disabled) {
  background: var(--surface-hover);
  color: var(--accent);
}

.stepper__btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.recipe-form .stepper input.stepper__input {
  width: 2.75rem;
  padding: 0;
  border: none;
  background: transparent;
  box-shadow: none;
  text-align: center;
  font-weight: 700;
}

.recipe-form .stepper input.stepper__input:focus {
  box-shadow: none;
}

.stepper__value {
  min-width: 6.5rem;
  padding: 0 0.25rem;
  text-align: center;
  font-size: 0.9rem;
  font-weight: 600;
  white-space: nowrap;
}

.servings-field {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.servings-field .text-input {
  flex: 1;
  min-width: 0;
}

/* Recipe-title suggestions under a textarea while typing "[[" */
.link-suggest {
  list-style: none;
  margin: -0.35rem 0 0;
  padding: 0.25rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: 0 10px 28px -14px rgba(0, 0, 0, 0.35);
}

.link-suggest__item {
  padding: 0.6rem 0.75rem;
  border-radius: 7px;
  font-size: 0.92rem;
  cursor: pointer;
}

.link-suggest__item:hover,
.link-suggest__item.is-active {
  background: var(--surface-hover);
  color: var(--accent-text);
}

.field-hint {
  margin: -0.25rem 0 0;
  font-size: 0.78rem;
  color: var(--text-tertiary);
}

.field-hint code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.95em;
  padding: 0.05rem 0.3rem;
  border-radius: 4px;
  background: var(--surface-hover);
  color: var(--text-secondary);
}

.field-label {
  margin: 0 0 -0.15rem;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-tertiary);
}

/* ---------- Buttons ---------- */
.btn {
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: 8px;
  padding: 0.55rem 1rem;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  align-self: flex-start;
}

.btn--accent {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--accent-contrast);
}

.btn--accent:hover {
  background: color-mix(in srgb, var(--accent) 88%, black);
  border-color: color-mix(in srgb, var(--accent) 88%, black);
}

.btn--ghost {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
}

.btn--ghost:hover {
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.btn--danger:hover {
  border-color: var(--danger);
  color: var(--danger);
}

.btn--danger-solid {
  border: 1px solid var(--danger);
  background: var(--danger);
  color: #ffffff;
}

.btn--danger-solid:hover {
  background: color-mix(in srgb, var(--danger) 88%, black);
  border-color: color-mix(in srgb, var(--danger) 88%, black);
}

.icon-btn {
  width: 1.9rem;
  height: 1.9rem;
  border: none;
  background: transparent;
  color: var(--text-tertiary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  transition: color 0.15s ease;
}

.icon-btn:hover {
  color: var(--text-primary);
}

.back-link {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.9rem;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  transition: color 0.15s ease;
}

.back-link:hover {
  color: var(--text-primary);
}

/* ---------- Labels ---------- */
.label-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.label-chips[hidden] {
  display: none;
}

.label-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: var(--surface-hover);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.15rem 0.55rem;
  font-size: 0.74rem;
  color: var(--text-secondary);
  white-space: nowrap;
}

.label-chip button {
  border: none;
  background: transparent;
  color: var(--text-tertiary);
  cursor: pointer;
  font-size: 0.85rem;
  line-height: 1;
  padding: 0;
}

.label-chip button:hover {
  color: var(--danger);
}

.label-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.label-picker__empty {
  color: var(--text-tertiary);
  font-size: 0.82rem;
}

.label-pill {
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  border: 1px solid transparent;
  background: var(--pill-bg);
  color: var(--text-secondary);
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.label-pill:hover {
  background: var(--pill-bg-hover);
  color: var(--text-primary);
}

.label-pill.is-selected {
  background: var(--accent);
  color: var(--accent-contrast);
}

.label-pill.is-selected:hover {
  background: color-mix(in srgb, var(--accent) 88%, black);
}

/* ---------- Toolbar: title, add, search, filters ---------- */
.list-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "title add"
    "search search"
    "labels labels";
  align-items: center;
  gap: 1rem 0.75rem;
  margin-bottom: 1.5rem;
}

.list-toolbar__title {
  grid-area: title;
}

.list-toolbar__add {
  grid-area: add;
  align-self: center;
  justify-self: end;
}

.list-toolbar__add-icon {
  display: none;
}

.list-toolbar__search {
  grid-area: search;
}

.list-toolbar__labels {
  grid-area: labels;
  align-self: start;
}

/* ---------- Under the list: sort + pagination ---------- */
.list-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 0.9rem;
}

.list-footer__tools {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.favorites-toggle svg {
  color: var(--text-tertiary);
  transition: color 0.15s ease;
}

.favorites-toggle.is-active {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, var(--surface));
  color: var(--accent-text);
}

.favorites-toggle.is-active svg {
  color: var(--accent);
  fill: currentColor;
}

.list-footer[hidden],
.pagination[hidden] {
  display: none;
}

.pagination {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  margin-left: auto;
}

.pagination__btn {
  min-width: 2.1rem;
  height: 2.1rem;
  padding: 0 0.45rem;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.pagination__btn:hover:not(:disabled) {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text-primary);
}

.pagination__btn.is-current,
.pagination__btn.is-current:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-contrast);
}

.pagination__btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.pagination__gap {
  min-width: 1.4rem;
  text-align: center;
  color: var(--text-tertiary);
}

/* Compact "2 / 5" replaces the page numbers on small screens. */
.pagination__status {
  display: none;
  min-width: 3.5rem;
  text-align: center;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.section-heading {
  font-size: clamp(1.6rem, 4vw, 2.1rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  margin: 0;
}

.section-heading__count {
  font-size: 0.55em;
  font-weight: 600;
  letter-spacing: 0;
  color: var(--text-tertiary);
  vertical-align: middle;
  margin-left: 0.2rem;
}

.sort-toggle {
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text-primary);
  cursor: pointer;
  flex: 0 0 auto;
  transition: border-color 0.15s ease;
}

.sort-toggle:hover {
  border-color: var(--border-strong);
}

.sort-toggle__arrow {
  color: var(--accent);
  font-weight: 700;
}

/* ---------- Search ---------- */
.search {
  position: relative;
}

.search__icon {
  position: absolute;
  left: 0.9rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-tertiary);
  pointer-events: none;
}

.search__input {
  width: 100%;
  font-family: inherit;
  font-size: 1rem;
  padding: 0.75rem 0.9rem 0.75rem 2.65rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text-primary);
  -webkit-appearance: none;
  appearance: none;
}

.search__input::placeholder {
  color: var(--text-tertiary);
}

.search__input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}

mark {
  background: color-mix(in srgb, var(--accent) 22%, transparent);
  color: inherit;
  border-radius: 3px;
  padding: 0 1px;
}

/* ---------- Browser: list + reading panel ---------- */
.recipe-browser {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 1.5rem;
  align-items: start;
}

.recipe-browser__list {
  min-width: 0;
}

.recipe-rows {
  list-style: none;
  margin: 0;
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
}

.recipe-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 0.55rem 0.75rem 1.1rem;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.recipe-row + .recipe-row {
  border-top: 1px solid var(--border);
}

.recipe-row:hover {
  background: var(--surface-hover);
}

.recipe-row.is-selected {
  background: color-mix(in srgb, var(--accent) 8%, var(--surface));
}

.recipe-row__main {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.15rem;
}

.recipe-row__link {
  border: none;
  background: none;
  padding: 0;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.3;
  color: var(--text-primary);
  text-align: left;
  cursor: pointer;
}

.recipe-row.is-selected .recipe-row__link {
  color: var(--accent-text);
}

.recipe-row__link::after {
  content: "";
  position: absolute;
  inset: 0;
}

.recipe-row__link:focus-visible {
  outline: none;
}

.recipe-row__link:focus-visible::after {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.recipe-row__meta {
  font-size: 0.8rem;
  color: var(--text-tertiary);
  overflow-wrap: anywhere;
}

/* Labels as quiet grey text, matching the meta line. */
.recipe-row__tags {
  font-size: 0.8rem;
  font-weight: 400;
  color: var(--text-tertiary);
}

.recipe-row__tag {
  white-space: nowrap;
}

.recipe-row__sep {
  margin: 0 0.12rem;
  font-weight: 400;
  color: var(--text-tertiary);
}

.favorite-btn {
  border: none;
  background: transparent;
  color: var(--text-tertiary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: color 0.15s ease, background-color 0.15s ease;
}

.favorite-btn:hover,
.favorite-btn.is-favorite {
  color: var(--accent);
}

.favorite-btn.is-favorite svg {
  fill: currentColor;
}

.recipe-row__favorite {
  position: relative;
  z-index: 1;
  flex: 0 0 auto;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 8px;
}

.empty-state {
  color: var(--text-tertiary);
  font-size: 0.85rem;
  margin: 0;
}

.empty-state[hidden] {
  display: none;
}

/* ---------- Reading panel ---------- */
.recipe-panel {
  position: sticky;
  top: 1.5rem;
  max-height: calc(100vh - 3rem);
  overflow-y: auto; /* scrolling past its end carries on with the page */
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
}

.recipe-panel [hidden] {
  display: none;
}

.recipe-panel__bar {
  position: absolute;
  top: 1.25rem;
  right: 1.25rem;
  display: flex;
  align-items: center;
}

.recipe-panel__back {
  display: none;
  align-items: center;
  gap: 0.3rem;
  height: 2.75rem;
  padding: 0 0.75rem 0 0.5rem;
  border: none;
  background: transparent;
  font: inherit;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  cursor: pointer;
}

.recipe-panel__tools {
  display: flex;
  align-items: center;
  gap: 0.15rem;
}

.panel-tool {
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 8px;
  color: var(--text-secondary);
  transition: color 0.15s ease, background-color 0.15s ease;
}

.panel-tool:hover {
  background: var(--surface-hover);
}

.panel-tool--edit:hover {
  color: var(--accent);
}

.recipe-panel__body {
  padding: 2rem 2.25rem 2.25rem;
}

.recipe-panel__head {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding-right: 5.5rem;
}

.recipe-panel__head h2 {
  margin: 0;
  font-size: clamp(1.5rem, 3vw, 1.9rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

/* The counts line and the "Wordt gebruikt in" line under it share one style. */
.recipe-panel__meta,
.detail__used-in {
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.45;
  color: var(--text-secondary);
}

.recipe-panel__placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  padding: 4.5rem 2rem;
  text-align: center;
}

.recipe-panel__placeholder p {
  margin: 0;
  font-size: 0.88rem;
  color: var(--text-tertiary);
}

.recipe-panel__placeholder .recipe-panel__placeholder-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.recipe-panel__placeholder-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 3rem;
  height: 3rem;
  margin-bottom: 0.6rem;
  border-radius: 50%;
  background: color-mix(in srgb, var(--accent) 10%, var(--surface));
  color: var(--accent);
}

/* Keep-screen-awake switch: only in the mobile recipe view. */
.awake-toggle {
  display: none;
  align-items: center;
  gap: 0.45rem;
  height: 2.75rem;
  padding: 0 0.55rem;
  border: none;
  background: transparent;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
}

.awake-toggle__switch {
  position: relative;
  width: 2rem;
  height: 1.15rem;
  border-radius: 999px;
  background: var(--switch-off);
  transition: background-color 0.2s ease;
}

.awake-toggle__switch::after {
  content: "";
  position: absolute;
  top: 0.15rem;
  left: 0.15rem;
  width: 0.85rem;
  height: 0.85rem;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
  transition: transform 0.2s ease;
}

.awake-toggle.is-on {
  color: var(--text-primary);
}

.awake-toggle.is-on .awake-toggle__switch {
  background: var(--accent);
}

.awake-toggle.is-on .awake-toggle__switch::after {
  transform: translateX(0.85rem);
}

.awake-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  border-radius: 8px;
}

.detail__grid {
  display: flex;
  flex-wrap: wrap;
  gap: 1.75rem 2.5rem;
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.detail__section--ingredients {
  flex: 1 1 240px;
  min-width: 0;
}

.detail__section--steps {
  flex: 1.6 1 320px;
  min-width: 0;
}

.detail__section h3 {
  margin: 0 0 0.75rem;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-tertiary);
}

.servings-control {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem 0.75rem;
  margin: -0.15rem 0 0.6rem;
}

.servings-reset {
  border: none;
  background: none;
  padding: 0.25rem 0;
  font: inherit;
  font-size: 0.8rem;
  color: var(--text-tertiary);
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

.servings-reset:hover {
  color: var(--text-primary);
}

/* Amounts recalculated for a different number of servings stand out a little. */
.detail__ingredients.is-scaled .qty {
  font-weight: 700;
  color: var(--accent-text);
}

/* "Wordt gebruikt in: …": recipes linking here, as thin orange links */
.detail__used-in .recipe-link {
  font-weight: 400;
  text-decoration: none;
}

.detail__used-in .recipe-link:hover,
.detail__used-in .recipe-link:focus-visible {
  text-decoration: underline;
  text-decoration-thickness: 1px;
}

/* [[Recipe links]] inside ingredients and steps */
.recipe-link {
  color: var(--accent-text);
  font-weight: 600;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  cursor: pointer;
}

.recipe-link:hover {
  text-decoration-thickness: 2px;
}

.recipe-link.is-missing {
  color: inherit;
  font-weight: inherit;
  text-decoration-style: dashed;
  text-decoration-color: var(--text-tertiary);
  cursor: help;
}

.detail__servings {
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
}

.detail__ingredients,
.detail__steps {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--text-primary);
}

.detail__ingredients li {
  position: relative;
  padding: 0.4rem 0 0.4rem 1rem;
  border-bottom: 1px solid var(--border);
}

.detail__ingredients li:last-child {
  border-bottom: none;
}

.detail__ingredients li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.98rem;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
}

.detail__steps {
  counter-reset: step;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.detail__steps li {
  counter-increment: step;
  position: relative;
  padding-left: 2.1rem;
}

.detail__steps li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  color: var(--accent-text);
  font-size: 0.75rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---------- Modals ---------- */
/* The overlay is the only scroller; a modal never scrolls itself. A scroll box inside a
   scroll box made iOS swallow swipes that started on the dialog. */
.modal-overlay {
  position: fixed;
  /* Sized to the visible area (set from JS via visualViewport): with the iOS keyboard up
     the overlay ends above it, so the bottom of a form can still be scrolled into view. */
  top: var(--vv-top, 0);
  left: 0;
  right: 0;
  height: var(--vv-height, 100%);
  background: var(--overlay);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 1rem;
  z-index: 50;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.modal-overlay--top {
  z-index: 60;
}

.modal-overlay[hidden] {
  display: none;
}

.modal {
  width: 100%;
  max-width: 360px;
  margin: auto; /* centres short dialogs; tall ones start at the top and scroll */
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

.modal--form {
  max-width: 520px;
}

.modal h2 {
  margin: 0 0 0.75rem;
  font-size: 1.15rem;
  color: var(--text-primary);
}

.modal p {
  margin: 0 0 1.25rem;
  color: var(--text-secondary);
  font-size: 0.88rem;
}

.modal__actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0.35rem;
}

.modal__actions-start {
  margin-right: auto;
}

.modal__actions .btn[hidden] {
  display: none;
}

.modal__close {
  width: 2.25rem;
  height: 2.25rem;
  flex: 0 0 auto;
  border-radius: 8px;
  font-size: 1.6rem;
  line-height: 1;
}

.modal__close:hover {
  background: var(--surface-hover);
}

a.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.btn.is-disabled {
  opacity: 0.4;
  pointer-events: none;
}

/* ---------- Order at Jumbo ---------- */
.jumbo-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1.1rem;
}

.jumbo-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.modal--jumbo {
  max-width: 640px;
  padding: 1.5rem 1.5rem 1.25rem;
}

.jumbo__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.jumbo__header h2 {
  margin: 0 0 0.2rem;
}

.modal .jumbo__subtitle {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-tertiary);
}

.jumbo-items {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--border);
}

.jumbo-item {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.8rem 0;
  border-bottom: 1px solid var(--border);
}

.jumbo-item__check {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  font-size: 0.92rem;
  line-height: 1.4;
  cursor: pointer;
}

.jumbo-item__check input {
  width: 1.1rem;
  height: 1.1rem;
  margin: 0.12rem 0 0;
  flex: 0 0 auto;
  accent-color: var(--accent);
  cursor: pointer;
}

.jumbo-item.is-off .jumbo-item__line {
  color: var(--text-tertiary);
}

.jumbo-item__product {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem 0.65rem;
  padding-left: 1.7rem;
}

.jumbo-item.is-off .jumbo-item__product {
  opacity: 0.45;
}

.jumbo-item__img {
  width: 2.75rem;
  height: 2.75rem;
  flex: 0 0 auto;
  object-fit: contain;
  border-radius: 8px;
  background: #ffffff;
  border: 1px solid var(--border);
}

.jumbo-item__select {
  flex: 1 1 14rem;
  min-width: 0;
  height: 2.4rem;
  padding: 0 0.6rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  font: inherit;
  font-size: 0.85rem;
  color: var(--text-primary);
}

.jumbo-item__select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}

.stepper--small .stepper__btn {
  width: 2rem;
  height: 2rem;
}

.stepper__count {
  min-width: 1.6rem;
  text-align: center;
  font-size: 0.9rem;
  font-weight: 700;
}

.jumbo-item__price {
  min-width: 4.5rem;
  margin-left: auto;
  text-align: right;
  font-size: 0.88rem;
  font-weight: 600;
}

.jumbo-item__status {
  font-size: 0.82rem;
  color: var(--text-tertiary);
}

.jumbo-item__status a {
  color: var(--text-secondary);
}

.modal .jumbo__note {
  margin: 0.85rem 0 0;
  font-size: 0.78rem;
  color: var(--text-tertiary);
}

/* Total + button stay in view at the bottom while the list scrolls. */
.jumbo__footer {
  position: sticky;
  bottom: -1rem; /* = overlay padding, so it sits flush with the screen edge */
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin: 1rem -1.5rem -1.25rem;
  padding: 0.9rem 1.5rem 1.25rem;
  background: var(--surface);
  border-top: 1px solid var(--border);
  border-radius: 0 0 14px 14px;
}

.jumbo__footer .modal__actions {
  margin: 0 0 0 auto;
}

.jumbo__total {
  font-size: 0.88rem;
  font-weight: 600;
}

/* ---------- Footer ---------- */
.app-footer {
  margin-top: clamp(2rem, 4vw, 3rem);
  padding-top: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.app-footer__text {
  font-size: 0.75rem;
  color: var(--text-tertiary);
}

.app-footer__actions {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

/* Theme toggle: a moon in light mode (go dark), a sun in dark mode (go light). */
.theme-toggle .theme-icon--sun {
  display: none;
}

:root[data-theme="dark"] .theme-toggle .theme-icon--sun {
  display: block;
}

:root[data-theme="dark"] .theme-toggle .theme-icon--moon {
  display: none;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .theme-icon--sun {
    display: block;
  }

  :root:not([data-theme="light"]) .theme-toggle .theme-icon--moon {
    display: none;
  }
}

/* ---------- Responsive ---------- */

/* Phone & tablet: list only; a recipe opens as a full-screen view. */
@media (max-width: 899px) {
  .recipe-browser {
    display: block;
  }

  .recipe-panel {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 40;
    max-height: none;
    overscroll-behavior: contain; /* full-screen view: never drag the list behind */
    border: none;
    border-radius: 0;
  }

  .recipe-panel.is-open {
    display: block;
  }

  .recipe-panel__bar {
    position: sticky;
    top: 0;
    right: auto;
    z-index: 1;
    justify-content: space-between;
    padding: 0.35rem 0.35rem 0.35rem 0.25rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
  }

  .recipe-panel__back,
  .awake-toggle {
    display: inline-flex;
  }

  .panel-tool {
    width: 2.75rem;
    height: 2.75rem;
  }

  .recipe-panel__body {
    padding: 1.4rem 1.25rem 2.5rem;
  }

  .recipe-panel__head {
    padding-right: 0;
  }

  .detail__ingredients,
  .detail__steps {
    font-size: 1rem;
  }

  .recipe-row__link {
    font-size: 1rem;
  }

  .recipe-row__favorite,
  .stepper__btn {
    width: 2.75rem;
    height: 2.75rem;
  }
}

@media (max-width: 640px) {
  .list-toolbar {
    gap: 0.9rem 0.5rem;
  }

  .list-toolbar__add {
    height: 2.75rem;
    width: 2.75rem;
    padding: 0;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .list-toolbar__add-icon {
    display: block;
  }

  .list-toolbar__add-label {
    display: none;
  }

  /* Filters scroll sideways in one row instead of stacking up. */
  .list-toolbar__labels {
    flex-wrap: nowrap;
    overflow-x: auto;
    margin-inline: calc(-1 * clamp(1rem, 3vw, 2rem));
    padding: 0 clamp(1rem, 3vw, 2rem) 2px;
    scrollbar-width: none;
  }

  .list-toolbar__labels::-webkit-scrollbar {
    display: none;
  }

  .list-toolbar__labels .label-pill {
    flex: 0 0 auto;
    white-space: nowrap;
    padding: 0.45rem 0.8rem;
  }

  .list-footer .sort-toggle {
    height: 2.75rem;
  }

  .pagination__num,
  .pagination__gap {
    display: none;
  }

  .pagination__status {
    display: inline-block;
  }

  .pagination__btn {
    min-width: 2.75rem;
    height: 2.75rem;
  }
}

@media (max-width: 480px) {
  .modal-overlay {
    padding: 0.75rem;
  }

  .modal {
    margin: 0 auto auto; /* top-aligned on phones, clear of the keyboard */
    padding: 1.1rem;
  }

  .jumbo__footer {
    bottom: -0.75rem;
    margin: 1rem -1.1rem -1.1rem;
    padding: 0.85rem 1.1rem 1.1rem;
  }

  .jumbo-item__product {
    padding-left: 0;
  }
}
