:root {
  --brand: #a71d6b;
  --brand-dark: #7d1450;
  --brand-soft: #f7e6ef;
  --ink: #1f1a1d;
  --muted: #6f6670;
  --line: #e9e3e6;
  --bg: #faf7f5;
  --card: #ffffff;
  --ok: #1f8a5b;
  --bad: #c2412d;
  --radius: 18px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--bg); }
body { overscroll-behavior: none; user-select: none; -webkit-user-select: none; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; touch-action: manipulation; }

.app {
  height: 100vh; height: 100dvh;
  display: grid;
  grid-template-columns: 1fr minmax(320px, 30vw);
  grid-template-rows: auto auto 1fr;
  grid-template-areas: "top basket" "cats basket" "grid basket";
}

.top { grid-area: top; display: flex; align-items: center; justify-content: space-between; padding: 22px 28px 10px; }
.brand { display: flex; gap: 16px; align-items: center; }
.logo { display: inline-grid; place-items: center; width: 56px; height: 56px; border-radius: 16px; background: var(--brand); color: #fff; font-weight: 800; letter-spacing: .5px; }
.brand h1 { margin: 0; font-size: 26px; letter-spacing: -.3px; }
.brand p { margin: 2px 0 0; color: var(--muted); font-size: 16px; }
.reader-pill { background: #fff3cd; color: #7a5300; padding: 10px 16px; border-radius: 999px; font-weight: 600; font-size: 15px; }

.crumb { grid-area: cats; display: flex; align-items: center; gap: 14px; padding: 8px 28px 14px; min-height: 64px; }
.crumb h2 { margin: 0; font-size: 22px; letter-spacing: -.2px; }
.back { padding: 12px 20px 12px 14px; border-radius: 999px; background: var(--ink); color: #fff; font-size: 17px; font-weight: 700; white-space: nowrap; }
.tile.cat-tile .ph, .tile.cat-tile img { height: clamp(130px, 15vw, 200px); }
.tile.cat-tile .name { font-size: 20px; font-weight: 700; }
.tile.cat-tile .price { color: var(--muted); font-weight: 600; font-size: 15px; }
.grid {
  grid-area: grid; overflow-y: auto; padding: 4px 28px 28px;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 16px; align-content: start; grid-auto-rows: max-content;
}
.tile {
  position: relative; display: block; width: 100%; padding: 0; text-align: left;
  background: var(--card); border-radius: var(--radius); overflow: hidden;
  box-shadow: 0 1px 0 var(--line), 0 6px 18px rgba(60, 20, 40, .06);
  transition: transform .08s ease;
}
.tile:active { transform: scale(.97); }
.tile .ph { width: 100%; height: clamp(100px, 11vw, 150px); background: var(--brand-soft); display: grid; place-items: center; font-size: 54px; line-height: 1; }
.tile .ph.c1 { background: #fbeee4; } .tile .ph.c2 { background: #e6f1f7; } .tile .ph.c3 { background: #f7e6ef; } .tile .ph.c4 { background: #eaf3e6; } .tile .ph.c5 { background: #f1ecf7; }
.tile img { width: 100%; height: clamp(100px, 11vw, 150px); object-fit: cover; display: block; }
.tile .meta { padding: 12px 14px 14px; }
.tile .name { font-size: 17px; font-weight: 600; line-height: 1.2; }
.tile .price { margin-top: 4px; font-size: 17px; color: var(--brand); font-weight: 700; }
.tile .badge { position: absolute; top: 10px; right: 10px; min-width: 34px; height: 34px; padding: 0 8px; border-radius: 999px; background: var(--brand); color: #fff; font-weight: 800; display: grid; place-items: center; box-shadow: 0 2px 8px rgba(0,0,0,.2); }
.empty-shop { color: var(--muted); font-size: 18px; }

.basket { grid-area: basket; background: var(--card); border-left: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.basket h2 { margin: 0; padding: 26px 24px 10px; font-size: 22px; }
.lines { list-style: none; margin: 0; padding: 0 16px; overflow-y: auto; flex: 1; }
.line { display: grid; grid-template-columns: 1fr auto; gap: 6px 10px; padding: 14px 8px; border-bottom: 1px solid var(--line); }
.line .n { font-weight: 600; font-size: 17px; }
.line .lp { font-weight: 700; font-size: 17px; text-align: right; }
.qty { display: flex; align-items: center; gap: 4px; grid-column: 1 / -1; }
.qty button { width: 44px; height: 44px; border-radius: 12px; background: var(--bg); border: 1px solid var(--line); font-size: 24px; font-weight: 700; line-height: 1; }
.qty span { min-width: 36px; text-align: center; font-weight: 700; font-size: 18px; }
.empty { color: var(--muted); padding: 6px 24px; flex: 1; font-size: 17px; }
.foot { padding: 18px 20px 24px; border-top: 1px solid var(--line); }
.total { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 14px; }
.total span { color: var(--muted); font-size: 18px; }
.total strong { font-size: 34px; letter-spacing: -.5px; }
.pay { display: block; width: 100%; padding: 22px; border-radius: 16px; background: var(--brand); color: #fff; font-size: 22px; font-weight: 800; text-align: center; text-decoration: none; }
.pay:active { background: var(--brand-dark); }
.pay:disabled { background: #d9cfd4; color: #fff; }
.pay.small { width: auto; padding: 18px 34px; font-size: 19px; }
.clear { display: block; width: 100%; margin-top: 10px; padding: 12px; color: var(--muted); font-size: 16px; font-weight: 600; }

.overlay { position: fixed; inset: 0; background: rgba(31, 26, 29, .55); backdrop-filter: blur(4px); display: grid; place-items: center; padding: 24px; z-index: 10; }
.sheet { background: var(--card); border-radius: 28px; width: min(560px, 100%); padding: 44px 36px; text-align: center; box-shadow: 0 30px 80px rgba(0,0,0,.3); }
.state { display: none; }
.sheet[data-state="starting"] .state[data-state="starting"],
.sheet[data-state="pending"] .state[data-state="pending"],
.sheet[data-state="paid"] .state[data-state="paid"],
.sheet[data-state="failed"] .state[data-state="failed"] { display: block; }
.sheet h2 { margin: 10px 0 6px; font-size: 28px; letter-spacing: -.3px; }
.hint { color: var(--muted); font-size: 19px; margin: 0 0 24px; }
.amount { font-size: 64px; font-weight: 800; margin: 0; color: var(--brand); letter-spacing: -1px; }
.arrow { display: inline-block; animation: bob 1.1s ease-in-out infinite; font-weight: 800; color: var(--brand); }
@keyframes bob { 50% { transform: translateY(8px); } }
.ghost { padding: 16px 30px; border-radius: 14px; border: 2px solid var(--line); font-weight: 700; font-size: 18px; }
.row { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.spinner { width: 64px; height: 64px; margin: 0 auto 10px; border: 6px solid var(--brand-soft); border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.tick svg { width: 110px; height: 110px; }
.tick circle { fill: none; stroke: var(--ok); stroke-width: 3; }
.tick path { fill: none; stroke: var(--ok); stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 40; stroke-dashoffset: 40; animation: draw .45s .15s ease forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
.cross { width: 96px; height: 96px; margin: 0 auto; border-radius: 50%; background: #fbe9e5; color: var(--bad); font-size: 56px; font-weight: 800; display: grid; place-items: center; }

/* Portrait tablets / phones */
@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; grid-template-rows: auto auto 1fr auto; grid-template-areas: "top" "cats" "grid" "basket"; }
  .basket { border-left: 0; border-top: 1px solid var(--line); max-height: 42vh; }
  .basket h2 { padding: 16px 20px 4px; font-size: 19px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); padding: 4px 16px 16px; gap: 12px; }
  .top, .crumb { padding-left: 16px; padding-right: 16px; }
  .brand h1 { font-size: 21px; }
  .total strong { font-size: 28px; }
  .pay { padding: 18px; font-size: 20px; }
}

/* Setup page */
body.setup { display: grid; place-items: center; min-height: 100vh; padding: 24px; user-select: auto; }
.setup-card { background: #fff; border-radius: 24px; padding: 40px; max-width: 520px; text-align: center; box-shadow: 0 10px 40px rgba(0,0,0,.08); }
.setup-card h1 { font-size: 24px; }
.setup-card p { color: var(--muted); font-size: 17px; line-height: 1.5; margin-bottom: 24px; }
