/* Layout: one-screen phone app. Full-bleed on phones, a framed device on wider screens. */
:root {
  /* ---- User design system (unchanged) ---- */
  --color-ink-black: #000000;
  --color-paper-white: #ffffff;
  --color-soft-mist: #e2e2e2;
  --color-graphite: #595959;
  --color-electric-indigo: #4d49fc;
  --color-figma-cyan: #00b6ff;
  --color-figma-green: #24cb71;
  --color-figma-orange: #ff7237;
  --color-lime-wash: #e4ff97;
  --color-lilac: #c4baff;
  --color-blush: #ffc9c1;
  --color-aqua-mist: #c7f8fb;
  --color-earworm-teal: #33dfdf;
  --color-mustard: #b98e01;

  --font-figmasans: 'figmaSans', 'Inter', ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-figmamono: 'figmaMono', 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  --text-caption: 12px; --leading-caption: 1.3; --tracking-caption: 0.48px;
  --text-body-sm: 16px; --leading-body-sm: 1.45; --tracking-body-sm: -0.11px;
  --text-body: 18px; --leading-body: 1.4; --tracking-body: -0.18px;
  --text-heading: 24px; --leading-heading: 1.35; --tracking-heading: -0.24px;
  --text-heading-lg: 56px; --leading-heading-lg: 1.1; --tracking-heading-lg: -0.84px;
  --text-display: 72px; --leading-display: 1.1; --tracking-display: -1.44px;

  --font-weight-w320: 320; --font-weight-w340: 340; --font-weight-regular: 400;
  --font-weight-w450: 450; --font-weight-w520: 520; --font-weight-bold: 700;

  --spacing-4: 4px; --spacing-8: 8px; --spacing-12: 12px; --spacing-16: 16px; --spacing-20: 20px;
  --spacing-24: 24px; --spacing-32: 32px; --spacing-40: 40px; --spacing-48: 48px;

  --radius-sm: 2px; --radius-lg: 8px; --radius-2xl: 16px; --radius-full: 50px;
  --radius-tags: 8px; --radius-cards: 16px; --radius-icons: 2px; --radius-buttons: 50px;
  --shadow-xl: rgba(0, 0, 0, 0.1) 0px 24px 70px 0px;

  --surface-canvas: #ffffff; --surface-card: #ffffff; --surface-soft-panel: #e2e2e2;

  /* ---- Theme roles built on the system ---- */
  --bg: var(--surface-canvas);
  --fg: var(--color-ink-black);
  --muted: var(--color-graphite);
  --line: var(--color-soft-mist);
  --panel: #f2f2f2;
  --card: var(--surface-card);
  --ink: var(--color-ink-black);       /* text on pastel fills, both themes */
  --accent: var(--color-electric-indigo);
  --good: #0f8f4a;
  --warn: #d4470d;
  --desk: #ececec;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c0c10; --fg: #f4f4f6; --muted: #a3a3ad; --line: #26262d; --panel: #18181e; --card: #131318;
    --accent: #8d8aff; --good: #3ddc84; --warn: #ff8a5c; --desk: #050507;
    --shadow-xl: rgba(0,0,0,0.6) 0px 24px 70px 0px; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0c0c10; --fg: #f4f4f6; --muted: #a3a3ad; --line: #26262d; --panel: #18181e; --card: #131318;
  --accent: #8d8aff; --good: #3ddc84; --warn: #ff8a5c; --desk: #050507;
  --shadow-xl: rgba(0,0,0,0.6) 0px 24px 70px 0px; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  background: var(--desk); color: var(--fg);
  font-family: var(--font-figmasans); font-size: var(--text-body-sm);
  line-height: var(--leading-body-sm); letter-spacing: var(--tracking-body-sm);
  font-weight: var(--font-weight-w340);
  display: grid; place-items: center;
  padding-left: max(0px, env(safe-area-inset-left, 0px));
  padding-right: max(0px, env(safe-area-inset-right, 0px));
}
button { font: inherit; color: inherit; letter-spacing: inherit; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.device {
  width: 100%; height: 100%; background: var(--bg); position: relative; overflow: hidden;
  display: flex; flex-direction: column;
}
@media (min-width: 520px) and (min-height: 700px) {
  .device { width: 390px; height: min(844px, calc(100% - 48px)); border-radius: 48px; border: 10px solid var(--ink); box-shadow: var(--shadow-xl); }
}

.view { flex: 1; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; }
.pad { padding: var(--spacing-16) max(var(--spacing-20), env(safe-area-inset-left, 0px)) var(--spacing-24); display: flex; flex-direction: column; gap: var(--spacing-16); }

.mono { font-family: var(--font-figmamono); font-size: var(--text-caption); line-height: var(--leading-caption); letter-spacing: var(--tracking-caption); text-transform: uppercase; }
.muted { color: var(--muted); }
.h1 { font-size: 32px; line-height: var(--leading-heading-lg); letter-spacing: -0.6px; font-weight: var(--font-weight-w520); margin: 0; text-wrap: balance; }
.h2 { font-size: var(--text-heading); line-height: var(--leading-heading); letter-spacing: var(--tracking-heading); font-weight: var(--font-weight-w520); margin: 0; }
.num { font-variant-numeric: tabular-nums; }

.btn { border: 1px solid var(--line); background: transparent; border-radius: var(--radius-buttons); padding: 14px 18px; font-size: 16px; font-weight: var(--font-weight-w450); cursor: pointer; }
.btn.primary { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.btn.block { width: 100%; }
.btn.small { padding: 8px 14px; font-size: 14px; min-height: 44px; }
.btn[disabled] { opacity: .4; cursor: not-allowed; }
.iconbtn { width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line); background: var(--card); display: grid; place-items: center; cursor: pointer; flex: none; }
.iconbtn svg { width: 18px; height: 18px; }

.g { width: 12px; height: 12px; flex: none; display: inline-block; vertical-align: -1px; }
.dot .g { width: 16px; height: 16px; }
.btn .g { width: 14px; height: 14px; vertical-align: -2px; }
.pill { display: inline-flex; align-items: center; gap: 4px; font-family: var(--font-figmamono); font-size: 11px; letter-spacing: .3px; padding: 4px 9px; border-radius: var(--radius-buttons); color: var(--ink); white-space: nowrap; }
.pill.lime { background: var(--color-lime-wash); } .pill.blush { background: var(--color-blush); }
.pill.aqua { background: var(--color-aqua-mist); } .pill.lilac { background: var(--color-lilac); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-cards); padding: var(--spacing-16); }
.panel { background: var(--panel); border-radius: var(--radius-cards); padding: var(--spacing-16); }
.art { display: block; width: 100%; height: 100%; }
.thumb { width: 56px; height: 56px; border-radius: var(--radius-lg); overflow: hidden; flex: none; }

/* top bar */
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px max(20px, env(safe-area-inset-left, 0px)) 4px; }
.top .title { font-weight: var(--font-weight-w520); font-size: 17px; }
.logo { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 22px; letter-spacing: -1px; line-height: 1; }
.logo svg { width: 30px; height: 30px; flex: none; }
.logo b { color: var(--color-electric-indigo); font-weight: 800; }
.avatar { width: 40px; height: 40px; border-radius: 50%; overflow: hidden; flex: none; }

/* score */
.score { border-radius: var(--radius-cards); padding: 20px; color: var(--ink); transition: background .4s; position: relative; overflow: hidden; }
.score.ok { background: var(--color-lime-wash); } .score.low { background: var(--color-blush); }
.score .row { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.score .big { font-size: var(--text-heading-lg); line-height: 1; letter-spacing: var(--tracking-heading-lg); font-weight: var(--font-weight-w520); }
.score .big small { font-size: 20px; letter-spacing: 0; }
.meter { position: relative; height: 10px; border-radius: 10px; background: rgba(0,0,0,.12); margin: 18px 0 10px; }
.meter i { position: absolute; inset: 0 auto 0 0; border-radius: 10px; background: var(--color-ink-black); transition: width .5s; }
.meter b { position: absolute; top: -6px; bottom: -6px; left: 75%; width: 2px; background: var(--color-ink-black); }
.score p { margin: 0; font-size: 14px; }

.boost { display: grid; grid-template-columns: 64px minmax(0,1fr); gap: 14px; align-items: center; }
.boost .thumb { width: 64px; height: 64px; }
.timer { font-family: var(--font-figmamono); font-size: 20px; color: var(--warn); }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stat .v { font-size: 22px; font-weight: var(--font-weight-w520); letter-spacing: -0.4px; }
.stat .k { font-size: 12px; color: var(--muted); }

.sechead { display: flex; justify-content: space-between; align-items: baseline; }
.sechead button { background: none; border: 0; color: var(--accent); cursor: pointer; font-size: 14px; padding: 0 4px; min-height: 44px; min-width: 44px; }
.rail { display: flex; gap: 12px; overflow-x: auto; margin: 0 -20px; padding: 0 20px 4px; scrollbar-width: none; }
.rail::-webkit-scrollbar { display: none; }
.mini { flex: none; width: 150px; cursor: pointer; text-align: left; background: none; border: 0; padding: 0; }
.mini .img { height: 150px; border-radius: var(--radius-cards); overflow: hidden; }
.mini .n { font-size: 14px; font-weight: var(--font-weight-w450); margin-top: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini .p { font-size: 13px; color: var(--muted); }

.act { display: grid; grid-template-columns: 36px minmax(0,1fr) auto; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.act:last-child { border-bottom: 0; }
.dot { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; color: var(--ink); font-size: 16px; }
.act .t { font-size: 14px; font-weight: var(--font-weight-w450); }
.act .s { font-size: 12px; color: var(--muted); }

/* hold list */
.item { display: grid; grid-template-columns: 72px minmax(0,1fr); gap: 14px; align-items: center; cursor: pointer; text-align: left; width: 100%; }
.item .thumb { width: 72px; height: 72px; }
.item .n { font-weight: var(--font-weight-w450); }
.item .line { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 6px; }
.item.done { opacity: .5; }
.filters { display: flex; gap: 8px; }
.filters button { border: 1px solid var(--line); background: transparent; border-radius: var(--radius-buttons); padding: 6px 16px; font-size: 14px; cursor: pointer; min-height: 44px; }
.filters button[aria-pressed="true"] { background: var(--fg); color: var(--bg); border-color: var(--fg); }

/* detail */
.hero { height: 300px; position: relative; }
.hero .back { position: absolute; top: 14px; left: 16px; }
.hero .art { height: 300px; }
.ring { width: 88px; height: 88px; flex: none; }
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.facts .panel .v { font-size: 20px; font-weight: var(--font-weight-w520); }
.facts .panel .k { font-size: 12px; color: var(--muted); }
.actions { display: grid; grid-template-columns: 1fr 1.4fr; gap: 10px; }

/* add */
.field { display: flex; align-items: center; gap: 10px; border: 1px solid var(--line); border-radius: var(--radius-buttons); padding: 6px 6px 6px 16px; background: var(--card); }
.field input { flex: 1; min-width: 0; border: 0; background: transparent; font: inherit; color: var(--fg); padding: 8px 0; outline: none; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips button { border: 1px solid var(--line); background: var(--card); border-radius: var(--radius-tags); padding: 8px 10px; font-size: 13px; cursor: pointer; min-height: 44px; display: flex; gap: 8px; align-items: center; }
.chips .thumb { width: 28px; height: 28px; border-radius: 6px; }
.preview { display: grid; grid-template-columns: 96px minmax(0,1fr); gap: 14px; align-items: center; }
.preview .thumb { width: 96px; height: 96px; }

/* squad */
.banner { border-radius: var(--radius-cards); overflow: hidden; position: relative; color: var(--ink); }
.banner .art { height: 190px; }
.banner .over { position: absolute; left: 10px; right: 10px; bottom: 10px; display: flex; justify-content: space-between; align-items: center; gap: 12px;
  background: var(--color-paper-white); color: var(--color-ink-black); border-radius: 12px; padding: 12px 14px; box-shadow: 0 4px 16px rgba(0,0,0,.08); }
.banner .over .mono { color: var(--color-graphite); }
.member { display: grid; grid-template-columns: 40px minmax(0,1fr) auto; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.member:last-child { border-bottom: 0; }
.member .bar { height: 6px; border-radius: 6px; background: var(--line); margin-top: 6px; overflow: hidden; }
.member .bar i { display: block; height: 100%; border-radius: 6px; }

/* rewards */
.drops { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.drop { border: 1px solid var(--line); border-radius: var(--radius-cards); overflow: hidden; background: var(--card); display: flex; flex-direction: column; }
.drop .img { height: 120px; position: relative; }
.drop .img .pill { position: absolute; top: 8px; left: 8px; }
.drop .body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.drop .n { font-size: 14px; font-weight: var(--font-weight-w450); }
.drop .c { font-size: 12px; color: var(--muted); }
.drop .btn { margin-top: auto; }

/* onboarding */
.onb { height: 100%; display: flex; flex-direction: column; }
.onb .art-wrap { flex: 1; min-height: 0; display: grid; place-items: center; padding: 24px; }
.onb .art-wrap .frame { width: 100%; max-width: 300px; aspect-ratio: 1; border-radius: 32px; overflow: hidden; }
.onb .copy { padding: 0 24px 24px; display: flex; flex-direction: column; gap: 12px; }
.onb .copy p { margin: 0; color: var(--muted); font-size: var(--text-body); line-height: var(--leading-body); }
.dots { display: flex; gap: 6px; }
.dots i { width: 8px; height: 8px; border-radius: 8px; background: var(--line); transition: width .3s; }
.dots i.on { width: 24px; background: var(--fg); }

/* tab bar */
.tabbar { display: grid; grid-template-columns: repeat(5, 1fr); align-items: center; border-top: 1px solid var(--line); background: var(--bg); padding: 6px 8px calc(8px + env(safe-area-inset-bottom, 0px)); }
.tabbar button { background: none; border: 0; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; color: var(--muted); padding: 6px 0; cursor: pointer; position: relative; }
.tabbar button svg { width: 22px; height: 22px; }
.tabbar button[aria-current="page"] { color: var(--fg); font-weight: var(--font-weight-w520); }
.tabbar .add { width: 52px; height: 52px; border-radius: 50%; background: var(--color-electric-indigo); color: #fff; justify-self: center; display: grid; place-items: center; margin-top: -18px; box-shadow: 0 8px 20px rgba(77,73,252,.35); }
.tabbar .add svg { width: 24px; height: 24px; }
.badge { position: absolute; top: 2px; right: calc(50% - 18px); min-width: 16px; height: 16px; border-radius: 8px; background: var(--color-figma-orange); color: var(--ink); font-size: 10px; display: grid; place-items: center; padding: 0 4px; font-weight: var(--font-weight-w520); }

/* sheet + toast */
.scrim { position: absolute; inset: 0; background: rgba(0,0,0,.4); display: flex; align-items: flex-end; z-index: 20; }
.sheet { background: var(--bg); width: 100%; border-radius: 24px 24px 0 0; padding: 12px 20px calc(20px + env(safe-area-inset-bottom, 0px)); display: flex; flex-direction: column; gap: 14px; animation: up .25s ease-out; }
.sheet .grab { width: 40px; height: 4px; border-radius: 4px; background: var(--line); align-self: center; }
@keyframes up { from { transform: translateY(40px); opacity: .6; } }
.toast { position: absolute; left: 16px; right: 16px; bottom: 92px; z-index: 30; background: var(--fg); color: var(--bg); border-radius: var(--radius-cards); padding: 12px 16px; font-size: 14px; display: flex; gap: 10px; align-items: center; transform: translateY(16px); opacity: 0; transition: .3s; pointer-events: none; }
.toast.show { transform: none; opacity: 1; }
.toast.win { background: var(--color-lime-wash); color: var(--ink); }
.toast.win .g { width: 16px; height: 16px; }
.toast span { flex: 1; min-width: 0; }
.toast button { pointer-events: auto; border: 0; background: transparent; font-weight: 520; text-decoration: underline; cursor: pointer; min-height: 44px; padding: 0 4px; color: inherit; }
.info { width: 24px; height: 24px; border-radius: 50%; border: 1.5px solid currentColor; background: none; font-size: 12px; font-weight: 520; display: inline-grid; place-items: center; cursor: pointer; vertical-align: 1px; margin-left: 6px; position: relative; }
.info::after { content: ""; position: absolute; inset: -10px; }

/* splash */
.splash { all: unset; box-sizing: border-box; height: 100%; width: 100%; cursor: pointer; background: var(--color-electric-indigo); color: var(--color-paper-white);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 20px; position: relative; overflow: hidden; }
.splash:focus-visible { outline: 3px solid var(--color-lime-wash); outline-offset: -6px; }
.splash .mark { width: 112px; height: 112px; }
.splash .arc { stroke-dasharray: 60; stroke-dashoffset: 60; animation: draw .7s .15s cubic-bezier(.6,0,.2,1) forwards; }
.splash .coin { transform-origin: 17.4px 16px; transform: scale(0); animation: pop .45s .75s cubic-bezier(.3,1.6,.5,1) forwards; }
.splash .word { font-size: 44px; font-weight: 800; letter-spacing: -2px; line-height: 1; opacity: 0; transform: translateY(10px); animation: rise .5s 1s ease-out forwards; }
.splash .word b { color: var(--color-lime-wash); }
.splash .tag { font-family: var(--font-figmamono); font-size: var(--text-caption); letter-spacing: 1.2px; text-transform: uppercase; opacity: 0; animation: rise .5s 1.25s ease-out forwards; }
.splash .tag i { font-style: normal; color: var(--color-lime-wash); }
.splash .blob { position: absolute; border-radius: 50%; opacity: .9; }
.splash .b1 { width: 220px; height: 220px; background: var(--color-lilac); top: -80px; right: -90px; animation: drift 6s ease-in-out infinite alternate; }
.splash .b2 { width: 160px; height: 160px; background: var(--color-lime-wash); bottom: -60px; left: -50px; animation: drift 7s ease-in-out infinite alternate-reverse; }
.splash .b3 { width: 44px; height: 44px; background: var(--color-figma-orange); bottom: 22%; right: 16%; animation: drift 5s ease-in-out infinite alternate; }
.splash .load { position: absolute; bottom: calc(48px + env(safe-area-inset-bottom, 0px)); width: 64px; height: 4px; border-radius: 4px; background: rgba(255,255,255,.25); overflow: hidden; }
.splash .load i { display: block; height: 100%; width: 0; background: var(--color-paper-white); animation: fill 2.2s .2s linear forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes pop { to { transform: scale(1); } }
@keyframes rise { to { opacity: 1; transform: none; } }
@keyframes fill { to { width: 100%; } }
@keyframes drift { to { transform: translate(-14px, 12px) scale(1.06); } }
@media (prefers-reduced-motion: reduce) {
  .splash .arc { stroke-dashoffset: 0; } .splash .coin { transform: none; } .splash .word, .splash .tag { opacity: 1; transform: none; }
  .splash .load i { width: 100%; }
}
@media (prefers-reduced-motion: reduce) { *, .sheet { transition: none !important; animation: none !important; } }

/* ---------- Phase 1: accounts, forms ---------- */
.stack { display: flex; flex-direction: column; gap: 10px; }
.lbl { font-size: 13px; font-weight: var(--font-weight-w450); color: var(--muted); margin-top: 4px; }
.input { width: 100%; font: inherit; color: var(--fg); background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-buttons); padding: 12px 16px; min-height: 48px; }
.input:focus-visible, .field:focus-within { outline: 2px solid var(--accent); outline-offset: 1px; }
.field input { outline: none; }
.field input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; }
.err { font-size: 14px; color: var(--warn); background: var(--panel); border-radius: var(--radius-tags); padding: 10px 12px; }
.link { background: none; border: 0; color: var(--accent); font-size: 14px; cursor: pointer; padding: 0 2px; min-height: 44px; text-decoration: none; display: inline-flex; align-items: center; }
.row-between { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.gbtn { display: flex; align-items: center; justify-content: center; gap: 10px; background: var(--card); }
.gicon { width: 20px; height: 20px; display: grid; }
.gicon svg { width: 20px; height: 20px; }
.or { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 13px; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.demo-cta { display: grid; grid-template-columns: 48px minmax(0,1fr) auto; gap: 12px; align-items: center; }
.demo-cta .thumb { width: 48px; height: 48px; }
button.avatar { border: 0; padding: 0; cursor: pointer; background: none; display: block; }
.cats { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 8px; }
.cat { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 8px 4px; border: 1px solid var(--line); border-radius: var(--radius-tags); background: var(--card); font-size: 12px; cursor: pointer; min-height: 44px; }
.cat .thumb { width: 40px; height: 40px; border-radius: 8px; }
.cat[aria-pressed="true"] { border-color: var(--fg); box-shadow: inset 0 0 0 1px var(--fg); font-weight: var(--font-weight-w520); }
.chips button { color: var(--fg); }
.banner .art { max-height: 190px; }
