/* Aloka — Kapruka purple for brand and chat, gold reserved for buying actions. */
:root {
  /* Theme 7 "Cream & white": warm cream page, pure-white cards and panels, exact Kapruka purple.
     Always light — the white side panels frame the cream conversation on purpose. */
  --brand: #402970;
  --brand-2: #5b3f99;
  --brand-ink: #ffffff;
  --brand-soft: #ece5f7; /* lilac tint: chips, selected chat, focus — stays distinct from the cream page */
  --gold: #e4b422;
  --gold-ink: #2a1f00;
  --gold-soft: #fbf3d9;
  --bg: #faf4ea;
  --surface: #ffffff;
  --ink: #2b2118;
  --muted: #7a6b5c;
  --line: #efe4d4;
  --ok: #1d7a46;
  --bad: #b3261e;
  --user-bg: #402970;
  --user-ink: #ffffff;
  --shadow: 0 1px 2px rgba(60, 40, 20, .06), 0 6px 20px rgba(60, 40, 20, .07);
  --shadow-up: 0 -8px 30px rgba(60, 40, 20, .18);
  --radius: 16px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans Sinhala", "Noto Sans Tamil", sans-serif;
  -webkit-font-smoothing: antialiased; overflow: hidden;
}
button, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden], .app [hidden] { display: none !important; }

/* ---------- layout: history | chat | shelf ---------- */
.app {
  display: grid; height: 100vh; height: 100dvh;
  grid-template-columns: 264px minmax(0, 1fr) minmax(340px, 400px);
}
.only-drawer, .only-sheet { display: none !important; }

/* ---------- sidebar ---------- */
.sidebar {
  background: var(--surface); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; min-height: 0; padding: 14px 12px;
}
.sidebar-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; }
.brand b { display: block; font-size: 16px; }
.brand small { display: block; font-size: 12px; color: var(--muted); }
.new-chat {
  display: flex; align-items: center; gap: 8px; width: 100%;
  border: 1px solid var(--line); background: var(--surface); color: var(--brand);
  border-radius: 12px; padding: 10px 12px; font-weight: 600;
  transition: background .15s, border-color .15s, transform .1s;
}
.new-chat:hover { background: var(--brand-soft); border-color: var(--brand-soft); }
.new-chat:active { transform: scale(.98); }
.history { flex: 1; overflow-y: auto; margin-top: 12px; display: flex; flex-direction: column; gap: 2px; }
.history h3 { font-size: 12px; font-weight: 600; color: var(--muted); margin: 12px 8px 4px; }
.history button {
  text-align: left; border: 0; background: transparent; border-radius: 10px; padding: 9px 10px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink); font-size: 14px;
  transition: background .15s;
}
.history button:hover { background: var(--bg); }
.history button.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.history .empty { color: var(--muted); font-size: 13px; padding: 8px 10px; }

/* ---------- chat column ---------- */
.chat { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.topbar {
  display: flex; align-items: center; gap: 10px; padding: 10px 18px;
  background: var(--surface); border-bottom: 1px solid var(--line);
  padding-top: max(10px, env(safe-area-inset-top));
}
.who { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.who-text { display: flex; flex-direction: column; min-width: 0; }
.who-text b { font-size: 16px; line-height: 1.2; }
.who-text small { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; display: block; background: var(--brand-soft); }
.avatar.sm { width: 32px; height: 32px; }
.avatar.xs { width: 24px; height: 24px; }
.avatar-wrap { position: relative; flex: none; }
.online { position: absolute; right: 0; bottom: 0; width: 11px; height: 11px; border-radius: 50%; background: #2bb673; box-shadow: 0 0 0 2px var(--surface); }
.top-actions { display: flex; align-items: center; gap: 8px; }
.sort select {
  height: 36px; border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 0 8px; font-size: 14px;
}
.icon-btn {
  width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface);
  display: grid; place-items: center; font-size: 16px; transition: background .15s, transform .1s;
}
.icon-btn:active { transform: scale(.94); }
.shelf-btn {
  height: 38px; border-radius: 10px; border: 0; padding: 0 12px; gap: 6px; align-items: center;
  background: var(--brand); color: var(--brand-ink); font-weight: 600;
}

.log {
  flex: 1; overflow-y: auto; overflow-x: hidden; padding: 20px max(18px, calc((100% - 760px) / 2));
  display: flex; flex-direction: column; gap: 12px; scroll-behavior: smooth;
}
.log > * { flex-shrink: 0; }

.welcome {
  align-self: center; max-width: 520px; text-align: center; margin: auto 0;
  padding: 8px 4px; animation: rise .5s var(--ease) both;
}
.welcome-photo {
  width: 112px; height: 112px; border-radius: 50%; object-fit: cover; margin: 0 auto 12px; display: block;
  box-shadow: 0 0 0 4px var(--surface), 0 0 0 6px var(--gold), var(--shadow);
  animation: breathe 5s ease-in-out infinite;
}
.welcome { position: relative; }
.welcome > :not(.lamp) { position: relative; z-index: 1; }
.welcome-name { font-size: 30px; margin: 4px 0 4px; letter-spacing: .5px; }
.welcome-hello { margin: 0 0 6px; font-size: 17px; color: var(--ink); }
.welcome-sub { margin: 0 0 18px; color: var(--muted); font-size: 15px; }

/* Startup "lamp of light" — Aloka means light. Plays once per visit. */
.lamp { position: absolute; left: 50%; top: 56px; width: 0; height: 0; pointer-events: none; }
.lamp .glow {
  position: absolute; left: 0; top: 0; width: 24px; height: 24px; border-radius: 50%; transform: translate(-50%, -50%);
  background: radial-gradient(circle, rgba(251, 231, 166, .95) 0%, rgba(228, 180, 34, .45) 35%, rgba(250, 244, 234, 0) 70%);
  opacity: .5;
}
.lamp .spark { position: absolute; left: var(--x); top: 40px; width: 6px; height: 6px; border-radius: 50%; background: var(--gold); opacity: 0; }
.welcome.intro .lamp .glow { animation: lamp-bloom 1.5s ease-out both; }
.welcome.intro .lamp .spark { animation: lamp-spark 1.9s ease-out var(--d) both; }
.welcome.intro .welcome-photo { animation: lamp-rise .9s cubic-bezier(.2, .8, .2, 1) .45s both, breathe 5s ease-in-out 1.6s infinite; }
.welcome-name {
  background: linear-gradient(90deg, var(--brand) 0%, var(--brand) 40%, var(--gold) 50%, var(--brand) 60%, var(--brand) 100%);
  background-size: 250% 100%; background-position: 0 0; -webkit-background-clip: text; background-clip: text; color: transparent;
}
.welcome.intro .welcome-name { animation: rise .45s var(--ease) 1s both, lamp-shine 1.5s ease-in-out 1.1s both; }
.welcome.intro .welcome-hello { animation: rise .45s var(--ease) 1.35s both; }
.welcome.intro .welcome-sub { animation: rise .45s var(--ease) 1.5s both; }
.welcome.intro .chips .chip { animation-delay: calc(var(--i, 0) * 70ms + 1.7s); }
.welcome:not(.intro) .lamp .glow { width: 320px; height: 320px; opacity: .35; }
@keyframes lamp-bloom { 0% { width: 24px; height: 24px; opacity: 0; } 35% { opacity: 1; } 100% { width: 360px; height: 360px; opacity: .4; } }
@keyframes lamp-spark { 0% { opacity: 0; transform: translateY(0) scale(.5); } 20% { opacity: 1; } 100% { opacity: 0; transform: translateY(-110px) scale(1); } }
@keyframes lamp-rise { from { opacity: 0; transform: scale(.6); filter: blur(6px); } to { opacity: 1; transform: none; filter: none; } }
@keyframes lamp-shine { from { background-position: 100% 0; } to { background-position: 0 0; } }
.chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.chip {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  padding: 9px 14px; border-radius: 999px; font-size: 14px;
  transition: border-color .15s, background .15s, transform .1s;
}
.chip:hover { border-color: var(--brand); }
.chip:active { transform: scale(.97); }
.chip.toggle[aria-pressed="true"] { background: var(--brand-soft); border-color: var(--brand-soft); color: var(--brand); font-weight: 600; }
.chips .chip { animation: rise .45s var(--ease) both; animation-delay: calc(var(--i, 0) * 60ms + 150ms); }

.row { display: flex; gap: 8px; align-items: flex-end; animation: rise .3s var(--ease) both; }
.row.user { justify-content: flex-end; }
.row .avatar.xs { margin-bottom: 2px; flex: none; }
.msg { max-width: min(85%, 620px); padding: 10px 14px; border-radius: 18px; overflow-wrap: anywhere; }
.msg p { margin: 0 0 8px; }
.msg p:last-child { margin: 0; }
.msg ul, .msg ol { margin: 4px 0 8px; padding-left: 20px; }
.msg li { margin: 2px 0; }
.msg a { color: var(--brand); }
.row.user .msg { background: var(--user-bg); color: var(--user-ink); border-bottom-right-radius: 6px; white-space: pre-wrap; }
.row.bot .msg { background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 6px; box-shadow: var(--shadow); }
.row.bot.cont .avatar { visibility: hidden; }
.msg.error { background: transparent !important; color: var(--bad); border: 1px dashed var(--bad) !important; box-shadow: none !important; }

/* ---------- product cards (chat + shelf) ---------- */
.picks { padding-left: 32px; display: flex; flex-direction: column; gap: 8px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.picks .grid { grid-template-columns: repeat(auto-fill, minmax(160px, 200px)); }
.card {
  position: relative; display: flex; flex-direction: column; text-align: left; padding: 0;
  background: var(--surface); color: var(--ink); border: 1.5px solid var(--line); border-radius: 16px;
  overflow: hidden; box-shadow: var(--shadow); cursor: pointer; touch-action: manipulation;
  animation: rise .4s var(--ease) both; animation-delay: calc(var(--i, 0) * 70ms);
  transition: transform .18s var(--ease), box-shadow .18s, border-color .18s, opacity .18s;
}
.card:hover { transform: translateY(-3px); border-color: var(--brand); box-shadow: 0 10px 26px rgba(64, 41, 112, .18); }
.card:active { transform: scale(.97); }
.card:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.card .img { position: relative; aspect-ratio: 1; background: var(--brand-soft); overflow: hidden; display: grid; place-items: center; }
.card img { width: 100%; height: 100%; object-fit: cover; transition: transform .35s var(--ease), opacity .3s; opacity: 0; }
.card img.loaded { opacity: 1; }
.card:hover img { transform: scale(1.05); }
.card .ph { font-size: 32px; font-weight: 700; color: var(--brand); opacity: .45; }
.card .ref {
  position: absolute; top: 8px; left: 8px; z-index: 1; min-width: 28px; height: 28px; padding: 0 8px;
  border-radius: 999px; display: grid; place-items: center; background: var(--brand); color: #fff; font-weight: 700; font-size: 14px;
  box-shadow: 0 0 0 2px var(--surface);
}
.card .pick {
  position: absolute; right: 8px; bottom: 8px; z-index: 1; padding: 6px 12px; border-radius: 999px;
  font-size: 13px; font-weight: 700; background: rgba(255, 255, 255, .95); color: #402970; box-shadow: 0 2px 8px rgba(0, 0, 0, .18);
  transition: background .15s, color .15s, transform .2s var(--ease);
}
.card:hover .pick { background: var(--gold); color: var(--gold-ink); }
.card .body { padding: 9px 11px 11px; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.card .title { font-size: 14px; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card .price { font-weight: 700; font-size: 15px; margin-top: 2px; }
.card .stock { font-size: 12px; color: var(--ok); }
.card .stock.out { color: var(--bad); }
.card .qv-btn {
  margin-top: auto; align-self: flex-start; border: 1px solid var(--line); background: var(--surface); color: var(--brand);
  font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px; transition: background .15s, border-color .15s;
}
.card .body > :nth-last-child(2) { margin-bottom: 8px; }
.card .qv-btn:hover { background: var(--brand-soft); border-color: var(--brand-soft); }
.card.selected { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft), var(--shadow); }
.card.selected .pick { background: var(--gold); color: var(--gold-ink); animation: pop .35s var(--ease); }
.has-choice .card:not(.selected) { opacity: .55; }
.has-choice .card:not(.selected):hover { opacity: 1; }
.see-all {
  align-self: flex-start; border: 0; background: var(--brand-soft); color: var(--brand); font-weight: 600;
  border-radius: 999px; padding: 8px 14px; font-size: 14px; transition: transform .1s, filter .15s;
}
.see-all:hover { filter: brightness(.97); }
.see-all:active { transform: scale(.97); }

/* skeleton while searching */
.skeleton .card { cursor: default; pointer-events: none; }
.skeleton .img, .skeleton .line {
  background: linear-gradient(90deg, var(--brand-soft) 0%, var(--surface) 50%, var(--brand-soft) 100%);
  background-size: 200% 100%; animation: shimmer 1.2s linear infinite;
}
.skeleton .line { height: 10px; border-radius: 6px; margin: 4px 0; }

/* checkout card — gold, the one place the eye should land */
.checkout {
  margin-left: 32px; align-self: flex-start; width: min(100% - 32px, 360px);
  background: var(--surface); border: 2px solid var(--gold); border-radius: 18px; padding: 14px 16px;
  box-shadow: var(--shadow); animation: rise .45s var(--ease) both, glow 1.6s ease-out .3s 1;
}
.checkout .label { font-size: 13px; color: var(--muted); }
.checkout .total { font-size: 24px; font-weight: 700; margin: 2px 0 10px; }
.pay {
  display: flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none;
  background: var(--gold); color: var(--gold-ink); font-weight: 700; padding: 13px; border-radius: 12px;
  transition: filter .15s, transform .1s;
}
.pay .lock, .cart-cta .lock { flex: none; }
.pay:hover { filter: brightness(1.05); }
.pay:active { transform: scale(.98); }
.checkout .note { font-size: 12px; color: var(--muted); margin-top: 8px; }

/* typing + composer */
.typing { display: flex; align-items: center; gap: 8px; padding: 2px max(18px, calc((100% - 760px) / 2)) 8px; color: var(--muted); font-size: 14px; }
.dots { display: inline-flex; gap: 3px; }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--brand); opacity: .35; animation: blink 1.2s infinite; }
.dots i:nth-child(2) { animation-delay: .2s; }
.dots i:nth-child(3) { animation-delay: .4s; }
.composer {
  display: flex; align-items: flex-end; gap: 8px; margin: 0 max(16px, calc((100% - 760px) / 2)) max(16px, env(safe-area-inset-bottom));
  padding: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow);
  transition: border-color .15s, box-shadow .15s;
}
.composer:focus-within { border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-soft); }
.composer textarea { flex: 1; border: 0; outline: 0; resize: none; background: transparent; max-height: 140px; padding: 8px 6px; font-size: 16px; }
.composer button {
  width: 44px; height: 44px; flex: none; border: 0; border-radius: 14px; background: var(--brand); color: var(--brand-ink);
  display: grid; place-items: center; transition: transform .1s, opacity .15s;
}
.composer button:active { transform: scale(.92); }
.composer button:disabled { opacity: .45; }

/* ---------- shelf ---------- */
.shelf { position: relative; background: var(--surface); border-left: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.shelf-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; padding: 16px 16px 10px; }
.shelf-head b { display: block; font-size: 16px; }
.shelf-head small { display: block; color: var(--muted); font-size: 13px; }
.shelf-tools { display: flex; align-items: center; gap: 8px; padding: 0 16px 10px; }
.shelf-tools .sort { margin-left: auto; }
.shelf-body { flex: 1; overflow-y: auto; padding: 4px 16px 16px; display: flex; flex-direction: column; gap: 12px; }
.shelf .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.shelf.flash { animation: flash 1s ease-out 1; }
.load-more {
  align-self: center; border: 1px solid var(--line); background: var(--surface); color: var(--brand); font-weight: 600;
  border-radius: 999px; padding: 9px 18px; transition: background .15s;
}
.load-more:hover { background: var(--brand-soft); }
.shelf-empty { color: var(--muted); }
.ghost-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.ghost-grid i { aspect-ratio: .8; border-radius: 16px; border: 1.5px dashed var(--line); }
.shelf-foot { padding: 12px 16px max(12px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--bg); }
.grabber { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 8px auto 0; }

/* ---------- currency pill, cart button, back to Kapruka ---------- */
.me-chip { display: inline-flex; align-items: center; gap: 7px; padding: 3px 12px 3px 3px; border-radius: 999px; background: var(--brand-soft); color: var(--brand); font-size: 14px; font-weight: 600; animation: rise .35s var(--ease) both; }
.me-initial { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--brand); color: var(--brand-ink); font-size: 13px; font-weight: 700; }
.me-name { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.currency-pill {
  height: 32px; display: inline-flex; align-items: center; gap: 4px; padding: 0 10px; border-radius: 999px;
  background: var(--bg); border: 1px solid var(--line); color: var(--muted); font-size: 13px; font-weight: 600; white-space: nowrap;
}
.cart-btn, .leave-btn {
  position: relative; height: 38px; min-width: 38px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 0 9px;
  transition: background .15s, transform .1s, border-color .15s;
}
.cart-btn:hover, .leave-btn:hover { border-color: var(--brand); }
.cart-btn:active, .leave-btn:active { transform: scale(.94); }
.leave-btn { color: var(--muted); font-size: 14px; font-weight: 600; }
.badge {
  position: absolute; top: -6px; right: -6px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 999px;
  background: var(--gold); color: var(--gold-ink); font-size: 12px; font-weight: 800; display: grid; place-items: center;
  box-shadow: 0 0 0 2px var(--surface);
}
.badge.bump { animation: pop .4s var(--ease); }
.approx { font-size: 12px; color: var(--muted); font-weight: 500; }

/* ---------- cart panel: dropdown on desktop ---------- */
.cart-panel {
  position: fixed; top: 64px; right: 16px; width: min(380px, calc(100vw - 32px)); max-height: calc(100vh - 90px); max-height: calc(100dvh - 90px); z-index: 28;
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 18px 50px rgba(30, 20, 60, .25);
  display: flex; flex-direction: column; animation: drop .22s var(--ease) both;
}
.cart-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 8px; }
.cart-head b { font-size: 17px; }
.cart-body { overflow-y: auto; padding: 4px 16px 16px; display: flex; flex-direction: column; gap: 12px; }
.cart-empty { color: var(--muted); text-align: center; padding: 18px 6px; }
.cart-empty .icon { font-size: 34px; display: block; margin-bottom: 6px; }
.cart-line { display: grid; grid-template-columns: 56px 1fr auto; gap: 10px; align-items: center; animation: rise .3s var(--ease) both; }
.cart-line img, .cart-line .ph { width: 56px; height: 56px; border-radius: 12px; object-fit: cover; background: var(--brand-soft); display: grid; place-items: center; color: var(--brand); font-weight: 700; }
.cart-line .name { font-size: 14px; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.cart-line .meta { font-size: 12px; color: var(--muted); }
.cart-line .amt { font-weight: 700; font-size: 14px; text-align: right; white-space: nowrap; }
.cart-line .remove { border: 0; background: none; color: var(--muted); font-size: 12px; text-decoration: underline; padding: 2px 0; justify-self: start; }
.cart-sum { border-top: 1px dashed var(--line); padding-top: 10px; display: flex; flex-direction: column; gap: 4px; font-size: 14px; }
.cart-sum div { display: flex; justify-content: space-between; gap: 10px; }
.cart-sum .muted { color: var(--muted); }
.cart-sum .grand { font-size: 18px; font-weight: 800; margin-top: 4px; }
.cart-note { font-size: 12px; color: var(--muted); }
.cart-cta {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; border: 0; text-decoration: none;
  background: var(--gold); color: var(--gold-ink); font-weight: 800; padding: 13px; border-radius: 12px; font-size: 15px;
  transition: filter .15s, transform .1s;
}
.cart-cta:hover { filter: brightness(1.05); }
.cart-cta:active { transform: scale(.98); }

/* ---------- leave confirmation ---------- */
.modal-back { position: fixed; inset: 0; z-index: 50; background: rgba(20, 12, 36, .5); display: grid; place-items: center; padding: 16px; animation: fade .2s both; }
.modal {
  width: min(400px, 100%); background: var(--surface); color: var(--ink); border-radius: 20px; padding: 22px 20px 18px;
  text-align: center; box-shadow: 0 24px 60px rgba(0, 0, 0, .3); animation: rise .28s var(--ease) both;
}
.modal-avatar { width: 56px; height: 56px; margin: 0 auto 10px; box-shadow: 0 0 0 3px var(--gold); }
.modal h2 { margin: 0 0 6px; font-size: 19px; }
.modal p { margin: 0 0 16px; color: var(--muted); font-size: 14px; }
.modal-actions { display: flex; gap: 10px; }
.modal-actions > * { flex: 1; min-height: 46px; border-radius: 12px; font-weight: 700; display: grid; place-items: center; text-decoration: none; font-size: 15px; transition: transform .1s, filter .15s; }
.modal-actions > *:active { transform: scale(.97); }
.btn-secondary { border: 1px solid var(--line); background: var(--surface); color: var(--ink); }
.btn-primary { border: 0; background: var(--brand); color: var(--brand-ink); }

/* ---------- animations ---------- */
@keyframes drop { from { opacity: 0; transform: translateY(-8px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes shimmer { to { background-position: -200% 0; } }
@keyframes blink { 50% { opacity: 1; } }
@keyframes pop { 0% { transform: scale(.8); } 60% { transform: scale(1.12); } 100% { transform: scale(1); } }
@keyframes glow { from { box-shadow: 0 0 0 0 rgba(228, 180, 34, .55); } to { box-shadow: 0 0 0 14px rgba(228, 180, 34, 0); } }
@keyframes breathe { 50% { transform: scale(1.025); } }
@keyframes flash { from { box-shadow: inset 0 0 0 3px var(--gold); } to { box-shadow: inset 0 0 0 3px transparent; } }
@keyframes fade { from { opacity: 0; } }
/* ---------- quick view (desktop only; covers the shelf) ---------- */
.qv { position: absolute; inset: 0; z-index: 5; background: var(--surface); display: flex; flex-direction: column; animation: qv-in .25s var(--ease) both; }
@keyframes qv-in { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: none; } }
.qv-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 12px 8px 8px; }
.qv-back { border: 0; background: transparent; color: var(--brand); font-weight: 600; padding: 8px 10px; border-radius: 10px; }
.qv-back:hover { background: var(--brand-soft); }
.qv-scroll { flex: 1; overflow-y: auto; padding: 0 16px 16px; }
.qv-main { aspect-ratio: 1; border-radius: 14px; overflow: hidden; background: var(--brand-soft); display: grid; place-items: center; }
.qv-main img { width: 100%; height: 100%; object-fit: cover; }
.qv-main .ph { font-size: 48px; font-weight: 700; color: var(--brand); opacity: .4; }
.qv-thumbs { display: flex; gap: 8px; margin-top: 8px; overflow-x: auto; }
.qv-thumbs button { flex: none; width: 56px; height: 56px; padding: 0; border: 2px solid transparent; border-radius: 10px; overflow: hidden; background: var(--brand-soft); }
.qv-thumbs button.on { border-color: var(--brand); }
.qv-thumbs img { width: 100%; height: 100%; object-fit: cover; display: block; }
.qv h3 { font-size: 17px; line-height: 1.3; margin: 14px 0 4px; }
.qv-price { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.qv-price b { font-size: 20px; }
.qv-price s { color: var(--muted); font-size: 14px; }
.qv-price .approx { color: var(--muted); font-size: 13px; }
.qv-meta { display: flex; gap: 12px; font-size: 13px; color: var(--muted); margin: 4px 0 12px; }
.qv-meta .stock { color: var(--ok); }
.qv-meta .stock.out { color: var(--bad); }
.qv-variants { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.qv-variants button { border: 1px solid var(--line); background: var(--surface); border-radius: 12px; padding: 7px 12px; font-size: 14px; font-weight: 600; text-align: left; transition: border-color .15s, background .15s; }
.qv-variants button small { display: block; font-weight: 500; font-size: 12px; color: var(--muted); }
.qv-variants button[aria-checked="true"] { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); }
.qv-variants button:disabled { opacity: .45; cursor: not-allowed; }
.qv-scroll p, .qv-scroll li { font-size: 14px; margin: 0 0 8px; }
.qv-scroll ul { padding-left: 18px; margin: 0 0 8px; }
.qv-error { color: var(--muted); font-size: 14px; }
.qv-loading { display: flex; gap: 6px; margin-top: 12px; }
.qv-loading i { height: 12px; border-radius: 6px; background: var(--brand-soft); flex: 1; animation: qv-pulse 1s ease-in-out infinite alternate; }
@keyframes qv-pulse { from { opacity: .5; } to { opacity: 1; } }
.qv-foot { padding: 12px 16px; border-top: 1px solid var(--line); }
.qv-choose { width: 100%; border: 0; border-radius: 12px; padding: 13px; background: var(--brand); color: var(--brand-ink); font-weight: 700; font-size: 15px; transition: filter .15s, transform .1s; }
.qv-choose:hover { filter: brightness(1.15); }
.qv-choose:active { transform: scale(.98); }
.qv-choose:disabled { opacity: .5; cursor: not-allowed; }

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

/* ---------- tablet: history becomes a drawer ---------- */
@media (max-width: 1180px) {
  .app { grid-template-columns: minmax(0, 1fr) minmax(320px, 360px); }
  .only-drawer { display: grid !important; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: min(300px, 86vw); z-index: 30;
    transform: translateX(-102%); transition: transform .28s var(--ease); box-shadow: var(--shadow-up);
  }
  .app.drawer-open .sidebar { transform: none; }
  .scrim { position: fixed; inset: 0; background: rgba(20, 12, 36, .45); z-index: 20; animation: fade .2s both; }
}

/* ---------- phone: shelf becomes a bottom sheet ---------- */
@media (max-width: 820px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .card .qv-btn, .qv { display: none !important; }
  .only-sheet { display: flex !important; }
  .icon-btn.only-sheet { display: grid !important; }
  .grabber.only-sheet { display: block !important; }
  .shelf {
    position: fixed; left: 0; right: 0; bottom: 0; height: 82vh; height: 82dvh; z-index: 25;
    border: 0; border-radius: 22px 22px 0 0; box-shadow: var(--shadow-up);
    transform: translateY(105%); transition: transform .32s var(--ease);
  }
  .app.sheet-open .shelf { transform: none; }
  .topbar { padding: 8px 12px; padding-top: max(8px, env(safe-area-inset-top)); }
  .who-text small { display: none; }
  .me-chip { padding: 3px; }
  .me-name { display: none; }
  .log { padding: 14px 12px; }
  .typing { padding: 2px 12px 6px; }
  .composer { margin: 0 10px max(10px, env(safe-area-inset-bottom)); }
  .msg { max-width: 88%; }
  .picks { padding-left: 0; }
  .picks .grid, .shelf .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .checkout { margin-left: 0; width: 100%; }
  .card .body { padding: 8px 9px 10px; }
  .card .title { font-size: 13px; }
  .card .pick { right: 6px; bottom: 6px; padding: 5px 10px; font-size: 12px; }
  .welcome-name { font-size: 26px; }
  .welcome-photo { width: 96px; height: 96px; }
  .lamp { top: 48px; }
  .leave-label { display: none; }
  .currency-pill { height: 30px; padding: 0 8px; font-size: 12px; }
  .top-actions { gap: 6px; }
  .cart-panel {
    top: auto; left: 0; right: 0; bottom: 0; width: auto; max-height: 82vh; max-height: 82dvh; border-radius: 22px 22px 0 0; border: 0;
    animation: sheet-up .3s var(--ease) both; padding-bottom: env(safe-area-inset-bottom);
  }
  .modal-back { place-items: end center; padding: 0; }
  .modal { border-radius: 22px 22px 0 0; padding-bottom: max(18px, env(safe-area-inset-bottom)); animation: sheet-up .3s var(--ease) both; }
  .modal-actions { flex-direction: column-reverse; }
}
@keyframes sheet-up { from { transform: translateY(100%); } to { transform: none; } }
