:root {
  --bg: #ffffff;
  --fg: #0a0a0a;
  --muted: #8a8a8e;
  --line: rgba(0, 0, 0, 0.08);
  --card: #ffffff;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.14), 0 2px 8px rgba(0, 0, 0, 0.06);
  --pill: rgba(0, 0, 0, 0.04);
  --pill-active: #0a0a0a;
  --pill-active-fg: #ffffff;
  --wa: #0a0a0a;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light; /* locked light — brand is B/W on white + coloured logo */
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  user-select: none;
}

#app {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  max-width: 480px;
  margin: 0 auto;
  padding-top: var(--safe-t);
  position: relative;
}

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px 8px;
}
.icon-btn {
  display: grid; place-items: center;
  width: 34px; height: 34px; margin-right: 4px;
  background: none; border: none; color: var(--fg); cursor: pointer;
}
.icon-btn .ic { width: 24px; height: 24px; stroke: currentColor; fill: none; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

.brandbar {
  display: inline-flex; align-items: center; gap: 9px;
  background: none; border: none; color: var(--fg); cursor: pointer;
  padding: 0; min-width: 0; flex: 1;
}
.logo { height: 44px; width: auto; object-fit: contain; flex: 0 0 auto; margin: -6px 0; }
.wordmark {
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.brand-x {
  font-size: 15px; font-weight: 500; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.brand-x b { color: var(--fg); font-weight: 700; text-transform: uppercase; letter-spacing: 0.01em; }
.liked-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--pill);
  border: none;
  color: var(--fg);
  padding: 7px 13px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease;
}
.liked-pill:active { transform: scale(0.94); }
.liked-pill .ic { width: 15px; height: 15px; fill: currentColor; stroke: none; }

/* ---------- Dashboard (brand picker) ---------- */
.dashboard {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 10px 20px calc(30px + var(--safe-b));
}
.dash-head { padding: 14px 2px 22px; }
.dash-head h1 { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.15; }
.dash-head p {
  color: var(--fg);
  font-size: 18px;
  font-weight: 400;
  font-style: italic;
  letter-spacing: -0.01em;
  margin-top: 8px;
}
.brand-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.brand-card {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: flex-start;
  padding: 18px 20px;
  border-radius: 22px;
  background: var(--card);
  border: 1px solid var(--line);
  background-size: cover;
  background-position: center;
  cursor: pointer;
  overflow: hidden;
  transition: transform 0.14s ease;
  aspect-ratio: 3/4;
  color: #fff;
}
.brand-card--feature { grid-column: 1 / -1; aspect-ratio: 16/9; }
.brand-card:active { transform: scale(0.98); }
.brand-card .bc-shade {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.62) 0%, rgba(0,0,0,0.18) 55%, rgba(0,0,0,0.02) 100%);
}
.brand-card .bc-name {
  position: relative;
  z-index: 1;
  font-size: 22px; font-weight: 700; letter-spacing: -0.02em;
  text-transform: uppercase;
}
.brand-card--feature .bc-name { font-size: 26px; }
.brand-card .bc-tag { position: relative; z-index: 1; color: rgba(255,255,255,0.85); font-size: 13px; margin-top: 3px; }
.brand-card .bc-arrow {
  position: absolute; z-index: 1; right: 16px; bottom: 16px;
  width: 24px; height: 24px; color: #fff;
}
.brand-card .bc-arrow svg { width: 100%; height: 100%; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Category segmented ---------- */
.cats {
  display: flex;
  gap: 8px;
  padding: 6px 20px 14px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.cats::-webkit-scrollbar { display: none; }
.cat {
  flex: 0 0 auto;
  background: var(--pill);
  color: var(--fg);
  border: none;
  padding: 8px 15px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, transform 0.12s ease;
  white-space: nowrap;
}
.cat:active { transform: scale(0.95); }
.cat.active { background: var(--pill-active); color: var(--pill-active-fg); }

.cat-pin {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 12px 8px 15px;
  background: var(--pill-active);
  color: var(--pill-active-fg);
}
.cat-pin .pin-sub {
  font-style: normal;
  font-weight: 400;
  opacity: 0.75;
}
.cat-pin .pin-x {
  width: 14px; height: 14px;
  stroke: currentColor; fill: none; stroke-width: 2.4;
  stroke-linecap: round; stroke-linejoin: round;
  opacity: 0.8;
}
.cat-sub { background: var(--pill); color: var(--fg); }
.cat-sub.active {
  background: var(--pill-active);
  color: var(--pill-active-fg);
}

/* ---------- Deck ---------- */
.deck-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 0 20px;
}
.card-stack {
  position: relative;
  flex: 1;
  min-height: 0;
  margin-bottom: 10px;
}

.card {
  position: absolute;
  inset: 0;
  border-radius: 28px;
  overflow: hidden;
  background: var(--card);
  box-shadow: var(--shadow);
  will-change: transform;
  touch-action: pan-y;
  display: flex;
  flex-direction: column;
}
.card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
  background: var(--pill);
}
.card-meta {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 46px 22px 22px;
  color: #fff;
  background: linear-gradient(to top, rgba(0,0,0,0.62) 0%, rgba(0,0,0,0.28) 45%, rgba(0,0,0,0) 100%);
}
.card-type {
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  opacity: 0.85;
  font-weight: 600;
}
.card-title {
  font-size: 21px;
  font-weight: 600;
  line-height: 1.22;
  margin: 5px 0 4px;
  letter-spacing: -0.01em;
}
.card-price { font-size: 16px; font-weight: 500; opacity: 0.95; }
.card-colors { display: flex; align-items: center; gap: 7px; margin-top: 9px; }
.card-colors .dot {
  width: 15px; height: 15px; border-radius: 50%;
  box-shadow: 0 0 0 1.5px rgba(255,255,255,0.85), 0 1px 3px rgba(0,0,0,0.35);
}
.card-colors .c-label {
  font-size: 11px; font-weight: 600; letter-spacing: 0.06em;
  text-transform: uppercase; opacity: 0.9;
}
.card-soldout {
  display: inline-block;
  margin-top: 8px;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 3px 8px;
  border: 1px solid rgba(255,255,255,0.6);
  border-radius: 6px;
}

/* swipe stamps */
.stamp {
  position: absolute;
  top: 30px;
  padding: 8px 16px;
  border: 3px solid currentColor;
  border-radius: 12px;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0.08em;
  opacity: 0;
  z-index: 2;
}
.stamp-like { right: 22px; color: #fff; transform: rotate(14deg); }
.stamp-nope { left: 22px; color: #fff; transform: rotate(-14deg); }

.deck-empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: center;
  color: var(--muted);
}
.deck-empty strong { color: var(--fg); font-size: 17px; font-weight: 600; }
.deck-empty button {
  margin-top: 14px;
  background: var(--pill-active);
  color: var(--pill-active-fg);
  border: none;
  border-radius: 999px;
  padding: 11px 22px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

/* ---------- Controls ---------- */
.controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 22px;
  padding: 8px 0 calc(14px + var(--safe-b));
}
.ctl {
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--fg);
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0,0,0,0.08);
  transition: transform 0.12s ease, background 0.2s ease;
}
.ctl:active { transform: scale(0.9); }
.ctl .ic { stroke: currentColor; fill: none; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.ctl-skip { width: 62px; height: 62px; }
.ctl-skip .ic { width: 26px; height: 26px; }
.ctl-undo { width: 50px; height: 50px; color: var(--muted); }
.ctl-undo .ic { width: 20px; height: 20px; }
.ctl-undo:disabled { opacity: 0.35; }
.ctl-refresh { width: 50px; height: 50px; color: var(--muted); }
.ctl-refresh .ic { width: 20px; height: 20px; }
.ctl-like { width: 62px; height: 62px; background: var(--pill-active); color: var(--pill-active-fg); border-color: transparent; }
.ctl-like .ic { width: 26px; height: 26px; fill: currentColor; stroke: none; }

/* ---------- Liked view ---------- */
.liked-view {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 4px 20px calc(30px + var(--safe-b));
}
.liked-head { padding: 6px 2px 18px; display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.liked-head h1 { font-size: 30px; font-weight: 700; letter-spacing: -0.02em; }
.liked-head p { color: var(--muted); font-size: 14px; margin-top: 3px; }
.clear-btn {
  flex: 0 0 auto;
  margin-top: 6px;
  background: none; border: none; color: var(--muted);
  font-size: 13px; font-weight: 600; cursor: pointer;
  padding: 6px 8px;
}
.clear-btn:disabled { opacity: 0.4; pointer-events: none; }
.clear-btn:active { opacity: 0.6; }
.liked-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.lcard {
  border-radius: 20px;
  overflow: hidden;
  background: var(--card);
  box-shadow: 0 6px 20px rgba(0,0,0,0.08);
  display: flex;
  flex-direction: column;
}
.lcard-img { position: relative; aspect-ratio: 3/4; }
.lcard-img img { width: 100%; height: 100%; object-fit: cover; }
.lcard-x {
  position: absolute; top: 8px; right: 8px;
  width: 26px; height: 26px; border-radius: 50%;
  background: rgba(0,0,0,0.55); color: #fff; border: none;
  display: grid; place-items: center; cursor: pointer; backdrop-filter: blur(6px);
}
.lcard-x svg { width: 13px; height: 13px; stroke: #fff; stroke-width: 2.4; fill: none; stroke-linecap: round; }
.lcard-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 5px; flex: 1; }
.lcard-brand { font-size: 10px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.lcard-title {
  font-size: 13.5px; font-weight: 600; line-height: 1.3; letter-spacing: -0.01em;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: calc(1.3em * 2);
}
.lcard .card-colors { margin-top: 8px; }
.lcard .card-colors .dot { width: 12px; height: 12px; box-shadow: 0 0 0 1px var(--line); }
.lcard .card-colors .c-label { color: var(--muted); }
.lcard-price { font-size: 13px; color: var(--muted); margin-top: 2px; }
.wa-btn {
  margin-top: auto;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  background: var(--wa); color: var(--bg);
  border: none; border-radius: 12px; padding: 9px 10px;
  font-size: 13px; font-weight: 600; cursor: pointer; text-decoration: none;
}
.wa-btn svg { width: 15px; height: 15px; fill: currentColor; }

.empty {
  display: none;
  flex-direction: column; align-items: center; gap: 6px;
  padding: 90px 0; text-align: center;
}
.empty p { font-size: 17px; font-weight: 600; }
.empty span { color: var(--muted); font-size: 14px; }
.liked-view.show-empty .liked-grid { display: none; }
.liked-view.show-empty .empty { display: flex; }

/* ---------- Splash ---------- */
.splash {
  position: absolute; inset: 0;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  z-index: 50;
  transition: opacity 0.4s ease;
}
.splash.hide { opacity: 0; pointer-events: none; }
.splash-msg { font-style: italic; font-size: 15px; color: var(--muted); }
.spinner {
  width: 30px; height: 30px;
  border: 2.5px solid var(--line);
  border-top-color: var(--fg);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.hidden { display: none !important; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 120px;
  transform: translateX(-50%) translateY(8px);
  background: rgba(10, 10, 10, 0.92);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  padding: 11px 18px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 100;
  max-width: 80vw;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- View transitions ---------- */
@keyframes viewIn {
  from { opacity: 0; transform: translateY(16px) scale(0.985); }
  to   { opacity: 1; transform: none; }
}
@keyframes cardsIn {
  from { opacity: 0; transform: translateY(22px) scale(0.96); }
  to   { opacity: 1; transform: none; }
}
.deck-view:not(.hidden),
.liked-view:not(.hidden),
.dashboard:not(.hidden) {
  animation: viewIn 0.34s cubic-bezier(0.22, 1, 0.36, 1);
}
.cats:not(.hidden) { animation: viewIn 0.34s cubic-bezier(0.22, 1, 0.36, 1); }
.deck-view:not(.hidden) .card-stack { animation: cardsIn 0.42s cubic-bezier(0.22, 1, 0.36, 1); }
@media (prefers-reduced-motion: reduce) {
  .deck-view, .liked-view, .dashboard, .cats, .card-stack { animation: none !important; }
}
