:root {
  /* Cores tiradas do logo: verde do anel/texto, creme do fundo, dourado da moeda */
  --bg: #FBF7EA;
  --surface: #FFFFFF;
  --surface-2: #F3EFE1;
  --text: #1F2A23;
  --muted: #5E6B62;
  --border: #E6E0CC;
  --primary: #1B6B45;
  --primary-hover: #145536;
  --primary-soft: #E2F0E7;
  --accent: #F5C02E;
  --logo-bg: #FEF9E8;
  --danger: #C0392B;
  --info-bg: #EAF2FB;
  --info-text: #1F4C7A;
  --warn-bg: #FFF5E0;
  --warn-text: #7A5310;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 40, 25, .06), 0 4px 16px rgba(20, 40, 25, .06);
  --tesco: #00539F;
  --sainsburys: #F06C00;
  --asda: #5A9E1A;
  --morrisons: #00563F;
  --aldi: #1B2F7A;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121814;
    --surface: #1A221D;
    --surface-2: #222C25;
    --text: #E6EEE8;
    --muted: #9AAAA0;
    --border: #2E3A32;
    --primary: #45A86E;
    --primary-hover: #58BA80;
    --primary-soft: #1F3527;
    --info-bg: #17263A;
    --info-text: #A9C9EE;
    --warn-bg: #33280F;
    --warn-text: #F2D08A;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25);
    --tesco: #4D93D9;
    --sainsburys: #FF8A2B;
    --asda: #7CC43A;
    --morrisons: #3DAE84;
    --aldi: #5B7BD9;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: 'Nunito', system-ui, -apple-system, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); }
h1, h2 { line-height: 1.2; margin: 0 0 .4em; }
h1 { font-size: clamp(1.5rem, 4vw, 2rem); font-weight: 800; }
h2 { font-size: 1.15rem; font-weight: 800; }
.hidden { display: none !important; }
.muted { color: var(--muted); }

/* ---------- Topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 20px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--primary); font-size: 1.35rem; font-weight: 800; letter-spacing: -.01em; }
.brand img { border-radius: 50%; object-fit: cover; background: var(--logo-bg); }
.tabs-nav { display: flex; gap: 4px; }
.tabs-nav a {
  position: relative; display: flex; align-items: center; gap: 6px;
  padding: 8px 12px; border-radius: 999px;
  color: var(--muted); text-decoration: none; font-weight: 700;
}
.tabs-nav a:hover { background: var(--surface-2); color: var(--text); }
.tabs-nav a.active { background: var(--primary-soft); color: var(--primary); }
.tabs-nav svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.badge {
  font-style: normal; font-size: .72rem; font-weight: 800;
  background: var(--accent); color: #3A2A00;
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px;
  display: inline-grid; place-items: center;
}

main { max-width: 920px; margin: 0 auto; padding: 24px 16px 32px; min-height: calc(100vh - 140px); }

/* ---------- Buttons & form ---------- */
.btn {
  font: inherit; font-weight: 800; cursor: pointer;
  border: 1px solid transparent; border-radius: 10px;
  padding: 11px 18px; transition: background .15s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-hover); }
.btn.primary:disabled { opacity: .55; cursor: default; }
.btn.ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.small { padding: 7px 12px; font-size: .9rem; }
.btn.block { width: 100%; }
.btn.danger { color: var(--danger); }
input:not([type=checkbox]) {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px; padding: 11px 14px; width: 100%;
}
input:focus-visible, .btn:focus-visible, a:focus-visible, button:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--primary) 45%, transparent); outline-offset: 2px;
}
input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--primary); cursor: pointer; flex: none; }

/* ---------- Search ---------- */
.hero {
  display: grid; grid-template-columns: 200px 1fr; align-items: center; gap: 24px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px 24px 20px 20px; box-shadow: var(--shadow); margin-bottom: 18px;
}
.hero-logo { width: 100%; height: auto; border-radius: 12px; background: var(--logo-bg); }
.hero-body { min-width: 0; }
.hero p { color: var(--muted); margin: 0 0 16px; }
.search { display: flex; gap: 8px; }
.search input { font-size: 1.05rem; }
.search-btns { display: flex; gap: 8px; }
.scan-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }

/* ---------- Import a list ---------- */
.import-btn { display: inline-flex; align-items: center; gap: 6px; margin-left: auto; }
.list-header h1 { margin-right: auto; }
.link-btn.inline { padding: 0; font-size: inherit; text-decoration: underline; }
body.modal-open { overflow: hidden; }
.modal {
  position: fixed; inset: 0; z-index: 55; display: flex; align-items: center; justify-content: center;
  padding: 16px; background: rgba(15, 25, 18, .55);
}
.modal-card {
  width: min(640px, 100%); max-height: calc(100dvh - 32px); overflow-y: auto; overscroll-behavior: contain;
  background: var(--surface); color: var(--text); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px;
}
.modal-card h2 { margin: 0 0 6px; font-size: 1.3rem; }
.modal-card .muted { color: var(--muted); margin: 0 0 12px; font-size: .95rem; }
.modal-card textarea {
  width: 100%; font: inherit; font-size: 1rem; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; resize: vertical; min-height: 160px;
}
.import-summary { font-size: .9rem; color: var(--muted); margin: 8px 0 0; min-height: 1.4em; }
.import-summary a { color: var(--primary); font-weight: 800; }
.modal-actions {
  position: sticky; bottom: -20px; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px;
  margin: 16px -20px -20px; padding: 12px 20px 16px; background: var(--surface); border-top: 1px solid var(--border);
}
.progress { height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; margin: 6px 0 10px; }
.progress span { display: block; height: 100%; width: calc(var(--p, 0) * 100%); background: var(--primary); transition: width .3s; }
.imp-rows { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.imp-row { border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; background: var(--surface); }
.imp-row.off { opacity: .6; }
.imp-head { display: flex; align-items: center; gap: 10px; }
.imp-q { flex: 1; min-width: 0; font-weight: 800; overflow-wrap: anywhere; }
.imp-qty { display: inline-flex; align-items: center; gap: 6px; font-size: .85rem; color: var(--muted); font-weight: 700; }
.imp-qty input { width: 64px; padding: 6px 8px; text-align: center; }
.imp-status { margin: 8px 0 0 30px; font-size: .9rem; color: var(--muted); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.imp-status.warn { color: var(--warn-text); }
.imp-status .link-btn { padding: 0; text-decoration: underline; }
.spinner.small { width: 16px; height: 16px; border-width: 2px; margin: 0; display: inline-block; flex: none; }
.imp-pick { display: flex; align-items: center; gap: 10px; margin: 8px 0 0 30px; padding-left: 10px; border-left: 4px solid var(--c); }
.imp-pick .thumb { width: 44px; height: 44px; flex: none; font-size: 1.4rem; }
.imp-pick select {
  flex: 1; min-width: 0; width: 100%; font: inherit; font-size: .92rem; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px; padding: 9px 10px; text-overflow: ellipsis;
}

/* ---------- Barcode scanner ---------- */
.scanner { position: fixed; inset: 0; z-index: 60; background: #000; display: flex; flex-direction: column; }
.scanner video { flex: 1; width: 100%; min-height: 0; object-fit: cover; }
.scanner-frame {
  position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%);
  width: min(78vw, 360px); height: min(40vw, 180px); border-radius: 14px;
  box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .45); border: 3px solid var(--accent); overflow: hidden;
}
.scanner-line {
  position: absolute; left: 6%; right: 6%; top: 50%; height: 2px; background: #ff4d4d;
  box-shadow: 0 0 8px #ff4d4d; animation: scan-sweep 1.6s ease-in-out infinite alternate;
}
@keyframes scan-sweep { from { top: 18%; } to { top: 82%; } }
.scanner-bar {
  position: absolute; left: 0; right: 0; bottom: 0; display: flex; flex-direction: column; align-items: center; gap: 12px;
  padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); background: linear-gradient(transparent, rgba(0, 0, 0, .75) 35%);
}
.scanner-status { margin: 0; color: #fff; font-weight: 700; text-align: center; }
.scanner-bar .btn { background: #fff; color: #111; min-width: 140px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer; user-select: none;
  border: 1.5px solid var(--border); border-radius: 999px; padding: 6px 12px; font-weight: 700; font-size: .92rem;
  background: var(--surface); color: var(--muted);
}
.chip .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c); opacity: .35; }
.chip[aria-pressed=true] { border-color: var(--c); color: var(--text); background: color-mix(in srgb, var(--c) 10%, var(--surface)); }
.chip[aria-pressed=true] .dot { opacity: 1; }

/* ---------- Search history ---------- */
.history { margin-top: 16px; padding-top: 14px; border-top: 1px dashed var(--border); }
.history-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; font-size: .85rem; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.link-btn { font: inherit; font-size: .85rem; font-weight: 700; text-transform: none; letter-spacing: 0; background: none; border: 0; padding: 4px 6px; color: var(--primary); cursor: pointer; }
.history-items { display: flex; flex-wrap: wrap; gap: 8px; }
.history-empty { margin: 0; color: var(--muted); font-size: .92rem; }
.hist-chip { display: inline-flex; align-items: center; max-width: 100%; border: 1px solid var(--border); border-radius: 999px; background: var(--surface-2); }
.hist-q { display: inline-flex; align-items: center; gap: 6px; min-width: 0; font: inherit; font-size: .92rem; font-weight: 600; color: var(--text); background: none; border: 0; padding: 6px 4px 6px 12px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hist-q svg { flex: none; color: var(--muted); }
.hist-x { font: inherit; font-size: 1.1rem; line-height: 1; color: var(--muted); background: none; border: 0; padding: 6px 12px 6px 6px; cursor: pointer; }
.hist-x:hover, .hist-q:hover { color: var(--primary); }

.note { border-radius: 10px; padding: 10px 14px; margin: 0 0 14px; background: var(--warn-bg); color: var(--warn-text); font-size: .93rem; }
.note.info { background: var(--info-bg); color: var(--info-text); }
.note a { color: inherit; font-weight: 800; }

.results-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px 16px; margin: 6px 2px 10px; }
.results-head h2 { margin: 0; }
.results-tools { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 16px; }
.sort { display: inline-flex; align-items: center; gap: 2px; background: var(--surface-2); border-radius: 10px; padding: 3px; }
.sort-label { font-size: .85rem; font-weight: 700; color: var(--muted); padding: 0 8px 0 6px; }
.sort button { font: inherit; font-size: .9rem; font-weight: 800; border: none; background: none; color: var(--muted); padding: 6px 12px; border-radius: 8px; cursor: pointer; }
.sort button[aria-pressed=true] { background: var(--surface); color: var(--primary); box-shadow: var(--shadow); }
.sort-note { margin: -2px 2px 10px; font-size: .88rem; color: var(--muted); }
.price-unit { font-size: .8rem; color: var(--muted); font-weight: 700; }
.price-unit.focus { font-size: .95rem; color: var(--primary); font-weight: 800; }
.check-all { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--muted); cursor: pointer; white-space: nowrap; }

.results { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.item {
  display: grid; grid-template-columns: auto 52px 1fr auto; align-items: center; gap: 14px;
  background: var(--surface); border: 1.5px solid var(--border); border-radius: var(--radius);
  padding: 12px 16px; cursor: pointer; transition: border-color .15s, background .15s;
}
.item:hover { border-color: color-mix(in srgb, var(--primary) 40%, var(--border)); }
.item.selected { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 5%, var(--surface)); }
.item.in-list { opacity: .7; }
.thumb {
  width: 52px; height: 52px; border-radius: 10px; background: var(--surface-2);
  display: grid; place-items: center; font-size: 1.7rem; overflow: hidden;
}
.thumb img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.info { min-width: 0; }
.name { font-weight: 700; overflow-wrap: anywhere; }
.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-top: 4px; font-size: .85rem; color: var(--muted); }
.store-tag { font-weight: 800; font-size: .75rem; letter-spacing: .02em; color: #fff; background: var(--c); padding: 2px 8px; border-radius: 6px; }
.promo { color: var(--primary); font-weight: 700; }
.rank { font-size: .75rem; font-weight: 800; color: #3A2A00; background: var(--accent); padding: 2px 8px; border-radius: 6px; }
.price-col { text-align: right; white-space: nowrap; }
.price { font-size: 1.25rem; font-weight: 800; }
.price-old { font-size: .85rem; color: var(--muted); text-decoration: line-through; }
.price-card { font-size: .78rem; font-weight: 800; color: var(--primary); }
.price-card.locked { color: var(--muted); font-weight: 700; }
.in-list-tag { font-size: .78rem; font-weight: 800; color: var(--primary); }

.empty { text-align: center; color: var(--muted); padding: 40px 16px; }
.empty .big { font-size: 2.6rem; display: block; margin-bottom: 6px; }

.add-bar {
  position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 15;
  width: min(880px, calc(100% - 32px));
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--text); color: var(--bg); border-radius: 16px; padding: 10px 10px 10px 18px;
  box-shadow: 0 10px 30px rgba(0,0,0,.25); font-weight: 700;
}

/* ---------- List ---------- */
.list-header { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.list-actions { display: flex; gap: 8px; }
.store-tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; margin-bottom: 14px; border-bottom: 1px solid var(--border); }
.store-tab {
  font: inherit; font-weight: 800; cursor: pointer; white-space: nowrap;
  background: none; border: none; border-bottom: 3px solid transparent;
  padding: 10px 14px; color: var(--muted); display: flex; align-items: center; gap: 8px;
}
.store-tab .count { font-size: .75rem; background: var(--surface-2); color: var(--muted); border-radius: 999px; padding: 1px 8px; }
.store-tab.active { color: var(--text); border-bottom-color: var(--c, var(--primary)); }
.store-tab.active .count { background: var(--c, var(--primary)); color: #fff; }
.store-group { margin-bottom: 20px; }
.store-group h3 { display: flex; justify-content: space-between; align-items: center; margin: 0 0 8px; font-size: 1rem; }
.store-group h3 .store-tag { font-size: .85rem; padding: 4px 10px; }
.list-item {
  display: grid; grid-template-columns: auto 44px 1fr auto auto; align-items: center; gap: 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; margin-bottom: 6px;
}
.list-item .thumb { width: 44px; height: 44px; font-size: 1.4rem; }
.list-item.done .name { text-decoration: line-through; color: var(--muted); }
.list-item.done .thumb { opacity: .5; }
.qty { display: flex; align-items: center; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.qty button { font: inherit; font-weight: 800; width: 32px; height: 32px; border: none; background: var(--surface-2); color: var(--text); cursor: pointer; }
.qty button:hover { background: var(--primary-soft); }
.qty span { min-width: 28px; text-align: center; font-weight: 800; }
.icon-btn { border: none; background: none; cursor: pointer; color: var(--muted); padding: 6px; border-radius: 8px; display: grid; place-items: center; }
.icon-btn:hover { color: var(--danger); background: var(--surface-2); }
.icon-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.line-total { text-align: right; min-width: 70px; }
.line-total .price { font-size: 1.05rem; }
.subtotal { font-weight: 800; }
.totals { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.totals .row { display: flex; justify-content: space-between; padding: 3px 0; }
.totals .row.grand { font-size: 1.3rem; font-weight: 800; border-top: 1px solid var(--border); margin-top: 8px; padding-top: 10px; }
.totals .save { color: var(--primary); font-weight: 800; }

/* ---------- Account ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); }
.narrow { max-width: 420px; margin: 20px auto; }
.seg { display: grid; grid-template-columns: 1fr 1fr; background: var(--surface-2); border-radius: 10px; padding: 4px; margin-bottom: 18px; }
.seg button { font: inherit; font-weight: 800; border: none; background: none; padding: 9px; border-radius: 8px; cursor: pointer; color: var(--muted); }
.seg button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.field { display: grid; gap: 6px; font-weight: 700; margin-bottom: 14px; }
.form-error { color: var(--danger); min-height: 1.2em; margin: 0 0 10px; font-weight: 700; font-size: .92rem; }
.profile-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 18px; }
.cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; margin-top: 14px; }
.loyalty {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow);
}
.loyalty .band { background: var(--c); color: #fff; padding: 12px 16px; font-weight: 800; display: flex; justify-content: space-between; align-items: center; }
.loyalty .band small { font-weight: 700; opacity: .9; }
.loyalty .body { padding: 14px 16px; }
.loyalty form { display: flex; gap: 8px; }
.loyalty .saved { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.loyalty .num { font-family: ui-monospace, Consolas, monospace; font-weight: 700; letter-spacing: .08em; }
.loyalty .err { color: var(--danger); font-size: .85rem; font-weight: 700; margin: 6px 0 0; min-height: 1em; }

.section-title { margin-top: 28px; }
.small { font-size: .88rem; }
#connect-box, #connected-box { margin-bottom: 8px; }
#connect-form { max-width: 480px; }
#connected-box .profile-head { margin-bottom: 0; }
#connected-box h2 { margin-bottom: 2px; }
.sync-ok { color: var(--primary); font-weight: 700; }

/* ---------- Opening animation ---------- */
.splash {
  position: fixed; inset: 0; z-index: 100;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
  background: var(--bg); overflow: hidden; cursor: pointer;
  animation: splash-out .45s ease 3.3s forwards; /* also hides itself if the script never runs */
}
.splash.skip { animation: splash-out .25s ease forwards; }
.splash-stage { position: relative; width: 300px; height: 170px; margin-top: 70px; perspective: 700px; }

/* The shopping list rises from behind the sheep and the coin once the sheep arrives.
   The wrapper hides the paper until it climbs out, with a soft fade at the bottom. */
.splash-list-wrap {
  position: absolute; left: 128px; top: -62px; width: 150px; height: 196px; overflow: hidden;
  -webkit-mask-image: linear-gradient(to bottom, #000 85%, transparent);
  mask-image: linear-gradient(to bottom, #000 85%, transparent);
}
.splash-list {
  position: absolute; left: 34px; top: 12px; width: 78px; height: auto;
  transform: rotate(8deg);
  filter: drop-shadow(0 2px 3px rgba(80, 60, 20, .15));
  animation: list-slide .8s cubic-bezier(.2, .8, .25, 1) 1.45s both;
}
@keyframes list-slide {
  from { transform: translateY(175px) rotate(8deg); }
  to { transform: translateY(0) rotate(8deg); }
}

.splash-coin {
  position: absolute; left: 172px; top: 28px; width: 112px; height: 112px;
  transform-style: preserve-3d;
  animation: coin-spin 1.2s linear infinite;
}
.coin-face { position: absolute; inset: 0; width: 100%; height: 100%; backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.coin-face.back { transform: rotateY(180deg); }

.splash-sheep {
  position: absolute; left: 22px; top: 22px; width: 180px; z-index: 1;
  animation: sheep-run 1.5s cubic-bezier(.22, .7, .3, 1) both;
}
.splash-sheep svg { display: block; width: 100%; height: auto; overflow: visible; }
.splash-sheep .bob { animation: sheep-bob .3s ease-in-out 5; }
.splash-sheep .leg { transform-box: fill-box; transform-origin: 50% 10%; }
.splash-sheep .leg-a { animation: leg-swing .3s linear 5; }
.splash-sheep .leg-b { animation: leg-swing .3s linear 5 reverse; }

.splash-word { text-align: center; animation: word-in .5s ease 1.95s both; }
.splash-word span { display: block; font-size: 2.2rem; font-weight: 800; color: var(--primary); letter-spacing: -.01em; }
.splash-word small { display: block; font-size: 1rem; color: var(--muted); font-weight: 600; }

@keyframes sheep-run { from { transform: translateX(calc(-50vw - 260px)); } to { transform: translateX(0); } }
@keyframes sheep-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-7px); } }
@keyframes leg-swing { 0% { transform: rotate(0); } 25% { transform: rotate(28deg); } 75% { transform: rotate(-28deg); } 100% { transform: rotate(0); } }
@keyframes coin-spin { from { transform: rotateY(0); } to { transform: rotateY(360deg); } }
@keyframes word-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes splash-out { to { opacity: 0; visibility: hidden; } }

@media (prefers-reduced-motion: reduce) {
  .splash-sheep, .splash-sheep .bob, .splash-sheep .leg, .splash-coin, .splash-word, .splash-list { animation: none; }
  .scanner-line { animation: none; }
  .splash { animation-delay: 1s; }
}

/* ---------- Credits ---------- */
.credits { text-align: center; color: var(--muted); font-size: .85rem; padding: 8px 16px 96px; }
.credits p { margin: 0; }
.credits strong { color: var(--primary); font-weight: 800; }
.credits a { text-decoration: none; }
.credits a:hover strong, .credits a:focus-visible strong { text-decoration: underline; }
.credits .copyright { margin-top: 4px; font-size: .75rem; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; top: 76px; transform: translate(-50%, -20px); opacity: 0; pointer-events: none;
  background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 999px; font-weight: 700;
  transition: opacity .2s, transform .2s; z-index: 50; max-width: calc(100% - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.spinner { width: 34px; height: 34px; border: 4px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; margin: 0 auto 10px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Mobile ---------- */
@media (max-width: 640px) {
  .topbar { padding: 8px 12px; }
  .brand span { display: none; }
  .tabs-nav a { padding: 8px 10px; }
  .tabs-nav a span:not(.badge) { display: none; }
  .hero { grid-template-columns: 1fr; gap: 12px; padding: 16px; }
  .hero-logo { width: 180px; justify-self: center; }
  .search { flex-direction: column; }
  .search-btns .btn { flex: 1; }
  .modal { padding: 0; align-items: flex-end; }
  .modal-card { max-height: 92dvh; border-radius: var(--radius) var(--radius) 0 0; padding: 18px 16px; }
  .modal-actions { margin: 16px -16px -18px; padding: 12px 16px calc(14px + env(safe-area-inset-bottom)); bottom: -18px; }
  .modal-actions .btn { flex: 1 1 auto; }
  .imp-pick, .imp-status { margin-left: 0; }
  .imp-pick .thumb { display: none; }
  .item { grid-template-columns: auto 44px 1fr; gap: 10px; padding: 12px; }
  .item .thumb { width: 44px; height: 44px; }
  .item .price-col { grid-column: 2 / -1; text-align: left; display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
  .list-item { grid-template-columns: auto 1fr auto; }
  .list-item .thumb { display: none; }
  .list-item .line-total { grid-column: 2; text-align: left; }
  .list-item .qty { grid-column: 3; grid-row: 1; }
  .list-item .icon-btn { grid-column: 3; grid-row: 2; justify-self: end; }
}
