/* Boop Card Studio. Butter Toast tokens from the Boop design system. */
:root {
  --bg: #FFF9EC; --surface: #FFFEF8; --line: #F0E2BF; --ink: #3A2E1E; --muted: #7A6545;
  --toast: #F6DC94; --crumb: #FCF0CC; --brand: #8A6420; --action: #2F5D50; --on-action: #FFF9EC;
  --alert: #C03B3B; --alert-soft: #FBE4E1; --alert-ink: #B23434; --warn-soft: #FDF0D8; --warn-ink: #8A5A12;
  --ok-soft: #E3EEE9; --ok-ink: #2A6E4C;
  --display: "Baloo 2", "Noto Sans HK", system-ui, sans-serif;
  --body: "Noto Sans HK", -apple-system, "PingFang HK", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Menlo, monospace;
  color-scheme: light;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.55 var(--body); }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--action); outline-offset: 2px; }

.top { position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 12px max(16px, env(safe-area-inset-left)); background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.brand { font: 700 18px/1 var(--display); display: flex; gap: 8px; align-items: baseline; }
.wordmark { font: 800 26px/1 var(--display); color: var(--brand); }
.top-actions { display: flex; gap: 8px; }

main { max-width: 1280px; margin: 0 auto; padding: 16px max(16px, env(safe-area-inset-left)) 64px; }
.intro { max-width: 70ch; color: var(--muted); margin: 4px 0 16px; }
.layout { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-start; }
.col { flex: 1 1 340px; min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.col.wide { flex: 999 1 560px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 16px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
h2 { margin: 0; font: 800 19px/1.2 var(--display); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.num { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--crumb); color: var(--brand); font-size: 14px; }
.muted { color: var(--muted); margin: 0; }
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }

.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 8px 16px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 500; }
.btn.small { min-height: 36px; padding: 4px 12px; font-size: 13px; align-self: flex-start; }
.btn.primary { background: var(--action); color: var(--on-action); border-color: var(--action); font-weight: 700; }
.btn.primary:disabled { opacity: .45; cursor: not-allowed; }
.btn.ghost { background: transparent; }

.drop { border: 2px dashed var(--line); border-radius: 16px; padding: 16px; display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.drop.over { border-color: var(--action); background: var(--ok-soft); }
.drop p { margin: 0; color: var(--muted); font-size: 14px; }
.slots { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.slot { display: grid; grid-template-columns: 72px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 8px; border: 1px solid var(--line); border-radius: 14px; }
.slot .thumb { width: 72px; height: 48px; border-radius: 8px; background: var(--crumb) center/cover no-repeat; }
.slot b { display: block; font-size: 14px; }
.slot small { color: var(--muted); font-size: 12px; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slot .req { color: var(--alert-ink); }

.form { display: flex; flex-direction: column; gap: 12px; }
.form label:not(.check) { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.form input:not([type=checkbox]):not([type=color]) { min-height: 44px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 12px; background: #fff; color: var(--ink); font-size: 15px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.check { display: flex; gap: 8px; align-items: center; font-size: 14px; min-height: 32px; }
.check input { width: 20px; height: 20px; accent-color: var(--action); }
.inline { display: flex; gap: 8px; align-items: center; font-size: 13px; color: var(--muted); }
.inline input { width: 120px; min-height: 36px; padding: 4px 10px; border: 1px solid var(--line); border-radius: 10px; }
fieldset { border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px 12px; margin: 0; display: flex; flex-direction: column; gap: 10px; }
legend { font-size: 13px; color: var(--muted); padding: 0 4px; }
.swatches { display: flex; flex-wrap: wrap; gap: 12px; }
.swatches label { flex-direction: row !important; align-items: center; color: var(--ink) !important; font-size: 13px !important; }
.swatches input[type=color] { width: 44px; height: 44px; padding: 0; border: 1px solid var(--line); border-radius: 12px; background: none; cursor: pointer; }
details summary { cursor: pointer; font-size: 14px; color: var(--muted); min-height: 32px; display: flex; align-items: center; }
details.internal[open] { display: flex; flex-direction: column; gap: 12px; }

.seg { display: inline-flex; background: var(--crumb); border-radius: 999px; padding: 4px; gap: 2px; }
.seg button { border: 0; background: transparent; border-radius: 999px; min-height: 36px; padding: 4px 14px; cursor: pointer; }
.seg button[aria-selected="true"] { background: var(--surface); font-weight: 700; box-shadow: 0 1px 3px rgba(58, 42, 30, .15); }

.stage { background: #F6EBD0; border-radius: 16px; padding: 24px 16px; display: flex; flex-wrap: wrap; gap: 24px; justify-content: center; align-items: flex-start; min-height: 320px; }
.fig { margin: 0; display: flex; flex-direction: column; gap: 8px; align-items: center; min-width: 0; }
.fig figcaption { font-size: 12.5px; color: var(--muted); text-align: center; max-width: 34ch; }
.empty { color: var(--muted); align-self: center; text-align: center; }

/* Card: bank-card shape. Sizes are in container units so every preview scales cleanly. */
.card { position: relative; width: min(100%, var(--w, 460px)); aspect-ratio: 1904 / 1200; border-radius: 3.7% / 5.9%; overflow: hidden;
  background: var(--card-fill, #F6DC94) center/cover no-repeat; box-shadow: 0 20px 36px -20px rgba(40, 25, 5, .6); container-type: inline-size; }
.card .art { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.card .mark { position: absolute; left: 4cqw; top: 3.6cqw; font: 800 5cqw/1 var(--display); color: #FFF9EC; text-shadow: 0 1px 6px rgba(0, 0, 0, .25); }
.card .plate { position: absolute; left: 3.4cqw; bottom: 3.4cqw; max-width: 52cqw; padding: 2.2cqw 3cqw; border-radius: 2.8cqw; display: flex; flex-direction: column; gap: .6cqw; }
.card .plate .n { font: 800 8.5cqw/1 var(--display); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .plate .s { font: 500 2.9cqw/1.2 var(--body); opacity: .85; }
.card .plate .c { font: 500 2.4cqw/1 var(--mono); opacity: .75; }
.card .ribbon { position: absolute; right: -11cqw; top: 5.5cqw; width: 44cqw; transform: rotate(35deg); background: var(--alert); color: #fff; text-align: center;
  font: 700 3.4cqw/7cqw var(--body); box-shadow: 0 1cqw 2cqw rgba(0, 0, 0, .25); }
.stack { position: relative; width: 100%; container-type: inline-size; }
.stack .card { position: absolute; left: 0; width: 100%; }
.stack .label { position: absolute; left: 4cqw; top: 3cqw; font: 800 4.6cqw/1 var(--display); }

/* Zones */
.zone { position: absolute; border: 2px dashed rgba(47, 93, 80, .9); background: rgba(47, 93, 80, .12); pointer-events: none; border-radius: 6px; }
.zone span { position: absolute; left: 4px; top: 4px; font: 600 10px/1.2 var(--mono); color: #fff; background: rgba(47, 93, 80, .9); padding: 2px 5px; border-radius: 4px; max-width: calc(100% - 8px); }
.zone.warmzone { border-color: rgba(154, 78, 23, .9); background: rgba(154, 78, 23, .1); }
.zone.warmzone span { background: rgba(154, 78, 23, .9); }

/* Wallet pass, approximately as Wallet draws a store card at 375 pt wide. */
.pass { width: 100%; border-radius: 14px; overflow: hidden; box-shadow: 0 20px 36px -20px rgba(40, 25, 5, .6); container-type: inline-size; }
.pass .head { display: flex; justify-content: space-between; align-items: center; padding: 3.6cqw 4.4cqw; }
.pass .logo { display: flex; gap: 2cqw; align-items: center; font: 600 4.6cqw/1 var(--body); }
.pass .logo i { width: 8.4cqw; height: 8.4cqw; border-radius: 2cqw; background: var(--toast); display: inline-block; }
.pass .f { display: flex; flex-direction: column; gap: .6cqw; }
.pass .f .l { font: 700 2.9cqw/1 var(--body); letter-spacing: .03em; text-transform: uppercase; }
.pass .f .v { font: 400 4.6cqw/1.2 var(--body); }
.pass .strip { position: relative; aspect-ratio: 375 / 123; background: #ccc center/cover no-repeat; }
.pass .strip .shade { position: absolute; inset: 0; background: linear-gradient(90deg, rgba(0, 0, 0, .32), rgba(0, 0, 0, 0) 55%); }
.pass .strip .pf { position: absolute; left: 4.4cqw; bottom: 4cqw; color: #fff; }
.pass .strip .pf .l { font: 700 2.9cqw/1 var(--body); opacity: .9; }
.pass .strip .pf .v { font: 400 9cqw/1.05 var(--body); }
.pass .fields { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 3cqw; padding: 4cqw 4.4cqw 7cqw; }

/* Phone with the app background */
.phone { position: relative; width: 100%; aspect-ratio: 390 / 844; border: 8px solid #1B1610; border-radius: 44px; overflow: hidden; background: #F2EADD; container-type: inline-size; }
.phone .scene { position: absolute; left: 0; top: 0; width: 100%; height: auto; }
.phone .ttl { position: absolute; left: 6cqw; top: 15cqw; font: 800 8cqw/1 var(--display); }
.phone .slot-card { position: absolute; left: 5cqw; right: 5cqw; top: 66cqw; }
.phone .slot-card .card { width: 100%; }
.phone .rows { position: absolute; left: 4cqw; right: 4cqw; top: 130cqw; background: #FFFEF8; border: 1px solid #F0E2BF; border-radius: 5cqw; font-size: 3.9cqw; }
.phone .rows div { display: flex; justify-content: space-between; padding: 3.4cqw 4cqw; border-bottom: 1px solid #F0E2BF; }
.phone .rows div:last-child { border-bottom: 0; }
.phone .tabbar { position: absolute; left: 3cqw; right: 3cqw; bottom: 3cqw; height: 15cqw; border-radius: 8cqw; background: rgba(255, 254, 248, .9); border: 1px solid #F0E2BF;
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); align-items: center; text-align: center; font-size: 3.2cqw; color: #7A6545; }
.phone .tabbar b { color: #8A6420; }
.phone .fade-note { position: absolute; left: 0; right: 0; top: 52%; border-top: 2px dashed rgba(154, 78, 23, .8); }

/* Checks */
.summary { font: 500 13px/1 var(--body); padding: 5px 10px; border-radius: 999px; background: var(--ok-soft); color: var(--ok-ink); }
.summary.err { background: var(--alert-soft); color: var(--alert-ink); }
.summary.warn { background: var(--warn-soft); color: var(--warn-ink); }
.issues { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.issues li { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 10px; align-items: start; padding: 10px 12px; border-radius: 12px; font-size: 14px; }
.issues li.error { background: var(--alert-soft); color: var(--alert-ink); }
.issues li.warn { background: var(--warn-soft); color: var(--warn-ink); }
.issues li.ok { background: var(--ok-soft); color: var(--ok-ink); }
.issues .tag { font: 600 11px/1.6 var(--mono); padding: 0 6px; border-radius: 6px; background: rgba(255, 255, 255, .6); }
.rules { margin: 8px 0 0; padding-left: 20px; font-size: 14px; display: flex; flex-direction: column; gap: 6px; }

@media (max-width: 520px) { .grid2 { grid-template-columns: 1fr; } }
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }

/* Sign-in gate */
body.locked .top-actions, body.locked main { display: none; }
.gate { min-height: 70vh; display: grid; place-items: center; padding: 24px 16px; }
.login { width: min(100%, 400px); display: flex; flex-direction: column; gap: 12px; }
.login h1 { margin: 0; font: 800 26px/1.2 var(--display); }
.login label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.login input { min-height: 44px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 12px; background: #fff; font-size: 16px; }
.en { color: var(--muted); font-size: .85em; font-weight: 400; }
.small { font-size: 13px; }
.gate-error { background: var(--alert-soft); color: var(--alert-ink); border-radius: 12px; padding: 10px 12px; font-size: 14px; }
.who { font-size: 12px; color: var(--muted); max-width: 22ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Errors where they happen */
.field-error { display: block; margin-top: 2px; font-size: 12.5px; line-height: 1.4; color: var(--alert-ink); }
.field-error.warn { color: var(--warn-ink); }
[aria-invalid="true"] { border-color: var(--alert-ink) !important; box-shadow: 0 0 0 1px var(--alert-ink); }
.check .field-error { margin-left: 4px; }
.slot.has-error { border-color: var(--alert-ink); background: var(--alert-soft); }
.slot.has-warn { border-color: #E6C88A; background: var(--warn-soft); }
.slot-issues { grid-column: 1 / -1; list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; font-size: 12.5px; }
.slot-issues li { color: var(--alert-ink); }
.slot-issues li.warn { color: var(--warn-ink); }
.zone.bad { border: 2.5px solid var(--alert-ink); background: rgba(178, 52, 52, .14); }
.zone.bad span { background: var(--alert-ink); white-space: normal; }
.zone.iffy { border: 2.5px solid #C08A1E; background: rgba(192, 138, 30, .14); }
.zone.iffy span { background: #8A5A12; white-space: normal; }
.issues button { all: unset; cursor: pointer; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; align-items: start; width: 100%; }
.issues button:focus-visible { outline: 2px solid var(--action); outline-offset: 4px; border-radius: 8px; }
.issues .go { font-size: 12px; text-decoration: underline; opacity: .8; }

/* Pop-ups */
.toasts { position: fixed; z-index: 20; left: 50%; transform: translateX(-50%); bottom: max(16px, env(safe-area-inset-bottom)); width: min(calc(100% - 32px), 460px);
  display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast { pointer-events: auto; display: flex; gap: 10px; align-items: center; padding: 12px 14px; border-radius: 14px; font-size: 14px;
  box-shadow: 0 10px 24px -10px rgba(40, 25, 5, .45); animation: pop .18s ease-out; background: var(--warn-soft); color: var(--warn-ink); border: 1px solid #E6C88A; }
.toast.error { background: var(--alert-soft); color: var(--alert-ink); border-color: #E7B3AE; }
.toast.ok { background: var(--ok-soft); color: var(--ok-ink); border-color: #BFD8CC; }
.toast span { flex: 1; }
.toast button { border: 0; background: rgba(255, 255, 255, .7); border-radius: 999px; min-height: 32px; padding: 0 12px; font-weight: 700; cursor: pointer; color: inherit; }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .toast { animation: none; } }
