/* ==========================================================================
   MadStore — storefront stylesheet (index.html + app.html)
   Dark : deep black base, purple + magenta glow, crisp white type
   Light: pure white base, black type, gold borders and accents
   ========================================================================== */

/* ---------- 1. Tokens ---------- */
:root {
  --font-display: "Bodoni Moda", "Didot", "Bodoni 72", "Times New Roman", serif;
  --font-ui: "Manrope", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --maxw: 1320px;
  --gutter: clamp(16px, 4vw, 48px);
  --header-h: 72px;
  color-scheme: dark light;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #050308;
  --glow:
    radial-gradient(70rem 42rem at 6% -8%, rgba(106, 27, 184, .45), transparent 62%),
    radial-gradient(56rem 38rem at 104% 2%, rgba(230, 26, 157, .26), transparent 60%);
  --header-bg: rgba(5, 3, 8, .78);
  --surface: rgba(255, 255, 255, .045);
  --surface-2: rgba(255, 255, 255, .08);
  --overlay-chip: rgba(5, 3, 8, .6);
  --modal-bg: #0e0716;
  --line: rgba(255, 255, 255, .13);
  --line-strong: rgba(255, 255, 255, .26);
  --text: #fff;
  --text-soft: rgba(255, 255, 255, .88);
  --muted: rgba(255, 255, 255, .68);
  --accent: #ff4fb8;
  --accent-strong: #e61a9d;
  --grad: linear-gradient(120deg, #6a1bb8 0%, #c4189f 55%, #ff2fa6 100%);
  --on-grad: #fff;
  --focus: #ff8fd2;
  --danger: #ff8a98;
  --hero-fade:
    linear-gradient(90deg, rgba(5, 3, 8, .94) 0%, rgba(5, 3, 8, .6) 42%, rgba(5, 3, 8, 0) 78%),
    linear-gradient(0deg, rgba(5, 3, 8, .75), rgba(5, 3, 8, 0) 45%);
  --shadow: 0 28px 70px rgba(0, 0, 0, .6);
  --ring: 0 0 0 4px rgba(255, 79, 184, .24);
  --scroll-thumb: rgba(255, 255, 255, .22);
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #fff;
  --glow:
    radial-gradient(60rem 36rem at 8% -10%, rgba(212, 175, 55, .22), transparent 60%),
    radial-gradient(48rem 30rem at 104% 0, rgba(212, 175, 55, .11), transparent 60%);
  --header-bg: rgba(255, 255, 255, .82);
  --surface: #fff;
  --surface-2: #faf6ea;
  --overlay-chip: rgba(255, 255, 255, .75);
  --modal-bg: #fff;
  --line: rgba(184, 137, 43, .34);
  --line-strong: rgba(184, 137, 43, .7);
  --text: #000;
  --text-soft: rgba(0, 0, 0, .84);
  --muted: rgba(0, 0, 0, .64);
  --accent: #8a6410;
  --accent-strong: #b8892b;
  --grad: linear-gradient(120deg, #f2d97f 0%, #d4af37 50%, #b8892b 100%);
  --on-grad: #000;
  --focus: #8a6410;
  --danger: #b3122d;
  --hero-fade:
    linear-gradient(90deg, rgba(255, 255, 255, .96) 0%, rgba(255, 255, 255, .72) 42%, rgba(255, 255, 255, 0) 78%),
    linear-gradient(0deg, rgba(255, 255, 255, .8), rgba(255, 255, 255, 0) 45%);
  --shadow: 0 24px 56px rgba(120, 90, 20, .2);
  --ring: 0 0 0 4px rgba(184, 137, 43, .25);
  --scroll-thumb: rgba(184, 137, 43, .45);
}

/* ---------- 2. Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 16px);
}
body {
  position: relative;
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
  font: 500 16px/1.6 var(--font-ui);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background: var(--glow);
  pointer-events: none;
}
body.lock { overflow: hidden; }

img { display: block; max-width: 100%; height: auto; }
a { color: inherit; text-decoration: none; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, p { overflow-wrap: anywhere; }
::selection { background: var(--accent-strong); color: var(--on-grad); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}
.skip-link {
  position: absolute; left: 12px; top: -80px; z-index: 200;
  padding: 10px 18px; border-radius: 999px;
  background: var(--grad); color: var(--on-grad); font-weight: 800;
}
.skip-link:focus { top: 12px; }

.icon {
  width: 1.25em; height: 1.25em; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round;
}

/* thin themed scrollbars on desktop */
@media (hover: hover) {
  * { scrollbar-width: thin; scrollbar-color: var(--scroll-thumb) transparent; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .01ms !important; animation-iteration-count: 1 !important;
    transition-duration: .01ms !important; scroll-behavior: auto !important;
  }
}

/* ---------- 3. Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  height: 46px; padding: 0 22px;
  border: 1px solid transparent; border-radius: 999px; background: none;
  font-weight: 800; font-size: 15px; line-height: 1; white-space: nowrap;
  transition: filter .2s, border-color .2s, transform .15s;
}
.btn:active { transform: scale(.98); }
.btn[disabled] { opacity: .65; cursor: progress; }
.btn-primary { background: var(--grad); color: var(--on-grad); box-shadow: 0 12px 32px -12px var(--accent-strong); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { background: var(--surface-2); border-color: var(--line); color: var(--text); }
.btn-ghost:hover { border-color: var(--line-strong); }
.btn-icon { width: 46px; padding: 0; }
.btn-lg { height: 58px; padding: 0 34px; font-size: 17px; }
.btn-block { width: 100%; }
.btn-google { background: #fff; color: #1f1f1f; border-color: #dadce0; }
.btn-google .icon { width: 20px; height: 20px; stroke: none; }

/* ---------- 4. Announcement bar ---------- */
.announce {
  display: flex; align-items: center; justify-content: center; gap: 14px;
  padding: 9px var(--gutter);
  background: var(--grad); color: var(--on-grad);
  font-size: 14px; font-weight: 700; text-align: center;
}
.announce a { text-decoration: underline; text-underline-offset: 3px; }
.announce button { display: grid; place-items: center; padding: 4px; border: 0; background: none; }

/* ---------- 5. Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: var(--header-bg);
  -webkit-backdrop-filter: blur(18px) saturate(1.4);
  backdrop-filter: blur(18px) saturate(1.4);
  border-bottom: 1px solid var(--line);
}
.header-inner {
  display: grid; align-items: center; gap: 12px 18px;
  grid-template-columns: auto auto minmax(0, 1fr) auto;
  grid-template-areas: "menu brand search actions";
  max-width: var(--maxw); margin: 0 auto;
  padding: 12px max(var(--gutter), env(safe-area-inset-right)) 12px max(var(--gutter), env(safe-area-inset-left));
}
#menuBtn { grid-area: menu; }
.brand { grid-area: brand; display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-logo {
  width: 42px; height: 42px; flex: none; object-fit: cover;
  border-radius: 13px; border: 1px solid var(--line-strong); background: var(--surface-2);
}
.brand-name {
  font-family: var(--font-display); font-size: 25px; font-weight: 700; letter-spacing: -.01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.header-actions { grid-area: actions; display: flex; align-items: center; gap: 10px; }
.gsi { display: flex; align-items: center; min-height: 44px; }

/* search */
.search { grid-area: search; position: relative; width: 100%; max-width: 640px; justify-self: center; }
.search-field {
  display: flex; align-items: center; gap: 10px; height: 46px; padding: 0 8px 0 16px;
  border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line);
  transition: border-color .2s, box-shadow .2s;
}
.search-field:focus-within { border-color: var(--accent-strong); box-shadow: var(--ring); }
.search-field .icon { color: var(--muted); }
.search-field input {
  flex: 1; min-width: 0; height: 100%; padding: 0;
  background: none; border: 0; outline: none; font-weight: 600;
  -webkit-appearance: none; appearance: none;
}
.search-field input::placeholder { color: var(--muted); opacity: 1; }
.search-field input::-webkit-search-cancel-button,
.search-field input::-webkit-search-decoration { -webkit-appearance: none; display: none; }
.search-kbd {
  display: grid; place-items: center; width: 28px; height: 28px;
  border: 1px solid var(--line); border-radius: 9px;
  color: var(--muted); font-size: 13px; font-weight: 800;
}
.search-results {
  position: absolute; left: 0; right: 0; top: calc(100% + 10px); z-index: 60;
  max-height: min(70vh, 540px); overflow: auto; padding: 8px;
  background: var(--modal-bg); border: 1px solid var(--line-strong);
  border-radius: 24px; box-shadow: var(--shadow);
}
.result { display: grid; grid-template-columns: 48px minmax(0, 1fr) auto; align-items: center; gap: 14px; padding: 8px 10px; border-radius: 16px; }
.result:hover, .result[aria-selected="true"] { background: var(--surface-2); }
.result img { width: 48px; height: 48px; border-radius: 28%; object-fit: cover; }
.result-name { display: block; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.result-sub { display: block; color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-empty { margin: 0; padding: 22px 16px; color: var(--muted); text-align: center; }
mark { background: none; color: var(--accent); font-weight: 800; }

/* account */
.account { position: relative; }
.avatar-btn {
  width: 46px; height: 46px; padding: 2px; overflow: hidden;
  border-radius: 50%; border: 2px solid var(--accent-strong); background: var(--bg);
}
.avatar-btn img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.popover {
  position: absolute; right: 0; top: calc(100% + 12px); z-index: 60;
  display: grid; gap: 12px; width: min(310px, 86vw); padding: 18px;
  background: var(--modal-bg); border: 1px solid var(--line-strong);
  border-radius: 24px; box-shadow: var(--shadow);
}
.popover strong { display: block; font-size: 17px; }
.popover small { display: block; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.status-pill {
  display: inline-flex; width: fit-content; padding: 5px 12px;
  border: 1px solid var(--line-strong); border-radius: 999px;
  color: var(--accent); font-size: 13px; font-weight: 800;
}
.status-pill[data-status="active"] { background: var(--grad); color: var(--on-grad); border-color: transparent; }

@media (max-width: 820px) {
  :root { --header-h: 124px; }
  .header-inner {
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-areas: "menu brand actions" "search search search";
  }
  .search { max-width: none; }
  .search-kbd { display: none; }
}
@media (max-width: 560px) {
  .btn-google { width: 46px; padding: 0; }
  .btn-google .btn-label { display: none; }
  .brand-name { font-size: 22px; }
}

/* ---------- 6. Drawer ---------- */
.scrim {
  position: fixed; inset: 0; z-index: 70;
  background: rgba(0, 0, 0, .6);
  -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
  opacity: 0; pointer-events: none; transition: opacity .25s;
}
.scrim.open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; z-index: 80; top: 0; bottom: 0; left: 0;
  display: flex; flex-direction: column; gap: 18px;
  width: min(360px, 88vw); padding: 18px; overflow-y: auto;
  background: var(--modal-bg); border-right: 1px solid var(--line-strong); box-shadow: var(--shadow);
  transform: translateX(-104%); visibility: hidden;
  transition: transform .32s cubic-bezier(.2, .8, .2, 1), visibility 0s .32s;
}
.drawer.open { transform: none; visibility: visible; transition: transform .32s cubic-bezier(.2, .8, .2, 1), visibility 0s; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.drawer-nav { display: grid; align-content: start; gap: 2px; flex: 1; }
.drawer-nav a { display: block; padding: 12px 14px; border-radius: 14px; font-weight: 700; }
.drawer-nav a:hover { background: var(--surface-2); }
.drawer-nav h2 { margin: 18px 14px 6px; color: var(--muted); font-size: 14px; font-weight: 800; }
.drawer-foot { display: grid; gap: 10px; }

/* ---------- 7. Hero carousel ---------- */
.hero { max-width: var(--maxw); margin: 22px auto 0; padding: 0 var(--gutter); }
.hero-frame {
  position: relative; overflow: hidden;
  border-radius: 34px; border: 1px solid var(--line-strong);
  background: var(--surface-2); box-shadow: var(--shadow);
}
.hero-track {
  display: flex; overflow-x: auto; scroll-behavior: smooth;
  scroll-snap-type: x mandatory; scrollbar-width: none; overscroll-behavior-x: contain;
}
.hero-track::-webkit-scrollbar { display: none; }
.slide {
  position: relative; flex: 0 0 100%; scroll-snap-align: start; scroll-snap-stop: always;
  display: flex; align-items: flex-end; overflow: hidden;
  aspect-ratio: 21 / 8; min-height: 340px; max-height: 560px;
}
.slide-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.slide::after { content: ""; position: absolute; inset: 0; background: var(--hero-fade); pointer-events: none; }
.slide-copy {
  position: relative; z-index: 1; max-width: 640px;
  padding: clamp(24px, 4.4vw, 60px); padding-bottom: clamp(68px, 7vw, 88px);
}
.slide-label {
  display: inline-flex; padding: 5px 14px;
  border: 1px solid var(--line-strong); border-radius: 999px;
  background: var(--overlay-chip); color: var(--accent);
  font-size: 13px; font-weight: 800;
}
.slide h2 {
  margin: 14px 0 10px;
  font-family: var(--font-display); font-weight: 600;
  font-size: clamp(32px, 5vw, 64px); line-height: 1.04; letter-spacing: -.015em;
}
.slide p { margin: 0 0 22px; max-width: 46ch; color: var(--text-soft); font-size: clamp(15px, 1.5vw, 18px); }
.slide-plain { background: var(--grad); }
.slide-plain::after { display: none; }
.slide-plain h2, .slide-plain p { color: var(--on-grad); }
.slide-plain .btn-primary { background: var(--bg); color: var(--text); box-shadow: none; }
.slide-skeleton { min-height: 340px; }

.hero-controls {
  position: absolute; z-index: 2;
  right: clamp(16px, 3vw, 32px); bottom: clamp(16px, 2.4vw, 26px);
  display: flex; align-items: center; gap: 10px;
}
.hero-btn {
  display: grid; place-items: center; width: 40px; height: 40px; padding: 0;
  border: 1px solid var(--line-strong); border-radius: 50%;
  background: var(--overlay-chip); color: var(--text);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  transition: border-color .2s, opacity .2s;
}
.hero-btn:hover { border-color: var(--accent-strong); }
.hero-dots { display: flex; gap: 8px; padding: 0 6px; }
.hero-dot {
  width: 10px; height: 10px; padding: 0;
  border: 1px solid var(--line-strong); border-radius: 99px; background: transparent;
  transition: width .3s, background .3s;
}
.hero-dot[aria-current="true"] { width: 30px; background: var(--accent-strong); border-color: var(--accent-strong); }

/* ---------- 8. Access band ---------- */
.access { max-width: var(--maxw); margin: 18px auto 0; padding: 0 var(--gutter); }
.access-inner {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 18px 28px;
  padding: 16px 24px;
  border: 1px solid var(--line-strong); border-radius: 26px; background: var(--surface);
}
.access-inner h2 { margin: 0; font-size: 18px; font-weight: 800; }
.access-inner p { margin: 2px 0 0; max-width: 70ch; color: var(--muted); font-size: 15px; }

/* ---------- 9. Shelves & cards ---------- */
.shelf { max-width: var(--maxw); margin: 46px auto 0; padding: 0 var(--gutter); }
.shelf-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.shelf-head h2 {
  margin: 0; font-family: var(--font-display); font-weight: 600;
  font-size: clamp(25px, 2.8vw, 34px); letter-spacing: -.01em;
}
.shelf-nav { display: flex; gap: 8px; }
.shelf-nav .hero-btn[disabled] { opacity: .35; cursor: default; }
@media (hover: none) { .shelf-nav { display: none; } }

.shelf-track {
  display: grid; grid-auto-flow: column; grid-auto-columns: clamp(138px, 16vw, 178px); gap: 20px;
  margin: 0 -4px; padding: 8px 4px 20px; overflow-x: auto;
  scroll-snap-type: x proximity; scroll-padding-inline: 4px; scrollbar-width: none;
  overscroll-behavior-x: contain;
}
.shelf-track::-webkit-scrollbar { display: none; }
.card { display: block; min-width: 0; scroll-snap-align: start; }
.card-art {
  position: relative; display: block; aspect-ratio: 1; overflow: hidden;
  border: 1px solid var(--line); border-radius: 28%; background: var(--surface-2);
  transition: transform .25s, box-shadow .25s, border-color .25s;
}
.card:hover .card-art { transform: translateY(-4px); box-shadow: var(--shadow); border-color: var(--accent-strong); }
.card-art img { width: 100%; height: 100%; object-fit: cover; }
.card-art .badge { position: absolute; right: 9px; bottom: 9px; }
.rank {
  position: absolute; left: 12px; top: 6px;
  font-family: var(--font-display); font-weight: 700; font-size: 46px; line-height: 1;
  color: #fff; text-shadow: 0 2px 16px rgba(0, 0, 0, .75);
}
.card-name { display: block; margin-top: 12px; font-weight: 800; font-size: 15px; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-sub { display: block; color: var(--muted); font-size: 13px; line-height: 1.45; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge {
  display: inline-flex; align-items: center; padding: 3px 10px;
  border: 1px solid rgba(255, 255, 255, .28); border-radius: 999px;
  background: rgba(0, 0, 0, .74); color: #fff;
  font-size: 12px; font-weight: 800;
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}

.empty { max-width: var(--maxw); margin: 64px auto; padding: 0 var(--gutter); text-align: center; color: var(--muted); }
.empty h2 { margin: 0 0 8px; color: var(--text); font-family: var(--font-display); font-size: 28px; }
.empty p { margin: 0 0 18px; }

.skeleton {
  background: linear-gradient(100deg, var(--surface-2) 30%, var(--surface) 50%, var(--surface-2) 70%);
  background-size: 220% 100%; animation: shimmer 1.5s linear infinite;
}
.sk-title { width: 220px; height: 30px; border-radius: 10px; }
.sk-line { display: block; width: 70%; height: 14px; margin-top: 14px; border-radius: 8px; }
@keyframes shimmer { to { background-position: -220% 0; } }

/* ---------- 10. Footer ---------- */
.site-footer {
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: 16px;
  max-width: var(--maxw); margin: 80px auto 0;
  padding: 28px var(--gutter) calc(48px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line); color: var(--muted); font-size: 14px;
}
.site-footer strong { color: var(--text); font-family: var(--font-display); font-size: 18px; }

/* ---------- 11. Subscription modal ---------- */
.modal {
  width: min(480px, calc(100vw - 24px)); max-height: calc(100vh - 24px); max-height: calc(100dvh - 24px);
  margin: auto; padding: 0; overflow: auto;
  border: 1px solid var(--line-strong); border-radius: 32px;
  background: var(--modal-bg); color: var(--text); box-shadow: var(--shadow);
}
.modal::backdrop { background: rgba(3, 1, 8, .72); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
.modal[open] { animation: pop .24s cubic-bezier(.2, .8, .2, 1); }
@keyframes pop { from { opacity: 0; transform: translateY(14px) scale(.97); } }
.modal-body { position: relative; padding: clamp(24px, 5vw, 36px); }
.modal-body::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 4px; background: var(--grad); }
.modal-close { position: absolute; top: 16px; right: 16px; width: 40px; height: 40px; }
.modal h2 { margin: 0 44px 8px 0; font-family: var(--font-display); font-weight: 600; font-size: 29px; line-height: 1.15; }
.modal p { margin: 0 0 14px; color: var(--muted); }
.price { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 12px; margin: 12px 0 4px; }
.price strong { font-family: var(--font-display); font-size: 54px; line-height: 1; color: var(--accent); }
.price span { color: var(--muted); font-weight: 700; }
.qr { width: min(250px, 100%); margin: 14px auto 16px; padding: 12px; border: 2px solid var(--accent-strong); border-radius: 26px; background: #fff; }
.qr img { width: 100%; aspect-ratio: 1; object-fit: contain; }
.qr-missing { display: grid; place-items: center; aspect-ratio: 1; padding: 12px; color: #333; text-align: center; font-size: 14px; }
.pay-steps { margin: 0 0 20px; padding-left: 20px; color: var(--muted); }
.pay-steps li { margin-bottom: 4px; padding-left: 4px; }
.modal-actions { display: grid; gap: 10px; }
.modal-gsi { display: flex; justify-content: center; min-height: 44px; margin-top: 18px; }

.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field label { font-weight: 800; font-size: 14px; }
.field input {
  width: 100%; height: 52px; padding: 0 16px; outline: none;
  border: 1px solid var(--line); border-radius: 16px; background: var(--surface-2);
}
.field input:focus { border-color: var(--accent-strong); box-shadow: var(--ring); }
.field input[aria-invalid="true"] { border-color: var(--danger); }
.field input:disabled { opacity: .7; }
.field .err { color: var(--danger); font-size: 13px; font-weight: 700; }
.field .err:empty { display: none; }
.check { display: flex; align-items: center; gap: 10px; margin: -2px 0 16px; color: var(--muted); font-size: 14px; }
.check input { width: 18px; height: 18px; accent-color: var(--accent-strong); }
.form-error { margin: 0 0 12px; color: var(--danger); font-weight: 700; }
.modal .form-error { color: var(--danger); }

/* ---------- 12. Toasts ---------- */
.toasts {
  position: fixed; z-index: 300; left: 50%; bottom: calc(22px + env(safe-area-inset-bottom));
  display: grid; gap: 10px; width: min(440px, calc(100vw - 28px));
  transform: translateX(-50%); pointer-events: none;
}
.toast {
  padding: 14px 18px; border: 1px solid var(--line-strong); border-radius: 18px;
  background: var(--modal-bg); box-shadow: var(--shadow); font-weight: 700;
  animation: pop .25s ease-out;
}
.toast[data-kind="ok"] { border-color: var(--accent-strong); }
.toast[data-kind="error"] { border-color: var(--danger); color: var(--danger); }

/* ==========================================================================
   App detail page
   ========================================================================== */
.crumb { max-width: var(--maxw); margin: 0 auto; padding: 0 var(--gutter); }
.back-link { display: inline-flex; align-items: center; gap: 6px; margin-top: 22px; color: var(--muted); font-weight: 800; }
.back-link:hover { color: var(--text); }

.app-banner { max-width: var(--maxw); margin: 14px auto 0; padding: 0 var(--gutter); }
.app-banner-frame {
  position: relative; overflow: hidden;
  aspect-ratio: 21 / 8; min-height: 210px; max-height: 480px;
  border: 1px solid var(--line-strong); border-radius: 34px; background: var(--surface-2);
}
.app-banner-frame img { width: 100%; height: 100%; object-fit: cover; }
.app-banner-frame::after { content: ""; position: absolute; inset: 0; background: linear-gradient(0deg, var(--bg) 0%, transparent 40%); }

.app-head {
  position: relative; display: grid; align-items: end; gap: 20px 28px;
  grid-template-columns: auto minmax(0, 1fr) auto;
  max-width: var(--maxw); margin: -64px auto 0; padding: 0 calc(var(--gutter) + 10px);
}
.app-icon {
  width: clamp(100px, 12vw, 152px); aspect-ratio: 1; overflow: hidden;
  border-radius: 28%; background: var(--surface-2);
  box-shadow: 0 0 0 4px var(--bg), var(--shadow);
}
.app-icon img { width: 100%; height: 100%; object-fit: cover; }
.app-title { min-width: 0; }
.app-title h1 { margin: 0 0 6px; font-family: var(--font-display); font-weight: 600; font-size: clamp(32px, 4.6vw, 56px); line-height: 1.04; letter-spacing: -.015em; }
.app-title .tagline { margin: 0 0 12px; max-width: 56ch; color: var(--muted); font-size: 17px; }
.app-title .developer { font-weight: 800; color: var(--accent); }
.app-title .developer a:hover { text-decoration: underline; text-underline-offset: 3px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.chip {
  display: inline-flex; align-items: center; padding: 5px 13px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--surface-2);
  font-size: 13px; font-weight: 800;
}
a.chip:hover { border-color: var(--line-strong); }
.chip-format { border-color: var(--accent-strong); color: var(--accent); }

.app-actions { display: grid; gap: 10px; justify-items: end; min-width: 270px; max-width: 340px; padding-bottom: 6px; }
.app-actions .btn { width: 100%; }
.action-note { margin: 0; text-align: right; color: var(--muted); font-size: 14px; }

.stats { max-width: var(--maxw); margin: 30px auto 0; padding: 0 calc(var(--gutter) + 10px); }
.stats dl {
  display: grid; grid-template-columns: repeat(4, 1fr); margin: 0; overflow: hidden;
  border: 1px solid var(--line); border-radius: 24px; background: var(--surface);
}
.stats div { min-width: 0; padding: 16px 22px; border-right: 1px solid var(--line); }
.stats div:last-child { border-right: 0; }
.stats dt { color: var(--muted); font-size: 13px; font-weight: 700; }
.stats dd { margin: 2px 0 0; font-size: 18px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.app-layout {
  display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 56px; align-items: start;
  max-width: var(--maxw); margin: 40px auto 0; padding: 0 calc(var(--gutter) + 10px);
}
.app-main { min-width: 0; }
.block { margin-bottom: 48px; }
.block h2 { margin: 0 0 18px; font-family: var(--font-display); font-weight: 600; font-size: 29px; letter-spacing: -.01em; }
.description { margin: 0; max-width: 70ch; color: var(--text-soft); font-size: 17px; line-height: 1.75; white-space: pre-line; }

.shots { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.shots[data-shape="landscape"] { grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); }
.shot {
  aspect-ratio: 9 / 16; padding: 0; overflow: hidden;
  border: 1px solid var(--line); border-radius: 22px; background: var(--surface-2);
  transition: border-color .2s, transform .2s;
}
.shots[data-shape="landscape"] .shot { aspect-ratio: 16 / 10; }
.shot:hover { border-color: var(--accent-strong); transform: translateY(-3px); }
.shot img { width: 100%; height: 100%; object-fit: cover; }

.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 14px 32px; margin: 0; padding: 0; list-style: none; }
.features li { display: flex; align-items: flex-start; gap: 12px; }
.tick { flex: none; display: grid; place-items: center; width: 26px; height: 26px; margin-top: 1px; border-radius: 50%; background: var(--grad); color: var(--on-grad); }
.tick .icon { width: 14px; height: 14px; stroke-width: 2.8; }

.releases { display: grid; }
.release { position: relative; padding: 0 0 26px 24px; border-left: 2px solid var(--line-strong); }
.release:last-child { padding-bottom: 0; }
.release::before { content: ""; position: absolute; left: -7px; top: 5px; width: 12px; height: 12px; border-radius: 50%; background: var(--accent-strong); box-shadow: 0 0 0 4px var(--bg); }
.release h3 { margin: 0; font-size: 18px; font-weight: 800; }
.release time { display: block; margin-bottom: 8px; color: var(--muted); font-size: 14px; }
.release ul { margin: 0; padding-left: 20px; color: var(--text-soft); }
.release li { margin-bottom: 4px; }

.sidebar { position: sticky; top: calc(var(--header-h) + 18px); display: grid; gap: 18px; }
.panel { padding: 24px; border: 1px solid var(--line); border-radius: 28px; background: var(--surface); }
.panel-accent { border-color: var(--line-strong); }
.panel h2 { margin: 0 0 14px; font-family: var(--font-display); font-size: 22px; font-weight: 600; }
.panel p { margin: 0; color: var(--muted); font-size: 15px; }
.panel dl { display: grid; gap: 12px; margin: 0; }
.panel dl div { display: flex; justify-content: space-between; gap: 16px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.panel dl div:last-child { padding-bottom: 0; border-bottom: 0; }
.panel dt { color: var(--muted); font-weight: 700; }
.panel dd { margin: 0; font-weight: 800; text-align: right; overflow-wrap: anywhere; }

.state { max-width: 560px; margin: 96px auto; padding: 0 var(--gutter); text-align: center; }
.state h1 { margin: 0 0 10px; font-family: var(--font-display); font-size: 36px; }
.state p { margin: 0 0 22px; color: var(--muted); }
.app-skeleton { display: grid; gap: 22px; max-width: var(--maxw); margin: 24px auto; padding: 0 var(--gutter); }
.sk-banner { height: clamp(210px, 28vw, 420px); border-radius: 34px; }
.sk-head { height: 140px; border-radius: 28px; }

/* screenshot lightbox */
.lightbox { width: min(1100px, 96vw); max-width: none; max-height: 96vh; max-height: 96dvh; margin: auto; padding: 0; overflow: visible; border: 0; background: transparent; color: #fff; }
.lightbox::backdrop { background: rgba(0, 0, 0, .86); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.lightbox-stage { display: grid; place-items: center; }
.lightbox img { width: auto; max-height: 82vh; max-height: 82dvh; border-radius: 22px; box-shadow: var(--shadow); }
.lightbox-bar { display: flex; align-items: center; justify-content: center; gap: 16px; margin-top: 14px; }
.lightbox-bar .hero-btn { color: #fff; background: rgba(255, 255, 255, .12); border-color: rgba(255, 255, 255, .3); }
.lightbox-count { min-width: 64px; text-align: center; font-weight: 800; }

/* ---------- App page responsive ---------- */
@media (max-width: 960px) {
  .app-layout { grid-template-columns: 1fr; gap: 8px; }
  .sidebar { position: static; margin-bottom: 40px; }
  .stats dl { grid-template-columns: repeat(2, 1fr); }
  .stats div:nth-child(2) { border-right: 0; }
  .stats div:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
}
@media (max-width: 720px) {
  .app-head { grid-template-columns: 1fr; gap: 16px; margin-top: -44px; }
  .app-actions { min-width: 0; max-width: none; justify-items: stretch; padding-bottom: 0; }
  .action-note { text-align: left; }
  .slide { aspect-ratio: auto; min-height: 420px; }
  .slide-copy { padding-bottom: 80px; }
  .modal { border-radius: 28px; }
}