:root {
  color-scheme: light;
  --ink: #1e1f1c;
  --muted: #74766f;
  --paper: #f5f1e9;
  --panel: #fffdf8;
  --line: #ddd8cd;
  --accent: #ff5b2e;
  --accent-dark: #d83e17;
  --green: #1d7a56;
  --green-soft: #e5f2ea;
  --shadow: 0 18px 45px rgba(56, 45, 28, 0.1);
  --radius: 24px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* {
  box-sizing: border-box;
}

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

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 0 0, rgba(255, 91, 46, 0.12), transparent 28rem),
    var(--paper);
}

.login-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: max(24px, env(safe-area-inset-top)) 18px max(24px, env(safe-area-inset-bottom));
}

.login-card {
  width: min(100%, 430px);
  padding: 34px 28px;
  border: 1px solid var(--line);
  border-radius: 30px;
  background: rgba(255, 253, 248, 0.96);
  box-shadow: var(--shadow);
}

.login-mark {
  display: grid;
  width: 58px;
  height: 58px;
  margin-bottom: 24px;
  place-items: center;
  border-radius: 18px;
  color: white;
  background: var(--accent);
  box-shadow: 0 10px 24px rgba(255, 91, 46, 0.24);
  font-size: 1.55rem;
  font-weight: 900;
}

.login-card h1 {
  margin-bottom: 16px;
}

.login-copy,
.dialog-copy {
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.55;
}

.login-form,
.password-form {
  display: grid;
  gap: 9px;
  margin-top: 24px;
}

.login-form label,
.password-form label {
  margin-top: 7px;
  font-size: 0.76rem;
  font-weight: 800;
}

.login-form input,
.password-form input {
  width: 100%;
  height: 52px;
  padding: 0 15px;
  border: 1px solid var(--line);
  border-radius: 16px;
  color: var(--ink);
  background: white;
}

.login-form .primary-button,
.password-form .primary-button {
  width: 100%;
  margin-top: 8px;
}

.login-error {
  margin: 14px 0 0;
  color: #9b3425;
  font-size: 0.78rem;
  font-weight: 750;
}

.privacy-note {
  margin: 24px 0 0;
  color: var(--muted);
  font-size: 0.68rem;
  line-height: 1.45;
  text-align: center;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

.app-shell {
  width: min(100%, 760px);
  min-height: 100vh;
  margin: 0 auto;
  padding: max(24px, env(safe-area-inset-top)) 18px max(36px, env(safe-area-inset-bottom));
}

.topbar,
.section-heading,
.summary-card,
.completed-toggle,
.app-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.topbar {
  gap: 16px;
  margin-bottom: 20px;
}

.eyebrow,
.section-kicker {
  margin: 0 0 4px;
  color: var(--accent-dark);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.16em;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.1rem, 7vw, 3.5rem);
  font-weight: 500;
  letter-spacing: -0.04em;
  line-height: 0.95;
}

h2 {
  margin-bottom: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.5rem;
  font-weight: 500;
  letter-spacing: -0.025em;
}

.sync-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 253, 248, 0.78);
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 700;
}

.sync-pill:focus-visible,
button:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(255, 91, 46, 0.28);
  outline-offset: 2px;
}

.sync-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #d4a129;
  box-shadow: 0 0 0 4px rgba(212, 161, 41, 0.13);
}

.sync-pill.online .sync-dot {
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(29, 122, 86, 0.13);
}

.sync-pill.offline .sync-dot {
  background: #ae3e2e;
  box-shadow: 0 0 0 4px rgba(174, 62, 46, 0.13);
}

.summary-card {
  gap: 22px;
  margin-bottom: 18px;
  padding: 20px 22px;
  border: 1px solid rgba(255, 91, 46, 0.19);
  border-radius: var(--radius);
  background: linear-gradient(135deg, #fff4ec, #fffdf8 64%);
  box-shadow: var(--shadow);
}

.summary-card > div:not(.summary-divider) {
  min-width: 0;
  flex: 1;
}

.summary-card > div:last-child {
  text-align: right;
}

.summary-number,
.summary-label {
  display: block;
}

.summary-number {
  font-size: 1.65rem;
  font-weight: 800;
  letter-spacing: -0.035em;
}

.summary-label {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.78rem;
}

.summary-divider {
  width: 1px;
  height: 42px;
  background: var(--line);
}

.add-panel,
.list-section,
.completed-section {
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 253, 248, 0.93);
  box-shadow: 0 10px 32px rgba(56, 45, 28, 0.06);
}

.add-panel,
.list-section {
  padding: 22px;
}

.section-heading {
  gap: 14px;
  margin-bottom: 18px;
}

.section-heading.compact {
  margin-bottom: 12px;
}

.voice-hint,
.people-mark {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
}

.people-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  color: var(--green);
  background: var(--green-soft);
}

.add-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.add-form input {
  min-width: 0;
  height: 52px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  color: var(--ink);
  background: white;
  font-size: 1rem;
}

.add-form input::placeholder {
  color: #9b9b94;
}

.primary-button {
  min-width: 92px;
  height: 52px;
  padding: 0 18px;
  border: 0;
  border-radius: 16px;
  color: white;
  background: var(--accent);
  box-shadow: 0 8px 20px rgba(255, 91, 46, 0.24);
  cursor: pointer;
  font-weight: 800;
}

.primary-button:active {
  transform: translateY(1px);
}

.primary-button:disabled {
  opacity: 0.55;
  cursor: wait;
}

.input-note {
  margin: 9px 2px 0;
  color: var(--muted);
  font-size: 0.74rem;
  line-height: 1.45;
}

.search-region {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.search-status {
  min-height: 18px;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
}

.product-grid {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(155px, 45%);
  gap: 10px;
  overflow-x: auto;
  padding: 2px 2px 10px;
  scroll-snap-type: x proximity;
}

.product-card {
  position: relative;
  display: flex;
  min-height: 208px;
  flex-direction: column;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: white;
  cursor: pointer;
  scroll-snap-align: start;
  text-align: left;
}

.product-card:hover {
  border-color: rgba(255, 91, 46, 0.5);
}

.product-card img {
  width: 100%;
  height: 102px;
  margin-bottom: 9px;
  border-radius: 12px;
  object-fit: contain;
  background: #faf8f3;
}

.product-card strong {
  display: -webkit-box;
  overflow: hidden;
  margin-bottom: 8px;
  font-size: 0.79rem;
  line-height: 1.25;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.product-price {
  margin-top: auto;
  color: var(--accent-dark);
  font-size: 0.95rem;
  font-weight: 800;
}

.product-meta {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.66rem;
}

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

.shopping-item {
  display: grid;
  grid-template-columns: auto 48px minmax(0, 1fr) auto;
  align-items: center;
  gap: 11px;
  min-height: 68px;
  padding: 9px 10px;
  border: 1px solid transparent;
  border-radius: 18px;
  background: #faf7f1;
  transition: opacity 180ms ease, transform 180ms ease, background 180ms ease;
}

.shopping-item.updating {
  opacity: 0.56;
}

.shopping-item.just-added {
  animation: settle-in 300ms ease both;
}

@keyframes settle-in {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

.check-button {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 2px solid #b4b2aa;
  border-radius: 50%;
  background: white;
  cursor: pointer;
  font-size: 1rem;
}

.check-button:hover {
  border-color: var(--green);
}

.item-image,
.item-image-placeholder {
  width: 48px;
  height: 48px;
  border-radius: 13px;
  background: white;
  object-fit: contain;
}

.item-image-placeholder {
  display: grid;
  place-items: center;
  color: var(--accent-dark);
  background: #fff0e8;
  font-size: 1.2rem;
  font-weight: 800;
}

.item-copy {
  min-width: 0;
}

.item-name {
  display: block;
  overflow: hidden;
  font-size: 0.92rem;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.item-detail {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.68rem;
}

.footer-button {
  padding: 4px 7px;
  border: 0;
  border-bottom: 1px solid currentColor;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-size: 0.68rem;
}

.settings-dialog {
  width: min(calc(100% - 28px), 430px);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 26px;
  color: var(--ink);
  background: var(--panel);
  box-shadow: 0 24px 70px rgba(30, 31, 28, 0.24);
}

.settings-dialog::backdrop {
  background: rgba(30, 31, 28, 0.46);
  backdrop-filter: blur(4px);
}

.settings-dialog h2 {
  margin-bottom: 10px;
}

.dialog-close-form {
  position: absolute;
  top: 13px;
  right: 13px;
}

.dialog-close {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: #efebe3;
  cursor: pointer;
  font-size: 1.2rem;
}

.password-note {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.7rem;
  line-height: 1.45;
}

.logout-button {
  width: 100%;
  margin-top: 20px;
  padding: 13px;
  border: 0;
  color: #9b3425;
  background: transparent;
  cursor: pointer;
  font-size: 0.76rem;
  font-weight: 800;
}

.item-price {
  color: var(--accent-dark);
  font-weight: 800;
}

.item-actions {
  display: flex;
  align-items: center;
  gap: 3px;
}

.quantity-button,
.delete-button {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  cursor: pointer;
  font-weight: 800;
}

.quantity-button:hover,
.delete-button:hover {
  background: #ece8df;
}

.quantity-value {
  min-width: 20px;
  text-align: center;
  font-size: 0.8rem;
  font-weight: 800;
}

.delete-button {
  color: #9b4536;
  font-size: 1rem;
}

.empty-state {
  padding: 34px 15px 24px;
  text-align: center;
}

.empty-icon {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  margin: 0 auto 12px;
  border-radius: 50%;
  color: var(--green);
  background: var(--green-soft);
  font-size: 1.55rem;
  font-weight: 800;
}

.empty-state h3 {
  margin-bottom: 6px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.25rem;
}

.empty-state p {
  max-width: 320px;
  margin: 0 auto;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.45;
}

.completed-section {
  overflow: hidden;
}

.completed-toggle {
  width: 100%;
  min-height: 56px;
  padding: 0 20px;
  border: 0;
  background: transparent;
  cursor: pointer;
  font-weight: 800;
}

.completed-list {
  padding: 0 12px 12px;
}

.completed-list .shopping-item {
  grid-template-columns: auto 40px minmax(0, 1fr) auto;
  min-height: 58px;
  opacity: 0.72;
}

.completed-list .item-name {
  text-decoration: line-through;
}

.completed-list .check-button {
  width: 32px;
  height: 32px;
  border-color: var(--green);
  color: white;
  background: var(--green);
}

.completed-list .item-image,
.completed-list .item-image-placeholder {
  width: 40px;
  height: 40px;
}

.app-footer {
  justify-content: center;
  gap: 6px;
  padding: 22px 8px 0;
  color: var(--muted);
  font-size: 0.68rem;
}

.toast {
  position: fixed;
  z-index: 20;
  right: 18px;
  bottom: max(22px, env(safe-area-inset-bottom));
  left: 18px;
  max-width: 520px;
  margin: auto;
  padding: 13px 16px;
  border-radius: 14px;
  color: white;
  background: #252622;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.24);
  font-size: 0.82rem;
  font-weight: 700;
  text-align: center;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  clip-path: inset(50%);
}

[hidden] {
  display: none !important;
}

@media (max-width: 520px) {
  .app-shell {
    padding-right: 12px;
    padding-left: 12px;
  }

  .add-panel,
  .list-section {
    padding: 18px 14px;
  }

  .voice-hint {
    max-width: 90px;
    text-align: right;
  }

  .shopping-item {
    grid-template-columns: auto 42px minmax(0, 1fr) auto;
    gap: 8px;
    padding-right: 6px;
    padding-left: 7px;
  }

  .item-image,
  .item-image-placeholder {
    width: 42px;
    height: 42px;
  }

  .quantity-button {
    width: 26px;
  }

  .delete-button {
    width: 25px;
  }

  .product-grid {
    grid-auto-columns: 48%;
  }
}

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