/* ============================================================
   Nexus — household organiser
   Mobile-first; a sidebar layout takes over from 900px up.
   ============================================================ */

:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #f1f3f9;
  --surface-3: #e7eaf3;
  --border: #e2e6f0;
  --border-strong: #cdd4e5;
  --text: #171a24;
  --text-dim: #5d6478;
  --text-faint: #8b93a8;
  --primary: #4f46e5;
  /* Derived, so setting --primary alone retints every accent surface. */
  --primary-soft: color-mix(in srgb, var(--primary) 11%, var(--surface));
  --primary-text: #ffffff;
  --danger: #dc2626;
  --danger-soft: #fee6e6;
  --success: #059669;
  --success-soft: #e3f6ef;
  --warning: #d97706;
  --warning-soft: #fdf1e0;
  --shadow-sm: 0 1px 2px rgba(16, 20, 40, .06), 0 1px 3px rgba(16, 20, 40, .04);
  --shadow-md: 0 4px 16px rgba(16, 20, 40, .08);
  --shadow-lg: 0 18px 48px rgba(16, 20, 40, .18);
  --radius: 14px;
  --radius-sm: 10px;
  --tab-h: 62px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d0f16;
    --surface: #161923;
    --surface-2: #1d2130;
    --surface-3: #262b3d;
    --border: #262b3a;
    --border-strong: #363d52;
    --text: #eef0f7;
    --text-dim: #a0a8bf;
    --text-faint: #737c94;
    --primary: #7c74ff;
    --primary-soft: color-mix(in srgb, var(--primary) 22%, var(--surface));
    --danger: #f87171;
    --danger-soft: #331e1e;
    --success: #34d399;
    --success-soft: #10291f;
    --warning: #fbbf24;
    --warning-soft: #2c2210;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, .45);
    --shadow-lg: 0 18px 48px rgba(0, 0, 0, .6);
  }
}
:root[data-theme="dark"] {
  --bg: #0d0f16; --surface: #161923; --surface-2: #1d2130; --surface-3: #262b3d;
  --border: #262b3a; --border-strong: #363d52;
  --text: #eef0f7; --text-dim: #a0a8bf; --text-faint: #737c94;
  --primary: #7c74ff; --primary-soft: color-mix(in srgb, var(--primary) 22%, var(--surface));
  --danger: #f87171; --danger-soft: #331e1e;
  --success: #34d399; --success-soft: #10291f;
  --warning: #fbbf24; --warning-soft: #2c2210;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.4); --shadow-md: 0 4px 16px rgba(0,0,0,.45); --shadow-lg: 0 18px 48px rgba(0,0,0,.6);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--primary); }
[hidden] { display: none !important; }

/* ---------- generic controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 10px 15px; min-height: 42px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  font-weight: 560; cursor: pointer;
  transition: background .14s, border-color .14s, transform .08s, opacity .14s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: scale(.975); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn--primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn--primary:hover { background: var(--primary); filter: brightness(1.08); }
.btn--danger { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.btn--ghost { background: transparent; border-color: transparent; color: var(--text-dim); }
.btn--ghost:hover { background: var(--surface-2); color: var(--text); }
.btn--block { width: 100%; }
.btn--sm { min-height: 34px; padding: 6px 11px; font-size: 13.5px; border-radius: 9px; }
a.btn { text-decoration: none; color: var(--text); }
/* The floating action button covers "add" on phones. */
.desktop-only { display: none; }
.toolbar { margin-bottom: 14px; }
/* A toolbar whose only content was the desktop button has nothing left to show. */
@media (max-width: 899px) { .toolbar:not(:has(.switch)) { display: none; } }
.btn--icon { padding: 8px; min-height: 38px; min-width: 38px; border-radius: 10px; }

.input, .select, .textarea {
  width: 100%; padding: 11px 13px; min-height: 44px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  outline: none; transition: border-color .14s, box-shadow .14s;
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent);
}
.textarea { min-height: 84px; resize: vertical; }
.select { appearance: none; padding-right: 34px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%238b93a8' stroke-width='2.5' stroke-linecap='round'><path d='M6 9l6 6 6-6'/></svg>");
  background-repeat: no-repeat; background-position: right 12px center; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > label { font-size: 13px; font-weight: 600; color: var(--text-dim); }
/* Standalone, so hints outside a .field wrapper are styled too. */
.hint { font-size: 12.5px; color: var(--text-faint); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.error-text { color: var(--danger); font-size: 13.5px; margin: 0 0 12px; }
.form-error {
  background: var(--danger-soft); color: var(--danger);
  padding: 10px 12px; border-radius: var(--radius-sm); font-size: 13.5px; margin-bottom: 14px;
}

/* ---------- auth screens ---------- */
.auth {
  min-height: 100dvh; display: grid; place-items: center; padding: 24px 18px;
}
.auth__card {
  width: 100%; max-width: 400px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 20px; padding: 28px 24px;
  box-shadow: var(--shadow-md);
}
.auth__logo {
  display: flex; align-items: center; gap: 11px; margin-bottom: 22px;
}
.auth__mark {
  width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center;
  background: linear-gradient(145deg, var(--primary), color-mix(in srgb, var(--primary) 55%, #ec4899));
  color: #fff; font-weight: 800; font-size: 20px;
}
.auth__title { font-size: 22px; }
.auth__sub { color: var(--text-dim); font-size: 14px; margin: 5px 0 22px; }

/* ---------- app shell ---------- */
.shell { min-height: 100dvh; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar__title { flex: 1; min-width: 0; }
.topbar__title h1 { font-size: 17px; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar__title p { margin: 1px 0 0; font-size: 12.5px; color: var(--text-faint); }
.topbar__switch {
  display: inline-flex; align-items: center; gap: 3px; cursor: pointer;
  border-radius: 6px; padding: 1px 5px 1px 4px; margin-left: -4px !important;
}
.topbar__switch:hover { background: var(--surface-2); color: var(--text-dim); }
.topbar__switch svg { transform: rotate(90deg); opacity: .8; }

.icon-btn {
  position: relative; display: grid; place-items: center;
  width: 40px; height: 40px; border-radius: 12px;
  border: 1px solid transparent; background: transparent; color: var(--text-dim); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn__dot {
  position: absolute; top: 5px; right: 5px; min-width: 17px; height: 17px; padding: 0 4px;
  border-radius: 9px; background: var(--danger); color: #fff;
  font-size: 10.5px; font-weight: 700; display: grid; place-items: center;
  border: 2px solid var(--bg);
}

.main { flex: 1; width: 100%; padding: 16px 14px calc(var(--tab-h) + var(--safe-b) + 82px); }
.main__inner { max-width: 780px; margin: 0 auto; }

/* bottom tab bar (phones) */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: grid; grid-template-columns: repeat(5, 1fr);
  padding-bottom: var(--safe-b);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  border-top: 1px solid var(--border);
}
.tabbar__item {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  height: var(--tab-h); border: none; background: none; cursor: pointer;
  color: var(--text-faint); font-size: 10.5px; font-weight: 600; position: relative;
}
.tabbar__item.is-active { color: var(--primary); }
.tabbar__item svg { width: 22px; height: 22px; }
.tabbar__badge {
  position: absolute; top: 8px; left: 50%; margin-left: 4px;
  min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px;
  background: var(--danger); color: #fff; font-size: 10px; font-weight: 700;
  display: grid; place-items: center;
}

.sidebar { display: none; }

/* floating add button */
.fab {
  position: fixed; right: 16px; bottom: calc(var(--tab-h) + var(--safe-b) + 16px); z-index: 35;
  width: 56px; height: 56px; border-radius: 18px; border: none;
  background: var(--primary); color: #fff; cursor: pointer;
  box-shadow: 0 8px 24px color-mix(in srgb, var(--primary) 45%, transparent);
  display: grid; place-items: center; transition: transform .1s;
}
.fab:active { transform: scale(.93); }
.fab svg { width: 26px; height: 26px; }

/* ---------- filter chips ---------- */
.chips {
  display: flex; gap: 8px; overflow-x: auto; padding: 2px 14px 12px; margin: 0 -14px;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 13px; border-radius: 999px; cursor: pointer;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text-dim); font-size: 13.5px; font-weight: 560; white-space: nowrap;
  transition: background .14s, color .14s, border-color .14s;
}
.chip:hover { border-color: var(--border-strong); }
.chip.is-active { background: var(--primary); border-color: var(--primary); color: #fff; }
.chip__dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.chip__count { opacity: .65; font-variant-numeric: tabular-nums; }
.chip--add { border-style: dashed; color: var(--text-faint); }

/* sort control above the shopping list */
.sortbar {
  display: flex; align-items: center; gap: 8px;
  margin: 0 2px 12px; color: var(--text-faint);
}
.sortbar label { font-size: 12.5px; font-weight: 600; }
.sortbar__select {
  flex: 1; min-height: 38px; padding: 7px 30px 7px 11px;
  font-size: 13.5px; background-color: var(--surface);
}
@media (min-width: 900px) { .sortbar__select { flex: 0 0 240px; } }

/* stacked destructive actions at the foot of an editor */
.danger-zone {
  display: flex; flex-direction: column; gap: 8px;
  margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border);
}

/* ---------- cards & lists ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
}
.card + .card { margin-top: 12px; }
.card__head {
  display: flex; align-items: center; gap: 10px;
  padding: 13px 15px; border-bottom: 1px solid var(--border);
}
.card__head h3 { font-size: 14.5px; flex: 1; }
.card__body { padding: 15px; }

.section-title {
  display: flex; align-items: center; gap: 9px;
  margin: 22px 2px 10px; font-size: 12px; font-weight: 700;
  letter-spacing: .07em; text-transform: uppercase; color: var(--text-faint);
}
.section-title:first-child { margin-top: 4px; }
.section-title span { flex: 1; }

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

.row {
  display: flex; align-items: flex-start; gap: 12px; padding: 12px 14px;
  background: var(--surface);
}
.row__main { flex: 1; min-width: 0; }
.row__title {
  font-weight: 560; overflow-wrap: anywhere; display: flex; align-items: center; gap: 7px; flex-wrap: wrap;
}
.row__meta {
  display: flex; align-items: center; gap: 7px; flex-wrap: wrap;
  margin-top: 5px; font-size: 12.5px; color: var(--text-faint);
}
.row__actions { display: flex; align-items: center; gap: 4px; flex: none; }
.row.is-done .row__title { text-decoration: line-through; color: var(--text-faint); }
.row--tappable { cursor: pointer; }
.row--tappable:hover { background: var(--surface-2); }

/* ---------- checkboxes ---------- */
.check {
  flex: none; width: 26px; height: 26px; margin-top: 1px; border-radius: 9px;
  border: 2px solid var(--border-strong); background: transparent; cursor: pointer;
  display: grid; place-items: center; padding: 0; transition: all .14s;
}
.check svg { width: 15px; height: 15px; opacity: 0; transform: scale(.5); transition: all .16s; }
.check:hover { border-color: var(--primary); }
.check.is-checked { background: var(--success); border-color: var(--success); color: #fff; }
.check.is-checked svg { opacity: 1; transform: scale(1); }
/* three-state shopping checkbox: the middle state is "in the trolley" */
.check.is-cart { background: var(--warning); border-color: var(--warning); color: #fff; }
.check.is-cart svg { opacity: 1; transform: scale(1); }

/* A plain icon chip for list rows. Deliberately not .check, whose SVG is
   hidden until the box is ticked. */
.row-icon {
  flex: none; width: 26px; height: 26px; margin-top: 1px; border-radius: 9px;
  display: grid; place-items: center;
  background: var(--surface-2); color: var(--text-dim);
}
.row-icon--accent { background: var(--primary); color: #fff; }

/* ---------- badges & tags ---------- */
.tag {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px; border-radius: 7px; font-size: 11.5px; font-weight: 620;
  background: var(--surface-2); color: var(--text-dim); white-space: nowrap;
}
.tag__dot { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.tag--project { background: var(--primary-soft); color: var(--primary); }
.tag--due { background: var(--surface-2); }
.tag--overdue { background: var(--danger-soft); color: var(--danger); }
.tag--today { background: var(--warning-soft); color: var(--warning); }
.tag--shop { background: var(--success-soft); color: var(--success); }

/* header for a run of items from one shop, when sorting by shop */
.shop-head {
  display: flex; align-items: center; gap: 9px; row-gap: 8px;
  /* The shop name gets the room it needs; the actions drop to their own line
     on a narrow phone rather than squeezing the name into an ellipsis. */
  flex-wrap: wrap;
  padding: 9px 14px; border-bottom: 1px solid var(--border);
}
.shop-head__dot { flex: none; width: 10px; height: 10px; border-radius: 50%; }
.shop-head__name {
  font-size: 14px; font-weight: 700; letter-spacing: -.01em;
  color: var(--text); overflow-wrap: anywhere;
}
.shop-head__count {
  font-size: 12.5px; color: var(--text-faint); font-variant-numeric: tabular-nums;
}
.shop-head__actions { display: flex; gap: 6px; margin-left: auto; flex: none; }
.shop-head__actions .shop-links { margin-top: 0; }
.shop-head__actions .btn { padding: 5px 9px; min-height: 30px; font-size: 12.5px; }
.shop-head--none .shop-head__name { color: var(--text-faint); font-weight: 600; }
.tag--ghost { background: transparent; border: 1px dashed var(--border-strong); color: var(--text-faint); }

.avatar {
  position: relative; overflow: hidden;
  flex: none; width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center; color: #fff;
  font-size: 11px; font-weight: 700; letter-spacing: .02em;
}
.avatar--lg { width: 42px; height: 42px; font-size: 16px; border-radius: 14px; }
.avatar__img {
  position: absolute; inset: 0;
  width: 100%; height: 100%; object-fit: cover; display: block;
}

/* the editable avatar in the profile form */
.avatar-edit { display: flex; align-items: center; gap: 14px; }
.avatar-edit .avatar { width: 72px; height: 72px; border-radius: 22px; font-size: 26px; }
.avatar-edit__actions { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.avatar-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 9px 2px 2px; border-radius: 999px;
  background: var(--surface-2); font-size: 11.5px; font-weight: 600; color: var(--text-dim);
}
.avatar-chip .avatar { width: 20px; height: 20px; font-size: 9.5px; }

/* ---------- empty state ---------- */
.empty { text-align: center; padding: 46px 22px; color: var(--text-faint); }
.empty svg { width: 42px; height: 42px; opacity: .35; margin-bottom: 12px; }
.empty h3 { font-size: 15px; color: var(--text-dim); margin-bottom: 5px; }
.empty p { margin: 0; font-size: 13.5px; max-width: 320px; margin-inline: auto; }

/* ---------- modal / bottom sheet ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(10, 12, 20, .5); backdrop-filter: blur(3px);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade .16s ease;
}
@keyframes fade { from { opacity: 0; } }
@keyframes slideUp { from { transform: translateY(14px); opacity: .4; } }
.modal {
  width: 100%; max-width: 520px; max-height: 92dvh; overflow-y: auto;
  background: var(--surface); border-radius: 22px 22px 0 0;
  padding: 8px 18px calc(20px + var(--safe-b));
  box-shadow: var(--shadow-lg); animation: slideUp .2s cubic-bezier(.2,.8,.3,1);
}
.modal__grip {
  width: 38px; height: 4px; border-radius: 2px; background: var(--border-strong);
  margin: 6px auto 14px;
}
.modal__head { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.modal__head h2 { font-size: 18px; flex: 1; }
.modal__actions { display: flex; gap: 10px; margin-top: 20px; }
.modal__actions .btn { flex: 1; }

/* Media dialogs give the picture the room instead of the chrome. */
.modal--flush { padding: 6px 10px calc(12px + var(--safe-b)); }
.modal--flush .modal__head { margin-bottom: 8px; }
.modal--flush .modal__head h2 { font-size: 14.5px; color: var(--text-dim); font-weight: 600; }

/* ---------- crop / rotate / mirror editor ---------- */
.editor { display: flex; flex-direction: column; gap: 12px; }
.editor__stage {
  position: relative; width: 100%; max-height: 52dvh;
  border-radius: 12px; overflow: hidden;
  background: #0b0d12 repeating-conic-gradient(#181c25 0% 25%, #12161d 0% 50%) 50% / 20px 20px;
  touch-action: none;            /* we handle panning and pinching ourselves */
}
.editor__canvas { display: block; width: 100%; height: 100%; cursor: grab; }
.editor__canvas:active { cursor: grabbing; }
.editor__hint { text-align: center; margin: 0; }
.editor__zoom { width: 100%; accent-color: var(--primary); }
.editor__tools { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.editor__tool { min-height: 44px; min-width: 48px; padding: 0 12px; }

/* ---------- colour wheel picker ---------- */
.wheel-picker { display: flex; flex-direction: column; gap: 16px; }
.wheel {
  position: relative; width: 100%; max-width: 248px; aspect-ratio: 1;
  margin: 2px auto 0; touch-action: none; cursor: crosshair;
}
.wheel__canvas { width: 100%; height: 100%; display: block; border-radius: 50%; }
.wheel__marker {
  position: absolute; width: 22px; height: 22px; border-radius: 50%;
  transform: translate(-50%, -50%); pointer-events: none;
  border: 3px solid #fff;
  box-shadow: 0 0 0 1.5px rgba(0, 0, 0, .45), 0 2px 6px rgba(0, 0, 0, .35);
}
.wheel__controls { display: flex; flex-direction: column; gap: 12px; }
.wheel__row { display: flex; align-items: center; gap: 12px; }
.wheel__row > span {
  flex: 0 0 74px; font-size: 12.5px; font-weight: 600; color: var(--text-dim);
}
.wheel__slider {
  flex: 1; -webkit-appearance: none; appearance: none;
  height: 14px; border-radius: 7px; background: var(--track, var(--surface-3));
  outline: none; border: 1px solid var(--border);
}
.wheel__slider::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 24px; height: 24px; border-radius: 50%;
  background: #fff; border: 2px solid var(--border-strong);
  box-shadow: 0 1px 4px rgba(0, 0, 0, .3); cursor: pointer;
}
.wheel__slider::-moz-range-thumb {
  width: 22px; height: 22px; border-radius: 50%;
  background: #fff; border: 2px solid var(--border-strong);
  box-shadow: 0 1px 4px rgba(0, 0, 0, .3); cursor: pointer;
}
.wheel__foot { display: flex; align-items: center; gap: 12px; }
.wheel__swatch {
  flex: none; width: 46px; height: 46px; border-radius: 14px;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .12);
}
.wheel__hex {
  flex: 1; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  text-transform: lowercase; letter-spacing: .04em;
}

/* camera-or-gallery chooser */
.source-choice { display: flex; flex-direction: column; gap: 10px; }
.source-choice__btn {
  justify-content: flex-start; gap: 14px; min-height: 60px;
  padding: 14px 18px; font-size: 15.5px; font-weight: 600;
}
.source-choice__btn svg { color: var(--primary); flex: none; }

/* ---------- toast ---------- */
.toasts {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--tab-h) + var(--safe-b) + 80px); z-index: 200;
  display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none; width: calc(100% - 28px); max-width: 420px;
}
.toast {
  pointer-events: auto; width: 100%;
  background: var(--text); color: var(--bg);
  padding: 12px 15px; border-radius: 12px; font-size: 13.5px; font-weight: 550;
  box-shadow: var(--shadow-lg); animation: slideUp .2s ease;
  display: flex; align-items: center; gap: 9px;
}
.toast--error { background: var(--danger); color: #fff; }
.toast--success { background: var(--success); color: #fff; }
.toast__action {
  margin-left: auto; background: none; border: none; cursor: pointer;
  color: inherit; font-weight: 700; text-decoration: underline; padding: 0;
}

/* ---------- shopping-specific ---------- */
.additem { position: relative; margin-bottom: 12px; }
.additem__input { padding-right: 46px; }
.additem__go {
  position: absolute; right: 5px; top: 5px; width: 34px; height: 34px;
  border-radius: 9px; border: none; background: var(--primary); color: #fff;
  display: grid; place-items: center; cursor: pointer;
}
.additem__go:disabled { opacity: .35; cursor: not-allowed; }
.suggest {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 20;
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius); box-shadow: var(--shadow-lg); overflow: hidden;
  max-height: 300px; overflow-y: auto;
}
.suggest__item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 11px 14px; border: none; background: none; cursor: pointer; text-align: left;
}
.suggest__item:hover, .suggest__item.is-cursor { background: var(--surface-2); }
.suggest__item + .suggest__item { border-top: 1px solid var(--border); }
.suggest__plus {
  flex: none; width: 26px; height: 26px; border-radius: 8px;
  background: var(--primary-soft); color: var(--primary);
  display: grid; place-items: center; font-weight: 800; font-size: 17px; line-height: 1;
}
.suggest__body { flex: 1; min-width: 0; }
.suggest__name { font-weight: 560; }
.suggest__hint { font-size: 12px; color: var(--text-faint); margin-top: 2px; }
.suggest__new .suggest__name { color: var(--primary); }

.cart-bar {
  position: sticky; bottom: calc(var(--tab-h) + var(--safe-b) + 10px); z-index: 25;
  margin-top: 16px;
}
.cart-bar .btn { box-shadow: var(--shadow-lg); }

.shop-links { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }

/* colour swatches — selected state is a matching ring plus a tick */
.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.swatch { position: relative; line-height: 0; }
/* The radios are visually hidden; the label is what you click. */
.swatch input[type="radio"] { position: absolute; opacity: 0; pointer-events: none; }
.swatch span {
  display: grid; place-items: center;
  width: 40px; height: 40px; border-radius: 13px; cursor: pointer; color: #fff;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .1);
  transition: box-shadow .15s, transform .12s;
}
.swatch span svg {
  opacity: 0; transform: scale(.4);
  transition: opacity .15s, transform .15s;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .4));
}
.swatch span:hover { transform: scale(1.07); }
.swatch input:checked + span {
  box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--swatch);
  transform: scale(1.07);
}
.swatch input:checked + span svg { opacity: 1; transform: scale(1); }
/* The "open the wheel" tile. Always last, and always a button rather than a
   swatch standing for a value, so it does not vanish once a colour is chosen. */
.swatch--picker { border: none; background: none; padding: 0; cursor: pointer; }
.swatch--picker span {
  background:
    conic-gradient(from .25turn, #ef4444, #f59e0b, #10b981, #0ea5e9, #6366f1, #ec4899, #ef4444);
}
.swatch--picker span svg {
  opacity: 1; transform: none;
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, .65));
}
.swatch--picker:hover span { transform: scale(1.07); }
.swatch--picker:focus-visible span {
  box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--primary);
}
.swatch input:focus-visible + span {
  box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--swatch), 0 0 0 8px color-mix(in srgb, var(--swatch) 35%, transparent);
}

/* quantity stepper */
.qty {
  display: inline-flex; align-items: center; flex: none;
  background: var(--surface-2); border-radius: 11px; padding: 2px;
}
.qty__btn {
  width: 28px; height: 28px; border: none; background: transparent;
  border-radius: 8px; cursor: pointer; color: var(--text-dim);
  display: grid; place-items: center; padding: 0;
}
.qty__btn:hover:not(:disabled) { background: var(--surface); color: var(--text); }
.qty__btn:disabled { opacity: .3; cursor: not-allowed; }
/* at quantity 1 there is nothing to subtract, so "-" becomes "remove" */
.qty__btn--remove { color: var(--danger); }
.qty__btn--remove:hover:not(:disabled) { background: var(--danger-soft); color: var(--danger); }
.qty__val {
  min-width: 34px; padding: 0 2px; text-align: center;
  display: flex; flex-direction: column; line-height: 1.15;
  font-size: 13px; font-weight: 650; font-variant-numeric: tabular-nums;
}
.qty__val small {
  font-size: 9.5px; font-weight: 600; color: var(--text-faint);
  letter-spacing: .01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 62px;
}
.qty--lg { padding: 4px; }
.qty--lg .qty__btn { width: 40px; height: 40px; border-radius: 9px; }
.qty--lg .qty__input {
  width: 62px; height: 40px; text-align: center; border: none; background: transparent;
  font-size: 16px; font-weight: 650; font-variant-numeric: tabular-nums; outline: none;
  -moz-appearance: textfield; appearance: textfield;
}
.qty--lg .qty__input::-webkit-outer-spin-button,
.qty--lg .qty__input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.qty-row { display: flex; align-items: center; gap: 10px; }
.qty-row .input { flex: 1; }

/* an item already sitting on the list cannot be added twice */
.suggest__item:disabled { cursor: not-allowed; }
.suggest__item:disabled .suggest__name { color: var(--text-faint); }

/* checkbox pills used for linking shops to an item */
.pick { display: flex; flex-wrap: wrap; gap: 8px; }
.pick__opt { position: relative; }
.pick__opt input { position: absolute; opacity: 0; pointer-events: none; }
.pick__opt span {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 13px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--border-strong); background: var(--surface);
  font-size: 13.5px; font-weight: 550; transition: all .14s;
}
.pick__opt input:checked + span {
  background: var(--primary); border-color: var(--primary); color: #fff;
}
.pick__opt input:focus-visible + span { box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 25%, transparent); }

/* ---------- project photo timeline ---------- */
.timeline { position: relative; padding-left: 22px; }
.timeline::before {
  content: ""; position: absolute; left: 5px; top: 6px; bottom: 6px;
  width: 2px; background: var(--border); border-radius: 1px;
}
.timeline__entry { position: relative; padding-bottom: 20px; }
.timeline__entry:last-child { padding-bottom: 0; }
.timeline__marker {
  position: absolute; left: -22px; top: 6px; width: 12px; height: 12px;
  border-radius: 50%; background: var(--primary);
  box-shadow: 0 0 0 3px var(--bg);
}
.timeline__body {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow: hidden;
}
.timeline__head { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px 10px; }
.timeline__head > .avatar { margin-top: 2px; }
.timeline__date { font-size: 13px; font-weight: 700; color: var(--primary); }
.timeline__caption { font-weight: 560; margin-top: 3px; overflow-wrap: anywhere; }

.photo-grid {
  display: grid; gap: 3px; padding: 0 3px 3px;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
}
.photo-grid__cell {
  position: relative; padding: 0; border: none; cursor: pointer;
  aspect-ratio: 1; border-radius: 8px; overflow: hidden; background: var(--surface-2);
}
.photo-grid__cell img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-grid__cell:hover img { opacity: .88; }

/* upload dialog */
.upload__previews {
  display: grid; gap: 6px; margin-bottom: 8px;
  grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
  max-height: 230px; overflow-y: auto; padding: 2px;
}
.upload__thumb {
  position: relative; aspect-ratio: 1; border-radius: 9px;
  background-size: cover; background-position: center; background-color: var(--surface-2);
  border: none; padding: 0; cursor: pointer;
}
.upload__edit {
  position: absolute; right: 3px; bottom: 3px;
  display: grid; place-items: center; width: 21px; height: 21px;
  border-radius: 6px; background: rgba(0, 0, 0, .58); color: #fff;
}
.upload__thumb:hover .upload__edit { background: var(--primary); }
.upload__remove {
  position: absolute; right: 3px; top: 3px;
  display: grid; place-items: center; width: 20px; height: 20px;
  border-radius: 50%; background: rgba(0, 0, 0, .58); color: #fff; cursor: pointer;
}
.upload__remove:hover { background: var(--danger); }

/* the "gather more pictures" tile, always last in the grid */
.upload__add {
  display: grid; place-items: center;
  background: var(--surface-2); color: var(--text-faint);
  border: 1.5px dashed var(--border-strong);
}
.upload__add:hover { border-color: var(--primary); color: var(--primary); }
.upload__progress {
  height: 6px; border-radius: 3px; background: var(--surface-3); overflow: hidden; margin-top: 6px;
}
.upload__bar { height: 100%; width: 0; background: var(--primary); transition: width .2s; }

/* lightbox */
.lightbox { display: flex; flex-direction: column; gap: 10px; }
.lightbox__stage {
  position: relative; display: grid; place-items: center;
  background: #000; border-radius: 12px; overflow: hidden; min-height: 30dvh;
}
.lightbox__img {
  max-width: 100%; max-height: min(62dvh, 620px);
  display: block; object-fit: contain;
}
.lightbox__nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 40px; height: 40px; border-radius: 50%; border: none; cursor: pointer;
  background: rgba(0, 0, 0, .55); color: #fff; display: grid; place-items: center;
}
.lightbox__nav:hover { background: rgba(0, 0, 0, .8); }
.lightbox__nav--prev { left: 8px; }
.lightbox__nav--next { right: 8px; }
.lightbox__bar { display: flex; align-items: center; gap: 10px; }
.lightbox__count { font-size: 13px; color: var(--text-faint); font-variant-numeric: tabular-nums; }

/* ---------- project message board ---------- */
.message-composer { display: flex; flex-direction: column; gap: 8px; }
/* The composer follows the feed, so it sits off it by the same gap the entries
   keep between themselves. */
.board__composer { margin-top: 10px; }
.message-composer__input { min-height: 62px; }
.message-composer__actions { display: flex; gap: 8px; justify-content: flex-end; }

.message-thread { padding: 4px 0; }
.message-thread + .message-thread { margin-top: 10px; }
.message { display: flex; gap: 10px; padding: 11px 14px; }
.message__main { flex: 1; min-width: 0; }
.message__head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.message__head strong { font-size: 14px; }
.message__head .faint { font-size: 12px; }
.message__body { margin-top: 3px; white-space: pre-wrap; overflow-wrap: anywhere; }
.message__foot { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.message__date {
  font-size: 12.5px; font-weight: 700; color: var(--primary);
}
.message .photo-grid { padding: 0; margin-top: 8px; }
.composer__date { display: flex; align-items: center; gap: 10px; }
.composer__date label { font-size: 12.5px; font-weight: 600; color: var(--text-dim); flex: none; }
.message-composer__actions { align-items: center; }
.message__foot .btn { padding: 4px 8px; min-height: 28px; font-size: 12.5px; }
.message__replies {
  margin-left: 26px; padding-left: 12px; border-left: 2px solid var(--border);
}
.message__replies .message { padding-top: 8px; padding-bottom: 8px; }

.reactions { display: flex; gap: 5px; flex-wrap: wrap; }
.reaction {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px; min-height: 28px; border-radius: 999px; cursor: pointer;
  background: var(--surface-2); border: 1px solid transparent;
  font-size: 13.5px; line-height: 1;
}
.reaction:hover { border-color: var(--border-strong); }
.reaction.is-mine { background: var(--primary-soft); border-color: var(--primary); }
.reaction__count { font-size: 11.5px; font-weight: 700; color: var(--text-dim); }
.reaction.is-mine .reaction__count { color: var(--primary); }
.reaction--add { color: var(--text-faint); border-style: dashed; border-color: var(--border-strong); }
.reaction--add:hover { color: var(--primary); border-color: var(--primary); }

.reaction-picker {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-bottom: 4px;
}
.reaction-picker__btn {
  min-height: 54px; font-size: 26px; line-height: 1; cursor: pointer;
  border: 1px solid var(--border); border-radius: 14px; background: var(--surface);
}
.reaction-picker__btn:hover { background: var(--surface-2); transform: scale(1.06); }

/* ---------- misc ---------- */
.inline.wrap { flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.inline { display: flex; align-items: center; gap: 10px; }
.spacer { flex: 1; }
.muted { color: var(--text-dim); }
.faint { color: var(--text-faint); font-size: 13px; }
.mono {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  font-size: 12.5px; word-break: break-all;
}
.linkbox {
  display: flex; gap: 8px; align-items: center;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px 12px; margin: 10px 0;
}
.linkbox .mono { flex: 1; min-width: 0; }
.divider { height: 1px; background: var(--border); margin: 18px 0; }
.spinner {
  width: 20px; height: 20px; border-radius: 50%;
  border: 2.5px solid var(--border-strong); border-top-color: var(--primary);
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.center-spinner { display: grid; place-items: center; padding: 60px 0; }

.switch { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; }
.switch__track {
  width: 42px; height: 25px; border-radius: 13px; background: var(--surface-3);
  position: relative; transition: background .18s; flex: none;
}
.switch__track::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 19px; height: 19px;
  border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: transform .18s;
}
.switch input:checked + .switch__track { background: var(--primary); }
.switch input:checked + .switch__track::after { transform: translateX(17px); }

/* ============================================================
   Desktop: swap the tab bar for a sidebar.
   ============================================================ */
@media (min-width: 900px) {
  .shell { flex-direction: row; }
  .tabbar { display: none; }
  .fab { display: none; }

  .sidebar {
    display: flex; flex-direction: column; gap: 4px;
    width: 246px; flex: none; padding: 18px 12px;
    border-right: 1px solid var(--border); background: var(--surface);
    position: sticky; top: 0; height: 100dvh; overflow-y: auto;
  }
  .sidebar__brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 18px; }
  .sidebar__brand--switch { cursor: pointer; border-radius: 10px; padding-bottom: 8px; margin-bottom: 10px; }
  .sidebar__brand--switch:hover { background: var(--surface-2); }
  .sidebar__brand--switch svg { margin-left: auto; transform: rotate(90deg); color: var(--text-faint); }
  .sidebar__brand .auth__mark { width: 34px; height: 34px; border-radius: 11px; font-size: 16px; }
  .sidebar__brand div { min-width: 0; }
  .sidebar__brand strong { display: block; font-size: 15px; }
  .sidebar__brand span { font-size: 12px; color: var(--text-faint); }
  .sidebar__item {
    display: flex; align-items: center; gap: 11px; padding: 9px 11px;
    border: none; background: none; border-radius: 10px; cursor: pointer;
    color: var(--text-dim); font-size: 14.5px; font-weight: 560; text-align: left; width: 100%;
  }
  .sidebar__item svg { width: 19px; height: 19px; flex: none; }
  .sidebar__item:hover { background: var(--surface-2); color: var(--text); }
  .sidebar__item.is-active { background: var(--primary-soft); color: var(--primary); }
  .sidebar__badge {
    margin-left: auto; min-width: 19px; height: 19px; padding: 0 5px; border-radius: 10px;
    background: var(--danger); color: #fff; font-size: 11px; font-weight: 700;
    display: grid; place-items: center;
  }
  .sidebar__foot { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--border); }

  .shell > div { flex: 1; min-width: 0; display: flex; flex-direction: column; }
  .topbar { padding: 14px 26px; }
  .topbar__title h1 { font-size: 20px; }
  .main { padding: 22px 26px 60px; }
  .main__inner { max-width: 860px; }
  .chips { padding: 2px 26px 14px; margin: 0 -26px; }

  .desktop-only { display: inline-flex; }

  .modal-backdrop { align-items: center; }
  .modal { border-radius: 20px; padding: 8px 24px 22px; max-height: 88dvh; }
  .modal__grip { display: none; }
  .modal__head { margin-top: 14px; }

  .toasts { bottom: 26px; left: auto; right: 26px; transform: none; align-items: flex-end; }
  .cart-bar { bottom: 18px; }
}

@media (min-width: 1280px) {
  .main__inner { max-width: 980px; }
}
