/* Shelf Life — one stylesheet, three themes. Every color and font comes from the variables below. */

:root,
[data-theme="playful"] {
  --bg: #FFF6EA; --ink: #1F1A3A; --sub: #5A5470; --card: #FFFFFF; --line: #1F1A3A; --soft-line: #E9E2D6;
  --accent: #6C4CF1; --accent-ink: #FFFFFF; --accent-soft: rgba(108, 76, 241, 0.28);
  --warm: #FF7A2F; --warm-ink: #1F1A3A;
  --good: #1E9E5A; --soon: #E89A00; --gone: #E5383B;
  --good-bg: #E4F6EC; --soon-bg: #FFF1CC; --gone-bg: #FFE1E1;
  --good-text: #14653A; --soon-text: #7A4F00; --gone-text: #A61B1E;
  --font-h: "Fredoka", system-ui, sans-serif; --font-b: "Nunito", system-ui, sans-serif;
  --h-weight: 700; --radius: 22px; --radius-sm: 14px;
  --border: 2px solid #1F1A3A; --shadow: 0 4px 0 #1F1A3A; --shadow-sm: 0 3px 0 #1F1A3A;
  --field-bg: #FFFFFF;
}

[data-theme="kitchen"] {
  --bg: #F4EDE1; --ink: #2E241B; --sub: #6B5A49; --card: #FBF7F0; --line: #D9CBB6; --soft-line: #E5D9C6;
  --accent: #8A5A3B; --accent-ink: #FFFFFF; --accent-soft: rgba(138, 90, 59, 0.25);
  --warm: #6E7F5C; --warm-ink: #FFFFFF;
  --good: #557A3E; --soon: #B77812; --gone: #A8402B;
  --good-bg: #E7EEDD; --soon-bg: #F6E6C6; --gone-bg: #F3D9D1;
  --good-text: #3D5A2B; --soon-text: #6E4708; --gone-text: #8A2F1E;
  --font-h: "Fraunces", Georgia, serif; --font-b: "DM Sans", system-ui, sans-serif;
  --h-weight: 600; --radius: 14px; --radius-sm: 10px;
  --border: 1px solid #D9CBB6; --shadow: none; --shadow-sm: none;
  --field-bg: #FBF7F0;
}

[data-theme="sleek"] {
  --bg: #0E1014; --ink: #F2F4F7; --sub: #A3ACBA; --card: #181B22; --line: #2A2F3A; --soft-line: #262B35;
  --accent: #C6F432; --accent-ink: #0E1014; --accent-soft: rgba(198, 244, 50, 0.22);
  --warm: #181B22; --warm-ink: #F2F4F7;
  --good: #3DDC84; --soon: #FFC53D; --gone: #FF6B6B;
  --good-bg: #1F242D; --soon-bg: #1F242D; --gone-bg: #1F242D;
  --good-text: #3DDC84; --soon-text: #FFC53D; --gone-text: #FF6B6B;
  --font-h: "Sora", system-ui, sans-serif; --font-b: "Inter", system-ui, sans-serif;
  --h-weight: 600; --radius: 18px; --radius-sm: 12px;
  --border: 1px solid #2A2F3A; --shadow: none; --shadow-sm: none;
  --field-bg: #181B22;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font-b);
  font-size: 16px; line-height: 1.4; -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--accent); }
[data-theme="playful"] a { color: #4B2FC0; }
h1, h2, h3 { font-family: var(--font-h); font-weight: var(--h-weight); margin: 0; line-height: 1.15; }
h1 { font-size: 30px; }
h2 { font-size: 20px; }
h3 { font-size: 17px; }
[data-theme="kitchen"] h1 { font-style: italic; }
.sub { color: var(--sub); font-size: 14px; }
.small { font-size: 13px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.screen {
  max-width: 720px; margin: 0 auto;
  padding: calc(20px + env(safe-area-inset-top)) 18px calc(110px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 18px;
}
.screen.bare { padding-bottom: 40px; min-height: 100vh; justify-content: center; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }

/* Header */
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.top .hello { font-size: 14px; font-weight: 700; color: var(--sub); }
.brand { color: var(--ink); }
[data-theme="playful"] .brand { color: var(--accent); }
.avatar {
  width: 44px; height: 44px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent); color: var(--accent-ink); font-family: var(--font-h); font-weight: 700; font-size: 17px;
  border: var(--border); text-decoration: none;
}

/* Cards */
.card { background: var(--card); border: var(--border); box-shadow: var(--shadow); border-radius: var(--radius); padding: 16px; }
.card.flat { box-shadow: none; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 18px;
  border-radius: var(--radius-sm); border: var(--border); background: var(--card); color: var(--ink);
  font: 800 15px var(--font-b); text-decoration: none; cursor: pointer;
}
[data-theme="kitchen"] .btn, [data-theme="sleek"] .btn { font-weight: 700; }
.btn.primary { background: var(--accent); color: var(--accent-ink); box-shadow: var(--shadow-sm); }
[data-theme="kitchen"] .btn.primary, [data-theme="sleek"] .btn.primary { border-color: var(--accent); }
.btn.good { background: var(--good); color: #fff; box-shadow: var(--shadow-sm); }
[data-theme="sleek"] .btn.good { color: #0E1014; border-color: var(--good); }
.btn.danger { color: var(--gone-text); }
.btn.block { width: 100%; }
.btn.small { min-height: 40px; padding: 0 12px; font-size: 14px; }
.btn:active { transform: translateY(2px); box-shadow: none; }
.linkbtn { background: none; border: 0; padding: 8px 0; color: var(--accent); font: 700 14px var(--font-b); cursor: pointer; text-decoration: underline; }
[data-theme="playful"] .linkbtn { color: #4B2FC0; }
.iconbtn {
  width: 44px; height: 44px; border-radius: 50%; border: var(--border); background: var(--card); color: var(--ink);
  display: inline-flex; align-items: center; justify-content: center; padding: 0; cursor: pointer; text-decoration: none;
}

/* Search pill */
.searchbar {
  display: flex; align-items: center; gap: 10px; height: 50px; padding: 0 16px; border-radius: 999px;
  background: var(--card); border: var(--border); color: var(--sub);
}
.searchbar input { flex: 1; border: 0; outline: none; background: transparent; font: 16px var(--font-b); color: var(--ink); min-width: 0; }

/* Morning numbers */
.summary {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; padding: 14px 18px;
  background: var(--warm); color: var(--warm-ink); border: var(--border); box-shadow: var(--shadow); border-radius: var(--radius);
}
[data-theme="kitchen"] .summary { border: 0; }
.summary .n { font-family: var(--font-h); font-size: 28px; font-weight: 700; line-height: 1; }
.summary .l { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 800; margin-top: 4px; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: 0 0 auto; display: inline-block; }
.dot.good { background: var(--good); } .dot.soon { background: var(--soon); } .dot.gone { background: var(--gone); }
[data-theme="playful"] .summary .dot { border: 2px solid #1F1A3A; }

/* Use-first strip */
.strip { display: flex; gap: 10px; overflow-x: auto; padding: 2px 2px 8px; margin: 0 -2px; scroll-snap-type: x proximity; }
.strip::-webkit-scrollbar { display: none; }
.mini {
  flex: 0 0 auto; width: 100px; padding: 10px 8px; display: flex; flex-direction: column; align-items: center; gap: 6px;
  background: var(--card); border: var(--border); box-shadow: var(--shadow); border-radius: var(--radius-sm);
  color: var(--ink); text-decoration: none; scroll-snap-align: start; text-align: center;
}

/* Place tabs */
.tabs { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: 0 0 auto; display: inline-flex; align-items: center; gap: 6px; height: 42px; padding: 0 16px; border-radius: 999px;
  background: var(--card); color: var(--ink); border: var(--border); font-weight: 800; font-size: 15px; text-decoration: none;
}
.tab .n { opacity: 0.7; font-weight: 600; }
.tab.on { background: var(--accent); color: var(--accent-ink); }
[data-theme="kitchen"] .tab.on, [data-theme="sleek"] .tab.on { border-color: var(--accent); }

/* Item grid */
.grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 600px) { .grid { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
.tile {
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 6px; text-align: center;
  background: var(--card); border: var(--border); box-shadow: var(--shadow); border-radius: var(--radius);
  color: var(--ink); text-decoration: none; min-width: 0;
}
.tile .name, .mini .name { font-weight: 800; font-size: 13px; line-height: 1.15; overflow-wrap: break-word; hyphens: auto; }
[data-theme="kitchen"] .tile .name, [data-theme="sleek"] .tile .name { font-weight: 700; }
/* Warm kitchen: items sit on wooden shelves */
[data-theme="kitchen"] .grid { column-gap: 0; row-gap: 18px; }
[data-theme="kitchen"] .tile {
  background: transparent; border: 0; border-radius: 0; box-shadow: 0 4px 0 #7A4E2E;
  border-bottom: 9px solid #A8724A; padding-bottom: 10px;
}

/* Pictures with freshness ring */
.pic {
  width: 68px; height: 68px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  position: relative; overflow: hidden; flex: 0 0 auto;
}
.pic.sm { width: 60px; height: 60px; }
.pic.lg { width: 220px; height: 220px; }
[data-theme="playful"] .pic { border: 3px solid var(--ring); background: var(--ring-bg); }
[data-theme="sleek"] .pic { background: #1F242D; box-shadow: 0 0 0 2px var(--ring), 0 0 22px color-mix(in srgb, var(--ring) 35%, transparent); }
[data-theme="kitchen"] .pic { background: transparent; overflow: visible; align-items: flex-end; }
[data-theme="kitchen"] .pic::after {
  content: ""; position: absolute; top: 2px; right: 2px; width: 13px; height: 13px; border-radius: 50%;
  background: var(--ring); border: 2px solid var(--bg);
}
[data-theme="kitchen"] .pic.lg { background: var(--card); border-radius: var(--radius); align-items: center; overflow: hidden; }
[data-theme="kitchen"] .pic.lg::after { top: 14px; right: 14px; width: 18px; height: 18px; }
.f-good { --ring: var(--good); --ring-bg: var(--good-bg); }
.f-soon { --ring: var(--soon); --ring-bg: var(--soon-bg); }
.f-gone { --ring: var(--gone); --ring-bg: var(--gone-bg); }
.pic svg { position: relative; z-index: 1; }
.liquid {
  position: absolute; left: 0; right: 0; bottom: 0; background: var(--accent-soft);
  border-top: 3px solid var(--accent); z-index: 2; transition: height 0.25s ease;
}
.lvl-1 { height: 25%; } .lvl-2 { height: 50%; } .lvl-3 { height: 75%; } .lvl-4 { height: 100%; border-top: 0; }

/* Freshness word, amount */
.fresh { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 800; color: var(--ink); }
[data-theme="sleek"] .fresh.good { color: var(--good); }
[data-theme="sleek"] .fresh.soon { color: var(--soon); }
[data-theme="sleek"] .fresh.gone { color: var(--gone); }
.amount { display: inline-flex; align-items: center; gap: 3px; }
.pip { width: 10px; height: 10px; border-radius: 3px; background: var(--soft-line); }
[data-theme="playful"] .pip { background: #E3DCF5; }
.pip.on { background: var(--accent); }
.amount .lbl { font-size: 11px; font-weight: 800; color: var(--sub); margin-left: 4px; }
.count { font-size: 12px; font-weight: 800; padding: 2px 9px; border-radius: 999px; background: var(--bg); color: var(--ink); }
[data-theme="sleek"] .count { background: #262B35; }
.pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px;
  font-size: 13px; font-weight: 800; background: var(--ring-bg); color: var(--ring-text, var(--ink)); border: 2px solid var(--ring);
}
.f-good .pill, .pill.f-good { --ring-text: var(--good-text); }
.f-soon .pill, .pill.f-soon { --ring-text: var(--soon-text); }
.f-gone .pill, .pill.f-gone { --ring-text: var(--gone-text); }

/* Empty states */
.empty { text-align: center; padding: 28px 16px; color: var(--sub); }
.empty h2 { color: var(--ink); margin-bottom: 6px; }

/* Bottom bar */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: var(--card); border-top: var(--border);
  padding: 8px 18px calc(10px + env(safe-area-inset-bottom));
}
.nav .in { max-width: 520px; margin: 0 auto; display: flex; justify-content: space-between; align-items: flex-start; }
.nav a {
  width: 68px; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 0;
  color: var(--sub); text-decoration: none; font-size: 11px; font-weight: 800;
}
.nav a.on { color: var(--accent); }
[data-theme="playful"] .nav a.on { color: #4B2FC0; }
[data-theme="kitchen"] .nav a.on { color: var(--ink); }
.nav a.big {
  width: 62px; height: 62px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); justify-content: center;
  margin-top: -26px; border: var(--border); box-shadow: var(--shadow);
}
[data-theme="playful"] .nav a.big { border-width: 3px; color: #fff; }
[data-theme="sleek"] .nav a.big { border-color: var(--accent); box-shadow: 0 0 24px rgba(198, 244, 50, 0.4); }
[data-theme="kitchen"] .nav a.big { border-color: var(--accent); box-shadow: 0 6px 16px rgba(46, 36, 27, 0.25); }

/* Toast messages */
.toasts { position: fixed; left: 12px; right: 12px; bottom: calc(96px + env(safe-area-inset-bottom)); z-index: 30; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  pointer-events: auto; max-width: 520px; width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: #1F1A3A; color: #fff; border-radius: 14px; padding: 12px 14px; font-weight: 700; font-size: 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}
[data-theme="sleek"] .toast { background: #F2F4F7; color: #0E1014; }
.toast.error { background: #A61B1E; color: #fff; }
.toast button {
  min-height: 36px; padding: 0 12px; border-radius: 10px; border: 0; background: #fff; color: #1F1A3A; font: 800 14px var(--font-b); cursor: pointer;
}
[data-theme="sleek"] .toast button { background: #0E1014; color: #F2F4F7; }

/* Forms */
label.field, .field { display: flex; flex-direction: column; gap: 6px; font-weight: 800; font-size: 14px; }
.field .help { font-weight: 500; color: var(--sub); font-size: 13px; }
.errorlist { list-style: none; margin: 0; padding: 0; color: var(--gone-text); font-weight: 700; font-size: 13px; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="date"], input[type="search"], select {
  width: 100%; min-height: 50px; padding: 0 14px; border-radius: var(--radius-sm); border: var(--border); background: var(--field-bg);
  color: var(--ink); font: 16px var(--font-b); -webkit-appearance: none; appearance: none;
}
input[type="date"] { display: block; padding-top: 12px; }
select { background-image: linear-gradient(45deg, transparent 50%, var(--sub) 50%), linear-gradient(135deg, var(--sub) 50%, transparent 50%);
  background-position: calc(100% - 20px) 22px, calc(100% - 14px) 22px; background-size: 6px 6px; background-repeat: no-repeat; }
input:focus-visible, select:focus-visible, .btn:focus-visible, a:focus-visible, button:focus-visible {
  outline: 3px solid var(--accent); outline-offset: 2px;
}
.check { display: flex; align-items: center; gap: 10px; font-weight: 700; min-height: 44px; }
.check input { width: 22px; height: 22px; accent-color: var(--accent); }

/* Choice chips (radio buttons) */
.choices { display: flex; flex-wrap: wrap; gap: 8px; }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice span {
  display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 14px; border-radius: 999px;
  border: var(--border); background: var(--card); font-weight: 800; font-size: 14px; cursor: pointer;
}
.choice input:checked + span { background: var(--accent); color: var(--accent-ink); }
[data-theme="kitchen"] .choice input:checked + span, [data-theme="sleek"] .choice input:checked + span { border-color: var(--accent); }
.choice input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 2px; }

/* Category picker: picture grid */
.cats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
@media (min-width: 600px) { .cats { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
.cat input { position: absolute; opacity: 0; pointer-events: none; }
.cat span {
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 4px; min-height: 84px; text-align: center;
  border: var(--border); border-radius: var(--radius-sm); background: var(--card); font-size: 11px; font-weight: 800; cursor: pointer; line-height: 1.1;
}
.cat input:checked + span { background: var(--accent-soft); outline: 3px solid var(--accent); outline-offset: -1px; }
.cat input:focus-visible + span { outline: 3px solid var(--accent); }

/* Level control */
.levels { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.levels button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); box-shadow: var(--shadow-sm); }
input[type="range"] { width: 100%; height: 36px; accent-color: var(--accent); margin: 0; }
.stepper { display: flex; align-items: center; gap: 14px; }
.stepper .num { font-family: var(--font-h); font-size: 34px; font-weight: 700; min-width: 64px; text-align: center; }

/* Detail rows */
.rows { display: flex; flex-direction: column; }
.rows > div { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--soft-line); }
.rows > div:last-child { border-bottom: 0; }
.rows .k { font-size: 13px; font-weight: 800; color: var(--sub); }
.rows .v { font-size: 15px; font-weight: 700; text-align: right; }
details > summary { cursor: pointer; list-style: none; }
details > summary::-webkit-details-marker { display: none; }

/* People / PIN */
.people { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.person {
  display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 20px 10px; border-radius: var(--radius);
  background: var(--card); border: var(--border); box-shadow: var(--shadow); text-decoration: none; color: var(--ink); font-weight: 800; font-size: 17px;
}
.person .avatar { width: 64px; height: 64px; font-size: 26px; }
.pinbox { font-family: var(--font-h); font-size: 34px; letter-spacing: 18px; text-align: center; }
.keypad { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; max-width: 320px; margin: 0 auto; width: 100%; }
.keypad button { min-height: 64px; font-size: 26px; font-family: var(--font-h); }

/* Lists in settings */
.list { display: flex; flex-direction: column; }
.list > .li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--soft-line); }
.list > .li:last-child { border-bottom: 0; }
.inline { display: inline; margin: 0; }
.copy { font: 14px ui-monospace, Menlo, monospace; word-break: break-all; background: var(--bg); padding: 10px; border-radius: 10px; }
table.plain { width: 100%; border-collapse: collapse; font-size: 14px; }
table.plain th, table.plain td { text-align: left; padding: 10px 6px; border-bottom: 1px solid var(--soft-line); vertical-align: top; }
.scroll-x { overflow-x: auto; }

/* ---------------------------------------------------------------------------
   Place scenes: items sit on fridge, freezer, pantry or garage shelves.
   Each scene sets --scene-bg, --shelf, --shelf-edge and --scene-ink.
   --------------------------------------------------------------------------- */
.scene {
  --scene-ink: #1F1A3A; --scene-sub: #4A4560;
  position: relative; overflow: hidden; border-radius: var(--radius);
  padding: 30px 12px 14px; background: var(--scene-bg); color: var(--scene-ink);
}
[data-theme="playful"] .scene { border: 2px solid #1F1A3A; box-shadow: 0 4px 0 #1F1A3A; }
[data-theme="kitchen"] .scene { border: 1px solid var(--line); }
[data-theme="sleek"] .scene { border: 1px solid var(--line); --scene-ink: #F2F4F7; --scene-sub: #B8C0CC; }
/* Shelves are drawn behind each 172px row, so a half-full row still gets a whole shelf,
   and an almost-empty place still shows two shelves. */
.scene .grid {
  position: relative; z-index: 1; column-gap: 0; row-gap: 22px; grid-auto-rows: 172px;
  min-height: 366px; margin: 0 -12px; padding: 0 12px;
  background: repeating-linear-gradient(to bottom,
    transparent 0 162px, var(--shelf) 162px 172px, var(--shelf-edge) 172px 177px, transparent 177px 194px);
}
.scene .tile {
  background: transparent; border: 0; border-radius: 0; box-shadow: none; color: var(--scene-ink);
  padding: 4px 4px 14px; justify-content: flex-end; gap: 4px; overflow: hidden;
}
.scene .tile .name { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.scene .tile .fresh, .scene .tile .amount .lbl { color: var(--scene-ink); }
.scene .count { background: rgba(255, 255, 255, 0.75); }
[data-theme="sleek"] .scene .count { background: rgba(0, 0, 0, 0.35); }
.scene .shelf { display: block; height: 10px; background: var(--shelf); box-shadow: 0 5px 0 var(--shelf-edge); margin: 0 -12px; }
.scene-empty { position: relative; z-index: 1; text-align: center; padding: 26px 10px 18px; color: var(--scene-ink); }
.scene-empty h2 { margin-bottom: 6px; }
.scene-empty p { color: var(--scene-sub); margin: 0 0 14px; }

/* Fridge: cool white walls, glass shelves, a warm light at the top */
.scene-fridge {
  --scene-bg: #EEF6FB; --shelf: rgba(160, 205, 228, 0.85); --shelf-edge: #7FB5D2;
  box-shadow: inset 12px 0 0 #DCEAF3, inset -12px 0 0 #DCEAF3;
}
[data-theme="playful"] .scene-fridge { box-shadow: inset 12px 0 0 #DCEAF3, inset -12px 0 0 #DCEAF3, 0 4px 0 #1F1A3A; }
.scene-fridge::before {
  content: ""; position: absolute; top: 8px; left: 50%; width: 46%; height: 10px; transform: translateX(-50%);
  border-radius: 999px; background: #FFF6C9; box-shadow: 0 0 18px 6px rgba(255, 240, 170, 0.75);
}


/* Freezer: frost, snowflakes and icicles along the top */
.scene-freezer {
  --scene-bg: #DDF0FA; --shelf: #F4FBFF; --shelf-edge: #9CCBE3;
  background-color: var(--scene-bg);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='70' height='70' viewBox='0 0 70 70'%3E%3Cg stroke='%23FFFFFF' stroke-width='1.6' stroke-linecap='round' opacity='0.7'%3E%3Cpath d='M18 10v16M10 18h16M12.5 12.5l11 11M23.5 12.5l-11 11'/%3E%3Cpath d='M52 44v12M46 50h12M48 46l8 8M56 46l-8 8'/%3E%3C/g%3E%3C/svg%3E");
  padding-top: 40px;
}
.scene-freezer::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 26px; z-index: 2;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='26' viewBox='0 0 48 26'%3E%3Cpath d='M0 0H48V5H44L41 20L38 5H31L28.5 13L26 5H17L13.5 25L10 5H5L3 11L1 5H0Z' fill='%23FFFFFF' stroke='%23A9D3EA' stroke-width='1.2' stroke-linejoin='round'/%3E%3C/svg%3E") repeat-x top left;
}
.scene-freezer::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  box-shadow: inset 0 0 28px 6px rgba(255, 255, 255, 0.9);
}
[data-theme="playful"] .scene-freezer .tile .pic, [data-theme="kitchen"] .scene-freezer .tile .pic { box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.7); }

/* Pantry: warm wooden back panel and wooden shelves */
.scene-pantry {
  --scene-bg: #F3E2C6; --shelf: #B57C4B; --shelf-edge: #7E5230;
  background-color: var(--scene-bg);
  background-image: repeating-linear-gradient(90deg, rgba(126, 82, 48, 0.08) 0 2px, transparent 2px 64px);
}
.scene-pantry::before {
  /* little scalloped shelf-paper trim along the top */
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 14px;
  background: radial-gradient(circle at 10px 0, #E46F5A 9px, transparent 9.5px) repeat-x;
  background-size: 20px 14px;
}

/* Garage: pegboard wall, steel shelves, a strip of hazard tape */
.scene-garage {
  --scene-bg: #DCD6CC; --shelf: #8E9AA7; --shelf-edge: #5D6977;
  background-color: var(--scene-bg);
  background-image: radial-gradient(circle, #B4AC9F 2px, transparent 2.6px);
  background-size: 20px 20px; background-position: 10px 18px;
}
.scene-garage::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 10px;
  background: repeating-linear-gradient(-45deg, #F2C230 0 12px, #2B2B2B 12px 24px);
}


/* Plain: just the theme's own cards */
.scene-plain { --scene-bg: transparent; --shelf: transparent; --shelf-edge: transparent; padding: 0; border: 0 !important; box-shadow: none !important; overflow: visible; }
.scene-plain .grid { column-gap: 10px; row-gap: 10px; grid-auto-rows: auto; min-height: 0; margin: 0; padding: 0; background: none; }
.scene-plain .tile { background: var(--card); border: var(--border); box-shadow: var(--shadow); border-radius: var(--radius); padding: 12px 6px; color: var(--ink); justify-content: flex-start; }
.scene-plain .count { background: var(--bg); }
.scene-plain .tile .fresh, .scene-plain .tile .amount .lbl { color: inherit; }

/* Dark & sleek versions of the scenes */
[data-theme="sleek"] .scene-fridge { --scene-bg: #17212B; --shelf: rgba(110, 170, 210, 0.45); --shelf-edge: #3E6683;
  box-shadow: inset 12px 0 0 #1D2A36, inset -12px 0 0 #1D2A36; }
[data-theme="sleek"] .scene-fridge::before { background: #CFE8FF; box-shadow: 0 0 22px 8px rgba(140, 200, 255, 0.45); }
[data-theme="sleek"] .scene-freezer { --scene-bg: #142330; --shelf: #2B4357; --shelf-edge: #1C2E3D;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='70' height='70' viewBox='0 0 70 70'%3E%3Cg stroke='%23BFE3FF' stroke-width='1.4' stroke-linecap='round' opacity='0.16'%3E%3Cpath d='M18 10v16M10 18h16M12.5 12.5l11 11M23.5 12.5l-11 11'/%3E%3Cpath d='M52 44v12M46 50h12M48 46l8 8M56 46l-8 8'/%3E%3C/g%3E%3C/svg%3E"); }
[data-theme="sleek"] .scene-freezer::after { box-shadow: inset 0 0 28px 6px rgba(140, 200, 255, 0.25); }
[data-theme="sleek"] .scene-pantry { --scene-bg: #2A2119; --shelf: #6E4A2C; --shelf-edge: #3E2917; }
[data-theme="sleek"] .scene-garage { --scene-bg: #24262A; --shelf: #4E5864; --shelf-edge: #2E353D;
  background-image: radial-gradient(circle, #3A3D43 2px, transparent 2.6px); }
[data-theme="sleek"] .scene-plain .tile { color: var(--ink); }

/* Scene picker swatches in the place form */
.scene-picks { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.scene-pick input { position: absolute; opacity: 0; pointer-events: none; }
.scene-pick > span { display: flex; flex-direction: column; gap: 6px; font-weight: 800; font-size: 14px; cursor: pointer; padding: 6px; border-radius: var(--radius-sm); border: 2px solid transparent; }
.scene-pick input:checked + span { border-color: var(--accent); background: var(--accent-soft); }
.scene-pick input:focus-visible + span { outline: 3px solid var(--accent); }
.scene.swatch { height: 64px; padding: 0; display: flex; align-items: flex-end; box-shadow: none !important; }
.scene.swatch .shelf { margin: 0 0 14px; width: 100%; }
.scene-plain.swatch { background: var(--card); border: var(--border) !important; }

/* Product photos instead of drawings */
.pic img { width: 74%; height: 74%; object-fit: contain; position: relative; z-index: 1; border-radius: 8px; }
.pic.lg img { width: 70%; height: 70%; }

/* Demo banner */
.demo-bar {
  position: sticky; top: 0; z-index: 25; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: calc(8px + env(safe-area-inset-top)) 16px 8px; background: #FFD84D; color: #1F1A3A; font-size: 13px;
}
.demo-bar button { min-height: 34px; padding: 0 12px; border-radius: 10px; border: 2px solid #1F1A3A; background: #fff; font: 800 13px var(--font-b); cursor: pointer; }
.demo-bar + .screen { padding-top: 16px; }

/* Shopping list rows */
.listrow {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 52px; padding: 4px 0;
  background: none; border: 0; color: var(--ink); font: inherit; text-align: left; cursor: pointer;
}
.listrow.done { color: var(--sub); text-decoration: line-through; }
.tick { width: 26px; height: 26px; flex: 0 0 auto; border-radius: 8px; border: var(--border); background: var(--card); position: relative; }
[data-theme="kitchen"] .tick, [data-theme="sleek"] .tick { border-width: 2px; border-color: var(--sub); }
.tick.on { background: var(--good); border-color: var(--good); }
.tick.on::after { content: ""; position: absolute; left: 8px; top: 3px; width: 6px; height: 12px; border: solid #fff; border-width: 0 3px 3px 0; transform: rotate(45deg); }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.nav a.big, .nav a.big.on { color: var(--accent-ink) !important; }
[data-theme="playful"] .nav a.big, [data-theme="playful"] .nav a.big.on { color: #fff !important; }

/* Store mode */
/* Let the scanner size its own video: forcing a size or "cover" crop moves the video
   under the scanner's target box, so the box looks off-center. */
.reader { width: 100%; border-radius: var(--radius); overflow: hidden; background: #111; position: relative; border: var(--border); }
#reader { width: 100%; }
#reader video { display: block; width: 100% !important; height: auto !important; }
.reader .hint { position: absolute; inset: auto 0 12px 0; text-align: center; color: #fff; font-weight: 800; font-size: 14px; text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6); z-index: 2; }
.reader-off { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; aspect-ratio: auto; min-height: 150px; padding: 18px; background: var(--card); color: var(--ink); text-align: center; }
.scanflash { animation: flash 0.6s ease; }
@keyframes flash { 0% { background: var(--good-bg); } 100% { background: var(--card); } }
.tray .li { gap: 12px; }
.tray .name { font-weight: 800; }
.badge { display: inline-flex; align-items: center; justify-content: center; min-width: 26px; height: 26px; padding: 0 8px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); font-weight: 800; font-size: 13px; }

/* Add: the AI shortcuts */
.ways { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.way {
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 16px 10px; text-align: center;
  background: var(--card); border: var(--border); box-shadow: var(--shadow); border-radius: var(--radius); color: var(--ink); text-decoration: none;
}
.way strong { font-size: 16px; }
.dropzone {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; min-height: 170px; padding: 18px;
  border: 3px dashed var(--accent); border-radius: var(--radius); background: var(--accent-soft); text-align: center; cursor: pointer; font-weight: 800;
}
.dropzone input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.thumbs { display: flex; gap: 8px; flex-wrap: wrap; }
.thumbs img { width: 72px; height: 96px; object-fit: cover; border-radius: 10px; border: var(--border); }
.busy { display: none; align-items: center; gap: 10px; font-weight: 800; }
.busy.on { display: flex; }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--accent-soft); border-top-color: var(--accent); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.confirm-row { display: grid; grid-template-columns: 28px 52px minmax(0, 1fr); gap: 10px; align-items: start; }
.confirm-row.off { opacity: 0.45; }
.confirm-row .keep { width: 24px; height: 24px; margin-top: 14px; accent-color: var(--accent); }
.confirm-fields { display: grid; grid-template-columns: minmax(0, 1fr) 72px; gap: 8px; }
.confirm-fields .wide { grid-column: 1 / -1; }
.confirm-fields select, .confirm-fields input { min-height: 44px; font-size: 15px; }
