/* Cards: monochrome ink-on-paper chrome, so the only colour on screen is the
   cards' own. The selected card sits on a "stage" with its code on a
   tear-off ticket; everything else is a compact list. */
@font-face {
  font-family: "Onest";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url(/fonts/onest-cyrillic-wght-normal.woff2) format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Onest";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url(/fonts/onest-latin-wght-normal.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  color-scheme: light dark;
  --bg: #f4f3ef;
  --surface: #ffffff;
  --surface-2: #ebe9e3;
  --text: #141416;
  --muted: #6e6c66;
  --line: rgba(20, 20, 22, 0.09);
  --line-strong: rgba(20, 20, 22, 0.16);
  --danger: #d93025;
  --warn: #f29900;
  --star: #f5b400;
  --shadow: 0 1px 2px rgba(20, 20, 22, 0.05), 0 8px 24px -12px rgba(20, 20, 22, 0.18);
  --font: "Onest", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --gutter: max(16px, env(safe-area-inset-left));
}
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f0f11;
    --surface: #18181b;
    --surface-2: #232327;
    --text: #f3f2ee;
    --muted: #9b9993;
    --line: rgba(255, 255, 255, 0.08);
    --line-strong: rgba(255, 255, 255, 0.15);
    --danger: #ff6b5e;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 10px 28px -12px rgba(0, 0, 0, 0.7);
  }
}
:root[data-theme="dark"] {
  --bg: #0f0f11;
  --surface: #18181b;
  --surface-2: #232327;
  --text: #f3f2ee;
  --muted: #9b9993;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.15);
  --danger: #ff6b5e;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 10px 28px -12px rgba(0, 0, 0, 0.7);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 var(--font);
  min-height: 100dvh;
  overscroll-behavior-y: none;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:focus-visible, a:focus-visible, input:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }
[hidden] { display: none !important; }
svg { fill: currentColor; stroke: currentColor; }
svg[fill="none"] { fill: none; }

/* ---------- Header ---------- */
.top, .wallet { max-width: 560px; margin-inline: auto; }
.top { padding: calc(var(--safe-top) + 10px) var(--gutter) 2px; }
.titlebar { display: flex; align-items: center; justify-content: space-between; }
h1 { font-size: 23px; line-height: 1; font-weight: 800; letter-spacing: -0.04em; margin: 0; }
#home { display: flex; align-items: center; gap: 9px; border: 0; background: none; padding: 6px 4px 6px 0; font: inherit; letter-spacing: inherit; }
#home:active { opacity: 0.6; }
/* A tiny ticket, the same shape as the stage's code panel. */
.mark {
  width: 15px; height: 21px; border-radius: 4px; background: var(--text); transform: rotate(-12deg);
  -webkit-mask: radial-gradient(circle 3.5px at 0 50%, #0000 97%, #000) left / 51% 100% no-repeat,
    radial-gradient(circle 3.5px at 100% 50%, #0000 97%, #000) right / 51% 100% no-repeat;
  mask: radial-gradient(circle 3.5px at 0 50%, #0000 97%, #000) left / 51% 100% no-repeat,
    radial-gradient(circle 3.5px at 100% 50%, #0000 97%, #000) right / 51% 100% no-repeat;
}
.top-actions { display: flex; gap: 8px; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 11px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  display: grid; place-items: center; transition: transform 0.12s ease;
}
.icon-btn:active { transform: scale(0.93); }
.icon-btn svg { width: 19px; height: 19px; }
.icon-btn.accent { background: var(--text); color: var(--bg); border-color: var(--text); }

.banner { max-width: 560px; margin: 4px auto 0; padding: 8px 16px; font-size: 14px; color: var(--muted); text-align: center; }
.banner button { border: 0; background: none; color: var(--text); font-weight: 700; text-decoration: underline; padding: 0 4px; }

/* ---------- Wallet ---------- */
.wallet { padding: 6px var(--gutter) calc(var(--safe-bottom) + 40px); }
.stage-box { min-height: 0; }
.searching .stage-box { display: none; }
.searching .finder { margin-top: 0; }

/* Card faces (stage, editor preview and face picker). */
.face {
  --c: #3a3a3c;
  --fg: #fff;
  position: relative; isolation: isolate; overflow: hidden;
  background-color: var(--c); color: var(--fg);
}
.face::before { content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none; }
.face-gradient::before {
  background: linear-gradient(155deg, color-mix(in srgb, var(--c) 82%, #fff) 0%, var(--c) 42%, color-mix(in srgb, var(--c) 78%, #000) 100%);
}
.face-dots::before { background: radial-gradient(color-mix(in srgb, var(--fg) 16%, transparent) 1.4px, transparent 1.6px) 0 0 / 14px 14px; }
.face-stripes::before { background: repeating-linear-gradient(135deg, color-mix(in srgb, var(--fg) 9%, transparent) 0 10px, transparent 10px 22px); }
.face-waves::before {
  background:
    radial-gradient(120% 80% at 110% 120%, color-mix(in srgb, var(--fg) 18%, transparent) 0 40%, transparent 41%),
    radial-gradient(90% 70% at 105% 115%, color-mix(in srgb, var(--fg) 14%, transparent) 0 55%, transparent 56%),
    linear-gradient(160deg, color-mix(in srgb, var(--c) 85%, #fff), var(--c));
}
.face-grid::before {
  background:
    linear-gradient(color-mix(in srgb, var(--fg) 10%, transparent) 1px, transparent 1px) 0 0 / 18px 18px,
    linear-gradient(90deg, color-mix(in srgb, var(--fg) 10%, transparent) 1px, transparent 1px) 0 0 / 18px 18px;
}
.face-photo { --fg: #fff !important; color: #fff; }
.face-photo::before { background: linear-gradient(rgba(0, 0, 0, 0.55), rgba(0, 0, 0, 0.15) 45%, rgba(0, 0, 0, 0.6)); }
.photo-face { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: -2; }
.face.mini { width: 100%; height: 100%; border-radius: 6px; display: grid; place-items: center; font-size: 11px; }

/* ---------- Stage ---------- */
.stage {
  border-radius: 26px;
  padding: 14px 14px 12px;
  display: flex; flex-direction: column; gap: 12px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14), 0 0 0 1px var(--line), 0 22px 44px -24px color-mix(in srgb, var(--c) 75%, #000);
  touch-action: pan-y;
}
.stage.swap { animation: swap 0.28s cubic-bezier(0.2, 0.9, 0.3, 1); }
@keyframes swap { from { opacity: 0.35; transform: translateY(10px) scale(0.985); } }
.stage-head { display: flex; align-items: center; gap: 12px; }
.logo {
  flex: none; width: 46px; height: 46px; border-radius: 50%; overflow: hidden;
  display: grid; place-items: center;
  background: color-mix(in srgb, var(--fg) 18%, transparent);
  font-weight: 800; font-size: 16px; letter-spacing: -0.02em;
}
/* Round tiles: a logo sits inset so its corners stay inside the circle. */
/* A squarish logo fills the circle like an app icon, so its own background
   is the tile's. A wide wordmark sits whole on white instead (app.js marks
   it .wide once it loads). */
.logo:has(img) { background: #fff; }
.logo img, .tile img { width: 100%; height: 100%; object-fit: cover; }
.logo img.wide, .tile img.wide { width: 78%; height: 78%; object-fit: contain; }
.stage-title { flex: 1; min-width: 0; }
.stage-name {
  font-size: 21px; line-height: 1.15; font-weight: 750; letter-spacing: -0.025em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.stage-name .fav { color: var(--star); font-size: 16px; vertical-align: 2px; }
.stage-sub { font-size: 13px; opacity: 0.75; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.round {
  flex: none; width: 40px; height: 40px; border-radius: 50%; border: 0; padding: 0;
  display: grid; place-items: center; color: var(--fg);
  background: color-mix(in srgb, var(--fg) 16%, transparent);
}
.round svg { width: 22px; height: 22px; }
.facts { display: flex; gap: 22px; overflow: hidden; }
.facts div { min-width: 0; }
.facts span { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; opacity: 0.7; white-space: nowrap; }
.facts b { display: block; font-size: 17px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stage-warn .badge { font-size: 12px; }

/* The code sits on a white tear-off ticket: scanners need dark-on-white. */
.ticket {
  width: 100%; border: 0; margin: 0;
  background: #fff; color: #111; border-radius: 18px;
  padding: 16px 18px 12px;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  container-type: inline-size;
  -webkit-mask: radial-gradient(circle 9px at 0 50%, #0000 97%, #000) left / 51% 100% no-repeat,
    radial-gradient(circle 9px at 100% 50%, #0000 97%, #000) right / 51% 100% no-repeat;
  mask: radial-gradient(circle 9px at 0 50%, #0000 97%, #000) left / 51% 100% no-repeat,
    radial-gradient(circle 9px at 100% 50%, #0000 97%, #000) right / 51% 100% no-repeat;
}
.ticket:active { filter: brightness(0.96); }
.ticket .code { width: 100%; display: grid; place-items: center; min-height: 80px; }
.ticket .code svg { display: block; max-width: 100%; fill: #000; stroke: none; }
.ticket .code.linear svg { width: 100%; height: auto; max-height: 112px; }
.ticket .code.square svg { width: min(58%, 230px); height: auto; }
/* One line, shrunk to fit: a mono glyph plus tracking is about 0.68em wide. */
.ticket .num {
  font-family: var(--mono); letter-spacing: 0.08em; text-align: center; white-space: nowrap;
  font-size: min(19px, calc(100cqi / (var(--len, 16) * 0.68)));
}
.ticket.plain { padding: 24px 18px 20px; }
.ticket.plain .num { font-size: min(28px, calc(100cqi / (var(--len, 16) * 0.68))); }
.code-error { color: #c5221f; font-size: 13px; text-align: center; }
.stage-actions { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 8px; }
.stage-actions button {
  height: 44px; border: 0; border-radius: 13px; padding: 0; color: var(--fg);
  background: color-mix(in srgb, var(--fg) 14%, transparent);
  display: grid; place-items: center; transition: transform 0.12s ease;
}
.stage-actions button:active { transform: scale(0.95); }
.stage-actions svg { width: 21px; height: 21px; }
.stage-actions [aria-pressed="true"] svg { color: var(--star); }
.stage .badge { background: color-mix(in srgb, var(--fg) 20%, transparent); }
.stage .badge.bad { background: var(--danger); color: #fff; }

/* ---------- Finder (search + filters, pinned while the list scrolls) ---------- */
.finder {
  position: sticky; top: 0; z-index: 5;
  margin-top: 14px;
  padding: calc(var(--safe-top) + 8px) 0 8px;
  background: var(--bg);
  /* Solid page colour out to the screen edges, inside the content column. */
  box-shadow: 0 0 0 100vmax var(--bg);
  clip-path: inset(0 -100vmax);
}
.find-row { display: flex; gap: 8px; }
.find-row .icon-btn { width: 46px; height: 46px; border-radius: 14px; flex: none; }
.search {
  flex: 1; min-width: 0;
  display: flex; align-items: center; gap: 8px;
  height: 46px; padding: 0 14px; border-radius: 14px;
  background: var(--surface); border: 1px solid var(--line); color: var(--muted);
}
.search:focus-within { border-color: var(--text); }
.search svg { width: 18px; height: 18px; flex: none; fill: none; }
.search input { flex: 1; min-width: 0; border: 0; background: none; outline: none; height: 100%; color: var(--text); font-size: 16px; }
.search input:focus-visible { outline: none; }
.search input::-webkit-search-cancel-button { display: none; }
.search-clear {
  flex: none; width: 30px; height: 30px; margin-right: -8px; border: 0; border-radius: 50%;
  display: grid; place-items: center; background: var(--line); color: var(--text); cursor: pointer;
}
.search-clear svg { width: 14px; height: 14px; stroke: currentColor; }
.search input:placeholder-shown + .search-clear { display: none; }
/* Filters: one scrolling track; the active filter is an ink pill. The edges
   fade so a cut-off filter reads as "more this way". */
.chips {
  position: relative;
  display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; scroll-behavior: smooth;
  margin-top: 8px; padding: 4px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  -webkit-mask: linear-gradient(90deg, #000 calc(100% - 22px), #0000);
  mask: linear-gradient(90deg, #000 calc(100% - 22px), #0000);
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; display: flex; align-items: center; gap: 6px;
  height: 34px; padding: 0 11px 0 9px; border: 0; border-radius: 10px;
  background: transparent; color: var(--muted);
  font-size: 14px; font-weight: 600; white-space: nowrap;
}
.chip:last-child { margin-right: 18px; }
.chip .ci { flex: none; }
.chip .n { font-size: 12px; opacity: 0.7; font-variant-numeric: tabular-nums; }
.chip[aria-pressed="true"] { background: var(--text); color: var(--bg); }
.chip:not([aria-pressed="true"]):active { background: var(--surface-2); }

/* ---------- List ---------- */
.section-label {
  display: flex; justify-content: space-between;
  font-size: 12px; font-weight: 650; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted);
  margin: 16px 4px 8px;
}
.section-label span { font-variant-numeric: tabular-nums; }
#list > .rows:first-child { margin-top: 10px; }
.rows { background: var(--surface); border: 1px solid var(--line); border-radius: 20px; overflow: hidden; }
.row-card {
  position: relative; width: 100%; min-height: 66px;
  display: flex; align-items: center; gap: 12px;
  border: 0; background: none; padding: 10px 14px; text-align: left;
  transition: background 0.15s ease;
}
.row-card + .row-card::before { content: ""; position: absolute; top: 0; left: 70px; right: 0; border-top: 1px solid var(--line); }
.row-card:active { background: var(--surface-2); }
.row-card[aria-current="true"] { background: var(--surface-2); box-shadow: inset 4px 0 0 var(--text); }
.row-card[aria-current="true"] + .row-card::before, .row-card[aria-current="true"]::before { border-color: transparent; }
.tile {
  flex: none; width: 44px; height: 44px; border-radius: 50%; overflow: hidden;
  display: grid; place-items: center;
  background: var(--c); color: var(--fg);
  font-weight: 800; font-size: 14px; letter-spacing: -0.02em;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--fg) 14%, transparent);
}
.tile.has-logo { background: #fff; box-shadow: none; }
.rc-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.rc-name { font-size: 16px; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rc-sub { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rc-end { flex: none; display: flex; align-items: center; gap: 6px; }
.fav { color: var(--star); }
.who {
  display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%;
  background: var(--surface-2); color: var(--text); font-size: 10px; font-weight: 800;
  box-shadow: inset 0 0 0 1px var(--line-strong);
}
.badge {
  display: inline-block; padding: 2px 7px; border-radius: 6px; font-size: 11px; font-weight: 650;
  background: var(--surface-2); white-space: nowrap;
}
.badge.warn { background: var(--warn); color: #000; }
.badge.bad { background: var(--danger); color: #fff; }

/* Grid view */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
#list > .grid:first-child { margin-top: 10px; }
.grid-card {
  aspect-ratio: 1.586; border: 0; border-radius: 16px; padding: 10px 12px; text-align: left;
  display: flex; flex-direction: column; justify-content: space-between; align-items: flex-start;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--fg) 12%, transparent);
  transition: transform 0.12s ease;
}
.grid-card:active { transform: scale(0.97); }
.grid-card[aria-current="true"] { outline: 3px solid var(--text); outline-offset: 2px; }
.grid-card .logo { width: 34px; height: 34px; font-size: 13px; }
.grid-card .fav { position: absolute; top: 9px; right: 11px; }
.grid-card .gc-name { font-size: 15px; font-weight: 700; line-height: 1.15; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.grid-card .gc-sub { font-size: 12px; opacity: 0.75; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: -8px; }
.grid-card .gc-sub:empty { display: none; }

.empty { text-align: center; color: var(--muted); padding: 60px 20px; }
.empty h2 { color: var(--text); font-size: 22px; letter-spacing: -0.02em; margin: 0 0 8px; }
.empty .button { margin-top: 16px; }

/* ---------- Sheets ---------- */
dialog { border: 0; padding: 0; color: var(--text); }
dialog::backdrop { background: rgba(10, 10, 12, 0.45); }
.sheet {
  width: 100%; max-width: 560px;
  height: calc(100dvh - var(--safe-top) - 12px); max-height: none;
  margin: auto auto 0;
  border-radius: 26px 26px 0 0;
  background: var(--bg);
  box-shadow: 0 -12px 48px rgba(0, 0, 0, 0.2);
  overflow: hidden;
}
.sheet.small { height: auto; max-height: 85dvh; }
.sheet[open] { display: flex; flex-direction: column; animation: sheet-in 0.3s cubic-bezier(0.2, 0.9, 0.25, 1); }
@keyframes sheet-in { from { transform: translateY(100%); } }
@media (min-width: 700px) {
  .sheet { margin: auto; border-radius: 26px; height: min(860px, 92dvh); }
  .sheet[open] { animation: fade-in 0.2s ease; }
}
@keyframes fade-in { from { opacity: 0; transform: scale(0.98); } }
@media (prefers-reduced-motion: reduce) {
  .sheet[open], .stage.swap { animation: none; }
}
.sheet-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px 8px; min-height: 54px; flex: none; position: relative;
}
.sheet-bar::before {
  content: ""; position: absolute; top: 6px; left: 50%; width: 36px; height: 4px; margin-left: -18px;
  border-radius: 2px; background: var(--line-strong);
}
.sheet-bar h2 { font-size: 16px; font-weight: 700; margin: 0; }
.link-btn { border: 0; background: none; color: var(--text); font-size: 16px; padding: 6px 0; font-weight: 500; }
.link-btn.strong { font-weight: 750; }
.link-btn:disabled { opacity: 0.4; }
.sheet-body { flex: 1; overflow-y: auto; padding: 0 16px calc(var(--safe-bottom) + 24px); -webkit-overflow-scrolling: touch; }

/* ---------- Details ---------- */
.ident { display: flex; align-items: center; gap: 14px; padding: 6px 2px 2px; }
.ident .tile { width: 56px; height: 56px; font-size: 18px; }
.ident h3 { font-size: 22px; letter-spacing: -0.025em; margin: 0; line-height: 1.15; }
.muted { color: var(--muted); font-size: 14px; }
.actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 16px; }
.action {
  border: 1px solid var(--line); border-radius: 16px; background: var(--surface); padding: 12px 2px 10px;
  display: flex; flex-direction: column; align-items: center; gap: 5px; font-size: 12px; font-weight: 650;
  transition: transform 0.12s ease;
}
.action:active { transform: scale(0.95); }
.action svg { width: 22px; height: 22px; }
.action[aria-pressed="true"] svg { color: var(--star); }

.group { margin-top: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; overflow: hidden; }
.group-title { font-size: 12px; font-weight: 650; text-transform: uppercase; color: var(--muted); margin: 22px 6px 6px; letter-spacing: 0.08em; }
.group-title + .group { margin-top: 0; }
.row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 46px; padding: 10px 16px; position: relative;
}
.row + .row::before { content: ""; position: absolute; top: 0; left: 16px; right: 0; border-top: 1px solid var(--line); }
.row .k { color: var(--text); flex: none; }
.row .v { color: var(--muted); text-align: right; min-width: 0; overflow-wrap: anywhere; }
.row.note .v { text-align: left; color: var(--text); white-space: pre-wrap; }
.row.note a { color: var(--text); font-weight: 650; text-decoration: underline; text-underline-offset: 3px; }
.row button.v { border: 0; background: none; color: var(--text); font-weight: 650; padding: 0; }
.photos { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }
.photos button { border: 0; padding: 0; border-radius: 12px; overflow: hidden; aspect-ratio: 1.586; background: var(--surface); }
.photos img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* ---------- Forms ---------- */
.field { display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 6px 16px; position: relative; }
.field + .field::before { content: ""; position: absolute; top: 0; left: 16px; right: 0; border-top: 1px solid var(--line); }
.field > span { flex: none; width: 108px; color: var(--text); }
.field input, .field select, .field textarea {
  flex: 1; min-width: 0; border: 0; background: none; outline: none; font-size: 16px; padding: 6px 0;
}
.field select { appearance: none; color: var(--muted); text-align: right; direction: rtl; }
.field textarea { resize: vertical; min-height: 70px; }
.field .inline-btn { flex: none; border: 0; border-radius: 10px; background: var(--surface-2); color: var(--text); font-weight: 650; padding: 7px 12px; font-size: 14px; }
.field.toggle { justify-content: space-between; }
/* `.field > span` sizes labels; the switch is a span too and must keep its own width. */
.field > .switch, .switch { position: relative; width: 50px; height: 30px; flex: none; }
.switch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch i { position: absolute; inset: 0; border-radius: 10px; background: var(--line-strong); transition: background 0.2s; }
.switch i::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 7px;
  background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25); transition: transform 0.2s, background 0.2s;
}
.switch input:checked + i { background: var(--text); }
.switch input:checked + i::after { transform: translateX(20px); background: var(--bg); }
.switch input:focus-visible + i { outline: 2px solid var(--text); outline-offset: 2px; }
.suggest { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px 2px 0; }
.suggest:empty { display: none; }
.suggest button { border: 0; border-radius: 10px; padding: 6px 12px 6px 8px; font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.swatches { display: flex; flex-wrap: wrap; gap: 10px; padding: 12px 16px; }
.swatch { width: 32px; height: 32px; border-radius: 10px; border: 0; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12); position: relative; }
.swatch[aria-pressed="true"]::after { content: ""; position: absolute; inset: -4px; border-radius: 13px; border: 2px solid var(--text); }
.swatch.custom { background: conic-gradient(red, yellow, lime, cyan, blue, magenta, red); overflow: hidden; }
.swatch.custom input { opacity: 0; width: 100%; height: 100%; cursor: pointer; }
.faces { display: flex; gap: 10px; overflow-x: auto; padding: 12px 16px; scrollbar-width: none; }
.faces button { flex: none; width: 72px; aspect-ratio: 1.586; border-radius: 9px; padding: 0; border: 2px solid transparent; background: none; }
.faces button[aria-pressed="true"] { border-color: var(--text); }
.img-slots { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; padding: 12px 16px; }
.img-slot {
  position: relative; border: 1.5px dashed var(--line-strong); border-radius: 12px; aspect-ratio: 1.586;
  display: grid; place-items: center; color: var(--muted); font-size: 13px; overflow: hidden; background: none;
}
.img-slot img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.img-slot .x {
  position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; border-radius: 50%; border: 0;
  background: rgba(0, 0, 0, 0.6); color: #fff; font-size: 14px; line-height: 22px; padding: 0; z-index: 1;
}
.img-slot input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
/* Editor: the card itself is the top of the form. */
.preview { margin: 4px 0 2px; box-shadow: none; }
.preview input, .preview select { border: 0; background: none; outline: none; color: inherit; font: inherit; padding: 0; margin: 0; width: 100%; }
.preview .edit-logo { position: relative; cursor: pointer; }
.preview .edit-logo input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.preview .logo-in { display: contents; }
.name-input { font-size: 21px; font-weight: 750; letter-spacing: -0.025em; line-height: 1.2; border-bottom: 1.5px dashed color-mix(in srgb, var(--fg) 35%, transparent) !important; }
.name-input::placeholder, .num-input::placeholder { color: inherit; opacity: 0.5; }
.cat-select { appearance: none; font-size: 13px !important; opacity: 0.8; margin-top: 4px !important; width: auto !important; cursor: pointer;
  padding-right: 16px !important;
  background: linear-gradient(45deg, transparent 50%, currentColor 50%) right 6px top 55% / 5px 5px no-repeat,
    linear-gradient(-45deg, transparent 50%, currentColor 50%) right 1px top 55% / 5px 5px no-repeat !important; }
.cat-select option { color: initial; }
.ticket.editing { cursor: default; padding-bottom: 10px; }
.ticket.editing .code[hidden] { display: none; }
.num-row { display: flex; align-items: center; gap: 8px; width: 100%; }
.num-input {
  flex: 1; min-width: 0; height: 40px; text-align: center;
  font-family: var(--mono) !important; letter-spacing: 0.08em; color: #111 !important;
  font-size: min(20px, calc(100cqi / (var(--len, 12) * 0.68))) !important;
  border-bottom: 1.5px dashed #c9c7c0 !important;
}
.num-input::placeholder { letter-spacing: 0.02em; font-family: var(--font); }
.scan-btn { flex: none; width: 40px; height: 40px; border: 0; border-radius: 12px; background: #141416; color: #fff; display: grid; place-items: center; }
.scan-btn svg { width: 20px; height: 20px; }
.danger-btn { width: 100%; margin-top: 22px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); color: var(--danger); font-weight: 650; min-height: 48px; }
.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--text); border-radius: 14px; background: var(--text); color: var(--bg); padding: 12px 22px;
  font-weight: 700; text-decoration: none; font-size: 16px;
}
.button.secondary { background: var(--surface); color: var(--text); border-color: var(--line-strong); }
.form-error { color: var(--danger); font-size: 14px; padding: 8px 16px 0; }
.menu-item { width: 100%; text-align: left; border: 0; background: none; color: var(--text); font-weight: 600; }
.members { display: flex; flex-direction: column; }
.member { display: flex; align-items: center; gap: 10px; }
.member .who { width: 30px; height: 30px; font-size: 12px; }
.small-print { color: var(--muted); font-size: 13px; padding: 8px 6px; }

/* ---------- Checkout (code full-screen) ---------- */
.checkout {
  position: fixed; inset: 0; width: 100%; height: 100%; max-width: none; max-height: none; margin: 0;
  background: #fff; color: #000;
  display: grid; place-items: center;
  padding: calc(var(--safe-top) + 20px) 18px calc(var(--safe-bottom) + 20px);
  touch-action: manipulation;
}
.checkout:not([open]) { display: none; }
.checkout::backdrop { background: #fff; }
.checkout video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.checkout-body { position: relative; width: 100%; max-width: 900px; display: flex; flex-direction: column; align-items: center; gap: 18px; }
.checkout .store { font-size: 20px; font-weight: 750; letter-spacing: -0.02em; text-align: center; }
.checkout .code { width: 100%; display: grid; place-items: center; }
.checkout .code svg { fill: #000; stroke: none; display: block; }
.checkout .code.linear svg { width: 100%; height: auto; max-height: 40dvh; }
.checkout .code.square svg { width: min(86vw, 62dvh); height: auto; }
.checkout .num { font-family: var(--mono); font-size: clamp(22px, 7vw, 40px); letter-spacing: 0.08em; text-align: center; word-break: break-all; }
.checkout .tip { font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: #8a8883; }

/* ---------- Scanner ---------- */
.scanner { width: 100%; height: 100%; max-width: none; max-height: none; margin: 0; background: #000; color: #fff; }
.scanner[open] { display: block; }
.scanner video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.scanner .frame {
  position: absolute; left: 50%; top: 45%; width: min(80vw, 420px); aspect-ratio: 1.6; transform: translate(-50%, -50%);
  border-radius: 18px; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.5); outline: 3px solid rgba(255, 255, 255, 0.9);
}
.scanner .bar {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 16px 16px calc(var(--safe-bottom) + 20px);
  display: flex; justify-content: space-around; gap: 10px;
}
.scanner .bar button { border: 0; border-radius: 12px; padding: 12px 18px; background: rgba(255, 255, 255, 0.16); color: #fff; font-weight: 650; }
.scanner .msg { position: absolute; top: calc(var(--safe-top) + 20px); left: 16px; right: 16px; text-align: center; font-size: 15px; text-shadow: 0 1px 3px #000; }
.scanner input[type="file"] { display: none; }

.photo-view { width: 100%; height: 100%; max-width: none; max-height: none; margin: 0; background: #000; }
.photo-view[open] { display: grid; place-items: center; }
.photo-view img { max-width: 100%; max-height: 100%; object-fit: contain; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--safe-bottom) + 24px); transform: translateX(-50%);
  z-index: 60; max-width: calc(100% - 32px);
  background: var(--text); color: var(--bg); padding: 12px 18px; border-radius: 14px;
  font-size: 15px; font-weight: 550; box-shadow: var(--shadow);
}

.auth-error { max-width: 420px; margin: 20vh auto; padding: 0 20px; text-align: center; }
.auth-error h1 { font-size: 24px; justify-content: center; }
.auth-error p { color: var(--muted); }
