:root {
  --ink: #342a3f;
  --muted: #786d80;
  --cream: #fffaf2;
  --paper: #ffffff;
  --coral: #ff7f66;
  --coral-dark: #e85f4e;
  --mint: #bdebd8;
  --mint-dark: #26785f;
  --lemon: #ffe49a;
  --lavender: #e4d8ff;
  --rose: #ffe0e7;
  --line: #eee5e7;
  --shadow: 0 14px 40px rgb(77 43 63 / 10%);
  --radius: 24px;
  font-family: "Avenir Next", Avenir, "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background: var(--cream);
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--cream);
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 8% 4%, rgb(255 224 231 / 75%) 0 90px, transparent 91px),
    radial-gradient(circle at 95% 18%, rgb(189 235 216 / 60%) 0 110px, transparent 111px),
    var(--cream);
}

button,
input,
select {
  font: inherit;
}

button {
  color: inherit;
}

button,
[role="button"] {
  -webkit-tap-highlight-color: transparent;
}

.app-shell {
  min-height: 100vh;
}

.splash,
.login-page {
  display: grid;
  min-height: 100vh;
  padding: 24px;
  place-content: center;
  text-align: center;
}

.splash-emoji {
  display: block;
  margin-bottom: 12px;
  font-size: 54px;
  animation: bob 1.6s ease-in-out infinite;
}

@keyframes bob {
  50% { transform: translateY(-7px) rotate(2deg); }
}

.login-card {
  width: min(100%, 410px);
  padding: 34px 24px 26px;
  overflow: hidden;
  border: 1px solid rgb(255 255 255 / 80%);
  border-radius: 34px;
  background: rgb(255 255 255 / 92%);
  box-shadow: var(--shadow);
  position: relative;
}

.login-card::before {
  content: "🍓  🥕  🥦";
  display: block;
  margin-bottom: 18px;
  font-size: 34px;
  letter-spacing: 8px;
}

.brand {
  margin: 0;
  color: var(--coral-dark);
  font-size: clamp(2.25rem, 10vw, 3.2rem);
  line-height: 1;
  letter-spacing: -2px;
}

.login-card > p {
  margin: 13px auto 26px;
  color: var(--muted);
  line-height: 1.55;
}

.field {
  display: grid;
  gap: 7px;
  text-align: left;
}

.field > span,
.field-label {
  color: var(--muted);
  font-size: .86rem;
  font-weight: 800;
  letter-spacing: .02em;
}

input[type="text"],
input[type="password"],
.field select,
.quantity-input {
  width: 100%;
  min-height: 52px;
  padding: 0 16px;
  border: 2px solid var(--line);
  border-radius: 16px;
  outline: none;
  background: #fff;
  color: var(--ink);
  transition: border-color .2s, box-shadow .2s;
}

input:focus {
  border-color: var(--coral);
  box-shadow: 0 0 0 4px rgb(255 127 102 / 13%);
}

select:focus {
  border-color: var(--coral);
  box-shadow: 0 0 0 4px rgb(255 127 102 / 13%);
}

.button {
  display: inline-flex;
  min-height: 48px;
  padding: 0 19px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: 16px;
  cursor: pointer;
  font-weight: 850;
  transition: transform .15s, filter .15s;
}

.button:active {
  transform: scale(.97);
}

.button:disabled {
  cursor: not-allowed;
  filter: grayscale(.4);
  opacity: .55;
}

.button-primary {
  background: var(--coral);
  color: white;
  box-shadow: 0 8px 18px rgb(232 95 78 / 22%);
}

.button-secondary {
  background: var(--mint);
  color: #205f4e;
}

.button-ghost {
  background: #f7f1f3;
  color: var(--ink);
}

.button-danger {
  background: var(--rose);
  color: #a23c54;
}

.button-wide {
  width: 100%;
  margin-top: 14px;
}

.form-error {
  min-height: 22px;
  margin: 12px 0 0;
  color: #b33e50;
  font-size: .9rem;
  font-weight: 700;
}

.page {
  width: min(100%, 760px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 0 16px calc(112px + env(safe-area-inset-bottom));
}

.topbar {
  display: flex;
  min-height: 84px;
  padding: 14px 2px 10px;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.live-status {
  display: inline-flex;
  padding: 7px 10px;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  background: rgb(255 255 255 / 85%);
  color: var(--muted);
  font-size: .72rem;
  font-weight: 850;
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #c9bec2;
  transition: background .2s, box-shadow .2s;
}

.live-status.connected {
  color: var(--mint-dark);
}

.live-status.connected .live-dot {
  background: #43b584;
  box-shadow: 0 0 0 4px rgb(67 181 132 / 14%);
}

.logo-button,
.icon-button {
  border: 0;
  background: transparent;
  cursor: pointer;
}

.logo-button {
  display: flex;
  padding: 5px;
  align-items: center;
  gap: 9px;
  color: var(--coral-dark);
  font-size: 1.35rem;
  font-weight: 900;
}

.logo-basket {
  font-size: 1.8rem;
}

.icon-button {
  width: 44px;
  height: 44px;
  border-radius: 15px;
  background: white;
  box-shadow: 0 6px 20px rgb(77 43 63 / 8%);
  font-size: 1.1rem;
}

.content {
  padding-bottom: 20px;
}

.hero {
  padding: 24px 22px;
  overflow: hidden;
  border-radius: 28px;
  background: linear-gradient(135deg, var(--lemon), #fff0c9);
  position: relative;
}

.hero::after {
  content: "🥑";
  position: absolute;
  right: 18px;
  bottom: -8px;
  font-size: 76px;
  transform: rotate(9deg);
  opacity: .9;
}

.hero h1,
.section-header h1,
.section-header h2 {
  margin: 4px 0 8px;
  line-height: 1.12;
  letter-spacing: -.6px;
}

.hero p {
  width: 70%;
  margin: 0;
  color: #725a3c;
  line-height: 1.45;
}

.eyebrow {
  color: var(--coral-dark);
  font-size: .76rem;
  font-weight: 900;
  letter-spacing: .09em;
  text-transform: uppercase;
}

.section-header {
  display: flex;
  margin: 26px 2px 14px;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
}

.section-header p {
  margin: 0;
  color: var(--muted);
}

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

.list-card,
.panel,
.product-row,
.shopping-item {
  border: 1px solid rgb(238 229 231 / 90%);
  background: rgb(255 255 255 / 94%);
  box-shadow: 0 8px 25px rgb(77 43 63 / 6%);
}

.list-card {
  width: 100%;
  padding: 17px 18px;
  border-radius: 20px;
  text-align: left;
  cursor: pointer;
}

.list-card-top,
.list-card-bottom,
.row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.list-card h3 {
  margin: 0;
  font-size: 1.05rem;
}

.list-card-bottom {
  margin-top: 10px;
  color: var(--muted);
  font-size: .86rem;
}

.status-pill {
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--mint);
  color: var(--mint-dark);
  font-size: .73rem;
  font-weight: 900;
}

.status-pill.completed {
  background: var(--lavender);
  color: #665192;
}

.progress-track {
  height: 8px;
  margin-top: 13px;
  overflow: hidden;
  border-radius: 99px;
  background: #f0eaeb;
}

.progress-bar {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--coral), #ffb277);
  transition: width .25s ease;
}

.empty-state {
  padding: 34px 22px;
  border: 2px dashed #e8dcde;
  border-radius: 24px;
  text-align: center;
  background: rgb(255 255 255 / 55%);
}

.empty-state .empty-icon {
  display: block;
  margin-bottom: 8px;
  font-size: 46px;
}

.empty-state h3 {
  margin: 0 0 7px;
}

.empty-state p {
  margin: 0 0 16px;
  color: var(--muted);
}

.bottom-nav {
  display: grid;
  position: fixed;
  z-index: 10;
  right: 12px;
  bottom: calc(10px + env(safe-area-inset-bottom));
  left: 12px;
  max-width: 720px;
  min-height: 72px;
  margin: 0 auto;
  padding: 7px;
  grid-template-columns: repeat(3, 1fr);
  border: 1px solid rgb(255 255 255 / 70%);
  border-radius: 24px;
  background: rgb(255 255 255 / 92%);
  box-shadow: 0 14px 35px rgb(77 43 63 / 16%);
  backdrop-filter: blur(16px);
}

.nav-button {
  display: grid;
  padding: 6px 2px;
  place-items: center;
  gap: 2px;
  border: 0;
  border-radius: 18px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: .67rem;
  font-weight: 800;
}

.nav-button .nav-icon {
  font-size: 1.25rem;
}

.nav-button.active {
  background: var(--rose);
  color: var(--coral-dark);
}

.panel {
  padding: 20px;
  border-radius: var(--radius);
}

.form-grid {
  display: grid;
  gap: 18px;
}

.product-picker {
  display: grid;
  gap: 10px;
}

.category-group {
  display: grid;
  gap: 9px;
}

.category-group + .category-group {
  margin-top: 18px;
}

.category-heading {
  display: flex;
  margin: 0 3px;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: .82rem;
  font-weight: 900;
  letter-spacing: .025em;
}

.picker-row {
  display: grid;
  padding: 12px;
  grid-template-columns: 32px minmax(0, 1fr) minmax(90px, 32%);
  align-items: center;
  gap: 10px;
  border: 2px solid var(--line);
  border-radius: 18px;
  background: #fff;
  transition: border-color .2s, background .2s;
}

.picker-row.selected {
  border-color: #8ed7ba;
  background: #f1fff9;
}

.picker-row input[type="checkbox"] {
  width: 22px;
  height: 22px;
  accent-color: var(--mint-dark);
}

.picker-name {
  min-width: 0;
  overflow: hidden;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.quantity-input {
  min-height: 42px;
  padding: 0 10px;
  border-radius: 13px;
}

.filters {
  display: flex;
  margin-bottom: 16px;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
}

.filter-button {
  padding: 9px 14px;
  border: 0;
  border-radius: 999px;
  background: #f3edef;
  color: var(--muted);
  cursor: pointer;
  font-weight: 800;
  white-space: nowrap;
}

.filter-button.active {
  background: var(--ink);
  color: white;
}

.add-product-form {
  display: grid;
  margin-bottom: 18px;
  grid-template-columns: minmax(0, 1fr) minmax(118px, .65fr) auto;
  gap: 9px;
}

.add-product-form select {
  min-width: 0;
  padding: 0 10px;
  border: 2px solid var(--line);
  border-radius: 16px;
  outline: none;
  background: #fff;
  color: var(--ink);
}

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

.product-row {
  display: flex;
  min-height: 62px;
  padding: 10px 11px 10px 16px;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-radius: 18px;
}

.product-row strong {
  min-width: 0;
  overflow-wrap: anywhere;
}

.product-main {
  display: grid;
  min-width: 0;
  gap: 4px;
}

.category-badge {
  width: max-content;
  max-width: 100%;
  padding: 3px 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #f5efff;
  color: #6b5895;
  font-size: .7rem;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.product-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 6px;
}

.mini-button {
  width: 39px;
  height: 39px;
  border: 0;
  border-radius: 13px;
  background: #f7f1f3;
  cursor: pointer;
}

.back-button {
  display: inline-flex;
  margin: 4px 0 14px;
  padding: 8px 3px;
  align-items: center;
  gap: 7px;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 800;
}

.list-detail-head {
  padding: 22px;
  border-radius: 26px;
  background: linear-gradient(145deg, var(--lavender), #f6f0ff);
}

.list-detail-head h1 {
  margin: 5px 0 12px;
  overflow-wrap: anywhere;
}

.shopping-items {
  display: grid;
  margin: 15px 0;
  gap: 10px;
}

.shopping-category + .shopping-category {
  margin-top: 18px;
}

.shopping-category .category-heading {
  margin: 0 5px 8px;
}

.shopping-category .shopping-items {
  margin: 0;
}

.shopping-item {
  display: grid;
  min-height: 74px;
  padding: 12px 15px;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  align-items: center;
  gap: 11px;
  border-radius: 20px;
}

.shopping-item.checked {
  background: #f3fff9;
}

.shopping-item.checked .item-name {
  color: var(--muted);
  text-decoration: line-through;
}

.check-button {
  display: grid;
  width: 42px;
  height: 42px;
  padding: 0;
  place-items: center;
  border: 3px solid #ddd2d6;
  border-radius: 50%;
  background: white;
  cursor: pointer;
  transition: background .2s, border-color .2s, transform .15s;
}

.check-button:active {
  transform: scale(.9);
}

.check-button svg {
  width: 23px;
  opacity: 0;
  stroke: white;
  stroke-width: 4;
  transition: opacity .15s, transform .2s;
  transform: scale(.5);
}

.checked .check-button,
.check-button.is-checked {
  border-color: #59b990;
  background: #59b990;
  box-shadow: 0 5px 13px rgb(38 120 95 / 22%);
}

.checked .check-button svg,
.check-button.is-checked svg {
  opacity: 1;
  transform: scale(1);
}

.item-name {
  display: block;
  overflow-wrap: anywhere;
  font-weight: 850;
}

.item-quantity {
  padding: 6px 10px;
  border-radius: 12px;
  background: var(--lemon);
  color: #715b1f;
  font-size: .82rem;
  font-weight: 850;
  white-space: nowrap;
}

.finish-button {
  width: 100%;
  min-height: 58px;
  margin-top: 8px;
  border-radius: 19px;
  font-size: 1.08rem;
}

.detail-actions {
  display: grid;
  margin-top: 12px;
  gap: 9px;
}

.template-button {
  width: 100%;
  min-height: 52px;
}

.completed-note {
  padding: 15px;
  border-radius: 17px;
  background: var(--mint);
  color: var(--mint-dark);
  text-align: center;
  font-weight: 850;
}

.toast {
  position: fixed;
  z-index: 30;
  right: 18px;
  bottom: calc(100px + env(safe-area-inset-bottom));
  left: 18px;
  max-width: 480px;
  margin: auto;
  padding: 13px 17px;
  border-radius: 16px;
  background: var(--ink);
  color: white;
  box-shadow: var(--shadow);
  font-weight: 750;
  opacity: 0;
  pointer-events: none;
  transform: translateY(15px);
  transition: opacity .2s, transform .2s;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.dialog {
  width: min(calc(100% - 30px), 430px);
  padding: 24px;
  border: 0;
  border-radius: 28px;
  color: var(--ink);
  box-shadow: 0 25px 80px rgb(52 42 63 / 28%);
}

.dialog::backdrop {
  background: rgb(52 42 63 / 42%);
  backdrop-filter: blur(4px);
}

.dialog h2 {
  margin: 5px 0 18px;
}

.dialog .field + .field {
  margin-top: 14px;
}

.dialog-copy-text {
  margin: -8px 0 18px;
  color: var(--muted);
  line-height: 1.45;
}

.dialog-close {
  float: right;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 50%;
  background: #f5eff1;
  cursor: pointer;
  font-size: 1.5rem;
}

.dialog-actions {
  display: grid;
  margin-top: 20px;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}

@media (min-width: 640px) {
  .page { padding-right: 24px; padding-left: 24px; }
  .hero { padding: 30px; }
  .hero::after { right: 35px; font-size: 94px; }
  .list-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
}

@media (max-width: 520px) {
  .add-product-form {
    grid-template-columns: 1fr auto;
  }

  .add-product-form select {
    grid-column: 1 / -1;
    grid-row: 2;
    min-height: 48px;
  }
}

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