/* ========================================
   Recipe index — Backyard Blue
   One card per idea (a video, photo or note), its recipes as
   notebook tabs on desktop and a numbered list on the phone.
   ======================================== */
.rx {
  max-width: 1248px;
  margin: 0 auto;
  padding: var(--space-lg) var(--space-lg) var(--space-2xl);
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

/* ── Head: kitchen cooks ──────────────── */
.rx-head {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.rx-head__actions {
  display: flex;
  flex: 1;
  align-items: center;
  gap: var(--space-sm);
}

.rx-cooks {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm-md);
  min-height: 44px;
  padding: var(--space-xs) var(--space-md) var(--space-xs) var(--space-xs);
  border: var(--line);
  border-radius: var(--radius-control);
  background: var(--color-paper);
  font-weight: var(--weight-bold);
  font-size: var(--text-body);
  line-height: var(--leading-title);
  font-family: var(--font-body);
  color: var(--color-ink);
  cursor: pointer;
  transition: background-color 150ms ease, transform 160ms var(--ease-out-soft);
}

@media (hover: hover) and (pointer: fine) {
  .rx-cooks:hover { background: var(--color-hover); }
}

.rx-cooks:active { transform: scale(0.97); }
.rx-cooks:focus-visible { outline: 3px solid var(--color-heeler); outline-offset: 2px; }
.rx-cooks__faces { display: inline-flex; }
.rx-cooks__faces .rx-avatar + .rx-avatar { margin-left: calc(var(--space-sm) * -1); }

/* ── Add a recipe ─────────────────────── */
/* One panel: inline on desktop, a bottom sheet behind a round
   button on the phone. Its colour follows the chosen source. */
.import-widget {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  padding: var(--space-lg) var(--space-lg) var(--space-lg);
  background: var(--color-cream-dark);
  border-radius: var(--radius-xl);
  color: var(--color-ink);
}

.import-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-sm-md) var(--space-md);
}

.import-title {
  margin: 0;
  font-weight: var(--weight-semibold);
  font-size: var(--text-headline);
  line-height: var(--leading-title);
  font-family: var(--font-display);
  color: var(--color-ink);
}

.import-close {
  order: 2;
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: var(--line);
  border-radius: var(--radius-round);
  background: var(--color-paper);
  color: var(--color-ink);
  cursor: pointer;
}

.import-close svg { width: 16px; height: 16px; }

/* Source tabs: a white thumb slides under the chosen one. */
.import-tabs {
  position: relative;
  display: flex;
  gap: var(--space-xs);
  padding: var(--space-xs);
  border-radius: var(--radius-lg);
  background: color-mix(in srgb, var(--color-ink) 7%, transparent);
}

.import-tabs::before {
  content: "";
  position: absolute;
  top: 4px;
  bottom: 4px;
  left: 4px;
  width: 116px;
  /* The selected-tab thumb keeps its ink edge (DESIGN.md Ink edges). */
  border: var(--line);
  border-color: var(--color-ink);
  border-radius: var(--radius-control);
  background: var(--color-paper);
  transition: transform 300ms cubic-bezier(0.3, 1.3, 0.5, 1);
}

[data-import-tabs-active-value="photo"] .import-tabs::before { transform: translateX(120px); }
[data-import-tabs-active-value="text"] .import-tabs::before { transform: translateX(240px); }

.import-tab {
  position: relative;
  width: 116px;
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: var(--space-sm) 0;
  border: 0;
  border-radius: var(--radius-control);
  background: transparent;
  font-weight: var(--weight-semibold);
  font-size: var(--text-body);
  line-height: var(--leading-title);
  font-family: var(--font-display);
  color: var(--color-ink-soft);
  cursor: pointer;
  transition: color 200ms ease;
}

.import-tab--active { color: var(--color-ink); }
.import-tab:focus-visible { outline: 3px solid var(--color-heeler); outline-offset: 2px; }
.import-tab-icon { width: 17px; height: 17px; flex: 0 0 auto; }

.import-panel {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

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

.import-panel--morph { animation: import-panel-in 260ms var(--ease-out-soft) both; }

@keyframes import-panel-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; }
}

.import-input-row,
.import-text,
.import-photo {
  margin: 0;
}

.import-input-row {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm-md);
}

/* Kitchen choice, only when the person can add to more than one. */
.import-destination {
  order: 2;
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  font-weight: var(--weight-semibold);
  font-size: var(--text-body);
  line-height: var(--leading-title);
  font-family: var(--font-body);
  color: var(--color-ink-soft);
}

.import-destination::before { content: "Add to"; }

.import-destination select {
  min-height: 44px;
  margin: 0;
  padding: 0 var(--space-lg) 0 var(--space-sm);
  field-sizing: content;
  border: 0;
  background-color: transparent;
  font-weight: var(--weight-extrabold);
  font-size: var(--text-body);
  line-height: var(--leading-title);
  font-family: var(--font-body);
  color: var(--color-ink);
}

/* YouTube: one search field with its button inside. */
.import-input-field {
  display: flex;
  align-items: center;
  gap: var(--space-sm-md);
  padding: var(--space-sm) var(--space-sm) var(--space-sm) var(--space-md);
  border: var(--line);
  border-radius: var(--radius-lg);
  background: var(--color-cream);
}

.import-input-field:focus-within { outline: 3px solid var(--ui-focus-outline); outline-offset: 0; }
.import-input-field--error { border-color: var(--color-tomato); }

.import-input-icon {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  color: var(--color-ink);
}

.import-input-field input {
  flex: 1 1 auto;
  min-width: 0;
  padding: var(--space-sm-md) 0;
  border: 0;
  outline: none;
  appearance: none;
  background: transparent;
  font-weight: var(--weight-regular);
  font-size: var(--text-body);
  line-height: var(--leading-label);
  font-family: var(--font-body);
  color: var(--color-ink);
}

body:not(.controller-prototype) .import-input-field input:focus,
body:not(.controller-prototype) .import-input-field input:focus-visible { outline: none; box-shadow: none; }

.import-input-field input::placeholder { color: var(--color-ink-soft); }

.import-submit-btn {
  position: relative;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-sm-md) var(--space-lg);
  border: var(--line);
  border-radius: var(--radius-control);
  background: var(--color-heeler);
  font-weight: var(--weight-semibold);
  font-size: var(--text-body);
  line-height: var(--leading-title);
  font-family: var(--font-display);
  color: var(--color-paper);
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 150ms ease, transform 160ms var(--ease-out-soft);
}

.import-input-field .import-submit-btn {
  border-radius: var(--radius-md);
  font-size: var(--text-body);
}

@media (hover: hover) and (pointer: fine) {
  .import-submit-btn:hover:not(:disabled) { background: var(--color-heeler-dark); }
}

.import-submit-btn:active:not(:disabled) { transform: scale(0.97); }
.import-submit-btn:focus-visible { outline: 3px solid var(--color-heeler); outline-offset: 2px; }
.import-submit-btn:disabled { background: var(--color-ink-faint); cursor: not-allowed; }
.import-input-field .import-submit-btn:disabled { background: var(--color-heeler); }

/* Sort, shown while the field holds a dish name. */
.youtube-search-options {
  flex: 0 0 auto;
  display: flex;
  gap: var(--space-xs);
  padding: var(--space-xs);
  border: var(--line);
  border-radius: var(--radius-lg);
  background: var(--color-cream);
}

.youtube-search-options[hidden] { display: none; }

.youtube-sort-option {
  position: relative;
  margin: 0;
  cursor: pointer;
}

.youtube-sort-option input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}

.youtube-sort-option span {
  display: block;
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-control);
  font-weight: var(--weight-extrabold);
  font-size: var(--text-label);
  line-height: var(--leading-title);
  font-family: var(--font-body);
  color: var(--color-ink);
  white-space: nowrap;
}

.youtube-sort-option input:checked + span {
  background: var(--color-ink);
  color: var(--color-paper);
}

.youtube-sort-option input:focus-visible + span { outline: 3px solid var(--color-heeler); outline-offset: 2px; }

/* Search results: four video cards across, a + to add each. */
.youtube-search-results {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm-md);
  animation: import-panel-in 280ms var(--ease-out-soft) both;
}

.youtube-search-results-head {
  display: flex;
  align-items: center;
  gap: var(--space-sm-md);
}

.youtube-search-results-head h3 {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  font-weight: var(--weight-bold);
  font-size: var(--text-body);
  line-height: var(--leading-body);
  font-family: var(--font-body);
  color: var(--color-ink-soft);
}

.youtube-search-close {
  position: relative;
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: var(--line);
  border-radius: var(--radius-round);
  background: var(--color-paper);
  color: var(--color-ink);
}

.youtube-search-close::after { content: ""; position: absolute; inset: -3px; }
.youtube-search-close svg { width: 16px; height: 16px; }

.youtube-search-empty {
  margin: 0;
  font-weight: var(--weight-semibold);
  font-size: var(--text-body);
  line-height: var(--leading-body);
  font-family: var(--font-body);
  color: var(--color-ink-soft);
}

.youtube-search-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--space-md);
  margin: 0;
  padding: 0;
  list-style: none;
}

.youtube-search-result {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-cream);
  transition: border-color 150ms ease;
}

@media (hover: hover) and (pointer: fine) {
  .youtube-search-result:hover { border-color: var(--line-color); }
}

.youtube-search-preview { display: block; }
.youtube-search-preview:focus-visible { outline: 3px solid var(--color-heeler); outline-offset: -3px; }

.youtube-search-preview img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  object-fit: cover;
}

.youtube-search-result-body {
  display: flex;
  align-items: flex-end;
  gap: var(--space-sm);
  padding: var(--space-sm-md) var(--space-sm-md) var(--space-sm-md);
}

.youtube-search-result-copy {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-2xs);
}

.youtube-search-result-title {
  display: -webkit-box;
  min-height: 2.6em;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  font-weight: var(--weight-medium);
  font-size: var(--text-body);
  line-height: var(--leading-label);
  font-family: var(--font-display);
  color: var(--color-ink);
  text-decoration: none;
}

.youtube-search-result-meta {
  display: flex;
  min-width: 0;
  gap: var(--space-sm);
  margin: 0;
  overflow: hidden;
  font-weight: var(--weight-semibold);
  font-size: var(--text-label);
  line-height: var(--leading-body);
  font-family: var(--font-body);
  color: var(--color-ink-soft);
  white-space: nowrap;
}

.youtube-search-result-meta > span { overflow: hidden; text-overflow: ellipsis; }
.youtube-search-result-meta > span + span::before { content: "· "; }

.youtube-search-add-form { flex: 0 0 auto; margin: 0; }

.youtube-search-add {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: var(--line);
  border-radius: var(--radius-round);
  border-color: var(--line-color);
  background: var(--color-cream-dark);
  color: var(--color-ink);
  cursor: pointer;
  transition: transform 160ms var(--ease-out-soft);
}

.youtube-search-add:active { transform: scale(0.94); }
.youtube-search-add:focus-visible { outline: 3px solid var(--color-heeler); outline-offset: 2px; }
.youtube-search-add svg { width: 18px; height: 18px; }

/* Photo: a dashed drop area, then the chosen page and its buttons. */
.import-photo {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md) var(--space-lg);
  padding: var(--space-lg) var(--space-lg) var(--space-lg) var(--space-lg);
  border: 1.5px dashed var(--color-ink-soft);
  border-radius: var(--radius-lg);
  background: var(--color-paper);
}

.import-photo[data-chosen] {
  gap: var(--space-md) var(--space-lg);
  padding: var(--space-md) var(--space-md) var(--space-md) var(--space-md);
  border: var(--line);
}

.import-photo--error { border-color: var(--color-tomato); }

.import-photo-preview {
  flex: 0 0 auto;
  width: 220px;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border: var(--line);
  border-radius: var(--radius-md);
}

.import-photo-preview[hidden] { display: none; }

.import-photo-copy {
  flex: 1 1 280px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.import-photo[data-chosen] .import-photo-copy { flex-basis: 240px; }

.import-photo-title {
  overflow-wrap: anywhere;
  font-weight: var(--weight-semibold);
  font-size: var(--text-title);
  line-height: var(--leading-label);
  font-family: var(--font-display);
}

.import-photo-body {
  max-width: 52ch;
  font-weight: var(--weight-regular);
  font-size: var(--text-body);
  line-height: var(--leading-body);
  font-family: var(--font-body);
  color: var(--color-ink-soft);
}

.import-photo-actions {
  flex: 0 0 auto;
  display: flex;
  gap: var(--space-sm);
}

.import-photo-pick {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm-md);
  min-height: 48px;
  padding: var(--space-xs) var(--space-lg) var(--space-xs) var(--space-xs);
  border: var(--line);
  border-radius: var(--radius-control);
  border-color: var(--line-color);
  background: var(--color-cream-dark);
  font-weight: var(--weight-semibold);
  font-size: var(--text-body);
  line-height: var(--leading-title);
  font-family: var(--font-display);
  color: var(--color-ink);
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 160ms ease, transform 160ms var(--ease-out-soft);
}

@media (hover: hover) and (pointer: fine) {
  .import-photo-pick:hover { border-color: var(--line-color); background: var(--color-cream-dark); transform: translateY(-1px); }
}

.import-photo-pick:active { transform: scale(0.97); }
.import-photo-pick:focus-within { outline: 3px solid var(--color-heeler); outline-offset: 2px; }

.import-photo-disc {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-round);
  background: var(--color-cream);
  transition: transform 220ms cubic-bezier(0.3, 1.4, 0.5, 1);
}

.import-photo-disc svg { width: 22px; height: 22px; }

@media (hover: hover) and (pointer: fine) {
  .import-photo-pick:hover .import-photo-disc { transform: rotate(-8deg); }
}

.import-photo-input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.import-photo[data-chosen] .import-photo-pick {
  min-height: 0;
  padding: var(--space-sm-md) var(--space-md);
  border-color: var(--line-color);
  background: var(--color-paper);
}

.import-photo[data-chosen] .import-photo-disc { display: none; }
.import-photo:not([data-chosen]) .import-submit-btn { display: none; }
.import-photo .import-submit-btn { padding-inline: var(--space-lg); }

/* Text: a roomy note field and one button. */
.import-text {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm-md);
}

.import-text-field {
  padding: var(--space-md) var(--space-md);
  border: var(--line);
  border-radius: var(--radius-lg);
  background: var(--color-cream);
  font-weight: var(--weight-regular);
  font-size: var(--text-body);
  line-height: var(--leading-body);
  font-family: var(--font-body);
  color: var(--color-ink);
  resize: vertical;
}

.import-text-field::placeholder { color: var(--color-ink-soft); }
body:not(.controller-prototype) textarea.import-text-field:focus,
body:not(.controller-prototype) textarea.import-text-field:focus-visible { outline: 3px solid var(--ui-focus-outline); outline-offset: 0; }
.import-text-field--error { border-color: var(--color-tomato); }

.import-text-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm-md) var(--space-sm-md);
}

.import-text-note {
  flex: 1 1 200px;
  min-width: 0;
  font-weight: var(--weight-regular);
  font-size: var(--text-body);
  line-height: var(--leading-body);
  font-family: var(--font-body);
  color: var(--color-ink-soft);
}

.import-error-banner {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm-md) var(--space-md);
  border: var(--line);
  border-radius: var(--radius-md);
  background: var(--color-paper);
  font-weight: var(--weight-bold);
  font-size: var(--text-body);
  line-height: var(--leading-body);
  font-family: var(--font-body);
  color: var(--color-ink);
}

.import-error-banner[hidden] { display: none; }
.import-error-banner svg { flex: 0 0 auto; width: 18px; height: 18px; color: var(--color-tomato); }

@media (min-width: 768px) {
  /* Add panel: always open on desktop; the hidden state only
     closes the phone sheet. */
  .rx-add__panel[hidden] {
    display: block;
  }

  .rx-add__toggle,
  .rx-add__backdrop,
  .import-close {
    display: none;
  }

  .rx-add__handle { display: none; }

  .import-input-field--youtube:has(.youtube-search-options:not([hidden])) .import-submit-btn { order: 1; }
}

@media (min-width: 768px) and (max-width: 1023px) {
  .youtube-search-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 767px) {
  /* Add sheet: a round button above the tab bar opens it. */
  .rx-add__toggle {
    position: fixed;
    z-index: var(--z-tab-bar-action);
    right: calc(20px + env(safe-area-inset-right, 0px));
    bottom: calc(100px + env(safe-area-inset-bottom, 0px));
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: var(--line);
    border-radius: var(--radius-round);
    background: var(--color-heeler);
    color: var(--color-paper);
    cursor: pointer;
    transition: transform 160ms var(--ease-out-soft);
  }

  .rx-add__toggle svg { width: 26px; height: 26px; }
  .rx-add__toggle:active { transform: scale(0.94); }
  .rx-add__toggle:focus-visible { outline: 3px solid var(--color-ink); outline-offset: 3px; }

  .rx-add__backdrop {
    display: none;
    position: fixed;
    z-index: var(--z-sheet-backdrop);
    inset: 0;
    background: color-mix(in srgb, var(--color-ink) 45%, transparent);
  }

  .rx-add:has(.rx-add__panel:not([hidden])) .rx-add__backdrop {
    display: block;
  }

  html:has(.rx-add:not(.rx-add--inline) .rx-add__panel:not([hidden])) { overflow: hidden; }

  .rx-add__panel {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: var(--z-sheet);
    height: min(760px, calc(100dvh - 84px));
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    padding: var(--space-sm) var(--space-md) calc(var(--space-lg) + env(safe-area-inset-bottom, 0px));
    border-top: var(--line);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    background: var(--color-cream);
    animation: rx-sheet-up 280ms var(--ease-out-soft) both;
  }

  .rx-add__panel[hidden] { display: none; }

  /* Empty shelf: the panel sits in the page above the empty state. */
  .rx-add--inline .rx-add__panel {
    position: static;
    height: auto;
    margin: var(--space-sm) 0 0;
    padding: 0;
    border-top: 0;
    border-radius: 0;
    background: transparent;
    animation: none;
  }

  .rx-add--inline :is(.rx-add__handle, .import-close) { display: none; }

  .rx-add__handle {
    flex: 0 0 auto;
    align-self: center;
    width: 44px;
    height: 5px;
    border-radius: var(--radius-round);
    background: var(--color-border);
  }

  .rx-add__panel .import-widget,
  .rx-add__panel .import-widget[data-import-tabs-active-value] {
    flex: 1 1 auto;
    min-height: 0;
    gap: var(--space-md);
    padding: 0;
    border-radius: 0;
    background: transparent;
  }

  .import-head { gap: var(--space-md) var(--space-sm-md); }
  .import-title { flex: 1 1 auto; }

  .import-tabs {
    order: 3;
    flex: 1 1 100%;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    border: var(--line);
    background: var(--color-paper);
  }

  .import-tabs::before { display: none; }

  .import-tab {
    width: auto;
    min-height: 42px;
    padding: 0;
    gap: var(--space-sm);
    color: var(--color-ink);
    transition: background-color 200ms ease, color 200ms ease;
  }

  .import-tab--active {
    background: var(--color-ink);
    color: var(--color-paper);
  }

  .import-tab-icon { width: 16px; height: 16px; }

  .import-panel { flex: 1 1 auto; min-height: 0; gap: var(--space-sm-md); }

  .import-input-field {
    flex-wrap: wrap;
    gap: var(--space-sm);
    padding: var(--space-xs) var(--space-xs) var(--space-xs) var(--space-md);
    border-radius: var(--radius-lg);
    background: var(--color-paper);
  }

  .import-input-icon { display: none; }
  .import-input-field input { font-size: var(--text-body); }

  .import-input-field .import-submit-btn {
    padding: var(--space-sm-md) var(--space-md);
    border-radius: var(--radius-md);
    font-size: var(--text-body);
  }

  .youtube-search-options { order: 3; margin: 0 0 var(--space-xs) calc(var(--space-sm) * -1); }

  .youtube-search-results {
    flex: 1 1 auto;
    min-height: 0;
    gap: var(--space-sm-md);
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  .youtube-search-results-head h3 { font-size: var(--text-label); }

  .youtube-search-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm-md);
  }

  .youtube-search-result {
    flex-direction: row;
    align-items: center;
    gap: var(--space-sm-md);
    padding: var(--space-sm);
    border-radius: var(--radius-lg);
    background: var(--color-paper);
  }

  .youtube-search-preview { flex: 0 0 112px; }
  .youtube-search-preview img { border-radius: var(--radius-sm); }

  .youtube-search-result-body {
    flex: 1 1 auto;
    min-width: 0;
    align-items: center;
    padding: 0;
  }

  .youtube-search-result-title { min-height: 0; font-size: var(--text-body); }

  .import-photo,
  .import-photo[data-chosen] {
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-md);
    padding: var(--space-md);
    border-radius: var(--radius-xl);
  }

  .import-photo-copy { flex: 0 0 auto; }
  .import-photo-preview { width: 100%; }
  .import-photo-actions > * { flex: 1 1 0; justify-content: center; min-height: 48px; }

  .import-text { flex: 1 1 auto; }

  .import-text-field {
    flex: 1 1 auto;
    min-height: 220px;
    padding: var(--space-md);
    background: var(--color-paper);
    resize: none;
  }

  .import-text-foot .import-submit-btn {
    flex: 1 1 100%;
    padding: var(--space-sm-md) var(--space-lg);
    font-size: var(--text-body);
  }
}

@keyframes rx-sheet-up {
  from { opacity: 0; transform: translateY(40px); }
  to { opacity: 1; }
}

/* ── Heading ──────────────────────────── */
.rx-groups {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

.rx-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-sm) var(--space-md);
  margin-top: var(--space-sm);
}

.rx-heading__title {
  margin: 0;
  font-weight: var(--weight-semibold);
  font-size: var(--text-headline);
  line-height: var(--leading-display);
  font-family: var(--font-display);
  color: var(--color-ink);
}

.rx-heading__summary {
  margin: 0;
  font-size: var(--text-body);
  line-height: normal;
  color: var(--color-ink-soft);
}

/* ── Filters ──────────────────────────── */
.rx-filters {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm-md);
}

.rx-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  min-height: 44px;
  padding: var(--space-sm) var(--space-md);
  border: var(--line);
  border-radius: var(--radius-control);
  background: var(--color-paper);
  color: var(--color-ink);
  font-weight: var(--weight-extrabold);
  font-size: var(--text-body);
  line-height: normal;
  font-family: var(--font-body);
  cursor: pointer;
  transition: background-color 150ms ease, color 150ms ease, transform 160ms var(--ease-out-soft);
}

.rx-chip:has(.rx-avatar) { padding-left: var(--space-sm); }

@media (hover: hover) and (pointer: fine) {
  .rx-chip[aria-pressed="false"]:hover { background: var(--color-hover); }
}

.rx-chip:active { transform: scale(0.96); }
.rx-chip:focus-visible { outline: 3px solid var(--ui-focus-outline); outline-offset: 2px; }

.rx-chip[aria-pressed="true"] {
  border-color: var(--color-ink);
  background: var(--color-ink);
  color: var(--color-paper);
}

.rx-filter-empty {
  margin: 0;
  padding: var(--space-xl);
  border: 1.5px dashed var(--color-heeler);
  border-radius: var(--radius-xl);
  background: var(--color-paper);
  text-align: center;
  font-weight: var(--weight-medium);
  font-size: var(--text-title);
  line-height: normal;
  font-family: var(--font-display);
}

/* ── Grid of idea cards ───────────────── */
.rx-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--space-xl) var(--space-lg);
  align-items: start;
  margin: 0;
  padding: var(--space-sm) 0 0;
  list-style: none;
}

.rx-group { min-width: 0; }
.rx-group[hidden],
.rx-card[hidden] { display: none; }

.rx-card {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.rx-card__head {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  padding: 0 var(--space-sm) var(--space-sm-md);
}

.rx-card__title {
  display: -webkit-box;
  min-height: 2.4em;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  font-weight: var(--weight-medium);
  font-size: var(--text-title);
  line-height: var(--leading-title);
  font-family: var(--font-display);
  /* The idea title is context; the recipe name is what people open. Same size
     and weight as a recipe name, one step quieter in colour. */
  color: var(--color-ink-soft);
  text-decoration: none;
  overflow-wrap: anywhere;
}

a.rx-card__title:hover { color: var(--color-heeler-dark); }

.rx-card__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-sm) var(--space-sm-md);
  /* One meta line, even when empty, so covers in a grid row line up. 22px = channel avatar. */
  min-height: 22px;
  margin: 0;
  font-size: var(--text-label);
  font-weight: var(--weight-semibold);
  line-height: normal;
  color: var(--color-ink-soft);
}

.rx-card__meta .channel-attribution--list {
  z-index: 1;
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  min-height: 0;
  color: inherit;
  font: inherit;
  text-decoration: none;
}

.rx-card__meta .channel-attribution--list .channel-attribution__avatar {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  border: 1px solid var(--line-color);
  border-radius: var(--radius-round);
  background: var(--color-hover);
}

@media (hover: hover) and (pointer: fine) {
  .rx-card__meta a.channel-attribution--list:hover { color: var(--color-ink); }
}

.rx-card__source {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
}

.rx-card__dot {
  width: 4px;
  height: 4px;
  border-radius: var(--radius-round);
  background: var(--color-ink-faint);
}

.rx-card__count { font-weight: var(--weight-extrabold); color: var(--color-heeler-dark); }
.rx-card__problem { font-weight: var(--weight-extrabold); color: var(--color-tomato-ink); }
.rx-card__detail { color: var(--color-ink-soft); }

.rx-card__cover {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border: var(--line);
  border-radius: var(--radius-cover);
  background: var(--color-hover);
}

.rx-card__cover img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: filter 600ms ease;
}

/* Motion Prompt 082, image zoom on hover: the image grows 1 -> 1.15 from its
   centre over 0.5s (cubic ease-out) inside a frame that does not move. */
@media (hover: hover) and (pointer: fine) {
  .rx-card__cover img {
    transform-origin: 50% 50%;
    transition: filter 600ms ease, transform 500ms var(--ease-out-cubic);
  }

  .rx-card__cover:hover img { transform: scale(1.15); }
}

.rx-card__cover--photo { background: var(--color-cream-dark); }
.rx-card__cover img[data-crop="center"] { object-position: 50% 50%; }
.rx-card__cover img[data-crop="portrait"] { object-position: 50% 15%; }
.rx-card__cover img[data-crop="tall"] { object-position: 50% 30%; }

.rx-card__photo-unavailable {
  position: absolute;
  inset: 0 0 var(--space-lg);
  align-items: center;
  justify-content: center;
}

.rx-card__photo-unavailable:not([hidden]) { display: flex; }

.rx-card__photo-disc {
  display: grid;
  place-items: center;
  width: calc(var(--space-sm) * 7);
  height: calc(var(--space-sm) * 7);
  border: var(--line);
  border-radius: var(--radius-round);
  background: var(--color-paper);
  color: var(--color-ink);
}

.rx-card--pending .rx-card__cover img { filter: saturate(0.5) brightness(1.08); }
.rx-card--empty .rx-card__cover img,
.rx-card--failed .rx-card__cover img { filter: saturate(0.3); opacity: 0.6; }

/* Reading progress: a striped Heeler Blue bar on the top edge */
.rx-card__progress {
  position: absolute;
  inset: 0 0 auto;
  height: 5px;
  background: color-mix(in srgb, var(--color-paper) 60%, transparent);
}

.rx-card__progress::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 42%;
  border-radius: 0 var(--radius-round) var(--radius-round) 0;
  background: var(--color-heeler);
  animation: rx-pulse 1.4s ease-in-out infinite;
}

/* Loading parts pulse in a flat fill. */
@keyframes rx-pulse { 50% { opacity: 0.45; } }

.rx-card__by {
  position: absolute;
  left: 10px;
  top: 10px;
}

.rx-avatar {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  overflow: hidden;
  border: var(--line);
  border-color: var(--line-color);
  border-radius: 50%;
  background: var(--color-cream-dark);
  color: var(--color-ink);
  font-weight: var(--weight-semibold);
  font-size: var(--text-label);
  line-height: var(--leading-display);
  font-family: var(--font-display);
}

.rx-avatar .profile-avatar-image { width: 100%; height: 100%; object-fit: cover; }
.rx-avatar--sm { width: 30px; height: 30px; }
.rx-avatar--xs { width: 22px; height: 22px; font-size: var(--text-label); border-width: 1px; }

.rx-card__status {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  font-weight: var(--weight-extrabold);
  color: var(--color-tomato-ink);
}

.rx-dots { display: inline-flex; gap: var(--space-2xs); }

.rx-dots span {
  width: 5px;
  height: 5px;
  border-radius: var(--radius-round);
  background: var(--color-tomato);
  animation: rx-dot 900ms ease-in-out infinite;
}

.rx-dots span:nth-child(2) { animation-delay: 150ms; }
.rx-dots span:nth-child(3) { animation-delay: 300ms; }

@keyframes rx-dot { 0%, 100% { opacity: 0.35; } 50% { opacity: 1; } }

/* ── Notebook tabs: one per recipe, tucked under the cover ── */
.rx-tabs {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  margin: calc(var(--space-lg) * -1) var(--space-sm-md) 0;
}

.rx-tab {
  --rx-tab-tilt: -1.5deg;
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  padding: var(--space-sm) var(--space-md);
  border: var(--line);
  border-radius: var(--radius-lg);
  background: var(--color-heeler);
  color: var(--color-paper);
  font-weight: var(--weight-semibold);
  font-size: var(--text-body);
  line-height: var(--leading-body);
  font-family: var(--font-display);
  text-decoration: none;
  transform: rotate(var(--rx-tab-tilt));
  transition: transform 160ms ease-out;
}

.rx-tab--1 { --rx-tab-tilt: 1deg; border-color: var(--line-color); background: var(--color-cream-dark); color: var(--color-ink); }
.rx-tab--2 { --rx-tab-tilt: -0.5deg; border-color: var(--line-color); background: var(--color-cream-dark); color: var(--color-ink); }
.rx-tab--3 { --rx-tab-tilt: 1.5deg; border-color: var(--line-color); background: var(--color-cream-dark); color: var(--color-ink); }

.rx-tab__label {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.rx-tabs[data-expanded="false"] .rx-tab--extra { display: none; }
.rx-tabs[data-expanded="true"] .rx-tab--extra { animation: rx-tab-in 240ms var(--ease-out-soft) both; }

@keyframes rx-tab-in { from { opacity: 0; transform: translateY(-8px) scale(0.96); } }

.rx-tab--more {
  --rx-tab-tilt: 0.5deg;
  border-style: dashed;
  background: var(--color-paper);
  color: var(--color-ink);
  cursor: pointer;
}

.rx-tab--ghost {
  --rx-tab-tilt: 1deg;
  width: 124px;
  height: 44px;
  border: 1.5px dashed var(--color-ink-faint);
  background: var(--color-hover);
  animation: rx-pulse 1.4s ease-in-out infinite;
}

@media (hover: hover) and (pointer: fine) {
  a.rx-tab:hover,
  .rx-tab--more:hover { transform: translateY(-2px) rotate(0deg); }
  .rx-tab--more:hover { border-style: solid; background: var(--color-cream-dark); }
}

.rx-tab:focus-visible { outline: 3px solid var(--ui-focus-outline); outline-offset: 2px; }

/* ── Tracklist: the phone shows recipes as a numbered list ── */
.rx-list { display: none; }

/* ── Hills under the page ─────────────── */
.rx-hills {
  position: relative;
  width: 100vw;
  height: 200px;
  overflow: hidden;
  margin-left: calc(50% - 50vw);
}

.rx-hills canvas {
  display: block;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

/* Flat ground along the foot of the drawn scene, in the same blue:
   the color the bottom edge takes at the end of the page. */
.rx-hills__ground {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 12px;
  background: var(--color-heeler);
}

/* The scene stitched in terry loops covers the flat scene and the ground
   (DESIGN.md Flat Rule, "stitched backyard"). The pointer and the page
   edges pass through it to the flat scene. Without WebGL it never draws,
   and the flat scene shows. */
.rx-hills .rx-hills__stitch {
  pointer-events: none;
  visibility: hidden;
}

.rx-hills .rx-hills__stitch[data-stitched] { visibility: visible; }

/* Phone: the ground runs on under the floating tab bar to the bottom edge. */
@media (max-width: 767px) {
  .rx-hills {
    box-sizing: content-box;
    padding-bottom: var(--tab-bar-clearance, 0px);
    margin-bottom: calc(-1 * var(--tab-bar-clearance, 0px));
  }

  .rx-hills canvas { bottom: auto; height: 200px; }
  .rx-hills .rx-hills__stitch { bottom: 0; height: 100%; }
  .rx-hills__ground { height: calc(12px + var(--tab-bar-clearance, 0px)); }
}

.app-main:has(> .rx-hills) { padding-bottom: 0; }

@media (prefers-reduced-motion: reduce) {
  .rx-card__progress::before,
  .rx-dots span,
  .rx-tab--ghost,
  .rx-list__shimmer,
  .rx-tabs[data-expanded="true"] .rx-tab--extra { animation: none; }
  .rx-dots span { opacity: 0.7; }
  .rx-card__cover:hover img { transform: none; }
  .rx-tab, .rx-chip, .rx-card__cover img, .import-widget, .import-tab, .import-tabs::before, .import-photo-pick, .import-photo-disc { transition: none; }
  .rx-add__panel, .import-panel--morph, .youtube-search-results { animation: none; }
  :is(.rx-chip, .rx-add__toggle, .rx-cooks, .import-submit-btn, .import-photo-pick, .youtube-search-add):active { transform: none; }
}

/* Phone tracklist rows show the title only; desktop adds the ingredient count. */
.rx-list__ingredients { display: none; }

/* ── Desktop: masonry cards ───────────── */
/* Each idea is a lifted card: cover, title, then its numbered recipes. The
   recipe-masonry controller packs the cards into the shortest column. Every
   part has a whole-pixel height, so cards and gaps land on whole pixels. */
@media (min-width: 641px) {
  .rx-grid {
    --rx-masonry-gap: 24;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: var(--space-lg);
  }

  .rx-grid--masonry {
    grid-auto-flow: row dense;
    grid-auto-rows: 1px;
    row-gap: 0;
    padding: calc(var(--space-sm) + var(--rx-masonry-nudge-y, 0px)) 0 0 var(--rx-masonry-nudge-x, 0px);
  }

  .rx-grid--masonry > .rx-group { align-self: start; }

  .rx-card {
    position: relative;
    overflow: hidden;
    border-radius: var(--radius-lg);
    background: var(--color-paper);
    box-shadow: var(--shadow-raised);
    container-type: inline-size;
  }


  .rx-card__cover {
    order: -1;
    border: 0;
    border-radius: 0;
  }

  /* A whole-pixel 16:9 cover, within half a pixel of the exact ratio. */
  @supports (height: round(1.5px, 1px)) {
    .rx-card__cover {
      aspect-ratio: auto;
      height: round(calc(100cqi * 9 / 16), 1px);
    }
  }

  .rx-card__photo-unavailable { inset: 0; }

  .rx-card__head {
    gap: var(--space-xs);
    padding: var(--space-sm-md) var(--space-md) var(--space-md);
  }

  .rx-card__title {
    min-height: 0;
    -webkit-line-clamp: 3;
    font-size: var(--text-body);
    line-height: var(--leading-masonry-title);
  }

  .rx-card__meta { line-height: var(--leading-masonry-meta); }

  .rx-tabs { display: none; }

  .rx-list {
    display: block;
    margin: 0;
    padding: 0 var(--space-xs) 0 var(--space-md);
    border-top: 1px solid var(--color-border);
    list-style: none;
  }

  .rx-list__item {
    display: flex;
    align-items: center;
  }

  .rx-list__item + .rx-list__item { border-top: 1px solid var(--color-border); }

  .rx-list__link {
    flex: 1 1 auto;
    min-width: 0;
    display: grid;
    grid-template-columns: 28px minmax(0, 1fr);
    align-items: center;
    column-gap: var(--space-sm-md);
    padding: var(--space-sm-md) 0;
    color: var(--color-ink);
    text-decoration: none;
  }

  a.rx-list__link:hover .rx-list__title { color: var(--color-heeler-dark); }
  .rx-list__link:focus-visible { outline: 3px solid var(--ui-focus-outline); outline-offset: -3px; border-radius: var(--radius-sm); }

  .rx-list__number {
    grid-row: span 2;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    box-sizing: border-box;
    border: 0;
    border-radius: var(--radius-round);
    background: var(--color-cream-dark);
    color: var(--color-ink-soft);
    font-weight: var(--weight-bold);
    font-size: var(--text-label);
    line-height: var(--leading-display);
    font-family: var(--font-body);
    font-variant-numeric: tabular-nums;
  }

  .rx-list__title {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    font-weight: var(--weight-medium);
    font-size: var(--text-body);
    line-height: var(--leading-masonry-row);
    font-family: var(--font-display);
  }

  .rx-list__ingredients {
    display: block;
    grid-column: 2;
    font-weight: var(--weight-semibold);
    font-size: var(--text-label);
    line-height: var(--leading-masonry-note);
    color: var(--color-ink-soft);
  }

  .rx-list__item--ghost { gap: var(--space-sm-md); height: calc(var(--space-sm-md) * 5); padding: 0; }
  .rx-list__item--ghost .rx-list__number { border: 1.5px dashed var(--color-ink-faint); background: none; }

  .rx-list__shimmer {
    width: 56%;
    height: 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-round);
    background: var(--color-hover);
    animation: rx-pulse 1.4s ease-in-out infinite;
  }

  .rx-list .recipe-favorite-control { flex: 0 0 auto; }

  .rx-list .recipe-favorite-button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--color-ink-soft);
    cursor: pointer;
  }

  .rx-list .recipe-favorite-button svg { width: 19px; height: 19px; stroke-width: 2.2; }
  .rx-list .recipe-favorite-button.is-favorited { color: var(--color-ink); }
  .rx-list .recipe-favorite-button.is-favorited svg { fill: var(--color-tomato); }
}

/* ── Phone ────────────────────────────── */
@media (max-width: 640px) {
  .rx { padding: 0 var(--space-md); }

  .rx-cooks { padding-right: var(--space-xs); }
  .rx-cooks__label { display: none; }

  .rx-groups { gap: var(--space-md); }
  .rx-heading { margin-top: 0; }
  .rx-heading__title { font-size: var(--text-title); }
  .rx-heading__summary { display: none; }

  .rx-filters {
    flex-wrap: nowrap;
    gap: var(--space-sm);
    /* Room for the 44px chip tap areas inside the scroll box. */
    margin-block: calc(var(--space-sm) * -1);
    padding-block: var(--space-sm);
    overflow-x: auto;
    scrollbar-width: none;
  }

  .rx-filters::-webkit-scrollbar { display: none; }

  .rx-chip {
    flex: 0 0 auto;
    min-height: 32px;
    padding: var(--space-xs) var(--space-sm-md);
    font-size: var(--text-label);
    line-height: var(--leading-display);
  }

  .rx-grid { grid-template-columns: minmax(0, 1fr); gap: 0; padding: 0; }
  .rx-group + .rx-group .rx-card { padding-top: var(--space-md); }
  .rx-card { padding-top: var(--space-xs); }

  .rx-card__head { gap: var(--space-xs); padding: 0 var(--space-xs) var(--space-sm-md); }
  .rx-card__title { min-height: 0; font-size: var(--text-body); line-height: var(--leading-label); }
  .rx-card__meta { min-height: 0; gap: var(--space-sm) var(--space-sm); font-size: var(--text-label); }
  .rx-card__meta .channel-attribution--list .channel-attribution__avatar { width: 20px; height: 20px; }
  .rx-card__cover { border-radius: var(--radius-cover); }

  .rx-tabs { display: none; }
  .rx-card__photo-unavailable { inset: 0; }

  .rx-list {
    display: block;
    margin: var(--space-sm) 0 0;
    padding: 0 var(--space-2xs);
    list-style: none;
  }

  .rx-list__item {
    display: flex;
    align-items: center;
  }

  .rx-list__item + .rx-list__item { border-top: 1.5px solid var(--color-border); }

  .rx-list__link {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: var(--space-sm-md);
    min-height: 46px;
    padding: 0 var(--space-xs);
    color: var(--color-ink);
    text-decoration: none;
  }

  .rx-list__number {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border: 0;
    border-radius: var(--radius-round);
    background: var(--color-cream-dark);
    color: var(--color-ink-soft);
    font-weight: var(--weight-bold);
    font-size: var(--text-label);
    line-height: var(--leading-display);
    font-family: var(--font-body);
    font-variant-numeric: tabular-nums;
  }

  .rx-list__title {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    font-weight: var(--weight-medium);
    font-size: var(--text-body);
    line-height: normal;
    font-family: var(--font-display);
  }

  .rx-list__item--ghost { gap: var(--space-sm-md); min-height: 46px; padding: 0 var(--space-sm); }
  .rx-list__item--ghost .rx-list__number { border: 1.5px dashed var(--color-ink-faint); background: none; }

  .rx-list__shimmer {
    width: 56%;
    height: 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-round);
    background: var(--color-hover);
    animation: rx-pulse 1.4s ease-in-out infinite;
  }

  .rx-list .recipe-favorite-control { flex: 0 0 auto; }

  .rx-list .recipe-favorite-button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--color-ink-soft);
    cursor: pointer;
  }

  .rx-list .recipe-favorite-button svg { width: 19px; height: 19px; stroke-width: 2.2; }
  .rx-list .recipe-favorite-button.is-favorited { color: var(--color-ink); }
  .rx-list .recipe-favorite-button.is-favorited svg { fill: var(--color-tomato); }

}
