/* Wocheneinkauf – one stylesheet, all values from design tokens.
   Spacing 4/8/12/16/24/32 · radius sm/md/lg · type 12/14/16/20/26 · one line-icon set. */

:root {
  --bg: var(--ui-background, #10171d);
  --surface: var(--ui-surface, #182129);
  --raised: var(--ui-raised, #202d36);
  --text: var(--ui-text, #f1f5f4);
  --muted: var(--ui-muted, #aab7c0);
  --border: var(--ui-border, #33424d);
  --accent: var(--ui-accent, #83d441);
  --on-accent: var(--ui-onAccent, #122009);
  --ok: #4fb46a;
  --warn: #e0a43a;
  --danger: #e2574c;
  --accent-soft: color-mix(in srgb, var(--accent) 16%, transparent);
  --warn-soft: color-mix(in srgb, var(--warn) 16%, transparent);

  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px;
  --r-md: var(--ui-radius, 6px);
  --r-sm: max(0px, calc(var(--r-md) - 2px));
  --r-lg: calc(var(--r-md) + 4px);
  --fs-meta: 0.75rem; --fs-body: 0.875rem; --fs-title: 1rem; --fs-section: 1.25rem; --fs-page: 1.625rem;
  --control: 40px;
  --row-pad: var(--s3);
  --nav-h: 64px;
  --topbar-h: 52px;
  --shadow: 0 8px 24px rgb(0 0 0 / 0.28);
  --focus: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent);
  color-scheme: dark;
}
:root[data-design='light'] { --ok: #2e8b47; --warn: #b7791f; --danger: #c53b30; --shadow: 0 8px 24px rgb(20 40 60 / 0.16); color-scheme: light; }
:root[data-density='comfortable'] { --row-pad: var(--s4); --control: 44px; }
:root[data-pictures='off'] .photo:not(.photo-fallback) { display: none; }
@supports not (color: color-mix(in srgb, red, blue)) {
  :root { --accent-soft: var(--raised); --warn-soft: var(--raised); }
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 400 var(--fs-body)/1.45 system-ui, -apple-system, 'Segoe UI', Roboto, 'Noto Sans', sans-serif;
  overflow-wrap: normal; hyphens: manual; -webkit-tap-highlight-color: transparent;
}
h1, h2, h3, p { margin: 0; }
h1 { font-size: var(--fs-page); font-weight: 700; letter-spacing: -0.01em; line-height: 1.2; }
h2 { font-size: var(--fs-section); font-weight: 650; }
h3 { font-size: var(--fs-title); font-weight: 600; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.45; }
:focus-visible { outline: none; box-shadow: var(--focus); }
.icon { flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.boot { padding: var(--s6); color: var(--muted); }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: var(--fs-meta); display: flex; flex-wrap: wrap; align-items: center; gap: var(--s1); }
[hidden] { display: none !important; }

/* ---------- Shell ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20; height: var(--topbar-h);
  display: flex; align-items: center; justify-content: space-between; gap: var(--s3);
  padding: 0 var(--s4); padding-top: env(safe-area-inset-top);
  background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: var(--s2); font-size: var(--fs-title); color: var(--text); }
.brand .icon { color: var(--accent); }
.status {
  display: inline-flex; align-items: center; gap: var(--s2); height: 32px; padding: 0 var(--s3);
  border: 1px solid var(--border); border-radius: 999px; background: var(--surface); font-size: var(--fs-meta); white-space: nowrap;
}
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.status-dot.online { background: var(--ok); }
.status-dot.waiting { background: var(--accent); }
.status-dot.offline, .status-dot.paused { background: var(--warn); }
.main {
  max-width: 960px; margin: 0 auto; padding: var(--s4);
  padding-bottom: calc(var(--nav-h) + var(--s6) + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: var(--s4);
}
body[data-view='einkauf'] .main { padding-bottom: calc(var(--nav-h) + 96px + env(safe-area-inset-bottom)); }
body[data-view='setup'] .main { padding-bottom: var(--s6); max-width: 560px; }

.bottom-nav {
  position: fixed; inset: auto 0 0 0; z-index: 30; display: grid; grid-template-columns: repeat(4, 1fr);
  height: calc(var(--nav-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface); border-top: 1px solid var(--border);
}
.nav-item {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  border: 0; background: none; color: var(--muted); font-size: var(--fs-meta); font-weight: 600; white-space: nowrap; min-width: 0;
}
.nav-item.active { color: var(--accent); }
.nav-item.active .icon { stroke-width: 2.1; }
.sidebar { display: none; }

@media (min-width: 900px) {
  .bottom-nav { display: none; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: 232px; z-index: 25; display: flex; flex-direction: column; gap: var(--s1);
    padding: var(--s4) var(--s3); background: var(--surface); border-right: 1px solid var(--border);
  }
  .side-brand { display: flex; align-items: center; gap: var(--s2); padding: var(--s2) var(--s3) var(--s4); font-size: var(--fs-title); }
  .side-brand .icon { color: var(--accent); }
  .side-item {
    display: flex; align-items: center; gap: var(--s3); height: 44px; padding: 0 var(--s3); border: 0; border-radius: var(--r-md);
    background: none; color: var(--muted); font-weight: 600; text-align: left; white-space: nowrap;
  }
  .side-item:hover { background: var(--raised); color: var(--text); }
  .side-item.active { background: var(--accent-soft); color: var(--text); }
  .side-item.active .icon { color: var(--accent); }
  .side-item.small { height: 38px; font-size: var(--fs-body); }
  .side-sub { margin-top: var(--s4); padding-top: var(--s3); border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: var(--s1); }
  .topbar .brand { visibility: hidden; }
  .topbar, .main { margin-left: 232px; }
  .main { padding: var(--s5) var(--s6) var(--s6); }
  body[data-view='einkauf'] .main { padding-bottom: 120px; }
  body[data-view='setup'] .topbar, body[data-view='setup'] .main { margin-left: auto; }
}

/* ---------- Page structure ---------- */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); flex-wrap: wrap; }
.toolbar { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; }
.toolbar.end { justify-content: flex-end; }
.week-switcher { display: flex; align-items: center; gap: var(--s1); }
.week-switcher strong { font-size: var(--fs-body); white-space: nowrap; min-width: 0; }
.section-label { font-size: var(--fs-meta); font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); margin-top: var(--s2); }
.stack { display: flex; flex-direction: column; gap: var(--s2); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: var(--s3); }
.filters { display: flex; flex-direction: column; gap: var(--s2); }
.grouped, .group { display: flex; flex-direction: column; gap: var(--s2); }
.grouped { gap: var(--s4); }
.group-heading {
  display: flex; align-items: center; gap: var(--s2); margin-top: var(--s2);
  font-size: var(--fs-meta); font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted);
}
.group-heading small { font-weight: 600; letter-spacing: 0; margin-left: auto; }

/* ---------- Buttons and chips ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2); height: var(--control); min-width: var(--control);
  padding: 0 var(--s4); border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); color: var(--text);
  font-size: var(--fs-body); font-weight: 600; white-space: nowrap; max-width: 100%;
}
.btn-label { overflow: hidden; text-overflow: ellipsis; }
.btn:hover:not(:disabled) { background: var(--raised); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary:hover:not(:disabled) { background: var(--accent); filter: brightness(1.06); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover:not(:disabled) { color: var(--text); }
.btn-danger { background: transparent; border-color: color-mix(in srgb, var(--danger) 55%, transparent); color: var(--danger); }
.btn-link { height: auto; min-width: 0; padding: 0; border: 0; background: none; color: var(--accent); font-weight: 600; }
.btn-icon { width: var(--control); padding: 0; }
.btn-block { width: 100%; }
.btn.is-on { color: var(--accent); }
.btn[aria-busy='true'] { opacity: 0.6; }
.hidden-soft { visibility: hidden; }

.chips { display: flex; gap: var(--s2); }
.chips.wrap { flex-wrap: wrap; }
.chips.scroll { overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.chips.scroll::-webkit-scrollbar { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: var(--s1); height: 32px; padding: 0 var(--s3); flex: none;
  border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text);
  font-size: var(--fs-body); font-weight: 500; white-space: nowrap;
}
.chip.active { background: var(--accent-soft); border-color: var(--accent); color: var(--text); }
.chip .icon { color: var(--muted); }

/* ---------- Form fields ---------- */
.field { display: flex; flex-direction: column; gap: var(--s1); min-width: 0; }
.field-label { font-size: var(--fs-meta); font-weight: 600; color: var(--muted); }
.field-hint { font-size: var(--fs-meta); color: var(--muted); }
.field-inline { flex-direction: row; align-items: center; gap: var(--s2); }
.field-inline .input { width: auto; height: 34px; }
.input {
  width: 100%; height: var(--control); padding: 0 var(--s3); border: 1px solid var(--border); border-radius: var(--r-md);
  background: var(--bg); color: var(--text);
}
textarea.input { height: auto; padding: var(--s3); line-height: 1.5; resize: vertical; }
input[type='color'].input { padding: 2px; height: var(--control); }
input[type='file'].input { height: auto; padding: var(--s2); }
.input:focus { border-color: var(--accent); outline: none; }
.switch { display: flex; align-items: center; gap: var(--s3); min-height: var(--control); cursor: pointer; }
.switch-input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-track { position: relative; flex: none; width: 40px; height: 24px; border-radius: 999px; background: var(--raised); border: 1px solid var(--border); transition: background 0.15s; }
.switch-thumb { position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: var(--muted); transition: transform 0.15s, background 0.15s; }
.switch-input:checked + .switch-track { background: var(--accent); border-color: var(--accent); }
.switch-input:checked + .switch-track .switch-thumb { transform: translateX(16px); background: var(--on-accent); }
.switch-input:focus-visible + .switch-track { box-shadow: var(--focus); }
.switch-input:disabled + .switch-track { opacity: 0.45; }
.switch-text { display: flex; flex-direction: column; min-width: 0; }
.switch-label { font-weight: 500; }

/* ---------- Lists and rows ---------- */
.list { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface); overflow: hidden; }
.row, .day-row, .menu-row {
  display: flex; align-items: center; gap: var(--s3); min-height: 56px; padding: var(--s2) var(--row-pad);
  border-bottom: 1px solid var(--border); background: transparent; text-align: left; width: 100%;
}
.list > :last-child { border-bottom: 0; }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.row-title { font-size: var(--fs-title); font-weight: 600; line-height: 1.3; }
.row-title, .day-title, .tile-name, .pick-name, .picker-name, .preview-name { hyphens: auto; -webkit-hyphens: auto; overflow-wrap: break-word; }
.row-meta { font-size: var(--fs-meta); color: var(--muted); }
.row-side { display: flex; flex-direction: column; align-items: flex-end; gap: var(--s1); flex: none; }
.row-icon { display: inline-flex; color: var(--muted); }
.clickable { cursor: pointer; }
.clickable:hover { background: var(--raised); }
.clickable:focus-visible { box-shadow: inset 0 0 0 2px var(--accent); }
.badges, .day-meta, .tags { display: flex; flex-wrap: wrap; gap: var(--s1); align-items: center; }
.badges { justify-content: flex-end; }
.badge {
  display: inline-flex; align-items: center; gap: 3px; height: 22px; padding: 0 var(--s2);
  border: 1px solid var(--border); border-radius: var(--r-sm); font-size: var(--fs-meta); font-weight: 600; color: var(--muted); white-space: nowrap;
}
.badge-short { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 45%, transparent); }
.badge-medium { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 45%, transparent); }
.badge-long { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, transparent); }
.badge-warn { color: var(--warn); background: var(--warn-soft); border-color: transparent; }
.tag { font-size: var(--fs-meta); color: var(--muted); }
.tag + .tag::before { content: '·'; margin-right: var(--s1); }
.stars { display: inline-flex; }
.star { display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; padding: 0; border: 0; background: none; color: var(--border); }
.star.on { color: var(--warn); }
.star.on .icon { fill: currentColor; }

/* Week */
.day-row { min-height: 64px; }
.day-row.today { box-shadow: inset 3px 0 0 var(--accent); }
.day-badge {
  flex: none; width: 44px; height: 44px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  border-radius: var(--r-md); background: var(--raised); line-height: 1.1;
}
.day-badge small { font-size: var(--fs-meta); color: var(--muted); text-transform: uppercase; font-weight: 600; }
.day-badge strong { font-size: var(--fs-title); }
.day-row.today .day-badge { background: var(--accent); color: var(--on-accent); }
.day-row.today .day-badge small { color: inherit; }
.day-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: var(--s1); }
.day-title { font-size: var(--fs-title); font-weight: 600; line-height: 1.3; }
.day-actions { display: flex; gap: 0; flex: none; margin-right: calc(-1 * var(--s2)); }
.day-actions .btn-icon { width: 36px; min-width: 36px; }
.week-tools { display: grid; grid-template-columns: 1fr auto; gap: var(--s2); }
@media (max-width: 360px) { .week-tools { grid-template-columns: 1fr; } }
.day-row.locked .day-badge { outline: 1px solid var(--accent); }

/* Shopping */
.shop-summary { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); flex-wrap: wrap; color: var(--muted); }
.progress { height: 4px; border-radius: 999px; background: var(--raised); overflow: hidden; margin-top: calc(-1 * var(--s2)); }
.progress span { display: block; height: 100%; background: var(--accent); transition: width 0.2s; }
.check-wrap { display: inline-flex; padding: var(--s1); }
.check { appearance: none; width: 24px; height: 24px; margin: 0; border: 2px solid var(--muted); border-radius: var(--r-sm); display: grid; place-items: center; cursor: pointer; }
.check:checked { background: var(--accent); border-color: var(--accent); }
.check:checked::after { content: ''; width: 11px; height: 6px; border: solid var(--on-accent); border-width: 0 0 2px 2px; transform: translateY(-1px) rotate(-45deg); }
.shop-row.done .row-title { text-decoration: line-through; color: var(--muted); }
.row-trash { color: var(--muted); }
.done-section { border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface); }
.done-section summary { padding: var(--s3) var(--s4); cursor: pointer; color: var(--muted); font-weight: 600; }
.done-section .list { border: 0; border-top: 1px solid var(--border); border-radius: 0; }
.add-bar {
  position: fixed; left: 0; right: 0; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); z-index: 26;
  display: flex; gap: var(--s2); padding: var(--s2) var(--s4); background: var(--surface); border-top: 1px solid var(--border);
}
@media (min-width: 900px) { .add-bar { left: 232px; bottom: 0; padding: var(--s3) var(--s6); } }
.picker { position: relative; flex: 1; min-width: 0; }
.picker .input { padding-left: 38px; }
.picker-icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); display: inline-flex; pointer-events: none; }
.picker-list:not(:empty) {
  position: absolute; left: 0; right: 0; bottom: calc(100% + var(--s2)); z-index: 5; max-height: 50vh; overflow-y: auto;
  border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--shadow);
}
.sheet .picker-list:not(:empty) { position: static; box-shadow: none; margin-top: var(--s2); }
.picker-option { display: flex; align-items: center; gap: var(--s3); width: 100%; min-height: 48px; padding: var(--s2) var(--s3); border: 0; border-bottom: 1px solid var(--border); background: none; text-align: left; }
.picker-option:last-child { border-bottom: 0; }
.picker-option:hover, .picker-option:focus-visible { background: var(--raised); }
.picker-name { flex: 1; font-weight: 600; min-width: 0; }
.picker-meta { font-size: var(--fs-meta); color: var(--muted); }
.picker-create .picker-name { color: var(--accent); }

/* Photos and tiles */
.photo { flex: none; width: 40px; height: 40px; border-radius: var(--r-md); object-fit: contain; background: var(--raised); }
.photo-fallback { display: inline-flex; align-items: center; justify-content: center; color: var(--muted); }
.standard { display: flex; flex-direction: column; gap: var(--s2); }
.tile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: var(--s2); }
.tile { position: relative; border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface); }
.tile.selected { border-color: var(--accent); background: var(--accent-soft); }
.tile-main {
  display: flex; flex-direction: column; align-items: center; gap: var(--s1); width: 100%; min-height: 108px; padding: var(--s3) var(--s2) var(--s2);
  border: 0; background: none; text-align: center;
}
.tile-main .photo { width: 44px; height: 44px; }
.tile-name { font-weight: 600; font-size: var(--fs-body); line-height: 1.25; max-width: 100%; }
.tile-unit { font-size: var(--fs-meta); color: var(--muted); }
.tile-count {
  position: absolute; top: var(--s1); right: var(--s1); min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px;
  background: var(--accent); color: var(--on-accent); font-size: var(--fs-meta); font-weight: 700; display: grid; place-items: center;
}
.tile-minus { position: absolute; top: 0; left: 0; width: 34px; height: 34px; min-width: 34px; }
.photo-editor { display: flex; align-items: center; gap: var(--s3); }
.photo-button { display: flex; flex-direction: column; align-items: center; gap: var(--s1); padding: var(--s2); border: 1px dashed var(--border); border-radius: var(--r-lg); background: none; color: var(--muted); font-size: var(--fs-meta); }
.photo-button .photo { width: 64px; height: 64px; }
.credits { display: flex; flex-direction: column; gap: var(--s1); font-size: var(--fs-meta); color: var(--muted); min-width: 0; }
.credit-links { display: flex; gap: var(--s3); }
.image-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: var(--s2); }
.image-card { display: flex; flex-direction: column; align-items: center; gap: var(--s1); padding: var(--s2); border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface); text-align: center; }
.image-card:not(:disabled):hover { border-color: var(--accent); }
.image-frame { width: 72px; height: 72px; display: grid; place-items: center; }
.image-frame .photo { width: 72px; height: 72px; }
.image-title { font-size: var(--fs-meta); font-weight: 600; max-height: 2.6em; overflow: hidden; }
.image-meta { font-size: 0.6875rem; color: var(--muted); max-height: 2.6em; overflow: hidden; }
.spinner { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--border); border-top-color: var(--accent); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } * { transition: none !important; } }

/* Cards, banners, empty states */
.card { display: flex; flex-direction: column; gap: var(--s3); padding: var(--s4); border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface); }
.card-quiet { background: transparent; }
.card-head { display: flex; align-items: center; gap: var(--s2); }
.card-head .btn { margin-left: auto; }
.card-head .icon { color: var(--muted); }
.card .list { border-radius: var(--r-md); }
details.card summary { cursor: pointer; font-weight: 600; }
.banner { display: flex; align-items: center; gap: var(--s3); padding: var(--s3) var(--s4); border-radius: var(--r-lg); background: var(--accent-soft); }
.banner > .icon { color: var(--accent); }
.banner-warn { background: var(--warn-soft); }
.banner-warn > .icon { color: var(--warn); }
.banner-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.banner-text span { font-size: var(--fs-meta); color: var(--muted); }
.banner-actions { display: flex; flex-wrap: wrap; gap: var(--s2); justify-content: flex-end; }
@media (max-width: 560px) { .banner { flex-wrap: wrap; } .banner-actions { width: 100%; } .banner-actions .btn { flex: 1; } }
.empty { display: flex; flex-direction: column; align-items: center; gap: var(--s2); padding: var(--s6) var(--s4); text-align: center; color: var(--muted); }
.empty strong { color: var(--text); font-size: var(--fs-title); }
.hero { display: flex; flex-direction: column; align-items: center; gap: var(--s2); padding: var(--s5) 0 var(--s2); text-align: center; }
.hero .icon { color: var(--accent); }
.hero p { color: var(--muted); }

/* Settings */
.menu { display: flex; flex-direction: column; gap: var(--s2); }
.menu-list { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface); overflow: hidden; }
.menu-list > * { border-bottom: 1px solid var(--border); }
.menu-list > :last-child { border-bottom: 0; }
.menu-row { border: 0; border-bottom: 1px solid var(--border); color: var(--text); cursor: pointer; }
.menu-row:hover { background: var(--raised); }
.menu-row > .icon:last-child { color: var(--muted); }
.menu-list > .switch { padding: var(--s2) var(--row-pad); }
.about { text-align: center; color: var(--muted); font-size: var(--fs-meta); }
.icon-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(48px, 1fr)); gap: var(--s2); }
.icon-choice { height: 48px; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); display: grid; place-items: center; }
.icon-choice.active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.sort-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; }
.sort-row { display: flex; align-items: center; gap: var(--s3); padding: var(--s1) var(--s1) var(--s1) var(--s3); border-bottom: 1px solid var(--border); background: var(--surface); }
.sort-row:last-child { border-bottom: 0; }
.sort-name { flex: 1; font-weight: 500; }
.design-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: var(--s2); }
.design-card { border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface); overflow: hidden; }
.design-card.active { border-color: var(--accent); }
.design-select { display: flex; flex-direction: column; align-items: flex-start; gap: var(--s1); width: 100%; padding: var(--s3); border: 0; background: none; text-align: left; }
.swatches { display: flex; gap: 4px; }
.swatch { width: 22px; height: 22px; border-radius: var(--r-sm); border: 1px solid var(--border); }
.design-actions { display: flex; justify-content: flex-end; border-top: 1px solid var(--border); }

/* Sheets (dialogs) */
.sheet {
  width: 100%; max-width: 100%; max-height: 92vh; margin: auto 0 0; padding: 0; border: 0;
  border-radius: var(--r-lg) var(--r-lg) 0 0; background: var(--bg); color: var(--text); box-shadow: var(--shadow);
  display: flex; flex-direction: column; overflow: hidden;
}
.sheet:not([open]) { display: none; }
.sheet::backdrop { background: rgb(0 0 0 / 0.5); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); padding: var(--s3) var(--s2) var(--s3) var(--s4); border-bottom: 1px solid var(--border); }
.sheet-head h2 { font-size: var(--fs-title); font-weight: 650; min-width: 0; }
.sheet-body { flex: 1; overflow-y: auto; padding: var(--s4); display: flex; flex-direction: column; gap: var(--s3); overscroll-behavior: contain; }
.sheet-foot { padding: var(--s3) var(--s4) calc(var(--s3) + env(safe-area-inset-bottom)); border-top: 1px solid var(--border); }
.sheet-error { padding: var(--s2) var(--s3); border-radius: var(--r-md); background: color-mix(in srgb, var(--danger) 15%, transparent); color: var(--danger); font-weight: 600; }
.sheet-text { color: var(--muted); }
@media (min-width: 700px) {
  .sheet { width: min(560px, 92vw); margin: auto; border-radius: var(--r-lg); max-height: 86vh; }
  .sheet-wide { width: min(760px, 94vw); }
  .sheet-foot { display: flex; justify-content: flex-end; }
  .sheet-foot .btn-block { width: auto; min-width: 160px; }
}
.pick-list { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; }
.pick-option { display: flex; align-items: center; gap: var(--s2); min-height: 48px; padding: var(--s2) var(--s3); border: 0; border-bottom: 1px solid var(--border); background: var(--surface); text-align: left; }
.pick-option:last-child { border-bottom: 0; }
.pick-option:hover { background: var(--raised); }
.pick-option.selected { background: var(--accent-soft); }
.pick-option .icon { color: var(--accent); }
.pick-name { flex: 1; font-weight: 500; min-width: 0; }
.preview { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--r-md); overflow: hidden; }
.preview:empty { display: none; }
.preview > .hint { padding: var(--s2) var(--s3); }
.preview-row { display: grid; grid-template-columns: 76px 1fr auto; gap: var(--s2); padding: 6px var(--s3); border-bottom: 1px solid var(--border); font-size: var(--fs-body); }
.preview-row:last-child { border-bottom: 0; }
.preview-qty { color: var(--muted); white-space: nowrap; }
.preview-name { font-weight: 500; min-width: 0; }
.preview-meta { font-size: var(--fs-meta); color: var(--muted); white-space: nowrap; }
.preview-meta.new { color: var(--accent); }

/* Toast */
#toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + 72px + env(safe-area-inset-bottom)); z-index: 60;
  display: flex; align-items: center; gap: var(--s3); max-width: min(520px, calc(100vw - 32px)); padding: var(--s2) var(--s2) var(--s2) var(--s4);
  border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--raised); color: var(--text); box-shadow: var(--shadow);
  transform: translate(-50%, 16px); opacity: 0; pointer-events: none; transition: opacity 0.15s, transform 0.15s;
}
#toast.visible { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.toast-text { padding: var(--s1) 0; }
.toast-action { flex: none; height: 32px; padding: 0 var(--s3); border: 0; border-radius: var(--r-md); background: none; color: var(--accent); font-weight: 700; }
@media (min-width: 900px) { #toast { bottom: var(--s5); left: calc(50% + 116px); } }
body[data-view='setup'] #toast { bottom: var(--s5); }

/* Small phones */
@media (max-width: 380px) {
  :root { --s4: 12px; }
  .row-side .stars { display: none; }
  .week-switcher strong { font-size: var(--fs-meta); }
}

/* ---------- Print: A4 landscape shopping list ---------- */
#print-area { display: none; }
@media print {
  @page { size: A4 landscape; margin: 8mm; }
  body { background: #fff; color: #000; font-size: 8pt; }
  #app, #toast, dialog { display: none !important; }
  #print-area { display: block; }
  .print-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4mm 8mm; margin-bottom: 3mm; }
  .print-head h1 { font-size: 13pt; }
  .print-meals { display: flex; flex-wrap: wrap; gap: 1mm 4mm; font-size: 7.5pt; width: 100%; }
  .print-grid { columns: 6; column-gap: 4mm; }
  .print-group { break-inside: avoid; margin-bottom: 2mm; }
  .print-group h2, .print-extras h2 { font-size: 8pt; margin: 0 0 1mm; border-bottom: 0.3mm solid #000; text-transform: uppercase; }
  .print-item { display: flex; align-items: center; gap: 1.5mm; line-height: 1.35; }
  .print-box { width: 2.6mm; height: 2.6mm; border: 0.3mm solid #000; flex: none; }
  .print-item.selected { font-weight: 700; }
  .print-item.selected .print-box { border-width: 0.6mm; display: grid; place-items: center; font-size: 6.5pt; line-height: 1; }
  .print-item.selected .print-box::after { content: '✓'; }
  .print-qty { margin-left: auto; white-space: nowrap; }
  .print-extras { margin-bottom: 3mm; }
  .print-extra-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0 4mm; }
}
