/* ============================================================
   В магазин — Black Neon Purple
   ============================================================ */

:root {
  --primary-rgb: 180, 92, 255;
  --accent-rgb: 255, 107, 214;
  --primary: rgb(var(--primary-rgb));
  --accent: rgb(var(--accent-rgb));

  --bg: #08050f;
  --surface: #151020;
  --field: #201632;
  --text: #faf7ff;
  --muted: #b6a8c8;
  --border: #493064;
  --on-primary: #1a1024;

  --card-top: rgba(255, 255, 255, 0.062);
  --card-bottom: rgba(255, 255, 255, 0.018);
  --card-border: rgba(var(--primary-rgb), 0.20);
  --card-shadow: 0 18px 38px rgba(0, 0, 0, 0.42);
  --nav-bg: rgba(21, 16, 32, 0.86);
  --overlay: rgba(5, 3, 10, 0.72);

  --ok: #3ed4b0;
  --radius: 24px;
  --nav-h: 66px;
  --ease: cubic-bezier(.22, .8, .32, 1);
}

html[data-theme="light"] {
  --bg: #f7f4fc;
  --surface: #ffffff;
  --field: #f0eaf8;
  --text: #21182d;
  --muted: #776d83;
  --border: #e5ddec;
  --on-primary: #ffffff;

  --card-top: rgba(255, 255, 255, 0.96);
  --card-bottom: rgba(255, 255, 255, 0.78);
  --card-border: rgba(var(--primary-rgb), 0.17);
  --card-shadow: 0 14px 30px rgba(82, 48, 120, 0.10);
  --nav-bg: rgba(255, 255, 255, 0.90);
  --overlay: rgba(28, 18, 40, 0.42);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI",
    Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

button { cursor: pointer; border: 0; background: none; padding: 0; }
svg {
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

.hidden { display: none !important; }

/* ------------------------------ shell ------------------------------ */

.app {
  position: relative;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  min-height: 100dvh;
  padding-bottom: calc(var(--nav-h) + 26px + env(safe-area-inset-bottom));
  background:
    linear-gradient(180deg,
      var(--bg) 0%,
      color-mix(in srgb, var(--bg) 91%, var(--primary)) 46%,
      var(--bg) 100%);
  overflow-x: hidden;
}

.bg-glow {
  position: fixed;
  top: -140px;
  left: 50%;
  transform: translateX(-50%);
  width: min(760px, 150vw);
  height: 420px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(var(--primary-rgb), 0.18), transparent 68%);
  pointer-events: none;
  z-index: 0;
  transition: background .35s;
}

.view {
  position: relative;
  z-index: 1;
  padding: calc(env(safe-area-inset-top) + 16px) 20px 8px;
  animation: viewIn .28s var(--ease);
}

@keyframes viewIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* ------------------------------ header ------------------------------ */

.topbar {
  display: flex;
  align-items: center;
  gap: 13px;
  margin-bottom: 20px;
}

.brand-mark {
  width: 52px;
  height: 52px;
  flex: 0 0 52px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  color: var(--primary);
  background:
    linear-gradient(145deg, rgba(var(--primary-rgb), 0.22), rgba(var(--accent-rgb), 0.10)),
    var(--field);
  border: 1px solid rgba(var(--primary-rgb), 0.35);
  box-shadow: 0 0 22px rgba(var(--primary-rgb), 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.10);
}

.brand-mark svg { width: 26px; height: 26px; }

.brand-copy { flex: 1; min-width: 0; }

.eyebrow {
  display: block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 2.4px;
  color: var(--primary);
  text-transform: uppercase;
}

h1 {
  margin: 2px 0 0;
  font-size: 26px;
  line-height: 1.08;
  font-weight: 800;
  letter-spacing: -0.4px;
}

.page-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
}

.page-head h2 {
  margin: 2px 0 1px;
  font-size: 26px;
  line-height: 1.1;
  font-weight: 800;
  letter-spacing: -0.4px;
}

.page-head p {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}

.icon-btn {
  flex: 0 0 46px;
  width: 46px;
  height: 46px;
  border-radius: 15px;
  display: grid;
  place-items: center;
  color: var(--primary);
  background:
    linear-gradient(145deg, rgba(var(--primary-rgb), 0.16), rgba(var(--primary-rgb), 0.04)),
    var(--field);
  border: 1px solid rgba(var(--primary-rgb), 0.30);
  box-shadow: 0 0 18px rgba(var(--primary-rgb), 0.16);
  transition: transform .16s var(--ease), box-shadow .2s;
}

.icon-btn:active { transform: scale(.93); }
.icon-btn svg { width: 21px; height: 21px; }

.glow-box {
  display: grid;
  place-items: center;
  border-radius: 15px;
  color: var(--primary);
  background: linear-gradient(145deg, rgba(var(--primary-rgb), 0.24), rgba(var(--primary-rgb), 0.07));
  border: 1px solid rgba(var(--primary-rgb), 0.30);
  box-shadow: 0 0 16px rgba(var(--primary-rgb), 0.16);
  flex: 0 0 auto;
}
.size-48 { width: 48px; height: 48px; border-radius: 16px; }
.size-52 { width: 52px; height: 52px; border-radius: 18px; }
.glow-box svg { width: 23px; height: 23px; }
.size-52 svg { width: 25px; height: 25px; }

/* ------------------------------ glass ------------------------------ */

.glass {
  background: linear-gradient(150deg, var(--card-top), var(--card-bottom));
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  box-shadow: var(--card-shadow), inset 0 1px 0 rgba(255, 255, 255, 0.055);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
}

/* ------------------------------ add card ------------------------------ */

.add-card { padding: 14px; margin-bottom: 16px; }

.add-head {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 12px;
  text-align: left;
  border-radius: 16px;
  padding: 2px;
}

.add-head-copy { flex: 1; min-width: 0; }

.add-title {
  display: block;
  margin-top: 2px;
  font-size: 21px;
  font-weight: 800;
  letter-spacing: -0.3px;
}

.chev {
  width: 22px;
  height: 22px;
  color: var(--muted);
  transition: transform .25s var(--ease);
}
.add-card.collapsed .chev { transform: rotate(-90deg); }

.add-body {
  display: grid;
  gap: 12px;
  overflow: hidden;
  max-height: 460px;
  opacity: 1;
  margin-top: 14px;
  transition: max-height .28s var(--ease), opacity .2s, margin-top .28s;
}
.add-card.collapsed .add-body {
  max-height: 0;
  opacity: 0;
  margin-top: 0;
  pointer-events: none;
}
.add-card.collapsed .add-head .glow-box svg { transform: none; }

.field { display: block; min-width: 0; }

.field-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .3px;
  color: var(--muted);
  margin: 0 0 6px 4px;
}

input[type="text"],
input[type="search"],
input[type="number"],
select {
  width: 100%;
  height: 50px;
  padding: 0 14px;
  color: var(--text);
  background: var(--field);
  border: 1px solid rgba(var(--primary-rgb), 0.14);
  border-radius: 15px;
  outline: none;
  transition: border-color .18s, box-shadow .18s;
  -webkit-appearance: none;
  appearance: none;
}

input::placeholder { color: color-mix(in srgb, var(--muted) 78%, transparent); }

input:focus, select:focus {
  border-color: rgba(var(--primary-rgb), 0.60);
  box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.13);
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input[type="number"] { -moz-appearance: textfield; }

select {
  padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23b6a8c8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 13px center;
}

.add-row { display: grid; grid-template-columns: 1fr 0.9fr 1.15fr; gap: 10px; }

.stepper {
  display: flex;
  align-items: center;
  height: 50px;
  background: var(--field);
  border: 1px solid rgba(var(--primary-rgb), 0.14);
  border-radius: 15px;
  overflow: hidden;
}

.stepper input {
  height: 100%;
  flex: 1;
  min-width: 0;
  text-align: center;
  padding: 0;
  border: 0;
  background: transparent;
  border-radius: 0;
  font-weight: 700;
}
.stepper input:focus { box-shadow: none; }

.step {
  width: 40px;
  height: 100%;
  flex: 0 0 40px;
  display: grid;
  place-items: center;
  font-size: 20px;
  font-weight: 700;
  color: var(--primary);
  background: rgba(var(--primary-rgb), 0.07);
  transition: background .15s;
}
.step:active { background: rgba(var(--primary-rgb), 0.20); }

.primary-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 52px;
  margin-top: 2px;
  border-radius: 16px;
  font-size: 15px;
  font-weight: 800;
  color: var(--on-primary);
  background: linear-gradient(120deg, var(--primary), var(--accent));
  box-shadow: 0 12px 26px rgba(var(--primary-rgb), 0.34);
  transition: transform .15s var(--ease), filter .2s;
}
.primary-btn svg { width: 20px; height: 20px; stroke-width: 2.4; }
.primary-btn:active { transform: scale(.975); filter: brightness(1.06); }

/* ------------------------------ search / chips ------------------------------ */

.search-wrap {
  position: relative;
  margin-bottom: 12px;
}

.search-wrap input {
  height: 52px;
  padding-left: 46px;
  padding-right: 44px;
  border-radius: 18px;
  background: var(--field);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.14), inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.search-icon {
  position: absolute;
  left: 15px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  color: var(--primary);
  pointer-events: none;
  stroke-width: 2;
}

.search-clear {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 34px;
  height: 34px;
  display: none;
  place-items: center;
  color: var(--muted);
  border-radius: 10px;
}
.search-clear.visible { display: grid; }
.search-clear svg { width: 17px; height: 17px; }

.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 1px 8px;
  margin: 0 -2px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.chips::-webkit-scrollbar { display: none; }

.chip {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 13px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  color: var(--muted);
  background: color-mix(in srgb, var(--field) 72%, transparent);
  border: 1px solid rgba(var(--primary-rgb), 0.13);
  transition: color .18s, background .18s, border-color .18s, box-shadow .18s;
}
.chip svg { width: 14px; height: 14px; }

.chip.active {
  color: var(--primary);
  background: rgba(var(--primary-rgb), 0.14);
  border-color: rgba(var(--primary-rgb), 0.52);
  box-shadow: 0 0 14px rgba(var(--primary-rgb), 0.16);
}

.list-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 32px;
  margin: 2px 0 8px;
  font-size: 12px;
  color: var(--muted);
}
.list-meta > span { flex: 1; }

.sort-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 8px;
  border-radius: 9px;
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
}
.sort-btn svg { width: 15px; height: 15px; stroke-width: 2; }
.sort-btn:active { background: rgba(var(--primary-rgb), 0.12); }

/* ------------------------------ product list ------------------------------ */

.product-list { display: grid; gap: 11px; }

.product {
  padding: 13px 13px 11px;
  animation: cardIn .26s var(--ease);
}

@keyframes cardIn {
  from { opacity: 0; transform: translateY(7px) scale(.99); }
  to { opacity: 1; transform: none; }
}

.product-main {
  display: flex;
  align-items: flex-start;
  gap: 11px;
}

.check {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  margin-top: 2px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: var(--on-primary);
  background: var(--field);
  border: 1px solid rgba(var(--border-rgb, 73, 48, 100), .8);
  border-color: color-mix(in srgb, var(--border) 80%, transparent);
  transition: background .18s, border-color .18s, box-shadow .18s, transform .12s;
}
.check svg { width: 20px; height: 20px; stroke-width: 2.6; opacity: 0; transform: scale(.5); transition: opacity .18s, transform .18s var(--ease); }
.check.on {
  background: var(--primary);
  border-color: var(--primary);
  box-shadow: 0 0 16px rgba(var(--primary-rgb), 0.45);
}
.check.on svg { opacity: 1; transform: scale(1); }
.check:active { transform: scale(.9); }

.product-info {
  flex: 1;
  min-width: 0;
  text-align: left;
  padding: 1px 0 0;
}

.product-name {
  display: block;
  font-size: 15.5px;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: .1px;
  overflow-wrap: anywhere;
}

.product.bought .product-name {
  color: var(--muted);
  text-decoration: line-through;
}

.product.bought .check { box-shadow: 0 0 10px rgba(var(--primary-rgb), 0.3); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 6px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 600;
  color: var(--cat, var(--primary));
  background: color-mix(in srgb, var(--cat, var(--primary)) 13%, transparent);
  border: 1px solid color-mix(in srgb, var(--cat, var(--primary)) 25%, transparent);
}
.badge svg { width: 11px; height: 11px; stroke-width: 2; }
.badge[data-cat="Продукты"] { --cat: var(--primary); }
.badge[data-cat="Быт"] { --cat: var(--accent); }
.badge[data-cat="Аптека"] { --cat: var(--ok); }
.badge[data-cat="Другое"] { --cat: var(--muted); }

.icon-btn-sm {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: var(--primary);
  background: color-mix(in srgb, var(--field) 62%, transparent);
  transition: background .15s, transform .12s;
}
.icon-btn-sm svg { width: 18px; height: 18px; stroke-width: 2; }
.icon-btn-sm:active { transform: scale(.9); background: rgba(var(--primary-rgb), 0.22); }

.product-qty {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 9px;
  padding-top: 9px;
  border-top: 1px solid color-mix(in srgb, var(--border) 42%, transparent);
}

.price-line {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-top: 8px;
  padding: 0 4px;
  font-size: 11.5px;
  color: var(--muted);
}
.price-line b { color: var(--text); font-size: 12.5px; }

.qty-label { flex: 1; font-size: 11px; color: var(--muted); }

.qty-btn {
  width: 30px;
  height: 30px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-size: 17px;
  font-weight: 700;
  color: var(--primary);
  background: var(--field);
  border: 1px solid rgba(var(--primary-rgb), 0.32);
  transition: transform .12s, opacity .15s;
}
.qty-btn:active { transform: scale(.9); }
.qty-btn:disabled { opacity: .38; }

.qty-value {
  width: 38px;
  text-align: center;
  font-size: 14px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

/* ------------------------------ empty / finish ------------------------------ */

.empty-card {
  padding: 30px 22px;
  text-align: center;
}
.empty-card .glow-box { margin: 0 auto; width: 62px; height: 62px; border-radius: 21px; }
.empty-card .glow-box svg { width: 29px; height: 29px; }
.empty-title { margin: 14px 0 4px; font-size: 17px; font-weight: 800; }
.empty-text { margin: 0; font-size: 12.5px; color: var(--muted); line-height: 1.45; }
.empty-card .outline-btn { margin-top: 14px; }

.outline-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 42px;
  padding: 0 16px;
  border-radius: 13px;
  font-size: 13px;
  font-weight: 700;
  color: var(--primary);
  border: 1px solid rgba(var(--primary-rgb), 0.5);
  background: rgba(var(--primary-rgb), 0.05);
  transition: background .15s;
}
.outline-btn:active { background: rgba(var(--primary-rgb), 0.16); }
.outline-btn svg { width: 16px; height: 16px; }

.finish-card {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 13px 14px;
  margin-bottom: 11px;
}
.finish-copy { flex: 1; min-width: 0; }
.finish-title { font-size: 13.5px; font-weight: 650; }
.finish-sub { font-size: 11px; color: var(--muted); margin-top: 1px; }
.finish-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 38px;
  padding: 0 14px;
  border-radius: 12px;
  font-size: 12.5px;
  font-weight: 800;
  color: var(--on-primary);
  background: linear-gradient(120deg, var(--primary), var(--accent));
  box-shadow: 0 8px 18px rgba(var(--primary-rgb), 0.28);
}
.finish-btn svg { width: 16px; height: 16px; stroke-width: 2.5; }
.finish-btn:active { transform: scale(.96); }

/* ------------------------------ statistics ------------------------------ */

.progress-card { padding: 18px; margin-bottom: 12px; }
.progress-top { display: flex; align-items: flex-end; gap: 12px; }
.progress-copy { flex: 1; min-width: 0; }
.progress-title { font-size: 17px; font-weight: 800; margin-top: 6px; letter-spacing: -.2px; }
.progress-hint { margin: 4px 0 0; font-size: 12px; color: var(--muted); }
.progress-percent {
  font-size: 34px;
  font-weight: 800;
  line-height: 1;
  color: var(--accent);
  letter-spacing: -1px;
  font-variant-numeric: tabular-nums;
}
.progress-track {
  height: 10px;
  margin-top: 15px;
  border-radius: 999px;
  background: var(--field);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  box-shadow: 0 0 14px rgba(var(--primary-rgb), 0.6);
  transition: width .5s var(--ease);
}

.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 11px;
  margin-bottom: 12px;
}
.stat-card {
  height: 112px;
  padding: 13px;
  display: flex;
  flex-direction: column;
}
.stat-card .glow-box { width: 34px; height: 34px; border-radius: 11px; }
.stat-card .glow-box svg { width: 17px; height: 17px; }
.stat-label { margin-top: auto; font-size: 11.5px; color: var(--muted); }
.stat-value {
  font-size: 23px;
  font-weight: 800;
  line-height: 1.12;
  color: var(--stat-accent, var(--primary));
  font-variant-numeric: tabular-nums;
}

.section { margin-top: 20px; }

.section-head {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  margin-bottom: 10px;
}
.section-head-copy { flex: 1; }
.section-title { font-size: 15px; font-weight: 800; letter-spacing: .2px; }
.section-sub { font-size: 11px; color: var(--muted); margin-top: 1px; }

.freq-list { display: grid; gap: 9px; }
.freq-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 12px;
}
.freq-icon {
  width: 38px; height: 38px; border-radius: 13px;
  display: grid; place-items: center;
  color: var(--primary);
  background: rgba(var(--primary-rgb), 0.12);
  border: 1px solid rgba(var(--primary-rgb), 0.22);
  flex: 0 0 38px;
}
.freq-icon svg { width: 18px; height: 18px; }
.freq-copy { flex: 1; min-width: 0; }
.freq-name { font-size: 13.5px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.freq-meta { font-size: 11px; color: var(--muted); margin-top: 2px; }
.add-mini {
  width: 32px; height: 32px; flex: 0 0 32px;
  border-radius: 10px; display: grid; place-items: center;
  color: var(--primary);
  background: var(--field);
  border: 1px solid rgba(var(--primary-rgb), 0.3);
}
.add-mini svg { width: 16px; height: 16px; stroke-width: 2.4; }
.add-mini:active { transform: scale(.9); }

.history-list { display: grid; gap: 10px; }
.batch { padding: 14px; }
.batch-head { display: flex; align-items: flex-start; gap: 10px; }
.batch-date { flex: 1; font-size: 13px; font-weight: 700; }
.batch-count { font-size: 11px; color: var(--muted); margin-top: 2px; }
.batch-items { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.batch-chip {
  font-size: 10.5px;
  padding: 3px 8px;
  border-radius: 999px;
  color: var(--muted);
  background: color-mix(in srgb, var(--field) 70%, transparent);
  border: 1px solid color-mix(in srgb, var(--border) 45%, transparent);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.batch-repeat {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 36px;
  padding: 0 12px;
  border-radius: 11px;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--primary);
  border: 1px solid rgba(var(--primary-rgb), 0.4);
  background: rgba(var(--primary-rgb), 0.07);
  white-space: nowrap;
}
.batch-repeat svg { width: 14px; height: 14px; }
.batch-repeat:active { background: rgba(var(--primary-rgb), 0.18); }

.section-empty {
  padding: 20px;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
}

/* ------------------------------ bottom nav ------------------------------ */

.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: calc(10px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 40;
  width: min(calc(100% - 28px), 532px);
  height: var(--nav-h);
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 7px;
  border-radius: 22px;
  background: var(--nav-bg);
  border: 1px solid var(--card-border);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.42), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  backdrop-filter: blur(20px) saturate(140%);
}

.nav-btn {
  flex: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border-radius: 15px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
  transition: color .18s, background .18s;
}
.nav-btn svg { width: 22px; height: 22px; stroke-width: 1.9; }
.nav-btn.active {
  color: var(--primary);
  background: rgba(var(--primary-rgb), 0.13);
  box-shadow: inset 0 0 0 1px rgba(var(--primary-rgb), 0.25);
}
.nav-btn:active { transform: scale(.97); }

/* ------------------------------ toast ------------------------------ */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--nav-h) + 22px + env(safe-area-inset-bottom));
  transform: translate(-50%, 16px);
  z-index: 60;
  width: min(calc(100% - 32px), 520px);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 15px;
  background: color-mix(in srgb, var(--surface) 88%, var(--primary));
  border: 1px solid rgba(var(--primary-rgb), 0.34);
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.4), 0 0 22px rgba(var(--primary-rgb), 0.16);
  color: var(--text);
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .25s var(--ease);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.toast span { flex: 1; line-height: 1.35; }
.toast-action {
  flex: 0 0 auto;
  color: var(--primary);
  font-size: 12.5px;
  font-weight: 800;
  padding: 6px 8px;
  border-radius: 8px;
}
.toast-action:active { background: rgba(var(--primary-rgb), 0.15); }

/* ------------------------------ modal / bottom sheet ------------------------------ */

.modal-root {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  background: var(--overlay);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  animation: fadeIn .18s;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.sheet {
  width: 100%;
  max-width: 560px;
  max-height: 92dvh;
  overflow-y: auto;
  padding: 20px 20px calc(20px + env(safe-area-inset-bottom));
  border-radius: 28px 28px 0 0;
  background: var(--surface);
  border: 1px solid var(--card-border);
  border-bottom: 0;
  box-shadow: 0 -18px 50px rgba(0, 0, 0, 0.5);
  animation: sheetIn .3s var(--ease);
  overscroll-behavior: contain;
}
@keyframes sheetIn {
  from { transform: translateY(28px); opacity: .4; }
  to { transform: none; opacity: 1; }
}

.sheet-grab {
  width: 42px;
  height: 5px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--muted) 38%, transparent);
  margin: -4px auto 16px;
}

.sheet-head {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-bottom: 16px;
}
.sheet-title { font-size: 20px; font-weight: 800; letter-spacing: -.3px; flex: 1; }
.sheet-close {
  width: 38px; height: 38px; border-radius: 12px;
  display: grid; place-items: center;
  color: var(--muted);
  background: var(--field);
  border: 1px solid color-mix(in srgb, var(--border) 55%, transparent);
}
.sheet-close svg { width: 18px; height: 18px; }

.sheet-actions { display: flex; gap: 10px; margin-top: 18px; }
.sheet-actions .primary-btn { margin: 0; }
.sheet-actions .outline-btn { flex: 0 0 auto; height: 52px; }

.form-stack { display: grid; gap: 12px; }

.toggle-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 14px;
  border-radius: 16px;
  background: color-mix(in srgb, var(--field) 70%, transparent);
  border: 1px solid color-mix(in srgb, var(--border) 45%, transparent);
}
.toggle-copy { flex: 1; min-width: 0; }
.toggle-title { font-size: 13.5px; font-weight: 650; }
.toggle-sub { font-size: 11px; color: var(--muted); margin-top: 2px; line-height: 1.35; }

.switch { position: relative; flex: 0 0 46px; width: 46px; height: 28px; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch span {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: color-mix(in srgb, var(--border) 70%, transparent);
  transition: background .2s;
  pointer-events: none;
}
.switch span::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--text);
  transition: transform .2s var(--ease), background .2s;
}
.switch input:checked + span { background: var(--primary); box-shadow: 0 0 14px rgba(var(--primary-rgb), 0.45); }
.switch input:checked + span::after { transform: translateX(18px); background: var(--on-primary); }

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 5px;
  border-radius: 16px;
  background: var(--field);
  border: 1px solid color-mix(in srgb, var(--border) 45%, transparent);
}
.seg {
  height: 40px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 650;
  color: var(--muted);
}
.seg svg { width: 15px; height: 15px; }
.segmented.three { grid-template-columns: repeat(3, 1fr); }
.segmented.four { grid-template-columns: repeat(4, 1fr); }
.segmented.four .seg { height: 38px; font-size: 11px; padding: 0 4px; }
.seg.active {
  color: var(--primary);
  background: rgba(var(--primary-rgb), 0.15);
  box-shadow: inset 0 0 0 1px rgba(var(--primary-rgb), 0.32);
}

.accents { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.accent-opt {
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px 2px 8px;
  border-radius: 14px;
  background: color-mix(in srgb, var(--field) 64%, transparent);
  border: 1px solid color-mix(in srgb, var(--border) 42%, transparent);
  font-size: 9.5px;
  color: var(--muted);
  transition: border-color .18s, background .18s;
}
.accent-opt.active {
  border-color: var(--swatch);
  background: color-mix(in srgb, var(--swatch) 13%, transparent);
  color: var(--swatch);
  box-shadow: 0 0 14px color-mix(in srgb, var(--swatch) 25%, transparent);
}
.accent-dot {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--swatch);
  box-shadow: 0 0 12px color-mix(in srgb, var(--swatch) 55%, transparent);
}

.settings-group { margin-top: 18px; }
.settings-label {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 1.4px;
  color: var(--primary);
  text-transform: uppercase;
  margin: 0 0 8px 3px;
}

.data-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 13px;
  border-radius: 14px;
  background: color-mix(in srgb, var(--field) 64%, transparent);
  border: 1px solid color-mix(in srgb, var(--border) 42%, transparent);
  font-size: 12.5px;
  font-weight: 600;
  width: 100%;
  text-align: left;
}
.data-row + .data-row { margin-top: 8px; }
.data-row svg { width: 18px; height: 18px; color: var(--primary); flex: 0 0 18px; }
.data-row span { flex: 1; }
.data-row:active { background: rgba(var(--primary-rgb), 0.12); }

.hint-box {
  display: flex;
  gap: 10px;
  padding: 13px;
  border-radius: 14px;
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--muted);
  background: rgba(var(--primary-rgb), 0.07);
  border: 1px solid rgba(var(--primary-rgb), 0.18);
}
.hint-box svg { width: 17px; height: 17px; flex: 0 0 17px; color: var(--primary); margin-top: 1px; }
.hint-box b { color: var(--text); font-weight: 650; }

.version-line {
  margin: 18px 0 0;
  text-align: center;
  font-size: 10.5px;
  color: color-mix(in srgb, var(--muted) 70%, transparent);
}

/* ------------------------------ welcome ------------------------------ */

.welcome {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(env(safe-area-inset-top) + 26px) 20px calc(env(safe-area-inset-bottom) + 26px);
  overflow-y: auto;
  background:
    radial-gradient(120% 80% at 50% -10%, rgba(var(--primary-rgb), 0.24), transparent 60%),
    linear-gradient(180deg,
      var(--bg) 0%,
      color-mix(in srgb, var(--bg) 88%, var(--primary)) 55%,
      var(--bg) 100%);
  overscroll-behavior: contain;
}

.welcome-glow {
  position: fixed;
  top: -170px;
  left: 50%;
  transform: translateX(-50%);
  width: min(760px, 150vw);
  height: 460px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(var(--accent-rgb), 0.14), transparent 68%);
  pointer-events: none;
}

.welcome-inner {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 440px;
  margin: auto;
}

.welcome-step { animation: viewIn .32s var(--ease); }

#welcomeChoice { text-align: center; }

.welcome-logo {
  width: 84px;
  height: 84px;
  margin: 0 auto 18px;
  border-radius: 27px;
  display: grid;
  place-items: center;
  color: var(--primary);
  background:
    linear-gradient(145deg, rgba(var(--primary-rgb), 0.24), rgba(var(--accent-rgb), 0.09)),
    var(--field);
  border: 1px solid rgba(var(--primary-rgb), 0.38);
  box-shadow: 0 0 34px rgba(var(--primary-rgb), 0.30),
    inset 0 1px 0 rgba(255, 255, 255, 0.10);
}
.welcome-logo svg { width: 40px; height: 40px; }
.welcome-logo.cloud { color: var(--accent); box-shadow: 0 0 34px rgba(var(--accent-rgb), 0.26); }

#welcomeChoice .eyebrow { margin-top: 4px; }

.welcome-title {
  margin: 4px 0 0;
  font-size: 34px;
  line-height: 1.06;
  font-weight: 800;
  letter-spacing: -1px;
}

.welcome-sub {
  max-width: 330px;
  margin: 9px auto 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted);
}

.welcome-options {
  display: grid;
  gap: 11px;
  margin-top: 26px;
  text-align: left;
}

.option-card {
  display: flex;
  align-items: center;
  gap: 13px;
  width: 100%;
  padding: 15px;
  border-radius: 20px;
  text-align: left;
  background: linear-gradient(150deg, var(--card-top), var(--card-bottom));
  border: 1px solid var(--card-border);
  box-shadow: var(--card-shadow), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  transition: transform .15s var(--ease), border-color .18s, background .18s;
}
.option-card:active { transform: scale(.98); }

.option-card.featured {
  background:
    linear-gradient(150deg, rgba(var(--primary-rgb), 0.17), rgba(var(--accent-rgb), 0.06)),
    var(--surface);
  border-color: rgba(var(--primary-rgb), 0.50);
  box-shadow: 0 14px 32px rgba(var(--primary-rgb), 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.option-icon {
  width: 46px;
  height: 46px;
  flex: 0 0 46px;
  border-radius: 15px;
  display: grid;
  place-items: center;
  color: var(--primary);
  background: rgba(var(--primary-rgb), 0.13);
  border: 1px solid rgba(var(--primary-rgb), 0.25);
}
.option-icon svg { width: 22px; height: 22px; }
.option-icon.cloud {
  color: var(--accent);
  background: rgba(var(--accent-rgb), 0.11);
  border-color: rgba(var(--accent-rgb), 0.24);
}

.option-copy { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.option-title { font-size: 14.5px; font-weight: 750; letter-spacing: -.1px; }
.option-text { font-size: 11.5px; line-height: 1.4; color: var(--muted); }

.option-arrow { width: 18px; height: 18px; flex: 0 0 18px; color: var(--muted); transform: rotate(-90deg); }

.welcome-note {
  margin: 17px 0 0;
  font-size: 10.5px;
  line-height: 1.55;
  color: color-mix(in srgb, var(--muted) 86%, transparent);
  text-align: center;
}

#welcomeAccount { text-align: left; }

.welcome-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 20px;
  padding: 7px 10px 7px 4px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 650;
  color: var(--muted);
}
.welcome-back svg { width: 16px; height: 16px; }
.welcome-back:active { background: rgba(var(--primary-rgb), 0.10); }

#welcomeAccount .welcome-logo {
  width: 64px;
  height: 64px;
  margin: 0 0 15px;
  border-radius: 21px;
}
#welcomeAccount .welcome-logo svg { width: 30px; height: 30px; }

#welcomeAccount .welcome-title { font-size: 30px; }

#welcomeAccount .welcome-sub {
  max-width: none;
  margin: 6px 0 18px;
}

.account-info { padding: 16px; }

.account-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: 0 0 8px;
  background: var(--accent);
  box-shadow: 0 0 10px rgba(var(--accent-rgb), 0.75);
}

.account-text {
  margin: 10px 0 12px;
  font-size: 12px;
  line-height: 1.55;
  color: var(--muted);
}

.account-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}
.account-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
  line-height: 1.35;
  color: var(--text);
}
.account-list svg { width: 15px; height: 15px; flex: 0 0 15px; color: var(--primary); }

#welcomeAccount .primary-btn { margin-top: 16px; }

/* ------------------------------ auth form ------------------------------ */

.auth-form {
  display: grid;
  gap: 11px;
  margin-top: 6px;
  text-align: left;
}

.auth-field { display: grid; gap: 6px; }

.auth-field > span {
  font-size: 10.5px;
  font-weight: 750;
  letter-spacing: 1.1px;
  text-transform: uppercase;
  color: var(--muted);
}

.auth-field input {
  width: 100%;
  height: 50px;
  padding: 0 14px;
  border-radius: 14px;
  font-size: 15px;
  font-family: inherit;
  color: var(--text);
  background: var(--field);
  border: 1px solid var(--card-border);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.auth-field input::placeholder { color: color-mix(in srgb, var(--muted) 85%, transparent); }
.auth-field input:focus {
  border-color: rgba(var(--primary-rgb), .65);
  box-shadow: 0 0 0 3px rgba(var(--primary-rgb), .14);
}

.auth-error {
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 12px;
  line-height: 1.45;
  color: #ff9bb3;
  background: rgba(255, 92, 158, .10);
  border: 1px solid rgba(255, 92, 158, .30);
}

.auth-alt {
  margin: 12px 0 0;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
}

.link-btn {
  font-size: 12px;
  font-weight: 750;
  color: var(--primary);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.auth-wide { width: 100%; margin-top: 10px; }
.primary-btn.auth-wide { margin-top: 12px; }

.outline-btn.danger {
  color: #ff7f9f;
  border-color: rgba(255, 92, 158, .45);
  background: rgba(255, 92, 158, .06);
}

.account-email {
  margin-top: 4px;
  padding: 9px 12px;
  border-radius: 12px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text);
  background: rgba(var(--primary-rgb), .09);
  border: 1px solid rgba(var(--primary-rgb), .20);
  word-break: break-all;
}

.status-dot.off { background: var(--muted); box-shadow: none; }
.account-text.small { font-size: 11px; margin-bottom: 0; }

/* ------------------------------ small screens ------------------------------ */

@media (max-width: 360px) {
  .view { padding-left: 14px; padding-right: 14px; }
  .add-row { grid-template-columns: 1fr; }
  .brand-mark { width: 46px; height: 46px; flex-basis: 46px; }
  h1 { font-size: 23px; }
}

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

/* ------------------------------ atmosphere ------------------------------ */

#snow {
  position: fixed;
  inset: 0;
  z-index: 105;
  pointer-events: none;
  opacity: 0;
  transition: opacity .5s ease;
}
#snow.on { opacity: 1; }

.garland {
  position: fixed;
  top: calc(env(safe-area-inset-top) + 7px);
  left: 0;
  right: 0;
  height: 18px;
  z-index: 106;
  pointer-events: none;
  display: none;
}
.garland.on { display: block; }

.garland::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 1px;
  background: linear-gradient(90deg,
    transparent,
    rgba(255, 255, 255, .34) 12%,
    rgba(255, 255, 255, .14) 50%,
    rgba(255, 255, 255, .34) 88%,
    transparent);
}

.garland .bulb {
  position: absolute;
  top: 0;
  width: 7px;
  height: 11px;
  margin-left: -3.5px;
  border-radius: 3.5px 3.5px 46% 46%;
  animation: bulbTwinkle 2.8s ease-in-out infinite;
}
.garland .bulb::after {
  content: "";
  position: absolute;
  inset: -5px;
  border-radius: 50%;
  background: inherit;
  opacity: .30;
  filter: blur(5px);
}
.garland .bulb.c0 { background: #FFD166; box-shadow: 0 0 8px rgba(255, 209, 102, .85); }
.garland .bulb.c1 { background: #FF5C7A; box-shadow: 0 0 8px rgba(255, 92, 122, .85); }
.garland .bulb.c2 { background: #5CFF9D; box-shadow: 0 0 8px rgba(92, 255, 157, .80); }
.garland .bulb.c3 { background: #7CE2FF; box-shadow: 0 0 8px rgba(124, 226, 255, .85); }

@keyframes bulbTwinkle {
  0%, 100% { opacity: .55; filter: brightness(.9); }
  45% { opacity: 1; filter: brightness(1.3); }
}

html[data-bg="fog"] .app {
  background:
    linear-gradient(180deg,
      var(--bg) 0%,
      color-mix(in srgb, var(--bg) 76%, var(--primary)) 50%,
      var(--bg) 100%);
}
html[data-bg="fog"] .bg-glow {
  top: -240px;
  height: 640px;
  width: min(1000px, 200vw);
  background: radial-gradient(circle,
    rgba(var(--primary-rgb), 0.30),
    rgba(var(--accent-rgb), 0.10) 46%,
    transparent 72%);
  filter: blur(14px);
}

html[data-bg="night"] .app {
  background: linear-gradient(180deg,
    color-mix(in srgb, var(--bg) 94%, #000) 0%,
    var(--bg) 100%);
}
html[data-bg="night"] .bg-glow { opacity: .30; }
html[data-bg="night"] .glass { box-shadow: 0 10px 24px rgba(0, 0, 0, .35); }

html.no-motion *,
html.no-motion *::before,
html.no-motion *::after {
  animation: none !important;
  transition: none !important;
}
html.no-motion #snow,
html.no-motion .garland { display: none !important; }

html[data-garland="1"] .view { padding-top: calc(env(safe-area-inset-top) + 34px); }

.finish-sub.budget-over { color: #ff9bb3; }

.welcome-credit {
  margin: 10px 0 0;
  text-align: center;
  font-size: 10.5px;
  color: color-mix(in srgb, var(--muted) 80%, transparent);
}
.welcome-credit a { color: var(--primary); text-decoration: none; font-weight: 700; }
