/* ==================================================================
   HomeBoard design system
   - Dark default, light theme via body.theme-light
   - Accent variants via body.accent-* classes
   - Full-viewport responsive layout: sidebar (desktop), bottom nav (mobile)
   ================================================================== */

:root {
  /* Dark palette */
  --bg: #1a1a1a;
  --surface: #232323;
  --surface-2: #2a2a2a;
  --card: #2f2f2f;
  --border: #3a3a3a;
  --border-strong: #4a4a4a;
  --text-main: #ececec;
  --text-secondary: #b4b4b4;
  --text-muted: #8a8a8a;

  /* Accent (green default) */
  --accent: #10a37f;
  --accent-hover: #0d8f70;
  --accent-soft: #1f3f38;
  --accent-soft-2: #1a3631;
  --accent-text: #d7fff3;

  --danger: #ef4444;
  --danger-soft: #3a1f1f;
  --warning: #ffd78b;
  --info: #6aa9ff;

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 8px 18px rgba(0, 0, 0, 0.32);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.42);

  --sidebar-w: 240px;
  --bottombar-h: 64px;
  --topbar-h: 56px;

  --font: Inter, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* Light theme */
body.theme-light {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f1f3f6;
  --card: #ffffff;
  --border: #e3e6ec;
  --border-strong: #cdd2da;
  --text-main: #111418;
  --text-secondary: #4b5563;
  --text-muted: #6b7280;
  --accent-soft: #def3eb;
  --accent-soft-2: #c8eadd;
  --accent-text: #0a4a3a;
  --danger-soft: #fde7e7;
  --shadow-md: 0 8px 18px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 16px 40px rgba(15, 23, 42, 0.12);
}

/* Accent variants */
body.accent-blue {
  --accent: #3b82f6; --accent-hover: #2563eb;
  --accent-soft: #1f2f4d; --accent-soft-2: #1d3a6b; --accent-text: #dbe9ff;
}
body.accent-blue.theme-light { --accent-soft: #dbeafe; --accent-soft-2: #bfdbfe; --accent-text: #1e3a8a; }
body.accent-orange {
  --accent: #f97316; --accent-hover: #ea580c;
  --accent-soft: #3a2517; --accent-soft-2: #4a2e1d; --accent-text: #ffe6d0;
}
body.accent-orange.theme-light { --accent-soft: #ffedd5; --accent-soft-2: #fed7aa; --accent-text: #7c2d12; }
body.accent-purple {
  --accent: #a855f7; --accent-hover: #9333ea;
  --accent-soft: #2f1f4d; --accent-soft-2: #3a2a5e; --accent-text: #ecd9ff;
}
body.accent-purple.theme-light { --accent-soft: #ede9fe; --accent-soft-2: #ddd6fe; --accent-text: #4c1d95; }

/* XXL mode */
body.xxl .btn { padding: 0.95rem 1.15rem; font-size: 1.1rem; }
body.xxl .icon-btn { min-width: 56px; height: 56px; font-size: 1.45rem; }
body.xxl .quick-add-btn { min-width: 76px; height: 56px; font-size: 1.1rem; }
body.xxl .item-name { font-size: 1.18rem; }
body.xxl .item-count { font-size: 1.3rem; min-width: 3rem; }
body.xxl .input { padding: 0.95rem 1.05rem; font-size: 1.05rem; }

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

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text-main);
  font-family: var(--font);
  -webkit-tap-highlight-color: transparent;
}
body { min-height: 100vh; min-height: 100dvh; }
button { font-family: inherit; }

/* App layout */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: 100vh; height: 100dvh;
  width: 100%;
}

.topbar { display: none; }
.bottom-nav { display: none; }

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  padding: 1rem 0.75rem; gap: 1rem;
  overflow-y: auto;
}

.brand { display: flex; align-items: center; gap: 0.6rem; padding: 0.25rem 0.5rem; }
.brand-logo {
  display: inline-grid; place-items: center;
  width: 36px; height: 36px; border-radius: 10px;
  background: var(--accent); color: #fff;
  font-weight: 800; font-size: 0.9rem;
}
.brand-name { font-size: 1.1rem; font-weight: 700; letter-spacing: 0.01em; }

.side-nav { display: flex; flex-direction: column; gap: 0.3rem; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 0.7rem;
  padding: 0.7rem 0.75rem;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent; color: var(--text-secondary);
  font-size: 0.96rem; font-weight: 600;
  cursor: pointer; text-align: left; position: relative;
}
.nav-item:hover { background: var(--surface-2); color: var(--text-main); }
.nav-item.active { background: var(--accent-soft); color: var(--text-main); border-color: var(--accent); }
.nav-ico { font-size: 1.1rem; }
.nav-badge {
  margin-left: auto;
  background: var(--accent); color: #fff;
  font-size: 0.72rem; font-weight: 700;
  padding: 0.05rem 0.5rem; border-radius: 999px;
  min-width: 1.4rem; text-align: center;
}
.sidebar-foot {
  padding-top: 0.5rem; border-top: 1px solid var(--border);
  display: grid; gap: 0.4rem;
}

.main { overflow-y: auto; padding: 1.5rem 1.75rem 2rem; }

/* Pages */
.page { display: none; animation: fadeIn 0.18s ease; }
.page.active { display: block; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.page-head {
  display: flex; align-items: flex-end;
  justify-content: space-between; gap: 1rem;
  margin-bottom: 1.25rem;
}
.greeting { margin: 0; font-size: 0.95rem; color: var(--text-secondary); }
.page-title-h2 { margin: 0.15rem 0 0; font-size: 1.65rem; font-weight: 700; letter-spacing: -0.01em; }
.page-head-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

/* Buttons */
.btn {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.65rem 0.95rem;
  font-size: 0.95rem; font-weight: 600;
  color: var(--text-main); background: var(--surface);
  cursor: pointer;
  transition: transform 0.08s ease, background 0.15s ease, border-color 0.15s ease;
  touch-action: manipulation;
}
.btn:hover { background: var(--surface-2); border-color: var(--border-strong); }
.btn:active, .nav-item:active, .icon-btn:active, .fab:active { transform: scale(0.97); }

.btn-primary { background: var(--accent); color: #fff; border-color: transparent; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: transparent; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text-main); border-color: var(--border); }
.btn-danger { background: transparent; border-color: var(--danger); color: #ffb4b4; }
.btn-danger:hover { background: rgba(239, 68, 68, 0.1); }
.btn-block { width: 100%; text-align: left; }

.topbar-actions { display: flex; gap: 0.25rem; }

/* Stats */
.grid-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.85rem;
  margin-bottom: 1rem;
}
.stat-tile {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem 1.1rem;
  text-align: left; cursor: pointer;
  color: var(--text-main); font: inherit;
  display: flex; flex-direction: column; gap: 0.4rem;
  transition: border-color 0.15s ease, transform 0.08s ease;
}
.stat-tile:hover { border-color: var(--accent); transform: translateY(-1px); }
.stat-label { color: var(--text-secondary); font-size: 0.86rem; }
.stat-value { font-size: 1.7rem; font-weight: 800; letter-spacing: -0.02em; }

/* Cards */
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem 1.15rem; margin-bottom: 1rem;
}
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 0.75rem; margin-bottom: 0.75rem;
}
.card-head h3 { margin: 0; font-size: 1.02rem; font-weight: 700; }
.muted { color: var(--text-muted); font-size: 0.85rem; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1rem; }
.watch-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

.micro-label {
  margin: 0 0 0.4rem; color: var(--text-muted);
  font-size: 0.78rem; text-transform: uppercase;
  letter-spacing: 0.06em; font-weight: 700;
}
.micro-hint { margin: 0.35rem 0 0; color: var(--text-muted); font-size: 0.8rem; }

.pill-list { display: grid; gap: 0.4rem; }
.pill {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 10px; padding: 0.5rem 0.7rem;
  font-size: 0.92rem; gap: 0.5rem;
}
.pill-name { font-weight: 600; }
.pill-meta { color: var(--text-secondary); font-size: 0.85rem; }
.pill.warn { border-color: var(--warning); }
.pill.danger { border-color: var(--danger); }

.empty-state { text-align: center; color: var(--text-secondary); padding: 1rem; margin: 0; }
.hint { color: var(--text-secondary); font-size: 0.92rem; margin: 0 0 0.85rem; }

/* Loc bars */
.loc-bars { display: grid; gap: 0.5rem; }
.loc-bar { display: grid; grid-template-columns: 110px 1fr 60px; align-items: center; gap: 0.6rem; }
.loc-bar-name { color: var(--text-secondary); font-size: 0.9rem; }
.loc-bar-track {
  background: var(--surface-2); border-radius: 999px;
  height: 8px; overflow: hidden;
  border: 1px solid var(--border);
}
.loc-bar-fill { height: 100%; background: var(--accent); border-radius: 999px; transition: width 0.25s ease; }
.loc-bar-val { text-align: right; font-weight: 700; color: var(--text-main); }

/* Toolbar */
.toolbar { display: flex; flex-direction: column; gap: 0.6rem; margin-bottom: 0.85rem; }
.toolbar-row { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; }

.location-tabs {
  display: flex; gap: 0.4rem; margin-bottom: 0.85rem;
  overflow-x: auto; padding-bottom: 0.2rem;
}
.loc-tab {
  border: 1px solid var(--border);
  background: var(--surface); color: var(--text-main);
  border-radius: 999px; padding: 0.5rem 0.95rem;
  font-weight: 600; cursor: pointer; white-space: nowrap;
}
.loc-tab.active { background: var(--accent-soft); border-color: var(--accent); color: var(--text-main); }

.quick-filters { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.filter-chip {
  border: 1px solid var(--border);
  background: var(--surface); color: var(--text-main);
  border-radius: 999px; padding: 0.4rem 0.85rem;
  font-weight: 600; cursor: pointer; white-space: nowrap;
}
.filter-chip.active { background: var(--accent-soft); border-color: var(--accent); }

.tag-filters { display: flex; gap: 0.4rem; flex-wrap: wrap; align-items: center; }
.tag-filters::before {
  content: "Tags";
  font-size: 0.78rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
}
.tag-chip {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-main);
  border-radius: 999px; padding: 0.3rem 0.7rem;
  font-size: 0.84rem; font-weight: 600;
  cursor: pointer; white-space: nowrap;
}
.tag-chip:hover { border-color: var(--border-strong); }
.tag-chip.active { background: var(--accent-soft); border-color: var(--accent); }

/* Inputs */
.input {
  width: 100%;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface); color: var(--text-main);
  padding: 0.75rem 0.9rem;
  font-size: 1rem; font-family: inherit;
}
.input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.input-compact { padding: 0.55rem 0.75rem; font-size: 0.92rem; }

/* Items */
.items-list { display: grid; gap: 0.7rem; }
.item-card {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 0.75rem; align-items: center;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 14px; padding: 0.85rem 1rem;
  transition: border-color 0.15s ease;
}
.item-card:hover { border-color: var(--border-strong); }
.item-card.is-empty { opacity: 0.62; }
.item-card.is-low { border-left: 3px solid var(--warning); }
.item-card.is-expiring { border-left: 3px solid var(--danger); }
.item-name { margin: 0; font-size: 1.05rem; font-weight: 700; }
.item-meta { margin: 0.25rem 0 0; color: var(--text-secondary); font-size: 0.9rem; }
.item-badges { margin-top: 0.45rem; display: flex; flex-wrap: wrap; gap: 0.35rem; }

.badge {
  display: inline-block;
  font-size: 0.74rem; padding: 0.18rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text-secondary); background: var(--surface);
  font-weight: 600;
}
.badge.warning { color: var(--warning); border-color: var(--warning); }
.badge.danger { color: #ffb4b4; border-color: var(--danger); }
.badge.info { color: var(--info); border-color: var(--info); }
.badge.tag { color: var(--accent-text); border-color: var(--accent); background: var(--accent-soft); }

.item-actions { display: flex; gap: 0.45rem; align-items: center; }
.item-count { min-width: 2.4rem; text-align: center; font-size: 1.05rem; font-weight: 800; }

.icon-btn {
  min-width: 42px; height: 42px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface); color: var(--text-main);
  font-size: 1.2rem; cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn.delete { color: var(--danger); }

.icon-btn-ghost {
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  border-radius: 10px;
  width: 40px; height: 40px;
  cursor: pointer; font-size: 1.1rem;
}
.icon-btn-ghost:hover { background: var(--surface-2); color: var(--text-main); }

.quick-add-btn {
  min-width: 56px; height: 42px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface); color: var(--text-main);
  font-weight: 700; cursor: pointer;
}
.quick-add-btn:hover { background: var(--surface-2); }

/* FAB */
.fab {
  position: fixed; right: 1.25rem;
  bottom: calc(var(--bottombar-h) + 1rem + env(safe-area-inset-bottom));
  border: none; border-radius: 999px;
  width: 60px; height: 60px;
  font-size: 1.6rem; font-weight: 800;
  background: var(--accent); color: #fff;
  cursor: pointer; box-shadow: var(--shadow-md);
  z-index: 25;
}
.fab:hover { background: var(--accent-hover); }

/* Modals */
.modal {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: grid; place-items: center;
  padding: 1rem; z-index: 50;
  animation: fadeIn 0.15s ease;
}
body.theme-light .modal { background: rgba(15, 23, 42, 0.45); }

.modal-surface {
  width: min(100%, 560px);
  max-height: 92vh;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--card);
  padding: 1.1rem 1.2rem 1.2rem;
  box-shadow: var(--shadow-lg);
}
.modal-add { width: min(100%, 980px); }
.modal-options { width: min(100%, 760px); }

.modal-head {
  display: flex; align-items: flex-start;
  justify-content: space-between; gap: 1rem;
  margin-bottom: 1rem;
}
.modal-head h2 { margin: 0; font-size: 1.3rem; font-weight: 700; }
.subtitle { margin: 0.2rem 0 0; color: var(--text-secondary); font-size: 0.92rem; }

.modal-body-split { display: grid; grid-template-columns: 1fr 1.05fr; gap: 1.1rem; }

.add-form { display: grid; gap: 0.85rem; align-content: start; }
.field { display: grid; gap: 0.35rem; }
.field-label { color: var(--text-secondary); font-size: 0.86rem; font-weight: 600; }
.field-row { display: flex; gap: 0.4rem; align-items: stretch; }
.field-row .input { flex: 1; }

.voice-btn { width: 44px; height: 44px; align-self: stretch; }
.voice-btn.listening { background: var(--accent-soft); color: var(--accent-text); }

.field-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0.7rem; }

.qty-control {
  display: grid; grid-template-columns: 44px 1fr 44px;
  gap: 0.4rem; align-items: stretch;
}
.qty-control .icon-btn { width: 100%; min-width: 0; }
.qty-input { text-align: center; font-weight: 700; font-size: 1.05rem; }

.modal-actions { margin-top: 0.4rem; display: flex; justify-content: flex-end; gap: 0.55rem; flex-wrap: wrap; }

/* Library side */
.add-library {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 0.9rem;
  display: flex; flex-direction: column;
  min-height: 0;
}
.library-head { display: grid; gap: 0.5rem; margin-bottom: 0.65rem; }
.library-head-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 0.5rem;
}
.library-head h3 { margin: 0; font-size: 1rem; }

.food-list { display: grid; gap: 0.4rem; overflow-y: auto; max-height: 56vh; padding-right: 0.15rem; }
.food-group-title {
  margin: 0.25rem 0 0.1rem; color: var(--text-muted);
  font-size: 0.74rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.06em;
}
.food-chip {
  width: 100%;
  display: flex; align-items: center; justify-content: space-between;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2); color: var(--text-main);
  padding: 0.55rem 0.7rem;
  cursor: pointer; text-align: left; font-family: inherit;
}
.food-chip:hover { border-color: var(--accent); }
.food-chip-main { display: flex; flex-direction: column; gap: 0.1rem; }
.food-chip-name { font-weight: 600; font-size: 0.94rem; }
.food-chip-category { color: var(--text-muted); font-size: 0.8rem; }

.quick-add-inline {
  border: 1px solid var(--accent);
  background: var(--accent-soft-2); color: var(--accent-text);
  border-radius: 8px;
  padding: 0.3rem 0.6rem;
  cursor: pointer; font-size: 0.84rem;
  font-weight: 700; font-family: inherit;
}
.quick-add-inline:hover { background: var(--accent); color: #fff; }

/* Options */
.options-list { display: grid; gap: 1.1rem; }
.opt-section {
  display: grid; gap: 0.55rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 0.95rem;
  background: var(--surface);
}
.opt-title {
  margin: 0 0 0.3rem;
  font-size: 0.88rem; font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase; letter-spacing: 0.06em;
}
.opt-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; }
.opt-buttons { display: flex; flex-wrap: wrap; gap: 0.5rem; }

.option-toggle {
  display: flex; align-items: center; gap: 0.55rem;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 10px; padding: 0.6rem 0.7rem;
  cursor: pointer; font-size: 0.94rem;
}
.option-toggle input { width: 18px; height: 18px; accent-color: var(--accent); }

.file-import-btn { display: inline-flex; align-items: center; justify-content: center; }

.kbd-list { margin: 0; padding-left: 1.1rem; color: var(--text-secondary); font-size: 0.92rem; }
.kbd-list li { margin: 0.1rem 0; }
kbd {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.05rem 0.4rem;
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: 0.82rem;
}

/* Custom food list (Options) */
.cf-form {
  display: grid;
  grid-template-columns: 1fr 180px auto;
  gap: 0.5rem;
}
.custom-food-list { display: grid; gap: 0.35rem; }
.custom-food-group-title {
  margin: 0.45rem 0 0.1rem;
  font-size: 0.74rem; font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.06em;
}
.cf-row {
  display: flex; align-items: center; gap: 0.6rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.45rem 0.55rem 0.45rem 0.75rem;
}
.cf-row .cf-name { flex: 1; font-weight: 600; }
.cf-row .cf-cat { color: var(--text-muted); font-size: 0.85rem; }

/* Shopping */
.shopping-list { display: grid; gap: 0.45rem; }
.shopping-row {
  display: flex; align-items: center; gap: 0.7rem;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.55rem 0.75rem;
}
.shopping-row .shop-check { width: 22px; height: 22px; accent-color: var(--accent); cursor: pointer; }
.shopping-row .shop-name { flex: 1; font-weight: 600; }
.shopping-row .shop-meta { color: var(--text-muted); font-size: 0.85rem; }

.row-form { display: grid; grid-template-columns: 1fr auto; gap: 0.5rem; margin-bottom: 0.7rem; }

/* History */
.history-list { display: grid; gap: 0.4rem; }
.history-row {
  display: grid; grid-template-columns: auto 1fr auto;
  gap: 0.6rem; align-items: center;
  padding: 0.5rem 0.75rem;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 10px; font-size: 0.92rem;
}
.history-row .h-icon {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border-radius: 8px;
  background: var(--surface); border: 1px solid var(--border);
}
.history-row .h-time { color: var(--text-muted); font-size: 0.82rem; }
.history-row .h-name { font-weight: 600; }
.history-row .h-detail { color: var(--text-secondary); font-size: 0.85rem; }

/* OCR modal */
.ocr-step { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; margin-bottom: 0.5rem; }
.ocr-progress { margin: 0.5rem 0 0.8rem; }
.ocr-results { display: grid; gap: 0.35rem; max-height: 50vh; overflow-y: auto; }
.ocr-row {
  display: flex; align-items: center; gap: 0.6rem;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 10px; padding: 0.5rem 0.7rem;
}
.ocr-row input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--accent); }
.ocr-row input[type="text"] {
  flex: 1; background: var(--surface); color: var(--text-main);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 0.4rem 0.55rem; font-family: inherit; font-size: 0.92rem;
}

/* Install banner */
.install-banner {
  position: fixed; top: 0.75rem; left: 50%;
  transform: translateX(-50%);
  background: var(--card); color: var(--text-main);
  border: 1px solid var(--accent);
  border-radius: 999px;
  padding: 0.55rem 0.95rem;
  display: flex; align-items: center; gap: 0.6rem;
  z-index: 65; box-shadow: var(--shadow-md);
  max-width: calc(100% - 2rem);
}
.install-banner-actions { display: flex; gap: 0.4rem; }
.install-banner .btn { padding: 0.35rem 0.7rem; font-size: 0.86rem; }

.install-steps { padding-left: 1.1rem; color: var(--text-secondary); }
.install-steps li { margin: 0.4rem 0; line-height: 1.5; }

/* Kiosk mode */
.kiosk-overlay {
  position: fixed; inset: 0;
  background: var(--bg);
  z-index: 80;
  display: flex; flex-direction: column;
  padding: 1.5rem 2rem 2rem;
  overflow-y: auto;
}
.kiosk-head {
  display: flex; align-items: flex-end;
  justify-content: space-between; gap: 1rem;
  margin-bottom: 1.5rem;
}
.kiosk-greeting { margin: 0; color: var(--text-secondary); }
.kiosk-head h2 { margin: 0.2rem 0 0; font-size: 2.4rem; }
.kiosk-actions { display: flex; gap: 0.6rem; }
.kiosk-actions .btn { padding: 1.05rem 1.4rem; font-size: 1.15rem; }

.kiosk-list {
  display: grid; gap: 0.7rem;
  max-width: 980px; width: 100%; margin: 0 auto;
}
.kiosk-row {
  display: flex; align-items: center; gap: 1rem;
  background: var(--surface-2);
  border: 2px solid var(--border);
  border-radius: 16px;
  padding: 1.1rem 1.3rem;
  font-size: 1.4rem;
}
.kiosk-row.done { opacity: 0.45; text-decoration: line-through; }
.kiosk-row input[type="checkbox"] {
  width: 32px; height: 32px;
  accent-color: var(--accent); cursor: pointer;
}
.kiosk-row .k-name { flex: 1; font-weight: 700; }
.kiosk-row .k-meta { color: var(--text-muted); font-size: 1rem; }
.kiosk-empty { text-align: center; font-size: 1.4rem; color: var(--text-muted); margin-top: 3rem; }

/* Share overlay */
.share-overlay {
  position: fixed; inset: 0;
  background: var(--bg);
  z-index: 75;
  overflow-y: auto;
  padding: 2rem 1rem;
}
.share-card {
  max-width: 720px; margin: 0 auto;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 1.2rem 1.4rem 1.4rem;
  box-shadow: var(--shadow-lg);
}

/* Toast */
.toast {
  position: fixed;
  bottom: calc(var(--bottombar-h) + 1rem + env(safe-area-inset-bottom));
  left: 50%; transform: translateX(-50%);
  background: var(--accent-soft-2);
  color: var(--accent-text);
  border: 1px solid var(--accent);
  border-radius: 12px;
  padding: 0.65rem 0.9rem;
  font-size: 0.95rem;
  z-index: 60;
  display: flex; align-items: center; gap: 0.7rem;
  max-width: calc(100% - 2rem);
  box-shadow: var(--shadow-md);
  animation: toastIn 0.18s ease;
}
@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}
.toast-action {
  border: 1px solid var(--accent);
  background: transparent;
  color: var(--accent-text);
  border-radius: 8px;
  padding: 0.32rem 0.6rem;
  cursor: pointer; font-weight: 700;
  font-family: inherit;
}

/* Drop overlay */
.drop-overlay {
  position: fixed; inset: 0;
  background: rgba(15, 90, 70, 0.35);
  backdrop-filter: blur(2px);
  display: grid; place-items: center;
  z-index: 70;
  animation: fadeIn 0.15s ease;
  pointer-events: none;
}
.drop-card {
  background: var(--card);
  border: 2px dashed var(--accent);
  color: var(--text-main);
  border-radius: var(--radius-lg);
  padding: 1.5rem 2rem;
  font-weight: 700; font-size: 1.1rem;
  pointer-events: none;
}

.hidden { display: none !important; }

/* Responsive */
@media (max-width: 980px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: var(--topbar-h) 1fr var(--bottombar-h);
  }
  .sidebar { display: none; }
  .topbar {
    display: flex; align-items: center;
    justify-content: space-between;
    padding: 0 0.85rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
  }
  .topbar #page-title { margin: 0; font-size: 1.1rem; font-weight: 700; }
  .bottom-nav {
    display: grid; grid-template-columns: repeat(5, 1fr);
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .bn-item {
    border: none; background: transparent;
    color: var(--text-secondary);
    font-size: 0.72rem; font-weight: 600;
    padding: 0.4rem 0.2rem;
    cursor: pointer;
    display: flex; flex-direction: column; align-items: center;
    gap: 0.15rem; position: relative;
  }
  .bn-item span:first-child { font-size: 1.25rem; }
  .bn-item.active { color: var(--accent); }
  .bn-badge {
    position: absolute;
    top: 0.3rem; right: 50%;
    transform: translateX(20px);
    background: var(--accent); color: #fff;
    font-size: 0.65rem; font-weight: 700;
    padding: 0.05rem 0.35rem;
    border-radius: 999px; min-width: 1.1rem;
    text-align: center;
  }
  .main { padding: 1rem 1rem 1.5rem; }
  .grid-stats { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
  .modal-body-split { grid-template-columns: 1fr; }
  .add-library { max-height: 50vh; }
  .food-list { max-height: 36vh; }
  .page-head { align-items: flex-start; flex-direction: column; }
  .page-head-actions { width: 100%; }
  .opt-grid-2 { grid-template-columns: 1fr; }
  .cf-form { grid-template-columns: 1fr; }
  .install-banner { font-size: 0.86rem; padding: 0.45rem 0.7rem; }
  .kiosk-head h2 { font-size: 1.8rem; }
  .kiosk-row { font-size: 1.15rem; padding: 0.85rem 1rem; }
  .kiosk-overlay { padding: 1rem; }
}

@media (max-width: 560px) {
  .grid-stats { grid-template-columns: 1fr 1fr; }
  .stat-value { font-size: 1.45rem; }
  .watch-cols { grid-template-columns: 1fr; }
  .item-card { grid-template-columns: 1fr auto; }
  .item-actions:last-child { grid-column: 2; }
  .field-grid-2 { grid-template-columns: 1fr; }
  .toolbar-row { flex-direction: column; align-items: stretch; }
  .install-banner { flex-direction: column; align-items: stretch; gap: 0.4rem; border-radius: 14px; }
  .install-banner-actions { justify-content: flex-end; }
}

@media (min-width: 1280px) {
  .main { padding: 2rem 2.5rem 2.5rem; }
}

/* Custom food / store edit row variants */
.cf-row.editing {
  flex-wrap: wrap;
  background: var(--card);
  border-color: var(--accent);
}
.cf-row.editing .cf-edit-form {
  display: grid;
  grid-template-columns: 1fr 1fr auto auto;
  gap: 0.4rem;
  width: 100%;
}
.cf-row.editing .cf-edit-form input,
.cf-row.editing .cf-edit-form select {
  background: var(--surface);
  color: var(--text-main);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.45rem 0.55rem;
  font-family: inherit;
}
.cf-row .cf-actions { display: flex; gap: 0.25rem; }

/* Shopping store selector card */
.shop-store-card { padding: 0.8rem 1rem; }
.shop-store-row {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 1rem;
  align-items: center;
}

.shopping-row .shop-price {
  display: flex; align-items: center; gap: 0.2rem;
  color: var(--text-secondary);
  font-size: 0.86rem;
}
.shopping-row .shop-price input {
  width: 70px;
  background: var(--surface);
  color: var(--text-main);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.3rem 0.4rem;
  font-family: inherit;
  font-size: 0.86rem;
  text-align: right;
}

/* Budget page */
.bud-chart {
  width: 100%;
  height: 140px;
  display: block;
}
.bud-chart .bud-grid { stroke: var(--border); stroke-width: 0.5; }
.bud-chart .bud-line { fill: none; stroke: var(--accent); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.bud-chart .bud-area { fill: var(--accent-soft); opacity: 0.6; }
.bud-chart .bud-dot { fill: var(--accent); }
.bud-chart-axis {
  display: flex; justify-content: space-between;
  color: var(--text-muted);
  font-size: 0.72rem;
  padding: 0.2rem 0.2rem 0;
}

.bud-bars { display: grid; gap: 0.55rem; }
.bud-bar-row {
  display: grid;
  grid-template-columns: 130px 1fr 90px;
  align-items: center;
  gap: 0.6rem;
}
.bud-bar-name { color: var(--text-main); font-weight: 600; font-size: 0.92rem; }
.bud-bar-track {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  height: 10px;
  overflow: hidden;
}
.bud-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
}
.bud-bar-val {
  text-align: right;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 980px) {
  .shop-store-row { grid-template-columns: 1fr; }
  .bud-bar-row { grid-template-columns: 90px 1fr 70px; }
}

/* Print: only the shopping list */
@media print {
  body * { visibility: hidden; }
  #print-area, #print-area * { visibility: visible; }
  #print-area {
    position: absolute;
    inset: 0;
    padding: 1cm;
    background: white;
    color: black;
  }
  #print-area h2 { margin-top: 0; }
  #print-area ul { padding-left: 1.2rem; }
  #print-area li { line-height: 1.6; font-size: 14pt; break-inside: avoid; }
}
