@font-face { font-family: 'Onest'; src: url('/static/fonts/Onest.ttf') format('truetype'); font-weight: 100 900; font-display: swap; }
:root {
  --sand: #F7F1E8;
  --terracotta: #9A4624;
  --amber: #EDA34A;
  --ink: #2A1810;
  --muted: #7A5A48;
  --line: #E2D3C0;
  --track: #F1E7D8;
  --white: #FFFFFF;
  --surface: #FFFFFF;      /* cards and bars (turns dark in the dark theme); --white stays literal white for text on terracotta */
  --edge: var(--edge);
  --line2: #D9C9B3;
  --seg: #EADFCD;
  --accent: #9A4624;      /* terracotta used as text / outline on a surface */
  --vh: var(--tg-viewport-stable-height, 100dvh);
  --safe-b: max(env(safe-area-inset-bottom, 0px), var(--tg-safe-area-inset-bottom, 0px));
}
/* dark theme: follows Telegram (or the choice in the profile) via data-theme on <html> */
:root[data-theme="dark"] {
  --sand: #1E120C; --surface: #2A1A12; --ink: #F7F1E8; --muted: #C2A995; --line: #4A3426; --track: #3A281D;
  --edge: #3A281D; --line2: #5A4333; --seg: #3A281D; --accent: #E8956A; color-scheme: dark;
}
:root[data-theme="dark"] .alert { background: #3A2418; border-color: #5A3A26; }
:root[data-theme="dark"] .qr-box:not(.stale) { background: #fff; border-radius: 16px; padding: 10px; }
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--sand); color: var(--ink); font-family: 'Onest', system-ui, -apple-system, sans-serif; -webkit-tap-highlight-color: transparent; }
body.dark-bg { background: var(--terracotta); }
button { font-family: inherit; cursor: pointer; }
a { color: inherit; text-decoration: none; }

.screen { position: relative; overflow: hidden; min-height: 100vh; min-height: var(--vh); padding: 20px 20px calc(24px + var(--safe-b)); display: flex; flex-direction: column; gap: 16px; max-width: 480px; margin: 0 auto; }
.screen.gift { background: var(--terracotta); color: var(--white); }
.screen > * { position: relative; }
.bg-pattern { position: absolute !important; pointer-events: none; opacity: .2; }

.top { display: flex; align-items: center; justify-content: space-between; height: 44px; }
.top img { height: 22px; width: auto; display: block; }

.hello { padding: 4px 4px 0; display: flex; flex-direction: column; gap: 2px; }
.hello small { font-size: 15px; color: var(--muted); }
.gift .hello small { color: rgba(255,255,255,.88); }
h1 { margin: 0; font-size: 30px; line-height: 36px; font-weight: 600; letter-spacing: -.01em; }

.progress { position: relative; overflow: hidden; border-radius: 28px; background: var(--terracotta); color: var(--white); padding: 20px; display: flex; flex-direction: column; gap: 18px; }
.progress .bg-pattern { right: -70px; top: -70px; width: 240px; height: 240px; }
.progress .count { font-size: 38px; line-height: 40px; font-weight: 600; }
.progress .count span { font-size: 20px; font-weight: 500; opacity: .8; }
.progress .sub { font-size: 14px; opacity: .9; margin-top: 2px; }
.progress .note { font-size: 13px; opacity: .85; }
.progress > * { position: relative; }

.slots { display: flex; justify-content: space-between; gap: 4px; padding: 4px 0; }
.slot { flex: 0 0 auto; width: 38px; height: 38px; border-radius: 50%; display: flex; align-items: center; justify-content: center; border: 1.5px solid rgba(255,255,255,.4); }
.slot svg { width: 20px; height: 20px; }
.slot.on { background: var(--amber); border-color: var(--amber); }
.slot.on path { fill: var(--terracotta); }
.slot.off path { fill: none; stroke: rgba(255,255,255,.4); stroke-width: 1.2; }
.slot.gift { border: 1.5px dashed var(--amber); }
.slot.gift img { width: 24px; height: 24px; }
.slot.gift.ready { background: var(--sand); border: 1.5px solid var(--sand); box-shadow: 0 0 0 4px rgba(237,163,74,.45); }
.gift .slots { padding: 4px 0 8px; }

.qr-card { flex: 1; min-height: 0; border-radius: 28px; background: var(--surface); color: var(--ink); padding: 20px; display: flex; flex-direction: column; align-items: center; gap: 14px; box-shadow: 0 1px 0 var(--edge); }
.qr-box { width: min(60vw, 240px); aspect-ratio: 1; display: flex; align-items: center; justify-content: center; }
.qr-box svg { width: 100%; height: 100%; display: block; }
.qr-box.stale { border: 1.5px dashed var(--line2); border-radius: 20px; background: var(--sand); flex-direction: column; gap: 10px; color: var(--ink); position: relative; overflow: hidden; }
.qr-box.stale img { position: absolute; width: 130%; opacity: .18; }
.qr-box.stale svg { width: 40px; height: 40px; position: relative; }
.qr-box.stale b { position: relative; font-size: 17px; font-weight: 600; }
.qr-title { font-size: 17px; font-weight: 600; text-align: center; }
.qr-hint { font-size: 13px; color: var(--muted); text-align: center; margin-top: 2px; line-height: 19px; }
.bar { width: 100%; height: 4px; border-radius: 2px; background: var(--track); overflow: hidden; }
.bar i { display: block; height: 100%; width: 100%; border-radius: 2px; background: var(--amber); transition: width .25s linear; }

.btn { height: 56px; width: 100%; border-radius: 28px; border: 0; background: var(--terracotta); color: var(--white); font-size: 17px; font-weight: 600; display: flex; align-items: center; justify-content: center; }
.btn.ghost { height: 48px; border-radius: 24px; border: 1.5px solid var(--accent); background: transparent; color: var(--accent); font-size: 16px; }
.btn.light { background: var(--white); color: var(--terracotta); }
.btn[disabled] { opacity: .6; }
.qr-card .btn { margin-top: auto; }

.welcome { background: var(--terracotta); color: var(--white); padding-top: 28px; }
.welcome .art { position: absolute !important; left: 50%; top: 34px; width: 420px; height: 420px; margin-left: -210px; }
.welcome .copy { margin-top: auto; display: flex; flex-direction: column; gap: 20px; }
.welcome .copy img { width: 132px; height: auto; display: block; }
.welcome h1 { font-size: 34px; line-height: 40px; }
.welcome p { margin: 0; font-size: 16px; line-height: 24px; opacity: .92; }
.welcome .legal { font-size: 12px; line-height: 17px; opacity: .8; text-align: center; margin-top: 14px; }

.center { margin: auto 0; display: flex; flex-direction: column; align-items: center; gap: 18px; text-align: center; }
.center .badge { width: 96px; height: 96px; border-radius: 50%; background: var(--surface); border: 1.5px solid var(--line); display: flex; align-items: center; justify-content: center; }
.center .badge svg { width: 44px; height: 44px; }
.center h1 { font-size: 28px; line-height: 34px; }
.center p { margin: 0; font-size: 16px; line-height: 24px; color: var(--muted); }
.screen .art-top { position: absolute !important; left: 50%; top: -80px; width: 460px; height: 460px; margin-left: -230px; opacity: .2; }
.spinner { margin: auto; width: 32px; height: 32px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--terracotta); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } .bar i { transition: none; } }

/* ---------- inner screens ---------- */
.screen.dark { background: #1E120C; color: var(--white); }
.back-space { height: 4px; }
.pill { height: 44px; padding: 0 16px; border-radius: 22px; border: 0; background: var(--amber); color: var(--ink); font-size: 14px; font-weight: 600; display: inline-flex; align-items: center; }
.icon-btn { width: 44px; height: 44px; border-radius: 50%; border: 1.5px solid var(--line); background: transparent; color: var(--ink); display: flex; align-items: center; justify-content: center; }
.gift .icon-btn { border-color: rgba(255,255,255,.35); color: var(--white); }
.icon-btn svg { width: 22px; height: 22px; }
.page-title { font-size: 17px; font-weight: 600; padding: 0 4px; height: 44px; display: flex; align-items: center; }

.who { display: flex; align-items: center; gap: 16px; padding: 8px 4px; }
.avatar { width: 72px; height: 72px; border-radius: 50%; background: var(--amber); color: var(--ink); font-size: 30px; font-weight: 600; display: flex; align-items: center; justify-content: center; flex: none; }
.avatar.sm { width: 40px; height: 40px; font-size: 17px; }
.avatar.md { width: 56px; height: 56px; font-size: 24px; }
.who b { display: block; font-size: 24px; line-height: 30px; font-weight: 600; }
.who span { font-size: 14px; color: var(--muted); }

.kpis { display: flex; gap: 10px; }
.kpi { flex: 1; border-radius: 22px; background: var(--surface); padding: 16px 16px; display: flex; flex-direction: column; gap: 2px; box-shadow: 0 1px 0 var(--edge); }
.kpi.accent { background: var(--terracotta); color: var(--white); box-shadow: none; }
.kpi b { font-size: 30px; line-height: 34px; font-weight: 600; }
.kpi span { font-size: 13px; color: var(--muted); }
.kpi.accent span { color: rgba(255,255,255,.9); }

.list { border-radius: 24px; background: var(--surface); box-shadow: 0 1px 0 var(--edge); display: flex; flex-direction: column; overflow: hidden; }
.row { display: flex; align-items: center; gap: 14px; min-height: 64px; padding: 8px 18px; border: 0; border-bottom: 1px solid var(--track); background: transparent; color: inherit; width: 100%; text-align: left; font-size: 16px; }
.row:last-child { border-bottom: 0; }
.row .grow { flex: 1; display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.row .grow small { font-size: 13px; color: var(--muted); }
.row .trail { font-size: 16px; font-weight: 600; color: var(--accent); }
.row .trail.sm { font-size: 14px; }
.row svg.chev { width: 20px; height: 20px; stroke: var(--muted); fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.dot { width: 40px; height: 40px; border-radius: 50%; background: var(--amber); display: flex; align-items: center; justify-content: center; flex: none; }
.dot.gift { background: var(--terracotta); }
.dot svg { width: 20px; height: 20px; }
.dot svg path { fill: var(--terracotta); }
.dot img { width: 26px; height: 26px; }
.link-danger { height: 48px; border: 0; background: transparent; color: var(--accent); font-size: 15px; font-weight: 600; margin: auto auto 0; padding: 0 24px; }
.btn.sm { height: 44px; width: auto; padding: 0 14px; font-size: 14px; border-radius: 22px; }
.btn.line { background: transparent; border: 1.5px solid var(--line); color: var(--accent); }
.empty { text-align: center; color: var(--muted); font-size: 15px; padding: 28px 12px; }

/* scanner + sheets */
.viewfinder { position: relative; flex: 1; min-height: 0; border-radius: 28px; overflow: hidden; background: linear-gradient(160deg, #3A2418 0%, #24150E 60%, #1A0F09 100%); display: flex; align-items: center; justify-content: center; border: 0; width: 100%; color: inherit; }
.viewfinder .art { position: absolute; left: 50%; top: 50%; width: 520px; height: 520px; margin: -260px 0 0 -260px; opacity: .06; }
.frame { position: relative; width: 240px; height: 240px; }
.frame i { position: absolute; width: 44px; height: 44px; border: 0 solid var(--amber); box-sizing: border-box; }
.frame i:nth-child(1) { left: 0; top: 0; border-left-width: 4px; border-top-width: 4px; border-top-left-radius: 18px; }
.frame i:nth-child(2) { right: 0; top: 0; border-right-width: 4px; border-top-width: 4px; border-top-right-radius: 18px; }
.frame i:nth-child(3) { left: 0; bottom: 0; border-left-width: 4px; border-bottom-width: 4px; border-bottom-left-radius: 18px; }
.frame i:nth-child(4) { right: 0; bottom: 0; border-right-width: 4px; border-bottom-width: 4px; border-bottom-right-radius: 18px; }
.frame b { position: absolute; left: 16px; right: 16px; top: 50%; height: 2px; border-radius: 1px; background: var(--amber); opacity: .8; }
.scan-copy { text-align: center; display: flex; flex-direction: column; gap: 4px; padding: 4px 0 8px; }
.scan-copy b { font-size: 20px; line-height: 26px; font-weight: 600; }
.scan-copy span { font-size: 14px; line-height: 20px; color: #D6BFAE; }
.sheet-wrap { margin: auto -20px calc(-24px - var(--safe-b)); }
.sheet { border-radius: 32px 32px 0 0; background: var(--sand); color: var(--ink); padding: 12px 24px calc(32px + var(--safe-b)); display: flex; flex-direction: column; gap: 22px; }
.sheet .grab { align-self: center; width: 40px; height: 4px; border-radius: 2px; background: var(--line2); }
.sheet .head { display: flex; align-items: center; gap: 14px; }
.sheet .head b { display: block; font-size: 22px; line-height: 28px; font-weight: 600; }
.sheet .head span { font-size: 14px; color: var(--muted); }
.sheet .box { border-radius: 24px; background: var(--surface); padding: 18px; display: flex; flex-direction: column; gap: 14px; box-shadow: 0 1px 0 var(--edge); }
.sheet .box .line1 { display: flex; align-items: baseline; justify-content: space-between; }
.sheet .box .line1 span { font-size: 15px; color: var(--muted); }
.sheet .box .line1 b { font-size: 24px; font-weight: 600; }
.sheet .box .line1 b small { font-size: 15px; font-weight: 500; color: var(--muted); }
.mini { display: flex; justify-content: space-between; }
.mini div { width: 38px; height: 38px; border-radius: 50%; box-sizing: border-box; display: flex; align-items: center; justify-content: center; border: 1.5px solid var(--line); }
.mini div.on { background: var(--amber); border-color: var(--amber); }
.mini div.on svg path { fill: var(--terracotta); }
.mini div.next { border: 2px dashed var(--accent); }
.mini svg { width: 20px; height: 20px; }
.gift-box { position: relative; overflow: hidden; border-radius: 24px; background: var(--terracotta); color: var(--white); padding: 20px; display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; }
.gift-box .medal { position: relative; width: 64px; height: 64px; border-radius: 50%; background: var(--sand); box-shadow: 0 0 0 6px rgba(237,163,74,.45); display: flex; align-items: center; justify-content: center; }
.gift-box .medal img { width: 42px; height: 42px; }
.gift-box b { position: relative; font-size: 22px; line-height: 28px; font-weight: 600; }
.gift-box span { position: relative; font-size: 14px; opacity: .9; }
.sheet .msg { display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center; padding-top: 8px; }
.sheet .msg .ring { width: 72px; height: 72px; border-radius: 50%; background: var(--surface); border: 2px solid var(--accent); display: flex; align-items: center; justify-content: center; }
.sheet .msg .ring svg { width: 34px; height: 34px; }
.sheet .msg b { font-size: 22px; line-height: 28px; font-weight: 600; }
.sheet .msg p { margin: 0; font-size: 15px; line-height: 22px; color: var(--muted); }
.sheet .warn { border-radius: 24px; background: var(--surface); padding: 18px; display: flex; flex-direction: column; gap: 6px; box-shadow: 0 1px 0 var(--edge); }
.sheet .warn b { font-size: 18px; line-height: 24px; font-weight: 600; color: var(--accent); }
.sheet .warn p { margin: 0; font-size: 15px; line-height: 22px; color: var(--muted); }
.sheet .btn.text { background: transparent; color: var(--accent); height: 48px; border-radius: 24px; font-size: 16px; }
.done-badge { width: 96px; height: 96px; border-radius: 50%; background: var(--amber); display: flex; align-items: center; justify-content: center; }
.done-badge svg { width: 44px; height: 44px; }

/* owner area */
.screen.owner { height: 100vh; height: var(--vh); min-height: 0; padding: 0; gap: 0; }
.screen.owner .scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; padding: 16px 20px 24px; display: flex; flex-direction: column; gap: 16px; }
.o-head { display: flex; align-items: baseline; justify-content: space-between; padding: 0 4px; }
.o-head h1 { font-size: 26px; line-height: 32px; }
.o-head span { font-size: 13px; color: var(--muted); }
.row.compact { min-height: 72px; }
.seg { display: flex; padding: 4px; border-radius: 26px; background: var(--seg); }
.seg button { flex: 1; height: 44px; border: 0; border-radius: 22px; background: transparent; color: var(--ink); font-size: 14px; font-weight: 500; }
.seg button.on { background: var(--terracotta); color: var(--white); font-weight: 600; }
.panel { border-radius: 24px; background: var(--surface); padding: 18px; display: flex; flex-direction: column; gap: 14px; box-shadow: 0 1px 0 var(--edge); }
.panel h3 { margin: 0; font-size: 15px; font-weight: 600; }
.chart { display: flex; align-items: flex-end; justify-content: space-between; height: 148px; padding-top: 4px; gap: 4px; }
.chart .col { flex: 1; max-width: 40px; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 4px; height: 100%; }
.chart .col span { font-size: 12px; color: var(--muted); }
.chart .col i { width: 100%; border-radius: 10px 10px 4px 4px; background: var(--amber); min-height: 3px; }
.chart .col.top span { color: var(--accent); font-weight: 600; }
.chart .col.top i { background: var(--terracotta); }
.axis { display: flex; justify-content: space-between; gap: 4px; font-size: 12px; color: var(--muted); }
.axis span { flex: 1; max-width: 40px; text-align: center; }
.promo { position: relative; overflow: hidden; border-radius: 24px; background: var(--terracotta); color: var(--white); padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.promo b { font-size: 18px; font-weight: 600; }
.promo p { margin: 2px 0 0; font-size: 14px; line-height: 20px; opacity: .92; }
.promo .link { display: flex; align-items: center; gap: 8px; height: 56px; border-radius: 28px; background: rgba(255,255,255,.14); padding: 0 6px 0 16px; }
.promo .link span { flex: 1; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.promo .row2 { display: flex; gap: 8px; }
.promo .btn.light { height: 44px; border-radius: 22px; font-size: 14px; flex: 1; width: auto; }
.nav { flex: none; position: relative; z-index: 2; display: flex; background: var(--surface); border-top: 1px solid var(--edge); padding: 8px 12px calc(10px + var(--safe-b)); }
.nav button { flex: 1; min-height: 56px; border: 0; background: transparent; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--muted); font-size: 12px; font-weight: 500; }
.nav button.on { color: var(--accent); font-weight: 600; }
.nav svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }

.stepper { display: flex; align-items: center; gap: 4px; }
.stepper button { width: 44px; height: 44px; border-radius: 50%; border: 1.5px solid var(--line); background: transparent; color: var(--ink); font-size: 22px; line-height: 1; }
.stepper output { min-width: 40px; text-align: center; font-size: 18px; font-weight: 600; }
.field { display: flex; flex-direction: column; gap: 10px; }
.field label { font-size: 14px; font-weight: 500; padding: 0 4px; }
.field input, .field textarea { box-sizing: border-box; width: 100%; padding: 0 20px; border-radius: 28px; border: 1.5px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; font-size: 16px; height: 56px; }
.field textarea { height: auto; min-height: 96px; padding: 16px 20px; line-height: 24px; border-radius: 24px; resize: none; font-size: 15px; }
.toast { position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%); background: var(--ink); color: var(--white); padding: 12px 20px; border-radius: 22px; font-size: 14px; max-width: calc(100% - 40px); z-index: 9; }
.toast.err { background: var(--terracotta); }

/* ---------- celebration overlay ---------- */
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.cele { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; padding: 24px; background: rgba(42, 24, 16, .58); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); animation: cele-fade .25s both; }
.cele.out { animation: cele-fade .24s reverse both; }
.cele-fx { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.cele-card { position: relative; overflow: hidden; width: min(100%, 340px); border-radius: 32px; background: var(--sand); color: var(--ink); padding: 28px 22px 20px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 14px; box-shadow: 0 24px 60px rgba(0, 0, 0, .35); animation: cele-card .55s cubic-bezier(.2, .9, .3, 1.15) both; }
.cele-card.terra { background: var(--terracotta); color: var(--white); }
.cele-card > * { position: relative; }
.cele-card .pat { position: absolute; right: -70px; top: -70px; width: 230px; height: 230px; opacity: .16; }
.cele-badge { width: 88px; height: 88px; border-radius: 50%; background: var(--amber); display: flex; align-items: center; justify-content: center; animation: cele-pop .6s .1s cubic-bezier(.2, .9, .3, 1.4) both; }
.cele-badge svg { width: 44px; height: 44px; }
.cele-badge .chk { stroke-dasharray: 30; stroke-dashoffset: 30; animation: cele-draw .5s .45s ease forwards; }
.cele-medal { width: 96px; height: 96px; border-radius: 50%; background: var(--sand); box-shadow: 0 0 0 6px rgba(237, 163, 74, .5), 0 0 0 14px rgba(237, 163, 74, .2); display: flex; align-items: center; justify-content: center; animation: cele-pop .7s .1s cubic-bezier(.2, .9, .3, 1.4) both; }
.cele-medal img { width: 64px; height: 64px; animation: cele-spin 1s .1s cubic-bezier(.2, .8, .2, 1) both; }
.cele-card h2 { margin: 0; font-size: 26px; line-height: 32px; font-weight: 600; letter-spacing: -.01em; }
.cele-count { display: flex; align-items: baseline; justify-content: center; gap: 8px; }
.odo { display: inline-block; height: 1em; overflow: hidden; font-size: 68px; line-height: 1; font-weight: 600; }
.odo-in { display: flex; flex-direction: column; transition: transform .8s cubic-bezier(.2, .8, .2, 1); }
.odo-in b { display: block; height: 1em; line-height: 1; font-weight: 600; }
.odo-in.go { transform: translateY(-1em); }
.cele-count .of { font-size: 22px; font-weight: 500; opacity: .75; }
.cele-slots { width: 100%; border-radius: 20px; background: var(--terracotta); padding: 12px; display: flex; justify-content: space-between; gap: 2px; }
.cele-card.terra .cele-slots { background: rgba(255, 255, 255, .14); }
.cele-slots .slot { width: 30px; height: 30px; border-width: 1.5px; }
.cele-slots .slot svg { width: 16px; height: 16px; }
.cele-slots .slot.gift img { width: 20px; height: 20px; }
.cele-slots .slot.gift.ready { box-shadow: 0 0 0 3px rgba(237, 163, 74, .5); }
.cele-slots .slot.pop { animation: cele-slot .75s .7s cubic-bezier(.2, .9, .3, 1.5) both; }
.cele-sub { margin: 0; font-size: 15px; line-height: 22px; color: var(--muted); }
.cele-card.terra .cele-sub { color: rgba(255, 255, 255, .92); }
.cele-hint { font-size: 12px; color: var(--muted); opacity: .8; }
.cele-card.terra .cele-hint { color: rgba(255, 255, 255, .7); }
@keyframes cele-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes cele-card { from { opacity: 0; transform: translateY(24px) scale(.92); } to { opacity: 1; transform: none; } }
@keyframes cele-pop { 0% { transform: scale(.3); opacity: 0; } 60% { transform: scale(1.12); opacity: 1; } 100% { transform: scale(1); } }
@keyframes cele-draw { to { stroke-dashoffset: 0; } }
@keyframes cele-spin { from { transform: rotate(-120deg) scale(.3); } to { transform: none; } }
@keyframes cele-slot { 0% { transform: scale(0); } 55% { transform: scale(1.45); box-shadow: 0 0 0 9px rgba(237, 163, 74, .5); } 100% { transform: scale(1); box-shadow: none; } }
@media (prefers-reduced-motion: reduce) {
  .cele, .cele *, .cele-card { animation-duration: .01ms !important; animation-delay: 0s !important; transition-duration: .01ms !important; }
  .cele-badge .chk { stroke-dashoffset: 0; }
}

/* ---------- phase 1 additions ---------- */
.qr-code { font-size: 13px; color: var(--muted); text-align: center; margin-top: 6px; }
.qr-code b { color: var(--ink); font-size: 15px; letter-spacing: .08em; font-variant-numeric: tabular-nums; }
.btn.ghost-light { height: 48px; border-radius: 24px; border: 1.5px solid rgba(255,255,255,.35); background: transparent; color: var(--white); font-size: 16px; }
.field input.code-input { height: 72px; text-align: center; font-size: 34px; font-weight: 600; letter-spacing: .12em; font-variant-numeric: tabular-nums; }
.field input[type="search"] { -webkit-appearance: none; appearance: none; }
.seg.small { padding: 3px; border-radius: 25px; }
.seg.small button { height: 40px; padding: 0 12px; font-size: 14px; }
.row.voided { opacity: .55; }
.row.voided .vt { text-decoration: line-through; }
.alert { display: flex; gap: 12px; align-items: flex-start; border-radius: 18px; background: #FBE9D8; border: 1px solid #F0C9A4; padding: 14px 16px; font-size: 14px; line-height: 20px; color: var(--ink); }
.alert svg { width: 22px; height: 22px; flex: none; margin-top: 1px; }
.nav.five button { font-size: 11px; padding: 0 2px; min-width: 0; }
.nav.five svg { width: 22px; height: 22px; }
button.row { cursor: pointer; font-family: inherit; }

.field input:focus, .field textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(154, 70, 36, .15); }

/* ---------- phase 2 additions ---------- */
.switch { position: relative; display: inline-block; width: 52px; height: 32px; flex: none; }
.switch input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 16px; background: #E2D3C0; transition: background .2s; }
.switch span::after { content: ''; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s; }
.switch input:checked + span { background: var(--terracotta); }
.switch input:checked + span::after { transform: translateX(20px); }
.switch input:focus-visible + span { box-shadow: 0 0 0 3px rgba(154, 70, 36, .3); }
.sel { height: 44px; min-width: 76px; border-radius: 22px; border: 1.5px solid var(--line); background: var(--surface); padding: 0 14px; font: inherit; font-size: 16px; color: var(--ink); }
.opts { display: flex; flex-direction: column; gap: 4px; }
.opt { display: flex; align-items: center; gap: 12px; min-height: 48px; font-size: 16px; }
.opt input[type="radio"], .opt input[type="checkbox"] { width: 22px; height: 22px; accent-color: var(--terracotta); flex: none; margin: 0; }
.opt input.days { width: 64px; height: 40px; border-radius: 20px; border: 1.5px solid var(--line); text-align: center; font: inherit; font-size: 16px; background: var(--surface); }
.opt em { font-style: normal; color: var(--muted); font-size: 14px; }
.field select { height: 52px; border-radius: 26px; border: 1.5px solid var(--line); padding: 0 18px; font: inherit; font-size: 16px; background: var(--surface); }
.panel .kpi { background: var(--sand); box-shadow: none; }
.panel .kpi.accent { background: var(--terracotta); }
.panel .kpi b { font-size: 28px; }
/* content blocks in the scrolling area must keep their height (they used to shrink and clip on long screens) */
.screen.owner .scroll > * { flex: none; }

/* rating screen */
.rate { margin: auto 0; display: flex; flex-direction: column; gap: 18px; padding: 8px 0 calc(8px + var(--safe-b)); }
.rate-top b { display: block; font-size: 24px; line-height: 30px; font-weight: 600; }
.rate-top p { margin: 6px 0 0; font-size: 15px; line-height: 22px; color: var(--muted); }
.rstars { display: flex; justify-content: space-between; gap: 6px; }
.rstar { flex: 1; height: 56px; border: 0; background: transparent; padding: 0; }
.rstar svg { width: 100%; height: 100%; fill: var(--track); transition: fill .15s, transform .15s; }
.rstar.on svg { fill: #EDA34A; }
.rstar:active svg { transform: scale(.9); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { min-height: 44px; padding: 0 16px; border-radius: 22px; border: 1.5px solid var(--line); background: var(--surface); color: var(--ink); font-size: 15px; }
.chip.on { background: var(--terracotta); border-color: var(--terracotta); color: var(--white); }
.rcomment { width: 100%; border-radius: 18px; border: 1.5px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; font-size: 16px; padding: 12px 14px; resize: none; box-sizing: border-box; }
.rate-actions { display: flex; flex-direction: column; gap: 10px; }

/* new-reviews counter */
.nav button { position: relative; }
.bdg { position: absolute; top: 4px; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--terracotta); color: var(--white); font: 600 11px/18px 'Onest', system-ui, sans-serif; font-style: normal; text-align: center; box-sizing: border-box; }
.bdg[hidden] { display: none; }
.row .bdg { position: static; flex: none; }

/* scanner: visible "tap to start the camera" button inside the frame area */
.tap-btn { position: absolute; left: 50%; bottom: 22px; transform: translateX(-50%); display: inline-flex; align-items: center; gap: 8px; height: 44px; padding: 0 18px; border-radius: 22px; background: var(--amber); color: #2A1810; font-size: 15px; font-weight: 600; white-space: nowrap; }
.tap-btn[hidden] { display: none; }
.tap-btn svg { width: 20px; height: 20px; }

/* gift: warm words, a softly glowing gift and a few twinkling sparks */
.gift-note { margin: 10px 0 0; font-size: 15px; line-height: 22px; color: rgba(255, 255, 255, .92); }
.cele-hello { margin: 0; font-size: 17px; font-weight: 600; color: rgba(255, 255, 255, .95); }
.cele-thanks { margin: 0; font-size: 14px; line-height: 20px; color: rgba(255, 255, 255, .8); }
.cele-medal.glow { animation: gift-breathe 2.2s ease-in-out infinite; }
.gift .slot.gift.ready { animation: gift-pulse 2s ease-in-out infinite; }
.screen.gift { position: relative; overflow: hidden; }
.spark { position: absolute; width: 10px; height: 10px; background: #F6C27A; clip-path: polygon(50% 0, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 38%); opacity: 0; animation: twinkle 3.2s ease-in-out infinite; pointer-events: none; }
.spark.s1 { left: 12%; top: 22%; } .spark.s2 { right: 14%; top: 30%; animation-delay: .9s; width: 14px; height: 14px; }
.spark.s3 { left: 26%; top: 42%; animation-delay: 1.7s; width: 8px; height: 8px; } .spark.s4 { right: 24%; top: 16%; animation-delay: 2.4s; }
@keyframes twinkle { 0%, 100% { opacity: 0; transform: scale(.4) rotate(0); } 50% { opacity: .95; transform: scale(1) rotate(45deg); } }
@keyframes gift-pulse { 0%, 100% { box-shadow: 0 0 0 4px rgba(237, 163, 74, .45); transform: scale(1); } 50% { box-shadow: 0 0 0 9px rgba(237, 163, 74, .18); transform: scale(1.08); } }
@keyframes gift-breathe { 0%, 100% { transform: scale(1); filter: drop-shadow(0 0 0 rgba(246, 194, 122, 0)); } 50% { transform: scale(1.06); filter: drop-shadow(0 0 18px rgba(246, 194, 122, .7)); } }
@media (prefers-reduced-motion: reduce) { .spark { display: none; } .cele-medal.glow, .gift .slot.gift.ready { animation: none; } }

/* redeem scene: sparks in the sand card use the amber of the brand */
.cele-card:not(.terra) .spark { background: #EDA34A; }
.cele-card .spark { z-index: 0; }
/* hello/thanks lines: dark on the sand card, white only on the terracotta one */
.cele-hello { color: var(--accent); }
.cele-thanks { color: var(--muted); }
.cele-card.terra .cele-hello { color: rgba(255, 255, 255, .95); }
.cele-card.terra .cele-thanks { color: rgba(255, 255, 255, .8); }

/* expired QR: the whole box is a tap target that renews the code */
button.qr-box.stale { font: inherit; padding: 0; cursor: pointer; }
button.qr-box.stale small { position: relative; font-size: 14px; color: var(--muted); }
button.qr-box.stale:active { transform: scale(.98); }
