/* ==========================================================================
   Design tokens
   Hard ink borders + offset shadows. Bold is spent on one thing per page
   (the ID pass on Menu, the key on Backup); everything else stays quiet.
   ========================================================================== */
:root {
  --primary: #4B36F5;          /* overridden from admin settings */
  --paper: #EDEFFD;
  --card: #FFFFFF;
  --ink: #17152B;
  --muted: #5A5873;
  --line: #17152B;
  --wallet: #FFD43B;
  --wallet-ink: #17152B;
  --mint: #0E8A5F;
  --mint-bg: #E2F7EC;
  --red: #D92D3A;
  --red-bg: #FFE8EA;
  --amber-bg: #FFF4D6;
  --shadow: 3px 3px 0 var(--line);
  --shadow-lg: 5px 5px 0 var(--line);

  --r-card: 16px;
  --r-ctl: 12px;
  --r-pill: 999px;

  --font-display: "Bricolage Grotesque", "Figtree", system-ui, sans-serif;
  --font-body: "Figtree", system-ui, -apple-system, "Segoe UI", sans-serif;

  --tabbar-h: 72px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}

[data-theme="dark"] {
  --paper: #121128;
  --card: #1E1C3B;
  --ink: #F1EFFF;
  --muted: #A9A6C9;
  --line: #3B3870;
  --mint: #3DD598;
  --mint-bg: #12352A;
  --red: #FF6B76;
  --red-bg: #3A1820;
  --amber-bg: #3A3016;
  --shadow: 3px 3px 0 #05040F;
  --shadow-lg: 5px 5px 0 #05040F;
  color-scheme: dark;
}

/* ==========================================================================
   Base
   ========================================================================== */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 16px/1.5 var(--font-body);
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
}
img, svg { display: block; max-width: 100%; }
a { color: inherit; }
p { margin: 0; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; border-radius: 6px; }

.page {
  max-width: 560px;
  margin: 0 auto;
  padding: 8px 16px calc(var(--tabbar-h) + var(--safe-b) + 96px);
}
.page__title {
  font: 800 28px/1.15 var(--font-display);
  letter-spacing: -0.02em;
  margin: 12px 0 16px;
}
.lead { color: var(--muted); margin: -6px 0 20px; max-width: 60ch; }
.section-title { font: 600 18px/1.3 var(--font-display); margin: 28px 0 10px; }

/* ==========================================================================
   Top bar
   ========================================================================== */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  max-width: 560px; margin: 0 auto;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 10px;
  background: var(--paper);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; min-width: 0; }
.brand__mark {
  display: grid; place-items: center; flex: none;
  width: 38px; height: 38px;
  background: var(--primary); color: #fff;
  border: 2px solid var(--line); border-radius: 11px; box-shadow: var(--shadow);
  font: 800 20px/1 var(--font-display);
}
.brand__name {
  font: 800 19px/1.1 var(--font-display); letter-spacing: -0.01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.wallet {
  display: flex; align-items: center; gap: 8px; flex: none;
  padding: 8px 14px;
  background: var(--wallet); color: var(--wallet-ink);
  border: 2px solid var(--line); border-radius: var(--r-pill); box-shadow: var(--shadow);
  font-weight: 700; text-decoration: none; font-variant-numeric: tabular-nums;
}
.wallet:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--line); }

.notice {
  max-width: 528px; margin: 0 auto 4px; padding: 10px 14px;
  background: var(--amber-bg); border: 2px solid var(--line); border-radius: var(--r-ctl);
  font-weight: 600; font-size: 15px;
}
@media (min-width: 561px) { .notice { margin-inline: auto; } }

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 10px 18px;
  background: var(--primary); color: #fff;
  border: 2px solid var(--line); border-radius: var(--r-ctl); box-shadow: var(--shadow);
  font: 700 16px/1.2 var(--font-body); text-decoration: none; cursor: pointer;
  transition: transform .08s, box-shadow .08s;
}
.btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--line); }
.btn--block { width: 100%; margin-top: 16px; min-height: 54px; font-size: 17px; }
.btn--sm { min-height: 40px; padding: 6px 12px; font-size: 15px; white-space: nowrap; flex: none; }
.btn--ghost { background: var(--card); color: var(--ink); }
.btn--danger { background: var(--red-bg); color: var(--red); }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-row .btn { flex: 1 1 140px; }

/* ==========================================================================
   Cards, rows, lists
   ========================================================================== */
.card {
  background: var(--card);
  border: 2px solid var(--line); border-radius: var(--r-card); box-shadow: var(--shadow);
  padding: 18px;
}
.card--row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card--row > span { display: flex; align-items: center; gap: 10px; }

.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.row {
  display: flex; align-items: center; gap: 14px;
  min-height: 62px; padding: 12px 16px;
  background: var(--card);
  border: 2px solid var(--line); border-radius: var(--r-card); box-shadow: var(--shadow);
  text-decoration: none; font-weight: 700; font-size: 17px;
}
.row:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--line); }
.row > .ico:last-child { margin-left: auto; color: var(--muted); flex: none; }
.row__icon {
  display: grid; place-items: center; flex: none;
  width: 38px; height: 38px; border-radius: 10px;
  background: color-mix(in srgb, var(--primary) 12%, var(--card)); color: var(--primary);
}
.row__title { flex: 1; min-width: 0; }
.row--highlight { background: var(--mint-bg); }
.row--highlight .row__icon { background: var(--card); color: var(--mint); }

.chip {
  display: inline-flex; align-items: center; padding: 2px 10px;
  border-radius: var(--r-pill); font-size: 13px; font-weight: 700;
}
.chip--ok { background: var(--mint-bg); color: var(--mint); }

/* ==========================================================================
   The ID pass (Menu) — the one loud element on that page
   ========================================================================== */
.pass {
  position: relative;
  margin: 8px 0 20px;
  background: var(--card);
  border: 2px solid var(--line); border-radius: 20px; box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.pass::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 8px; background: var(--primary);
}
.pass__top, .pass__bottom {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 12px;
  padding: 22px 18px 16px;
}
.pass__bottom { padding-top: 16px; }
.pass__label { color: var(--muted); font-size: 14px; font-weight: 600; }
.pass__id {
  font: 800 clamp(24px, 7.2vw, 34px)/1.05 var(--font-display);
  letter-spacing: 0.01em; white-space: nowrap; font-variant-numeric: tabular-nums; margin-top: 2px;
}
.pass__balance { font: 800 24px/1.1 var(--font-display); font-variant-numeric: tabular-nums; margin-top: 2px; }
.pass__perf {
  position: relative; height: 0; margin: 0 18px;
  border-top: 2px dashed color-mix(in srgb, var(--line) 45%, transparent);
}
.pass__perf::before, .pass__perf::after {
  content: ""; position: absolute; top: -12px; width: 22px; height: 22px;
  background: var(--paper); border: 2px solid var(--line); border-radius: 50%;
}
.pass__perf::before { left: -31px; }
.pass__perf::after { right: -31px; }
.pass__hint { padding: 0 18px 16px; color: var(--muted); font-size: 14px; }

/* Theme switch */
.segmented {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px;
  padding: 4px; margin-bottom: 16px;
  background: var(--card); border: 2px solid var(--line); border-radius: var(--r-ctl);
}
.segmented button {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; border: 0; border-radius: 8px; background: none; cursor: pointer;
  font-weight: 600; color: var(--muted);
}
.segmented button[aria-checked="true"] { background: var(--primary); color: #fff; }

/* ==========================================================================
   Recovery key
   ========================================================================== */
.keycard { margin-bottom: 16px; }
.keycard__label { color: var(--muted); font-weight: 600; font-size: 14px; }
.keycard__key {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px;
  margin: 10px 0 16px;
}
.keycard__key span {
  display: grid; place-items: center; padding: 12px 0;
  background: var(--paper); border: 2px solid var(--line); border-radius: 10px;
  font: 800 clamp(16px, 4.6vw, 22px)/1 var(--font-display); letter-spacing: 0.04em;
}
.keycard__warn { margin-top: 14px; color: var(--muted); font-size: 14px; }
.saved { display: flex; align-items: center; gap: 8px; color: var(--mint); font-weight: 700; margin-top: 8px; }

.steps { margin: 0; padding-left: 22px; display: grid; gap: 8px; }
.steps li::marker { font-weight: 800; color: var(--primary); }

/* Forms */
.field__label { display: block; font-weight: 700; margin-bottom: 8px; }
.input {
  width: 100%; min-height: 52px; padding: 12px 14px;
  background: var(--card); color: var(--ink);
  border: 2px solid var(--line); border-radius: var(--r-ctl);
  font: 600 17px/1.2 var(--font-body);
}
.input--key { font: 800 22px/1 var(--font-display); letter-spacing: 0.1em; text-transform: uppercase; text-align: center; }
.input--key::placeholder { color: color-mix(in srgb, var(--muted) 55%, transparent); letter-spacing: 0.1em; }
.input.is-invalid { border-color: var(--red); }
.field__error { margin-top: 8px; color: var(--red); font-weight: 600; }
.field__warn { margin-top: 12px; padding: 10px 12px; background: var(--amber-bg); border-radius: 10px; font-size: 15px; }

/* Nav back link */
.back { display: inline-flex; align-items: center; gap: 6px; margin-top: 6px; color: var(--muted); font-weight: 600; text-decoration: none; }

/* ==========================================================================
   Messages
   ========================================================================== */
.flash { margin: 6px 0 14px; padding: 12px 14px; border: 2px solid var(--line); border-radius: var(--r-ctl); font-weight: 600; background: var(--card); }
.flash--success { background: var(--mint-bg); }
.flash--error { background: var(--red-bg); }
.flash--info { background: var(--amber-bg); }

.banner {
  display: flex; align-items: center; gap: 12px; margin: 8px 0 20px; padding: 12px 14px;
  background: var(--amber-bg); border: 2px solid var(--line); border-radius: var(--r-ctl);
  text-decoration: none; font-size: 15px;
}
.banner > .ico:first-child { flex: none; }
.banner > .ico:last-child { flex: none; margin-left: auto; }

.empty {
  display: grid; justify-items: start; gap: 8px;
  padding: 24px 20px; margin-top: 8px;
  background: var(--card); border: 2px dashed var(--line); border-radius: var(--r-card);
  color: var(--muted);
}
.empty__title { color: var(--ink); font: 800 20px/1.2 var(--font-display); }
.empty .btn { margin-top: 8px; }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + var(--safe-b) + 20px); z-index: 60;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  padding: 10px 16px; background: var(--ink); color: var(--paper);
  border-radius: var(--r-pill); font-weight: 600; white-space: nowrap;
  transition: opacity .2s, transform .2s;
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* iOS install sheet */
.sheet {
  width: min(92vw, 420px); padding: 20px;
  background: var(--card); color: var(--ink);
  border: 2px solid var(--line); border-radius: 20px; box-shadow: var(--shadow-lg);
}
.sheet::backdrop { background: rgb(10 8 30 / .45); }
.sheet__title { font: 800 22px/1.2 var(--font-display); margin: 0 0 12px; }

/* ==========================================================================
   Bottom tab bar + floating buttons
   ========================================================================== */
.tabbar {
  position: fixed; inset: auto 0 0 0; z-index: 30;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  height: calc(var(--tabbar-h) + var(--safe-b)); padding: 0 12px var(--safe-b);
  background: var(--card); border-top: 2px solid var(--line);
}
@media (min-width: 600px) {
  .tabbar { left: 50%; right: auto; width: 560px; transform: translateX(-50%); border: 2px solid var(--line); border-bottom: 0; border-radius: 18px 18px 0 0; }
}
.tabbar__item {
  display: grid; justify-items: center; gap: 2px;
  color: var(--muted); text-decoration: none; font-size: 13px; font-weight: 700;
}
.tabbar__item.is-active { color: var(--primary); }
.tabbar__create {
  display: flex; align-items: center; gap: 6px;
  margin-top: -26px; padding: 14px 22px;
  background: var(--primary); color: #fff;
  border: 2px solid var(--line); border-radius: var(--r-pill); box-shadow: var(--shadow);
  text-decoration: none; font-weight: 800; font-size: 16px;
}
.tabbar__create:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--line); }

.fabs {
  position: fixed; z-index: 25;
  right: max(14px, calc(50vw - 280px + 14px));
  bottom: calc(var(--tabbar-h) + var(--safe-b) + 16px);
  display: grid; gap: 12px;
}
.fab {
  display: grid; place-items: center; width: 50px; height: 50px;
  border: 2px solid var(--line); border-radius: 50%; box-shadow: var(--shadow); color: #fff;
}
.fab--tg { background: #2AABEE; }
.fab--yt { background: #FF0033; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ==========================================================================
   Level 2: catalog
   ========================================================================== */
.row__glyph {
  display: grid; place-items: center; flex: none;
  width: 40px; height: 40px; border-radius: 11px;
  background: var(--paper); border: 2px solid var(--line);
}
.row__glyph img { border-radius: 6px; }
.row__title small { display: block; font-weight: 500; font-size: 14px; color: var(--muted); }
.list--tight { gap: 10px; }
.page__title--icon { display: flex; align-items: center; gap: 12px; }

.row--service { align-items: center; font-size: 16px; }
.row__price { margin-left: auto; text-align: right; font: 800 17px/1.1 var(--font-display); font-variant-numeric: tabular-nums; white-space: nowrap; }
.row__price small { display: block; font: 500 12px/1.3 var(--font-body); color: var(--muted); }

.badges { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.badge { padding: 1px 8px; border-radius: var(--r-pill); font-size: 12px; font-weight: 700; background: color-mix(in srgb, var(--primary) 12%, var(--card)); color: var(--primary); }
.badge--hot, .badge--fast { background: #FFE3D1; color: #B33F00; }
.badge--refill, .badge--lifetime { background: var(--mint-bg); color: var(--mint); }
[data-theme="dark"] .badge--hot, [data-theme="dark"] .badge--fast { background: #42230F; color: #FFB27A; }
.chip--time { background: var(--amber-bg); color: var(--ink); font-weight: 600; margin-left: 6px; }

.svc-head { display: flex; gap: 14px; align-items: flex-start; margin: 12px 0 20px; }
.svc-head__name { font: 800 24px/1.15 var(--font-display); letter-spacing: -0.01em; margin: 0; }
.svc-head__meta { color: var(--muted); font-weight: 600; margin-top: 4px; display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }

.order-form { display: grid; gap: 18px; }
.field__hint { margin-top: 6px; color: var(--muted); font-size: 14px; }
.input--area { min-height: 120px; resize: vertical; line-height: 1.4; font-weight: 500; }

/* Packs: two-column grid of tappable tickets */
.packs { border: 0; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.packs legend { grid-column: 1 / -1; padding: 0; }
.pack {
  position: relative; display: grid; gap: 2px; padding: 12px 12px 10px; cursor: pointer;
  background: var(--card); border: 2px solid var(--line); border-radius: 14px; box-shadow: var(--shadow);
}
.pack input { position: absolute; opacity: 0; pointer-events: none; }
.pack__qty { font: 800 24px/1 var(--font-display); }
.pack__price { font-weight: 700; font-variant-numeric: tabular-nums; }
.pack__price s { color: var(--muted); font-weight: 500; font-size: 13px; margin-right: 2px; }
.pack__off { position: absolute; top: 10px; right: 10px; padding: 1px 7px; border-radius: 8px; background: var(--red); color: #fff; font-size: 12px; font-weight: 800; }
.pack__tag { position: absolute; top: -11px; left: 10px; padding: 0 8px; border-radius: 8px; background: var(--wallet); color: var(--wallet-ink); border: 2px solid var(--line); font-size: 12px; font-weight: 800; }
.pack:has(input:checked) { background: var(--primary); color: #fff; }
.pack:has(input:checked) .pack__price s { color: rgb(255 255 255 / .7); }
.pack:has(input:focus-visible) { outline: 3px solid var(--primary); outline-offset: 3px; }

.summary {
  padding: 14px 16px; border: 2px dashed var(--line); border-radius: var(--r-card); background: var(--card);
  display: grid; gap: 6px;
}
.summary__row { display: flex; justify-content: space-between; font-variant-numeric: tabular-nums; }
.summary__row b { font: 800 18px/1.3 var(--font-display); }
.summary__row--muted { color: var(--muted); }
.summary__row--muted b { font-size: 16px; }
.is-short { color: var(--red); }

.btn--go { margin-top: 0; }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; box-shadow: var(--shadow); }
.btn.is-busy { opacity: .7; pointer-events: none; }

.details { margin-top: 24px; background: var(--card); border: 2px solid var(--line); border-radius: var(--r-card); }
.details summary { padding: 14px 16px; font-weight: 700; cursor: pointer; }
.details__body { padding: 0 16px 16px; color: var(--muted); max-width: 70ch; }
.emoji { line-height: 1; }
