/* ------------------------------------------------------------------ tokens */

:root {
  color-scheme: light;
  --font: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --ease: cubic-bezier(.2, .8, .2, 1);

  --bg: #f5f5f3;
  --surface: #ffffff;
  --surface-2: #f1f1ef;
  --surface-3: #e8e8e5;
  --border: rgba(20, 20, 25, .09);
  --border-strong: rgba(20, 20, 25, .16);
  --text: #18181b;
  --text-2: #52525b;
  --text-3: #8a8a93;
  --text-4: #b4b4bb;
  --accent: #2563eb;
  --focus: rgba(37, 99, 235, .35);
  --ok: #16a34a;
  --soon: #d97706;
  --bad: #dc2626;
  --ok-bg: rgba(22, 163, 74, .1);
  --soon-bg: rgba(217, 119, 6, .12);
  --bad-bg: rgba(220, 38, 38, .1);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .05);
  --shadow-md: 0 4px 16px -4px rgba(0, 0, 0, .12), 0 1px 3px rgba(0, 0, 0, .06);
  --shadow-lg: 0 24px 64px -16px rgba(0, 0, 0, .28), 0 2px 8px rgba(0, 0, 0, .08);

  /* appliance */
  --app-body: linear-gradient(160deg, #fdfdfc, #eaeae7);
  --app-edge: rgba(0, 0, 0, .08);
  --app-shadow: 0 30px 60px -30px rgba(30, 30, 40, .35), 0 2px 6px rgba(0, 0, 0, .05), inset 0 1px 0 #fff;
  --fridge-in: #f7f9fa;
  --freezer-in: #eef3f7;
  --in-edge: rgba(0, 0, 0, .07);
  --in-shade: rgba(40, 60, 80, .16);
  --light-glow: rgba(255, 252, 235, .95);
  --glass: linear-gradient(180deg, rgba(190, 215, 228, .75), rgba(160, 190, 205, .45));
  --glass-hi: rgba(255, 255, 255, .9);
  --drawer-bg: rgba(255, 255, 255, .55);
  --drawer-edge: rgba(110, 140, 160, .22);
  --drawer-handle: rgba(90, 110, 130, .28);
  --target: rgba(37, 99, 235, .08);

  /* containers */
  --lid-l: 50%;
  --lid-s: 42%;
  --food-l: 80%;
  --food-s: 50%;
  --rim-l: 94%;
  --tub-hi: rgba(255, 255, 255, .45);
  --chip-bg: #ffffff;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0d0d0f;
    --surface: #17171a;
    --surface-2: #1e1e22;
    --surface-3: #27272c;
    --border: rgba(255, 255, 255, .08);
    --border-strong: rgba(255, 255, 255, .15);
    --text: #f4f4f5;
    --text-2: #b4b4bc;
    --text-3: #7d7d87;
    --text-4: #52525b;
    --accent: #60a5fa;
    --focus: rgba(96, 165, 250, .4);
    --ok: #4ade80;
    --soon: #fbbf24;
    --bad: #f87171;
    --ok-bg: rgba(74, 222, 128, .12);
    --soon-bg: rgba(251, 191, 36, .13);
    --bad-bg: rgba(248, 113, 113, .13);
    --shadow-md: 0 4px 16px -4px rgba(0, 0, 0, .6), 0 1px 3px rgba(0, 0, 0, .4);
    --shadow-lg: 0 24px 64px -16px rgba(0, 0, 0, .7), 0 2px 8px rgba(0, 0, 0, .4);
    --app-body: linear-gradient(160deg, #2a2b30, #1b1c20);
    --app-edge: rgba(255, 255, 255, .07);
    --app-shadow: 0 30px 60px -30px rgba(0, 0, 0, .8), inset 0 1px 0 rgba(255, 255, 255, .06);
    --fridge-in: #131519;
    --freezer-in: #10151b;
    --in-edge: rgba(255, 255, 255, .06);
    --in-shade: rgba(0, 0, 0, .5);
    --light-glow: rgba(255, 245, 210, .07);
    --glass: linear-gradient(180deg, rgba(120, 150, 170, .35), rgba(90, 115, 135, .18));
    --glass-hi: rgba(255, 255, 255, .14);
    --drawer-bg: rgba(255, 255, 255, .025);
    --drawer-edge: rgba(140, 170, 195, .14);
    --drawer-handle: rgba(160, 180, 200, .22);
    --target: rgba(96, 165, 250, .1);
    --lid-l: 58%;
    --lid-s: 38%;
    --food-l: 38%;
    --food-s: 32%;
    --rim-l: 26%;
    --tub-hi: rgba(255, 255, 255, .16);
    --chip-bg: #1d1f24;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d0d0f;
  --surface: #17171a;
  --surface-2: #1e1e22;
  --surface-3: #27272c;
  --border: rgba(255, 255, 255, .08);
  --border-strong: rgba(255, 255, 255, .15);
  --text: #f4f4f5;
  --text-2: #b4b4bc;
  --text-3: #7d7d87;
  --text-4: #52525b;
  --accent: #60a5fa;
  --focus: rgba(96, 165, 250, .4);
  --ok: #4ade80;
  --soon: #fbbf24;
  --bad: #f87171;
  --ok-bg: rgba(74, 222, 128, .12);
  --soon-bg: rgba(251, 191, 36, .13);
  --bad-bg: rgba(248, 113, 113, .13);
  --shadow-md: 0 4px 16px -4px rgba(0, 0, 0, .6), 0 1px 3px rgba(0, 0, 0, .4);
  --shadow-lg: 0 24px 64px -16px rgba(0, 0, 0, .7), 0 2px 8px rgba(0, 0, 0, .4);
  --app-body: linear-gradient(160deg, #2a2b30, #1b1c20);
  --app-edge: rgba(255, 255, 255, .07);
  --app-shadow: 0 30px 60px -30px rgba(0, 0, 0, .8), inset 0 1px 0 rgba(255, 255, 255, .06);
  --fridge-in: #131519;
  --freezer-in: #10151b;
  --in-edge: rgba(255, 255, 255, .06);
  --in-shade: rgba(0, 0, 0, .5);
  --light-glow: rgba(255, 245, 210, .07);
  --glass: linear-gradient(180deg, rgba(120, 150, 170, .35), rgba(90, 115, 135, .18));
  --glass-hi: rgba(255, 255, 255, .14);
  --drawer-bg: rgba(255, 255, 255, .025);
  --drawer-edge: rgba(140, 170, 195, .14);
  --drawer-handle: rgba(160, 180, 200, .22);
  --target: rgba(96, 165, 250, .1);
  --lid-l: 58%;
  --lid-s: 38%;
  --food-l: 38%;
  --food-s: 32%;
  --rim-l: 26%;
  --tub-hi: rgba(255, 255, 255, .16);
  --chip-bg: #1d1f24;
}

/* ------------------------------------------------------------------ base */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }
html:has(dialog[open]) { overflow: hidden; }

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: 400 14px/1.45 var(--font);
  font-feature-settings: 'cv11', 'ss01';
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
body:not(.is-ready) * { transition: none !important; }
body.is-dragging, body.is-dragging * { cursor: grabbing !important; user-select: none; -webkit-user-select: none; }

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
a { color: var(--accent); }
h1, h2, h3, p { margin: 0; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.icon { flex: none; display: block; }

/* ------------------------------------------------------------------ buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 38px;
  padding: 0 14px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  font-weight: 500;
  font-size: 14px;
  white-space: nowrap;
  transition: background .15s, border-color .15s, transform .1s, opacity .15s;
}
.btn:hover:not(:disabled) { background: var(--surface-2); }
.btn:active:not(:disabled) { transform: scale(.98); }
.btn:disabled { opacity: .45; }
.btn-primary { background: var(--text); color: var(--bg); border-color: transparent; }
.btn-primary:hover:not(:disabled) { background: var(--text); opacity: .88; }
.btn-danger { background: var(--bad); color: #fff; border-color: transparent; }
.btn-danger:hover:not(:disabled) { background: var(--bad); opacity: .9; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.btn-ghost-danger { color: var(--bad); }
.btn-ghost-danger:hover:not(:disabled) { background: var(--bad-bg); color: var(--bad); }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex: none;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text-2);
  transition: background .15s, color .15s;
}
.icon-btn:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.icon-btn:disabled { opacity: .35; }
.icon-btn--lg { width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--border-strong); }

.spinner {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  border-top-color: var(--text-2);
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------------ top bar */

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 6px;
  height: 60px;
  padding: 0 max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left));
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  backdrop-filter: saturate(1.6) blur(16px);
  -webkit-backdrop-filter: saturate(1.6) blur(16px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-weight: 650; font-size: 16px; letter-spacing: -.01em; }
.brand-mark { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; background: var(--text); color: var(--bg); }
.topbar-spacer { flex: 1; }
.btn-add { margin-left: 6px; }

.sync {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-right: 6px;
  font-size: 12.5px;
  color: var(--text-3);
  white-space: nowrap;
}
.sync.warn { color: var(--soon); }
.sync.is-busy .icon { animation: spin 1.2s linear infinite; }

.account { position: relative; }
.btn-signin { height: 36px; padding: 0 12px; }
.avatar-btn { display: grid; place-items: center; width: 36px; height: 36px; padding: 0; border: 0; border-radius: 50%; background: none; }
.avatar-btn:hover .avatar { box-shadow: 0 0 0 3px var(--surface-3); }
.avatar {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--surface-3);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
  transition: box-shadow .15s;
}
.avatar.lg { width: 40px; height: 40px; font-size: 14px; }

.menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 250px;
  padding: 6px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  animation: menu-in .16s var(--ease);
  transform-origin: top right;
}
@keyframes menu-in { from { opacity: 0; transform: scale(.96) translateY(-4px); } }
.menu-profile { display: flex; align-items: center; gap: 12px; padding: 10px 10px 12px; margin-bottom: 4px; border-bottom: 1px solid var(--border); }
.menu-name { font-weight: 600; }
.menu-email { font-size: 12.5px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; }
.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  height: 38px;
  padding: 0 10px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--text-2);
  text-align: left;
}
.menu-item:hover, .menu-item:focus-visible { background: var(--surface-2); color: var(--text); outline: none; }

/* ------------------------------------------------------------------ layout */

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 32px;
  align-items: start;
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px max(16px, env(safe-area-inset-right)) 80px max(16px, env(safe-area-inset-left));
}
.stage { min-width: 0; }
.stage-hint { margin-top: 14px; text-align: center; font-size: 12.5px; color: var(--text-3); min-height: 18px; }

.panel {
  position: sticky;
  top: 84px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-height: calc(100dvh - 104px);
  overflow: auto;
  padding: 2px;
  margin: -2px;
  scrollbar-width: thin;
}

/* ------------------------------------------------------------------ appliance */

.appliance {
  max-width: 700px;
  margin: 0 auto;
  padding: 12px;
  border-radius: 28px;
  background: var(--app-body);
  border: 1px solid var(--app-edge);
  box-shadow: var(--app-shadow);
}
.appliance-seam { height: 12px; position: relative; }
.appliance-seam::after {
  content: '';
  position: absolute;
  left: 18px;
  right: 18px;
  top: 5px;
  height: 2px;
  border-radius: 1px;
  background: var(--app-edge);
}

.unit {
  position: relative;
  border-radius: 18px;
  background: var(--fridge-in);
  box-shadow: inset 0 0 0 1px var(--in-edge), inset 0 14px 30px -20px var(--in-shade);
  overflow: hidden;
  isolation: isolate;
}
.unit--fridge::before {
  content: '';
  position: absolute;
  inset: 0 0 auto;
  height: 160px;
  background: radial-gradient(60% 100% at 50% 0%, var(--light-glow), transparent 70%);
  pointer-events: none;
  z-index: -1;
}
.unit--freezer { background: var(--freezer-in); }
.unit--freezer::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(40% 30% at 12% 0%, rgba(200, 225, 245, .22), transparent 70%),
    radial-gradient(40% 30% at 90% 100%, rgba(200, 225, 245, .16), transparent 70%);
  pointer-events: none;
  z-index: -1;
}

.unit-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px 2px;
  font-size: 12px;
  color: var(--text-3);
}
.unit-title { display: flex; align-items: center; gap: 7px; font-weight: 600; color: var(--text-2); font-size: 13px; }
.unit-sub { font-variant-numeric: tabular-nums; }
.unit-body { padding: 4px 0 8px; }

.comp {
  position: relative;
  display: grid;
  grid-template-columns: 136px minmax(0, 1fr);
  align-items: start;
  gap: 12px;
  padding: 6px 14px 8px;
  transition: background-color .18s, box-shadow .18s;
}
.comp-head { display: flex; align-items: center; gap: 4px; min-width: 0; min-height: 32px; }
.comp-name {
  flex: 1;
  min-width: 0;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--text-2);
  overflow-wrap: anywhere;
}
.comp-add {
  display: grid;
  place-items: center;
  flex: none;
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: 7px;
  background: none;
  color: var(--text-3);
  opacity: 0;
  transition: opacity .15s, background .15s, color .15s;
}
.comp:hover .comp-add, .comp-add:focus-visible { opacity: 1; }
.comp-add:hover { background: var(--surface-3); color: var(--text); }
@media (hover: none) { .comp-add { opacity: .7; } }

.comp-items {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  min-width: 0;
  min-height: 32px;
}
.comp-empty { font-size: 12px; line-height: 32px; color: var(--text-4); transition: color .15s; }

.comp--shelf { padding-bottom: 16px; }
.comp--shelf::after {
  content: '';
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 5px;
  height: 5px;
  border-radius: 3px;
  background: var(--glass);
  box-shadow: inset 0 1px 0 var(--glass-hi), 0 6px 10px -6px var(--in-shade);
  pointer-events: none;
}

.comp--drawer {
  margin: 6px 10px 8px;
  padding: 6px 12px 17px;
  border-radius: 13px;
  background: var(--drawer-bg);
  border: 1px solid var(--drawer-edge);
}
.comp--drawer::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: 5px;
  width: 44px;
  height: 4px;
  margin-left: -22px;
  border-radius: 2px;
  background: var(--drawer-handle);
  pointer-events: none;
}
.unit--fridge .comp--drawer { margin-top: 8px; }

body.is-dragging .comp-empty { color: var(--text-3); }
.comp.is-target { background-color: var(--target); box-shadow: inset 0 0 0 2px var(--accent); border-radius: 13px; }
.comp.is-target .comp-name { color: var(--accent); }

/* ------------------------------------------------------------------ containers */

.stack {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  flex: none;
  max-width: 100%;
  min-height: 32px;
  padding: 0 10px 0 7px;
  border: 0;
  border-radius: 9px;
  background: var(--chip-bg);
  box-shadow: inset 0 0 0 1px var(--border), var(--shadow-sm);
  color: var(--text);
  cursor: grab;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  transition: opacity .2s, filter .2s, transform .18s var(--ease), background .15s, box-shadow .15s;
}
.stack:hover { background: var(--surface); box-shadow: inset 0 0 0 1px var(--border-strong), var(--shadow-md); }
.stack:focus-visible { outline-offset: 1px; }
.stack.is-soon { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--soon) 45%, transparent), var(--shadow-sm); }
.stack.is-expired { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--bad) 50%, transparent), var(--shadow-sm); }
.stack.is-pressing { transform: scale(.96); }
.stack.is-drag-source { opacity: .25; }
.stack.is-dim { opacity: .25; filter: saturate(.2); }

.chip-tub {
  flex: none;
  width: 18px;
  height: 14px;
  border-radius: 2px 2px 4px 4px;
  background: linear-gradient(180deg, hsl(var(--hue) var(--lid-s) var(--lid-l)) 0 4px, hsl(var(--hue) var(--food-s) var(--food-l)) 4px);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .08);
}
.chip-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; font-weight: 550; }
.chip-count { flex: none; font-size: 12px; font-weight: 650; color: var(--text-2); font-variant-numeric: tabular-nums; }
.stack-meta {
  display: flex;
  align-items: center;
  flex: none;
  gap: 4px;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-3);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ok); }
.thaw { color: var(--accent); }
.stack.is-soon .dot { background: var(--soon); }
.stack.is-soon .stack-meta { color: var(--soon); }
.stack.is-expired .dot { background: var(--bad); }
.stack.is-expired .stack-meta { color: var(--bad); }

/* Tub illustration used in the empty state and detail sheet. */
.tub {
  --lid: hsl(var(--hue) var(--lid-s) var(--lid-l));
  --food: hsl(var(--hue) var(--food-s) var(--food-l));
  --rim: hsl(var(--hue) 25% var(--rim-l));
  position: relative;
  display: block;
  width: 64px;
  height: 20px;
  border-radius: 4px 4px 7px 7px;
  background: linear-gradient(180deg, var(--lid) 0 5px, var(--rim) 5px 7px, var(--food) 7px);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .07), inset 0 -3px 5px -3px rgba(0, 0, 0, .18), 0 1px 1px rgba(0, 0, 0, .08);
}
.tub::after {
  content: '';
  position: absolute;
  left: 5px;
  right: 30px;
  top: 9px;
  height: 2px;
  border-radius: 1px;
  background: var(--tub-hi);
}

.drag-ghost {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 1000;
  margin: 0;
  pointer-events: none;
  opacity: 1 !important;
  background: var(--surface);
  filter: drop-shadow(0 12px 16px rgba(0, 0, 0, .25));
  transition: none;
  will-change: transform;
}

.skeleton {
  width: 128px;
  height: 32px;
  border-radius: 9px;
  background: linear-gradient(90deg, var(--surface-3) 25%, var(--surface-2) 50%, var(--surface-3) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.3s linear infinite;
  opacity: .6;
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* ------------------------------------------------------------------ panel */

.search {
  position: relative;
  display: flex;
  align-items: center;
}
.search-icon { position: absolute; left: 12px; color: var(--text-3); pointer-events: none; }
.search input {
  width: 100%;
  height: 42px;
  padding: 0 40px 0 38px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.search input::placeholder { color: var(--text-3); }
.search input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus); }
.search input::-webkit-search-cancel-button { display: none; }
.search-kbd {
  position: absolute;
  right: 10px;
  padding: 1px 7px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  font: 500 11px var(--font);
  color: var(--text-3);
  pointer-events: none;
}
.search input:focus + .search-kbd, .search input:not(:placeholder-shown) + .search-kbd { display: none; }
@media (hover: none) { .search-kbd { display: none; } }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.stat-label { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--text-3); white-space: nowrap; }
.stat-value { font-size: 24px; font-weight: 650; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat.is-warn { background: var(--soon-bg); border-color: transparent; }
.stat.is-warn .stat-label, .stat.is-warn .stat-value { color: var(--soon); }

.panel-body { display: flex; flex-direction: column; gap: 18px; }
.list { display: flex; flex-direction: column; gap: 2px; }
.list-title { margin: 0 4px 6px; font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); }
.list-empty { padding: 10px 4px; font-size: 13px; color: var(--text-3); }

.row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-radius: 12px;
  background: none;
  text-align: left;
  transition: background .15s;
}
.row:hover { background: var(--surface); box-shadow: var(--shadow-sm); }
.row-swatch {
  flex: none;
  width: 10px;
  height: 28px;
  border-radius: 4px;
  background: linear-gradient(180deg, hsl(var(--hue) var(--lid-s) var(--lid-l)) 0 30%, hsl(var(--hue) var(--food-s) var(--food-l)) 30%);
}
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.row-title { font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-count { color: var(--text-3); font-weight: 500; }
.row-sub { font-size: 12.5px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.pill {
  flex: none;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 550;
  background: var(--ok-bg);
  color: var(--ok);
  white-space: nowrap;
}
.pill.is-soon { background: var(--soon-bg); color: var(--soon); }
.pill.is-expired { background: var(--bad-bg); color: var(--bad); }

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 28px 22px 22px;
  border-radius: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  text-align: center;
}
.empty h2 { font-size: 16px; font-weight: 650; margin-top: 4px; }
.empty p { color: var(--text-2); font-size: 13.5px; margin-bottom: 8px; }
.empty .btn { width: 100%; }
.empty-art { display: flex; flex-direction: column-reverse; align-items: center; }
.empty-art .tub + .tub { margin-bottom: -2px; }

.panel-loading { display: flex; flex-direction: column; gap: 10px; }
.skeleton-row {
  height: 46px;
  border-radius: 12px;
  background: linear-gradient(90deg, var(--surface-3) 25%, var(--surface-2) 50%, var(--surface-3) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.3s linear infinite;
  opacity: .6;
}

/* ------------------------------------------------------------------ dialogs */

.dlg {
  width: min(460px, calc(100vw - 32px));
  max-width: none;
  max-height: none;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  overflow: visible;
}
.dlg--confirm { width: min(400px, calc(100vw - 32px)); }
.dlg[data-type="qty"] { width: min(380px, calc(100vw - 32px)); }
.dlg::backdrop {
  background: rgba(8, 8, 12, .42);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}
.dlg[open] .sheet { animation: sheet-in .24s var(--ease); }
.dlg[open]::backdrop { animation: fade-in .24s ease; }
.dlg[data-closing] .sheet { animation: sheet-out .17s ease forwards; }
.dlg[data-closing]::backdrop { animation: fade-out .17s ease forwards; }
@keyframes sheet-in { from { opacity: 0; transform: translateY(8px) scale(.98); } }
@keyframes sheet-out { to { opacity: 0; transform: translateY(6px) scale(.98); } }
@keyframes fade-in { from { opacity: 0; } }
@keyframes fade-out { to { opacity: 0; } }

.sheet {
  display: flex;
  flex-direction: column;
  max-height: calc(100dvh - 48px);
  overflow: auto;
  border-radius: 22px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  overscroll-behavior: contain;
}
.sheet-head {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 20px 16px 4px 22px;
}
.sheet-heading { flex: 1; min-width: 0; padding-top: 4px; }
.sheet-heading h2 { font-size: 18px; font-weight: 650; letter-spacing: -.01em; overflow-wrap: anywhere; }
.sheet-heading p { margin-top: 2px; color: var(--text-3); font-size: 13.5px; }
.sheet-body { padding: 14px 22px 8px; }
.sheet-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 16px 16px;
  margin-top: auto;
}
.sheet-foot--split { justify-content: space-between; border-top: 1px solid var(--border); padding-top: 10px; padding-bottom: 10px; margin-top: 10px; }
.sheet--compact .sheet-body { padding-top: 22px; }
.confirm-title { font-size: 17px; font-weight: 650; }
.confirm-body { margin-top: 8px; color: var(--text-2); }

@media (max-width: 600px) {
  .dlg, .dlg--confirm, .dlg[data-type="qty"] {
    width: 100vw;
    margin: auto 0 0;
  }
  .sheet {
    max-height: calc(100dvh - 24px);
    border-radius: 22px 22px 0 0;
    border-bottom: 0;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .dlg[open] .sheet { animation: sheet-up .3s var(--ease); }
  .dlg[data-closing] .sheet { animation: sheet-down .2s ease forwards; }
  @keyframes sheet-up { from { transform: translateY(40%); opacity: 0; } }
  @keyframes sheet-down { to { transform: translateY(40%); opacity: 0; } }
}

/* detail */

.detail-tubs { display: flex; flex-direction: column-reverse; align-items: center; padding-top: 6px; }
.detail-tubs .tub { width: 44px; height: 15px; }
.detail-tubs .tub::after { display: none; }
.detail-tubs .tub + .tub { margin-bottom: -2px; }

.safety {
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--ok-bg);
  color: var(--ok);
}
.safety.is-soon { background: var(--soon-bg); color: var(--soon); }
.safety.is-expired { background: var(--bad-bg); color: var(--bad); }
.safety-label { display: flex; align-items: center; gap: 8px; font-weight: 650; font-size: 15px; }
.bar { height: 5px; margin: 12px 0 10px; border-radius: 3px; background: color-mix(in srgb, currentColor 18%, transparent); overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: inherit; background: currentColor; transition: width .4s var(--ease); }
.safety-line { font-size: 13px; color: var(--text-2); }

.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; margin: 18px 2px; }
.facts dt { font-size: 12px; color: var(--text-3); margin-bottom: 2px; }
.facts dd { margin: 0; font-weight: 500; }
.facts dd span { display: block; font-weight: 400; font-size: 12.5px; color: var(--text-3); }
.facts-notes { grid-column: 1 / -1; }
.facts-notes dd { font-weight: 400; color: var(--text-2); white-space: pre-wrap; overflow-wrap: anywhere; }

.qty-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 12px 12px 14px;
  margin-bottom: 12px;
  border-radius: 14px;
  background: var(--surface-2);
}
.qty-title { font-weight: 600; }
.qty-sub { font-size: 12.5px; color: var(--text-3); }

.stepper {
  display: inline-flex;
  align-items: center;
  flex: none;
  height: 38px;
  border-radius: 11px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  overflow: hidden;
}
.stepper button {
  display: grid;
  place-items: center;
  width: 36px;
  height: 100%;
  border: 0;
  background: none;
  color: var(--text-2);
  transition: background .15s;
}
.stepper button:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.stepper button:disabled { opacity: .3; }
.stepper output { min-width: 56px; text-align: center; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; padding: 0 4px; }
.stepper output span { color: var(--text-3); font-weight: 500; }
.stepper input {
  width: 48px;
  height: 100%;
  border: 0;
  background: none;
  text-align: center;
  font-weight: 600;
  outline: none;
  -moz-appearance: textfield;
  appearance: textfield;
}
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.stepper:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus); }
.stepper--field { width: 100%; height: 42px; }
.stepper--field input { flex: 1; }

.detail-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.detail-actions .btn { height: 44px; border-radius: 12px; }

.move-grid { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; animation: fade-in .2s ease; }
.move-zone { display: flex; align-items: center; gap: 6px; margin: 0 2px 6px; font-size: 12px; font-weight: 600; color: var(--text-3); }
.move-opts { display: grid; grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 6px; }
.move-opt {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  height: 40px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  font-size: 13.5px;
  font-weight: 500;
  text-align: left;
  transition: background .15s, border-color .15s;
}
.move-opt:hover:not(:disabled) { border-color: var(--accent); background: var(--target); }
.move-opt.is-here { opacity: .5; border-style: dashed; }
.move-n { font-size: 12px; color: var(--text-3); font-variant-numeric: tabular-nums; }

.history { margin-top: 18px; border-top: 1px solid var(--border); padding-top: 12px; }
.history summary {
  cursor: pointer;
  list-style: none;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  display: flex;
  align-items: center;
  gap: 6px;
}
.history summary::-webkit-details-marker { display: none; }
.history summary::after { content: ''; width: 6px; height: 6px; border-right: 1.5px solid; border-bottom: 1.5px solid; transform: rotate(-45deg); transition: transform .15s; margin-left: 2px; }
.history[open] summary::after { transform: rotate(45deg) translate(-2px, -1px); }
.history ol { list-style: none; margin: 10px 0 4px; padding: 0 0 0 14px; border-left: 1px solid var(--border-strong); display: flex; flex-direction: column; gap: 10px; }
.history li { position: relative; display: flex; justify-content: space-between; gap: 12px; font-size: 13px; }
.history li::before { content: ''; position: absolute; left: -18px; top: 6px; width: 7px; height: 7px; border-radius: 50%; background: var(--surface); border: 1.5px solid var(--text-4); }
.h-text { color: var(--text-2); }
.h-time { flex: none; color: var(--text-3); font-size: 12px; font-variant-numeric: tabular-nums; }

/* quantity */

.qty-sheet { text-align: center; }
.qty-route { margin-top: 4px; color: var(--text-3); font-size: 13px; }
.qty-big { display: flex; align-items: center; justify-content: center; gap: 22px; margin: 22px 0 16px; }
.qty-display { display: flex; flex-direction: column; align-items: center; min-width: 72px; }
.qty-display output { font-size: 44px; font-weight: 650; line-height: 1; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.qty-display span { margin-top: 4px; font-size: 12.5px; color: var(--text-3); }
.chips { display: flex; justify-content: center; flex-wrap: wrap; gap: 6px; }
.chip {
  height: 32px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  font-size: 13px;
  font-weight: 500;
  transition: background .15s, color .15s, border-color .15s;
}
.chip:hover { background: var(--surface-2); }
.chip.is-active { background: var(--text); color: var(--bg); border-color: transparent; }
.dlg[data-type="qty"] .sheet-foot .btn { flex: 1; height: 44px; border-radius: 12px; }

/* form */

.form { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field label, .field .label { font-size: 13px; font-weight: 550; color: var(--text-2); }
.optional { font-weight: 400; color: var(--text-3); }
.field input:not([type="radio"]):not(.stepper input), .field select, .field textarea {
  width: 100%;
  min-height: 42px;
  padding: 9px 12px;
  border-radius: 11px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.field textarea { resize: vertical; min-height: 64px; }
.field select { appearance: none; -webkit-appearance: none; padding-right: 34px; background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%), linear-gradient(135deg, var(--text-3) 50%, transparent 50%); background-position: calc(100% - 18px) 18px, calc(100% - 13px) 18px; background-size: 5px 5px; background-repeat: no-repeat; }
.field input:not([type="radio"]):not(.stepper input):focus, .field select:focus, .field textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus); }
.field input:not([type="radio"]):not(.stepper input)[aria-invalid="true"] { border-color: var(--bad); }
.field input:not([type="radio"]):not(.stepper input)[aria-invalid="true"]:focus { box-shadow: 0 0 0 3px var(--bad-bg); }
.field-error { font-size: 12.5px; color: var(--bad); min-height: 0; }
.field-error:empty { display: none; }
.field input::placeholder, .field textarea::placeholder { color: var(--text-4); }

.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch { position: relative; cursor: pointer; }
.swatch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.swatch span {
  display: block;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(180deg, hsl(var(--hue) var(--lid-s) var(--lid-l)) 0 40%, hsl(var(--hue) var(--food-s) var(--food-l)) 40%);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .08);
  transition: transform .15s var(--ease), box-shadow .15s;
}
.swatch:hover span { transform: scale(1.08); }
.swatch input:checked + span { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--text); }
.swatch input:focus-visible + span { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent); }

.form-hint { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); padding: 10px 12px; border-radius: 11px; background: var(--surface-2); }
.form-hint:empty { display: none; }
.form-hint.is-soon { color: var(--soon); background: var(--soon-bg); }
.form-hint.is-expired { color: var(--bad); background: var(--bad-bg); }

/* settings */

.settings { display: flex; flex-direction: column; gap: 26px; padding-bottom: 22px; }
.settings h3 { margin: 0 0 10px; font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); }
.segmented { display: grid; grid-template-columns: repeat(3, 1fr); padding: 3px; border-radius: 12px; background: var(--surface-2); }
.segmented label { position: relative; }
.segmented input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.segmented span { display: grid; place-items: center; height: 34px; border-radius: 9px; font-weight: 500; color: var(--text-2); transition: background .15s, color .15s, box-shadow .15s; }
.segmented input:checked + span { background: var(--surface); color: var(--text); box-shadow: var(--shadow-md); }
.segmented input:focus-visible + span { outline: 2px solid var(--accent); }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.setting-row:first-of-type { padding-top: 0; }
.setting-title { font-weight: 550; }
.setting-desc { font-size: 12.5px; color: var(--text-3); }
.setting-row .stepper output { min-width: 80px; }
.settings-note { margin-top: 10px; font-size: 12.5px; color: var(--text-3); }
.account-card { display: flex; align-items: center; gap: 12px; padding: 12px 12px 12px 14px; border-radius: 14px; background: var(--surface-2); }
.account-info { flex: 1; min-width: 0; }
.data-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.data-actions .btn-ghost-danger { margin-left: auto; }

.setup-steps { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 10px; color: var(--text-2); }
.setup-steps code { font-size: 12.5px; padding: 1px 5px; border-radius: 5px; background: var(--surface-2); }

/* ------------------------------------------------------------------ toasts */

.toasts {
  position: fixed;
  inset: auto 0 0 0;
  width: auto;
  height: auto;
  margin: 0;
  padding: 0 16px calc(20px + env(safe-area-inset-bottom));
  border: 0;
  background: transparent;
  color: inherit;
  overflow: visible;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}
.toasts:popover-open { display: flex; }
.toast {
  display: flex;
  align-items: center;
  gap: 4px;
  max-width: min(520px, 100%);
  min-height: 46px;
  padding: 6px 6px 6px 16px;
  border-radius: 14px;
  background: var(--text);
  color: var(--bg);
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
  animation: toast-in .28s var(--ease);
}
.toast.is-leaving { animation: toast-out .2s ease forwards; }
.toast--error { background: var(--bad); color: #fff; }
.toast-body { flex: 1; display: flex; flex-direction: column; padding: 4px 8px 4px 0; font-size: 13.5px; font-weight: 500; }
.toast-sub { font-weight: 400; opacity: .7; font-size: 12.5px; }
.toast-action {
  height: 34px;
  padding: 0 12px;
  border: 0;
  border-radius: 9px;
  background: color-mix(in srgb, var(--bg) 16%, transparent);
  color: inherit;
  font-weight: 600;
  font-size: 13px;
}
.toast-action:hover { background: color-mix(in srgb, var(--bg) 26%, transparent); }
.toast-close { display: grid; place-items: center; width: 30px; height: 30px; border: 0; border-radius: 8px; background: none; color: inherit; opacity: .6; }
.toast-close:hover { opacity: 1; }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px) scale(.97); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px) scale(.97); } }

/* ------------------------------------------------------------------ responsive */

@media (max-width: 1000px) {
  .layout { grid-template-columns: minmax(0, 1fr); gap: 24px; }
  .panel { position: static; max-height: none; overflow: visible; max-width: 700px; width: 100%; margin: 0 auto; padding: 0; }
}

@media (max-width: 640px) {
  .topbar { gap: 2px; }
  .brand-name, .sync span { display: none; }
  .sync { margin-right: 4px; }
  .btn-add span { display: none; }
  .btn-add { width: 38px; padding: 0; }
  .btn-signin { padding: 0 10px; }
  .layout { padding-top: 16px; }
  .appliance { padding: 8px; border-radius: 22px; }
  .unit { border-radius: 15px; }
  .appliance-seam { height: 8px; }
  .appliance-seam::after { top: 3px; }
  .comp { grid-template-columns: minmax(0, 1fr); gap: 2px; padding-left: 12px; padding-right: 10px; }
  .comp-head { min-height: 26px; }
  .comp--drawer { margin-left: 8px; margin-right: 8px; padding-left: 10px; padding-right: 10px; }
  .field-row { grid-template-columns: 1fr; }
  .facts { grid-template-columns: 1fr 1fr; }
  .stat-value { font-size: 21px; }
}

@media (max-width: 360px) {
  .stat-label { font-size: 11px; }
  .stats { gap: 6px; }
  .stat { padding: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ------------------------------------------------------------------ stage bar */

.stage-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  max-width: 700px;
  margin: 0 auto 10px;
}
.stage-actions { display: flex; align-items: center; gap: 2px; flex: none; }
.btn-sm { height: 32px; padding: 0 11px; font-size: 13px; border-radius: 9px; gap: 6px; }

/* ------------------------------------------------------------------ settings additions */

.select-wrap { position: relative; display: flex; align-items: center; }
.select-wrap > .icon { position: absolute; left: 12px; color: var(--text-3); pointer-events: none; }
.select-wrap select, .lay-kind {
  appearance: none;
  -webkit-appearance: none;
  background-color: var(--surface);
  background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%), linear-gradient(135deg, var(--text-3) 50%, transparent 50%);
  background-size: 5px 5px;
  background-repeat: no-repeat;
  outline: none;
}
.select-wrap select {
  width: 100%;
  height: 42px;
  padding: 0 34px 0 38px;
  border-radius: 11px;
  border: 1px solid var(--border-strong);
  background-position: calc(100% - 18px) 18px, calc(100% - 13px) 18px;
}
.select-wrap select:focus, .lay-kind:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus); }
.setting-row--card { padding: 12px 12px 12px 14px; border: 0; border-radius: 14px; background: var(--surface-2); }
.foot-group { display: flex; gap: 8px; }

/* ------------------------------------------------------------------ layout editor */

.dlg[data-type="layout"] { width: min(580px, calc(100vw - 32px)); }
.lay-zone + .lay-zone { margin-top: 22px; }
.lay-title { display: flex; align-items: center; gap: 7px; margin: 0 0 10px; font-size: 13px; font-weight: 600; color: var(--text-2); }
.lay-title span { margin-left: auto; font-size: 12px; font-weight: 500; color: var(--text-3); font-variant-numeric: tabular-nums; }
.lay-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.lay-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 6px 6px 10px;
  border-radius: 12px;
  background: var(--surface-2);
  animation: fade-in .2s ease;
}
.lay-glyph { flex: none; width: 22px; height: 16px; }
.lay-item--shelf .lay-glyph { background: linear-gradient(180deg, transparent 11px, var(--text-3) 11px 14px, transparent 14px); border-radius: 2px; }
.lay-item--drawer .lay-glyph {
  border: 1.5px solid var(--text-3);
  border-radius: 4px;
  background: linear-gradient(90deg, transparent 6px, var(--text-3) 6px 13px, transparent 13px) left bottom 2px / 100% 1.5px no-repeat;
}
.lay-name {
  flex: 1;
  min-width: 0;
  height: 34px;
  padding: 0 10px;
  border-radius: 9px;
  border: 1px solid transparent;
  background: var(--surface);
  font-weight: 500;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.lay-name:hover { border-color: var(--border-strong); }
.lay-name:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus); }
.lay-kind {
  height: 34px;
  padding: 0 28px 0 10px;
  border-radius: 9px;
  border: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-2);
  background-position: calc(100% - 15px) 14px, calc(100% - 10px) 14px;
}
.lay-count {
  display: grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 11px;
  background: var(--text);
  color: var(--bg);
  font-size: 11px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}
.lay-actions { display: flex; }
.icon-btn--sm { width: 30px; height: 30px; border-radius: 8px; }
.icon-btn--danger:hover:not(:disabled) { color: var(--bad); background: var(--bad-bg); }
.lay-add { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 8px; }
.lay-max { font-size: 12px; color: var(--text-3); }

@media (max-width: 600px) {
  .dlg[data-type="layout"] { width: 100vw; }
  .lay-item { flex-wrap: wrap; }
  .lay-name { flex-basis: calc(100% - 30px); }
  .lay-kind { margin-left: 30px; }
  .lay-actions { margin-left: auto; }
}
/* ------------------------------------------------------------------ sharing */

.fridge-switch { position: relative; min-width: 0; }
.fridge-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  max-width: 100%;
  padding: 6px 10px 6px 6px;
  border: 0;
  border-radius: 12px;
  background: none;
  text-align: left;
  transition: background .15s;
}
.fridge-btn[aria-haspopup]:hover, .fridge-btn[aria-expanded="true"] { background: var(--surface-2); }
.fridge-btn:not([aria-haspopup]) { cursor: default; }
.fridge-btn-icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-2);
}
.fridge-btn-text { display: flex; flex-direction: column; min-width: 0; }
.fridge-btn-name { font-weight: 600; font-size: 14.5px; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fridge-btn-sub { font-size: 12px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fridge-btn-chevron { color: var(--text-3); flex: none; }

.fridge-menu { left: 0; right: auto; min-width: 270px; max-width: min(340px, calc(100vw - 32px)); transform-origin: top left; z-index: 20; }
.fridge-item { height: auto; min-height: 46px; padding: 6px 10px; }
.fridge-item-check { display: grid; place-items: center; width: 18px; flex: none; color: var(--text); }
.fridge-item-text { display: flex; flex-direction: column; min-width: 0; }
.fridge-item-text span { color: var(--text); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fridge-item-text small { font-size: 12px; color: var(--text-3); }
.menu-sep { height: 1px; margin: 6px 4px; background: var(--border); }

.share { display: flex; flex-direction: column; gap: 22px; padding-bottom: 22px; }
.share h3 { display: flex; align-items: center; gap: 8px; margin: 0 0 10px; font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); }
.share h3 span { padding: 1px 7px; border-radius: 999px; background: var(--surface-2); font-size: 11px; letter-spacing: 0; }
.share-note { display: flex; gap: 10px; padding: 12px 14px; border-radius: 12px; background: var(--surface-2); color: var(--text-2); font-size: 13.5px; }
.share-note .icon { margin-top: 2px; color: var(--text-3); }

.people { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.people li { display: flex; align-items: center; gap: 12px; padding: 8px 4px; }
.people .avatar { width: 36px; height: 36px; font-size: 13px; flex: none; }
.person { flex: 1; min-width: 0; }
.person-name { font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person-email { font-size: 12.5px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag { display: inline-block; margin-left: 4px; padding: 1px 7px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); font-size: 11px; font-weight: 600; vertical-align: 1px; }
.tag--owner { background: var(--ok-bg); color: var(--ok); }

.invite-body { color: var(--text-2); font-size: 13.5px; margin-bottom: 12px; }
.link-box {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 5px 5px 12px;
  border-radius: 12px;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text-3);
}
.link-box input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: none;
  font: 500 13px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--text);
  outline: none;
}
.link-box .btn { flex: none; }
.invite-expiry { margin-top: 8px; font-size: 12.5px; color: var(--text-3); }
.invite-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.btn-block { width: 100%; height: 44px; border-radius: 12px; }

/* sign-in dialog */

.dlg[data-type="auth"] .sheet { max-width: 400px; }
fieldset.auth-body { border: 0; margin: 0; min-width: 0; display: flex; flex-direction: column; gap: 14px; }
.auth-lead { font-size: 14px; line-height: 1.5; color: var(--text-2); }
.btn-google { gap: 10px; }
.auth-or { display: flex; align-items: center; gap: 12px; font-size: 12px; color: var(--text-3); text-transform: lowercase; }
.auth-or::before, .auth-or::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; padding: 3px; border-radius: 11px; background: var(--surface-2); }
.auth-tabs button { height: 32px; border: 0; border-radius: 8px; background: none; color: var(--text-2); font-size: 13.5px; font-weight: 550; transition: background .15s, color .15s, box-shadow .15s; }
.auth-tabs button[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.field-label-row { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.field-hint { font-size: 12.5px; color: var(--text-3); }
.password { position: relative; }
.field .password input { padding-right: 44px; }
.password .icon-btn { position: absolute; top: 50%; right: 4px; transform: translateY(-50%); width: 34px; height: 34px; }
.link-btn { padding: 0; border: 0; background: none; color: var(--accent); font-size: 13px; font-weight: 500; }
.link-btn:hover { text-decoration: underline; }
.auth-back { align-self: center; }
.auth-error { font-size: 13px; line-height: 1.45; }
.auth-sent { display: flex; gap: 12px; align-items: flex-start; padding: 14px; border-radius: 12px; background: var(--surface-2); font-size: 14px; line-height: 1.5; color: var(--text-2); }
.auth-sent .icon { color: var(--accent); margin-top: 1px; }

.account-links { display: flex; flex-wrap: wrap; gap: 8px 20px; margin-top: 12px; }
.link-btn--danger { color: var(--bad); }
.delete-account { display: flex; flex-direction: column; gap: 12px; }
.delete-account .share-art { margin-bottom: 0; }
.delete-account .confirm-body { line-height: 1.5; }

/* email verification banner */

.notice { padding: 10px max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left)); }
.notice-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
  max-width: 1400px;
  margin: 0 auto;
  padding: 8px 8px 8px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  font-size: 13.5px;
  color: var(--text-2);
}
.notice-inner > .icon { color: var(--accent); }
.notice-text { flex: 1 1 240px; min-width: 0; }
.notice-actions { display: flex; align-items: center; gap: 4px; margin-left: auto; }

.share-signin { display: flex; flex-direction: column; align-items: center; text-align: center; }
.share-art {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  margin-bottom: 14px;
  border-radius: 18px;
  background: var(--surface-2);
  color: var(--text-2);
}
.share-art.is-bad { background: var(--bad-bg); color: var(--bad); }

@media (max-width: 640px) {
  .stage-actions .btn-sm span { display: none; }
  .stage-actions .btn-sm { width: 36px; padding: 0; }
  .fridge-btn-sub { display: none; }
}
/* ------------------------------------------------------------------ setup guide */

.dlg[data-type="onboarding"] { width: min(560px, calc(100vw - 32px)); }
.onb { min-height: min(560px, calc(100dvh - 48px)); }
.onb-body { flex: 1; padding-top: 22px; }
.onb[data-step="welcome"] .onb-body, .onb[data-step="done"] .onb-body { display: flex; flex-direction: column; justify-content: center; padding-bottom: 22px; }
.onb-body h2 { font-size: 21px; font-weight: 650; letter-spacing: -.01em; }
.onb-lead { margin: 6px 0 18px; color: var(--text-2); }
.onb-foot { align-items: center; border-top: 1px solid var(--border); padding-top: 12px; }
.onb-spacer { flex: 1; }
.onb-foot .btn-primary { min-width: 132px; }

.onb-progress { display: flex; align-items: center; gap: 12px; padding: 18px 22px 0; font-size: 12px; font-weight: 500; color: var(--text-3); white-space: nowrap; }
.onb-bar { flex: 1; height: 4px; border-radius: 2px; background: var(--surface-3); overflow: hidden; }
.onb-bar i { display: block; height: 100%; border-radius: inherit; background: var(--text); transition: width .35s var(--ease); }

.onb-hero { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; padding: 14px 0 6px; }
.onb-hero p { max-width: 400px; color: var(--text-2); }
.onb-tubs { display: flex; flex-direction: column-reverse; align-items: center; margin-bottom: 10px; }
.onb-tubs .tub { width: 76px; height: 24px; }
.onb-tubs .tub + .tub { margin-bottom: -2px; }
.onb-points { list-style: none; margin: 18px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.onb-points li { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 12px; background: var(--surface-2); color: var(--text); font-weight: 500; }
.onb-points .icon { color: var(--text-2); }
.share-art.is-ok { background: var(--ok-bg); color: var(--ok); }

.choices { display: grid; gap: 8px; }
.choices--lang { grid-template-columns: repeat(2, 1fr); }
.choices--theme { grid-template-columns: repeat(3, 1fr); }
.choice {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 14px;
  border-radius: 12px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  cursor: pointer;
  transition: border-color .15s, background .15s, box-shadow .15s;
}
.choice:hover { background: var(--surface-2); }
.choice input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.choice-label { flex: 1; font-weight: 550; }
.choice-check { display: none; color: var(--text); }
.choice:has(input:checked) { border-color: var(--text); box-shadow: inset 0 0 0 1px var(--text); }
.choice:has(input:checked) .choice-check { display: block; }
.choice:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.choice--theme { flex-direction: column; align-items: stretch; padding: 10px; text-align: center; }

.theme-prev { display: flex; flex-direction: column; gap: 5px; height: 76px; padding: 10px; border-radius: 9px; border: 1px solid var(--border); }
.theme-prev i { display: block; height: 10px; border-radius: 3px; }
.theme-prev i:first-child { width: 60%; }
.theme-prev i:nth-child(2) { width: 85%; }
.theme-prev i:nth-child(3) { width: 45%; }
.theme-prev--light { background: #f5f5f3; }
.theme-prev--light i { background: #ffffff; box-shadow: 0 0 0 1px rgba(0, 0, 0, .06); }
.theme-prev--dark { background: #0d0d0f; }
.theme-prev--dark i { background: #26272c; }
.theme-prev--system { background: linear-gradient(135deg, #f5f5f3 50%, #0d0d0f 50%); }
.theme-prev--system i { background: #8a8a93; opacity: .5; }

.onb-fridge { display: flex; gap: 22px; align-items: flex-start; }
.onb-controls { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 18px; }
.onb-label { font-size: 13px; font-weight: 550; color: var(--text-2); margin-bottom: 8px; }
.chips--left { justify-content: flex-start; }
.onb-rows { display: flex; flex-direction: column; border-radius: 14px; background: var(--surface-2); padding: 4px 12px; }
.onb-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 52px; font-weight: 500; }
.onb-row + .onb-row { border-top: 1px solid var(--border); }
.onb-switch { position: relative; cursor: pointer; }
.onb-switch input { position: absolute; opacity: 0; width: 44px; height: 26px; right: 0; margin: 0; cursor: pointer; }
.onb-switch i { position: relative; flex: none; width: 44px; height: 26px; border-radius: 13px; background: var(--surface-3); transition: background .2s; }
.onb-switch i::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: transform .2s var(--ease); }
.onb-switch input:checked + i { background: var(--text); }
.onb-switch input:checked + i::after { transform: translateX(18px); background: var(--bg); }
.onb-switch input:focus-visible + i { outline: 2px solid var(--accent); outline-offset: 2px; }

.mini-fridge {
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 5px;
  width: 128px;
  padding: 6px;
  border-radius: 16px;
  background: var(--app-body);
  border: 1px solid var(--app-edge);
  box-shadow: var(--shadow-md);
  position: sticky;
  top: 0;
}
.mini-unit { display: flex; flex-direction: column; gap: 6px; padding: 8px 7px; border-radius: 11px; box-shadow: inset 0 0 0 1px var(--in-edge); transition: all .25s var(--ease); }
.mini-unit--fridge { background: var(--fridge-in); min-height: 60px; }
.mini-unit--freezer { background: var(--freezer-in); }
.mini-shelf { display: block; height: 18px; border-bottom: 3px solid color-mix(in srgb, var(--accent) 22%, var(--surface-3)); animation: fade-in .25s ease; }
.mini-drawer { display: block; height: 18px; border-radius: 5px; border: 1px solid var(--drawer-edge); background: var(--drawer-bg); animation: fade-in .25s ease; }

.onb-safety { gap: 0; padding-bottom: 0; }
.onb-final { display: flex; flex-direction: column; gap: 8px; margin-top: 22px; }

@media (max-width: 600px) {
  .dlg[data-type="onboarding"] { width: 100vw; }
  .onb { min-height: calc(100dvh - 24px); }
  .onb-fridge { flex-direction: column-reverse; align-items: stretch; }
  .mini-fridge { position: static; flex-direction: row; width: auto; }
  .mini-unit { flex: 1; }
  .choices--theme { grid-template-columns: repeat(3, 1fr); gap: 6px; }
  .theme-prev { height: 60px; }
  .onb-foot .btn-primary { min-width: 0; }
}
.invite-qr { display: flex; align-items: center; gap: 14px; margin-top: 14px; padding: 12px; border-radius: 14px; background: var(--surface-2); }
.invite-qr p { flex: 1; font-size: 13px; color: var(--text-2); }
.qr { flex: none; width: 132px; height: 132px; padding: 6px; border-radius: 10px; background: #ffffff; }
.qr:empty { background: linear-gradient(90deg, #eee 25%, #f6f6f6 50%, #eee 75%); background-size: 200% 100%; animation: shimmer 1.3s linear infinite; }
.qr svg { display: block; width: 100%; height: 100%; }
.qr svg path { fill: #111; }