/* ui · shape: Workbench (chef library: photo-top cards, editor, ingredient index) · theme: from nasa.digi-works.org via tokens.css (Plex Sans/Mono + Newsreader, ink primary, colour only for meaning) · nav: side rail / bottom dock (app.css) · footer: none · tone: utilitarian-warm */
/* Card language from docs/sketches/vision.html, restyled with the current tokens. */
:root {
  --color-card: oklch(99.4% 0.004 260);
  --color-scrim: oklch(11% 0.006 260 / 0.55);
  --radius-card: 20px; --radius-inset: 12px;
  --shadow-card: 0 1px 2px oklch(16% 0.006 260 / 0.06), 0 4px 14px oklch(16% 0.006 260 / 0.05);
}
@media (prefers-color-scheme: dark) {
  :root { --color-card: var(--color-paper-2); --shadow-card: none; }
}

.shell-panel.wide { max-width: var(--size-wide); width: 100%; }
h2, h3 { margin: 0; }
.sum { font-family: var(--font-voice); font-size: var(--text-lg); line-height: 1.3; }
.section { font-size: var(--text-base); font-weight: 500; margin-top: var(--space-xs); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
select { min-height: var(--size-touch); padding: 0 var(--space-xs); font: inherit; color: var(--color-ink); background: var(--color-paper); border: var(--rule-hair) solid var(--color-rule); border-radius: var(--radius-sm); }
input[type="search"] { min-width: 0; }

/* Controls */
.toolbar { display: flex; flex-wrap: wrap; gap: var(--space-xs); align-items: center; }
.toolbar input { flex: 1 1 220px; }
.seg { display: inline-flex; justify-self: start; padding: 2px; gap: 2px; border-radius: 999px; background: var(--color-paper-2); border: var(--rule-hair) solid var(--color-rule); }
.seg button { min-height: var(--size-touch); min-width: var(--size-touch); padding: 0 var(--space-sm); font: inherit; font-size: var(--text-sm); color: var(--color-ink-2); background: none; border: 0; border-radius: 999px; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--color-card); color: var(--color-ink); font-weight: 500; box-shadow: var(--shadow-card); }
.small-seg { flex-wrap: wrap; border-radius: var(--radius-inset); }
.check { display: flex; flex-direction: row; align-items: center; gap: var(--space-xs); min-height: var(--size-touch); color: var(--color-ink); font-size: var(--text-sm); cursor: pointer; }
.check input { min-height: 0; width: 20px; height: 20px; margin: 0; flex: none; accent-color: var(--color-accent); }
.link { min-height: var(--size-touch); padding: 0 var(--space-2xs); font: inherit; font-size: var(--text-sm); color: var(--color-link); background: none; border: 0; cursor: pointer; justify-self: start; }
.link.back { padding-left: 0; }
.actions { display: flex; flex-wrap: wrap; gap: var(--space-xs); align-items: center; }
.btn.file { display: inline-flex; align-items: center; justify-self: start; }
.btn.file:focus-within { outline: var(--rule-thick) solid var(--color-focus); outline-offset: 2px; }
.status { font-size: var(--text-sm); color: var(--color-ink-2); }

/* Photo-top cards */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 264px), 1fr)); gap: var(--space-sm); align-items: start; }
.mcard { background: var(--color-card); border-radius: var(--radius-card); box-shadow: var(--shadow-card); border: var(--rule-hair) solid var(--color-rule); overflow: hidden; display: grid; }
.ph { margin: var(--space-2xs) var(--space-2xs) 0; aspect-ratio: 16 / 9; border-radius: var(--radius-inset); overflow: hidden; background: var(--color-photo); position: relative; }
.ph img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ph .note { position: absolute; left: var(--space-2xs); bottom: var(--space-2xs); font-size: var(--text-xs); color: var(--color-ink); background: var(--color-card); padding: 2px var(--space-2xs); border-radius: 999px; }
.ph.empty { display: grid; place-items: center; padding: var(--space-sm); text-align: center; }
.ph.empty span { font-family: var(--font-voice); font-size: var(--text-lg); line-height: 1.25; color: var(--color-ink-2); overflow-wrap: anywhere; hyphens: auto; }
.mcard .body { padding: var(--space-xs) var(--space-sm) var(--space-sm); display: grid; gap: var(--space-2xs); }
.mcard .head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-xs); }
.mcard .title { font-size: var(--text-base); font-weight: 500; line-height: 1.25; overflow-wrap: anywhere; hyphens: auto; }
.mcard hr { width: 100%; border: 0; border-top: var(--rule-hair) solid var(--color-rule); margin: var(--space-3xs) 0 0; }
.pill { display: inline-block; white-space: nowrap; font-size: var(--text-xs); font-weight: 500; padding: 3px var(--space-2xs); border-radius: 999px; background: var(--color-paper-2); color: var(--color-ink-2); }
.meta-row { display: flex; flex-wrap: wrap; gap: var(--space-3xs) var(--space-sm); font-family: var(--font-mono); font-size: var(--text-xs); color: var(--color-ink-2); }
.card-foot { display: flex; align-items: center; justify-content: space-between; gap: var(--space-xs); }

/* Allergen icons: one line icon per group; names in the legend */
.codes { display: inline-flex; flex-wrap: wrap; gap: var(--space-3xs); }
.codes i { width: 24px; height: 24px; display: inline-grid; place-items: center; border-radius: 6px; border: var(--rule-hair) solid var(--color-rule); color: var(--color-ink-2); }
.codes i svg { width: 15px; height: 15px; }
.codes.none { font-size: var(--text-xs); color: var(--color-ink-3); }
.codes-btn { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2xs); min-height: var(--size-touch); min-width: var(--size-touch); padding: 0; font: inherit; color: var(--color-ink-2); background: none; border: 0; text-align: left; cursor: pointer; }
.codes-more { font-size: var(--text-sm); color: var(--color-link); }

/* Legend sheet (bottom sheet on the phone, centred dialog from tablet width) */
dialog.sheet { width: min(100%, var(--size-column)); max-height: 90dvh; margin: auto auto 0; padding: var(--space-sm) var(--space-sm) var(--space-md); border: 0; border-radius: var(--radius-card) var(--radius-card) 0 0; background: var(--color-card); color: var(--color-ink); display: grid; gap: var(--space-xs); overflow-y: auto; }
dialog.sheet:not([open]) { display: none; }
dialog.sheet::backdrop { background: var(--color-scrim); }
@media (min-width: 768px) { dialog.sheet { margin: auto; border-radius: var(--radius-card); } }
.legend { display: grid; }
.legend > div { display: grid; grid-template-columns: 24px minmax(0, 1fr) auto; align-items: center; gap: var(--space-xs); padding: var(--space-2xs) 0; border-top: var(--rule-hair) solid var(--color-rule); font-size: var(--text-sm); color: var(--color-ink-3); }
.legend svg { width: 22px; height: 22px; }
.legend > div.in { color: var(--color-ink); font-weight: 500; }
.legend .from { display: block; font-weight: 400; font-size: var(--text-xs); color: var(--color-ink-2); }
.legend .num { font-family: var(--font-mono); font-size: var(--text-xs); }

/* Dish editor */
.editor { display: grid; gap: var(--space-sm); }
.editor-grid { display: grid; gap: var(--space-md); align-items: start; }
@media (min-width: 900px) { .editor-grid { grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); } }
.photo-edit { display: grid; gap: var(--space-xs); }
.photo-edit .ph { margin: 0; }
.preview { display: grid; gap: var(--space-3xs); padding: var(--space-xs) var(--space-sm); background: var(--color-card); border: var(--rule-hair) solid var(--color-rule); border-radius: var(--radius-inset); }
.recipe { display: grid; }
.rrow { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: var(--space-2xs) var(--space-xs); padding: var(--space-2xs) 0; border-top: var(--rule-hair) solid var(--color-rule); }
.rname { display: grid; gap: 2px; font-size: var(--text-sm); overflow-wrap: anywhere; hyphens: auto; }
.rname .codes i { width: 20px; height: 20px; }
.rname .codes i svg { width: 13px; height: 13px; }
.ramount { display: flex; flex-direction: row; align-items: center; gap: var(--space-3xs); color: var(--color-ink-2); }
.amount { width: 6.5em; text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.unit { font-family: var(--font-mono); font-size: var(--text-xs); width: 2.5em; }
@media (max-width: 479px) {
  .rrow { grid-template-columns: minmax(0, 1fr) auto; }
  .rname { grid-column: 1 / -1; }
}
.results { display: grid; }
.results button { display: flex; justify-content: space-between; align-items: center; gap: var(--space-xs); min-height: var(--size-touch); padding: 0 var(--space-xs); font: inherit; font-size: var(--text-sm); text-align: left; color: var(--color-ink); background: var(--color-card); border: var(--rule-hair) solid var(--color-rule); border-top-width: 0; cursor: pointer; }
.results button:first-child { border-top-width: var(--rule-hair); border-radius: var(--radius-sm) var(--radius-sm) 0 0; }
.results button:last-child { border-radius: 0 0 var(--radius-sm) var(--radius-sm); }
.results button:only-child { border-radius: var(--radius-sm); }
.results button:hover { background: var(--color-paper-2); }
.results button:focus-visible { outline: var(--rule-thick) solid var(--color-focus); outline-offset: -2px; }

/* Ingredient index */
.irows { display: grid; }
.irow { border-top: var(--rule-hair) solid var(--color-rule); }
.irow > summary { list-style: none; display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1.4fr) minmax(0, 1.4fr); align-items: center; gap: var(--space-3xs) var(--space-sm); min-height: var(--size-touch); padding: var(--space-2xs) 0; cursor: pointer; font-size: var(--text-sm); }
.irow > summary::-webkit-details-marker { display: none; }
.irow[open] > summary { font-weight: 500; }
.irow.new { border-top: 0; }
.irow.new > summary { display: flex; }
.iname { overflow-wrap: anywhere; hyphens: auto; }
.icodes { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2xs); }
.icodes .num { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--color-ink-2); }
.istate { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--color-ink-2); }
.istate.open { color: var(--color-ink); font-weight: 500; }
@media (max-width: 599px) {
  .irow > summary { grid-template-columns: minmax(0, 1fr) auto; }
  .iname { grid-column: 1 / -1; }
}
.iedit { display: grid; gap: var(--space-xs); padding: var(--space-2xs) 0 var(--space-md); }
.allergen-edit { margin: 0; padding: 0; border: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr)); gap: 0 var(--space-sm); }
.allergen-edit legend { font-size: var(--text-sm); color: var(--color-ink-2); padding: 0 0 var(--space-3xs); }
.allergen-edit .check svg { width: 20px; height: 20px; flex: none; color: var(--color-ink-2); }
.allergen-edit .check .num { margin-left: auto; font-family: var(--font-mono); font-size: var(--text-xs); color: var(--color-ink-3); }
.parts { display: grid; padding-left: var(--space-lg); }
.irow > summary .unsaved { grid-column: 1 / -1; color: var(--color-error); }
