:root {
  --cream: #f7f1e7;
  --paper: #fffdf8;
  --ink: #332b26;
  --muted: #756b63;
  --line: #ded3c5;
  --accent: #7f6a58;
  --accent-dark: #625144;
  --accent-soft: #eee4d8;
  --green-soft: #e9f0e8;
  --danger: #8a4f4f;
  --shadow: 0 10px 30px rgba(78, 62, 48, 0.08);
}

* { box-sizing: border-box; }

html { background: var(--cream); }

body {
  margin: 0;
  min-width: 320px;
  background: var(--cream);
  color: var(--ink);
  font-family: ui-rounded, "SF Pro Rounded", "Segoe UI", system-ui, -apple-system, sans-serif;
}

button, input, select { font: inherit; }
button { cursor: pointer; }

.app-shell {
  width: min(100%, 720px);
  margin: 0 auto;
  padding: 18px 14px calc(28px + env(safe-area-inset-bottom));
}

.hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 6px 18px;
}

.hero h1, .card h2 { margin: 0; }
.hero h1 { font-size: clamp(2rem, 9vw, 3.2rem); line-height: 1; letter-spacing: -0.04em; }
.subtitle { margin: 8px 0 0; color: var(--muted); }
.hero-cart { font-size: clamp(3rem, 14vw, 5.2rem); transform: rotate(-4deg); }

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

.card {
  margin-bottom: 14px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.active-card { border-width: 1.5px; }
.section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.section-heading.compact { align-items: center; }
.card h2 { font-size: 1.15rem; }

.badge {
  padding: 6px 9px;
  border-radius: 999px;
  background: var(--green-soft);
  color: #4e664b;
  font-size: 0.76rem;
  font-weight: 700;
  white-space: nowrap;
}

.empty-state { padding: 22px 4px 14px; text-align: center; color: var(--muted); }
.empty-state p { margin: 8px auto 0; max-width: 280px; }
.empty-icon { font-size: 3rem; filter: grayscale(0.15); }

.store-name { margin: 0 0 8px; color: var(--muted); font-weight: 650; }
.aisle-display { display: flex; align-items: baseline; gap: 10px; margin: 2px 0 8px; }
.aisle-label { font-size: 0.8rem; font-weight: 800; letter-spacing: 0.12em; color: var(--muted); }
.aisle-display strong { font-size: clamp(2.4rem, 12vw, 4.1rem); line-height: 0.95; letter-spacing: -0.04em; }
.meta { margin: 0 0 10px; font-weight: 650; }
.note { margin: 0 0 10px; padding: 11px 12px; border-radius: 14px; background: var(--accent-soft); }
.time-text { margin: 0 0 14px; color: var(--muted); font-size: 0.9rem; }

.field { display: block; margin-bottom: 14px; }
.field > span, fieldset legend { display: block; margin-bottom: 6px; font-size: 0.88rem; font-weight: 750; }
.field em, fieldset em { color: var(--muted); font-size: 0.76rem; font-style: normal; font-weight: 500; }

input, select {
  width: 100%;
  min-height: 48px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  outline: none;
  background: #fff;
  color: var(--ink);
  font-size: 16px;
}

input:focus, select:focus, button:focus-visible { outline: 3px solid rgba(127,106,88,0.22); outline-offset: 2px; }
#aisleInput { text-transform: uppercase; font-weight: 800; letter-spacing: 0.04em; }

.field-grid { display: grid; grid-template-columns: 0.75fr 1.25fr; gap: 10px; }
.position-fieldset { margin: 0 0 14px; padding: 0; border: 0; }
.segmented { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.segmented button {
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #fff;
  color: var(--ink);
  font-weight: 700;
}
.segmented button.selected { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-dark); }

.button {
  min-height: 46px;
  padding: 11px 15px;
  border-radius: 14px;
  border: 1px solid transparent;
  font-weight: 800;
}
.button-full { width: 100%; }
.button-primary { background: var(--accent); color: #fff; }
.button-primary:active { background: var(--accent-dark); }
.button-secondary { background: var(--accent-soft); color: var(--accent-dark); border-color: #d2c2b1; }
.button-plain { background: transparent; color: var(--muted); border-color: var(--line); }
.text-button { border: 0; background: transparent; color: var(--accent-dark); font-weight: 800; padding: 8px; }
.form-message { min-height: 1.2em; margin: 10px 2px 0; color: var(--muted); font-size: 0.85rem; }

.store-form { margin-bottom: 14px; padding: 14px; border-radius: 16px; background: var(--accent-soft); }
.store-form-actions { display: flex; gap: 8px; }
.store-form-actions .button { flex: 1; }

.stores-list, .history-list { display: grid; gap: 9px; }
.store-row, .history-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}
.store-row:first-child, .history-row:first-child { border-top: 0; }
.store-main, .history-main { min-width: 0; }
.store-main strong, .history-main strong { display: block; overflow-wrap: anywhere; }
.store-main small, .history-main small { display: block; margin-top: 3px; color: var(--muted); }
.row-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 5px; }
.mini-button {
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #fff;
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 750;
}
.mini-button.danger { color: var(--danger); }

.install-card p:not(.eyebrow) { color: var(--muted); line-height: 1.5; }
.install-hint { margin-bottom: 0; font-size: 0.88rem; }

.empty-list { margin: 4px 0; padding: 10px 0; color: var(--muted); }
footer { padding: 6px 8px 12px; color: var(--muted); font-size: 0.78rem; text-align: center; }
.hidden { display: none !important; }

@media (max-width: 470px) {
  .field-grid { grid-template-columns: 1fr; gap: 0; }
  .hero { align-items: flex-end; }
  .hero-cart { font-size: 3.4rem; }
  .card { padding: 16px; border-radius: 20px; }
  .store-row, .history-row { align-items: flex-start; }
  .row-actions { max-width: 110px; }
}

@media (prefers-reduced-motion: no-preference) {
  .card { animation: appear 240ms ease both; }
  @keyframes appear { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
}
