:root {
  --bg: #0f0d0b;
  --surface: #1a1714;
  --surface-2: #231f1a;
  --line: #342d26;
  --text: #f4ede3;
  --muted: #a69a8a;
  --faint: #6f6457;
  --ember: #ff6b2c;
  --ember-2: #ffb347;
  --moss: #8fd694;
  --danger: #ff6161;
  --radius: 20px;
  --display: "Space Grotesk", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font-family: var(--display);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  background:
    radial-gradient(900px 500px at 85% -10%, rgba(255, 107, 44, .14), transparent 60%),
    radial-gradient(700px 400px at -10% 110%, rgba(255, 179, 71, .07), transparent 60%),
    var(--bg);
  background-attachment: fixed;
}
body::before { /* film grain */
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 0; opacity: .05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--ember-2); }

.app { position: relative; z-index: 1; max-width: 560px; margin: 0 auto; padding: 18px 18px 120px; }

/* ---------- top bar ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: -.02em; text-decoration: none; color: var(--text); }
.mark { width: 34px; height: 34px; border-radius: 10px; background: var(--ember); display: grid; place-items: center; box-shadow: 0 6px 24px rgba(255,107,44,.35); }
.mark svg { width: 22px; height: 22px; }
.who { color: var(--muted); font-size: 14px; display: flex; gap: 8px; align-items: center; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--surface-2); border: 1px solid var(--line); display: grid; place-items: center; font-weight: 700; font-size: 13px; color: var(--ember-2); }

/* ---------- type ---------- */
h1 { font-size: 40px; line-height: 1.02; letter-spacing: -.035em; margin: 0 0 10px; }
h2 { font-size: 22px; letter-spacing: -.02em; margin: 0 0 12px; }
h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); margin: 28px 0 12px; font-weight: 600; }
.lede { color: var(--muted); font-size: 17px; margin: 0 0 24px; }
.em { color: var(--ember); }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* ---------- buttons ---------- */
.btn { appearance: none; border: 0; cursor: pointer; border-radius: 16px; padding: 16px 20px; font-weight: 700; font-size: 17px; letter-spacing: -.01em; transition: transform .08s ease, filter .2s, background .2s; display: inline-flex; align-items: center; justify-content: center; gap: 10px; text-decoration: none; }
.btn:active { transform: scale(.98); }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.btn-primary { background: linear-gradient(135deg, var(--ember), #ff8a3d); color: #1a0e06; box-shadow: 0 10px 30px rgba(255,107,44,.28); }
.btn-primary:hover { filter: brightness(1.06); }
.btn-ghost { background: var(--surface-2); color: var(--text); border: 1px solid var(--line); }
.btn-block { width: 100%; }
.btn-sm { padding: 9px 14px; font-size: 14px; border-radius: 12px; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }

/* ---------- cards ---------- */
.card { background: linear-gradient(180deg, var(--surface), rgba(26,23,20,.85)); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 14px; }
.card.link { display: block; text-decoration: none; color: inherit; transition: border-color .2s, transform .1s; }
.card.link:hover { border-color: #4a3f34; }
.card.link:active { transform: scale(.995); }
.card-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.card-title { font-size: 19px; font-weight: 700; letter-spacing: -.02em; margin: 0 0 4px; }
.meta { color: var(--muted); font-size: 14px; display: flex; flex-wrap: wrap; gap: 6px 12px; }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; padding: 5px 10px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.pill.live { color: var(--moss); border-color: rgba(143,214,148,.3); background: rgba(143,214,148,.08); }
.pill.live::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--moss); box-shadow: 0 0 0 3px rgba(143,214,148,.2); }
.pill.warn { color: var(--ember-2); border-color: rgba(255,179,71,.3); background: rgba(255,179,71,.08); }
.pill.bad { color: var(--danger); border-color: rgba(255,97,97,.3); background: rgba(255,97,97,.08); }
.stake-chip { font-family: var(--mono); font-weight: 700; color: var(--ember-2); }

/* ---------- progress ring ---------- */
.ring { position: relative; width: 64px; height: 64px; flex: none; }
.ring svg { transform: rotate(-90deg); }
.ring .track { stroke: var(--surface-2); }
.ring .bar { stroke: url(#g); transition: stroke-dashoffset .6s cubic-bezier(.2,.8,.2,1); }
.ring .label { position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--mono); font-weight: 700; font-size: 14px; }
.ring.big { width: 150px; height: 150px; }
.ring.big .label { font-size: 30px; line-height: 1; text-align: center; }
.ring.big .label small { display: block; font-size: 12px; color: var(--muted); font-family: var(--display); font-weight: 500; margin-top: 4px; }

/* ---------- Next Digit ---------- */
.digits { font-family: var(--mono); font-size: 15px; letter-spacing: .04em; color: var(--faint); margin-top: 14px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.digits .on { color: var(--ember-2); }
.digits .next { display: inline-block; min-width: .7em; color: var(--ember); animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .25; } }
.digit-hero { text-align: center; padding: 22px 12px 8px; }
.digit-hero .big { font-family: var(--mono); font-weight: 700; font-size: clamp(28px, 9vw, 44px); letter-spacing: .02em; word-break: break-all; line-height: 1.15; }
.digit-hero .big .on { color: var(--ember-2); text-shadow: 0 0 28px rgba(255,179,71,.25); }
.digit-hero .big .next { color: var(--ember); animation: pulse 1.6s ease-in-out infinite; }
.digit-hero .cap { color: var(--muted); font-size: 14px; margin-top: 8px; }

/* ---------- forms ---------- */
label.f { display: block; font-size: 13px; font-weight: 600; color: var(--muted); letter-spacing: .06em; text-transform: uppercase; margin: 22px 0 10px; }
input.in, textarea.in { width: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 15px 16px; font-size: 17px; outline: none; transition: border-color .2s, box-shadow .2s; }
input.in:focus, textarea.in:focus { border-color: var(--ember); box-shadow: 0 0 0 4px rgba(255,107,44,.15); }
textarea.in { resize: vertical; min-height: 84px; }
.code-in { font-family: var(--mono); text-transform: uppercase; letter-spacing: .3em; text-align: center; font-size: 26px !important; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 9px 14px; font-size: 14px; cursor: pointer; transition: all .15s; }
.chip:hover { border-color: #4a3f34; }
.chip.on { background: rgba(255,107,44,.14); border-color: var(--ember); color: var(--ember-2); }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 4px; gap: 4px; }
.seg button { border: 0; background: transparent; padding: 11px 6px; border-radius: 10px; cursor: pointer; font-weight: 600; color: var(--muted); }
.seg button.on { background: var(--surface-2); color: var(--text); box-shadow: 0 1px 0 rgba(255,255,255,.04) inset, 0 4px 12px rgba(0,0,0,.25); }
input[type=range] { width: 100%; accent-color: var(--ember); }
.range-row { display: flex; align-items: center; gap: 14px; }
.range-val { font-family: var(--mono); font-weight: 700; font-size: 22px; min-width: 64px; text-align: right; }

.deal { border: 1px dashed #4a3f34; background: rgba(255,107,44,.04); }
.deal p { margin: 6px 0; }
.deal .k { color: var(--muted); }

/* ---------- check-in composer ---------- */
.composer textarea { margin-bottom: 10px; }
.photo-pick { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.photo-pick img { width: 56px; height: 56px; object-fit: cover; border-radius: 12px; border: 1px solid var(--line); }
.done-banner { text-align: center; padding: 18px; color: var(--moss); font-weight: 700; }

/* ---------- members / feed ---------- */
.member { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.member:last-child { border-bottom: 0; }
.member .grow { flex: 1; min-width: 0; }
.bar-track { height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin-top: 6px; }
.bar-fill { height: 100%; background: linear-gradient(90deg, var(--ember), var(--ember-2)); border-radius: 99px; }
.feed-item { padding: 14px 0; border-bottom: 1px solid var(--line); }
.feed-item:last-child { border-bottom: 0; }
.feed-item.void { opacity: .5; }
.feed-item .top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.feed-item img { width: 100%; max-height: 280px; object-fit: cover; border-radius: 14px; margin-top: 10px; border: 1px solid var(--line); }
.flag-btn { background: none; border: 1px solid var(--line); border-radius: 10px; padding: 5px 10px; font-size: 12px; color: var(--muted); cursor: pointer; }
.flag-btn.on { color: var(--danger); border-color: rgba(255,97,97,.4); }

.invite { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.invite .code { font-family: var(--mono); font-size: 26px; font-weight: 700; letter-spacing: .18em; color: var(--ember-2); }

.empty { text-align: center; padding: 40px 10px 20px; }
.empty .big-digits { font-family: var(--mono); font-size: 52px; font-weight: 700; color: var(--surface-2); letter-spacing: .04em; margin-bottom: 8px; -webkit-text-stroke: 1px var(--line); }

/* ---------- hero (signed out) ---------- */
.hero { min-height: 82vh; display: flex; flex-direction: column; justify-content: center; }
.hero h1 { font-size: clamp(44px, 13vw, 66px); }
.hero .stream { font-family: var(--mono); color: var(--surface-2); font-size: 18px; word-break: break-all; line-height: 1.5; margin-bottom: 26px; max-height: 108px; overflow: hidden; -webkit-mask-image: linear-gradient(180deg, #000 30%, transparent); mask-image: linear-gradient(180deg, #000 30%, transparent); }
.hero .stream .on { color: var(--ember); }
.steps { display: grid; gap: 10px; margin: 6px 0 28px; }
.step { display: flex; gap: 12px; align-items: baseline; color: var(--muted); }
.step b { color: var(--text); font-family: var(--mono); color: var(--ember-2); }

/* ---------- toast / sheet / dev ---------- */
.toast { position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%) translateY(20px); background: #2b251f; border: 1px solid var(--line); color: var(--text); padding: 12px 18px; border-radius: 14px; font-size: 15px; opacity: 0; pointer-events: none; transition: all .25s; z-index: 50; max-width: 90vw; box-shadow: 0 12px 40px rgba(0,0,0,.5); }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.bad { border-color: rgba(255,97,97,.5); }
.sheet-bg { position: fixed; inset: 0; background: rgba(0,0,0,.6); backdrop-filter: blur(4px); z-index: 60; display: flex; align-items: flex-end; justify-content: center; animation: fade .2s; }
.sheet { width: 100%; max-width: 560px; background: var(--surface); border: 1px solid var(--line); border-bottom: 0; border-radius: 26px 26px 0 0; padding: 22px 20px calc(22px + env(safe-area-inset-bottom)); animation: up .25s cubic-bezier(.2,.8,.2,1); }
.sheet .amt { font-family: var(--mono); font-size: 40px; font-weight: 700; text-align: center; margin: 10px 0 4px; }
.sheet .grab { width: 40px; height: 5px; border-radius: 9px; background: var(--line); margin: -6px auto 16px; }
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }

.devbar { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(18px + env(safe-area-inset-bottom)); z-index: 40; display: flex; gap: 6px; align-items: center; background: rgba(26,23,20,.92); backdrop-filter: blur(10px); border: 1px solid var(--line); border-radius: 999px; padding: 6px 6px 6px 14px; font-size: 12px; color: var(--muted); box-shadow: 0 10px 30px rgba(0,0,0,.45); white-space: nowrap; }
.devbar button { border: 1px solid var(--line); background: var(--surface-2); border-radius: 999px; padding: 7px 12px; font-size: 12px; cursor: pointer; font-weight: 600; }

.back { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); text-decoration: none; font-size: 15px; margin-bottom: 14px; }
.center { text-align: center; }
.spacer { height: 12px; }
.spin { width: 22px; height: 22px; border: 3px solid var(--line); border-top-color: var(--ember); border-radius: 50%; animation: rot 0.8s linear infinite; margin: 60px auto; }
@keyframes rot { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---------- step data ---------- */
.steps-link { color: var(--text); text-decoration: none; font-size: 13px; font-weight: 600; border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 6px 10px; }
.steps-num { font-size: 34px; font-weight: 700; margin: 6px 0 8px; letter-spacing: -.01em; }
.steps-hero .steps-num { font-size: 44px; }
.source-head { display: flex; align-items: center; gap: 12px; }
.source-head .grow { flex: 1; min-width: 0; }
.src-icon { width: 40px; height: 40px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); display: grid; place-items: center; font-weight: 700; flex: none; font-size: 18px; }
.source.soon { opacity: .72; }
details { margin-top: 14px; }
summary { cursor: pointer; color: var(--ember-2); font-weight: 600; }
.howto { padding-left: 20px; margin: 12px 0 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; color: var(--muted); }
.howto > li { min-width: 0; }
.howto b { color: var(--text); }
.copy-row { display: flex; gap: 8px; align-items: center; margin-top: 4px; }
.copy-row code { flex: 1; min-width: 0; overflow-x: auto; white-space: nowrap; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 9px 10px; font-family: var(--mono); font-size: 12px; color: var(--ember-2); }
code { font-family: var(--mono); font-size: .92em; }
.linkish { background: none; border: 0; color: var(--ember-2); text-decoration: underline; cursor: pointer; padding: 0; font-size: inherit; }
.pill.verified { text-transform: none; letter-spacing: 0; }
.pill.verified::before { display: none; }
.src-icon.heart { color: #ff5a6e; }

/* ---------- community pot ---------- */
.pot { background: linear-gradient(160deg, rgba(80,160,255,.10), rgba(26,23,20,.9) 55%); border-color: rgba(120,180,255,.22); }
.pot-head { display: flex; align-items: center; gap: 12px; }
.pot-head .grow { flex: 1; min-width: 0; }
.pot-icon { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: rgba(80,160,255,.12); border: 1px solid rgba(120,180,255,.25); font-size: 20px; flex: none; }
.pot-num { font-size: 28px; font-weight: 700; }
.pot-track { height: 10px; margin-top: 12px; }
.pot-track .bar-fill { background: linear-gradient(90deg, #4aa3ff, #8fd3ff); }
.hero #pot-slot .card { margin: 0 0 18px; }

/* =====================================================================
   Themes. Dark is the default above; light follows the phone setting
   (or the toggle). Step challenges swap the ember accent for green.
   ===================================================================== */
:root { --card-top: var(--surface); --card-bot: rgba(26,23,20,.85); --glow: rgba(255,107,44,.14); --glow-2: rgba(255,179,71,.07);
  --btn-ink: #1a0e06; --btn-a: var(--ember); --btn-b: #ff8a3d; --btn-shadow: rgba(255,107,44,.28); --chrome: rgba(26,23,20,.92); --toast: #2b251f; --grain: .05; }
[data-theme="light"] {
  --bg: #f7f3ec; --surface: #ffffff; --surface-2: #f2ece2; --line: #e6ddcf; --text: #1e1a15; --muted: #6d6358; --faint: #b3a797;
  --ember: #e8531a; --ember-2: #b85f00; --moss: #1c9a52; --danger: #d23838;
  --card-top: #ffffff; --card-bot: #fffdf9; --glow: rgba(255,120,60,.16); --glow-2: rgba(255,190,90,.14);
  --btn-ink: #ffffff; --btn-a: #ef5a1c; --btn-b: #ff8a3d; --btn-shadow: rgba(239,90,28,.25); --chrome: rgba(255,255,255,.94); --toast: #1e1a15; --grain: .025;
}
.steps-accent { --ember: #13b673; --ember-2: #4fd99a; --btn-a: #13b673; --btn-b: #34d18c; --btn-shadow: rgba(19,182,115,.28); --btn-ink: #04170e; }
[data-theme="light"] .steps-accent { --ember: #0e9a5f; --ember-2: #0b7f4e; --btn-a: #10a466; --btn-b: #22c07d; --btn-shadow: rgba(16,164,102,.25); --btn-ink: #ffffff; }

body { background:
    radial-gradient(900px 500px at 85% -10%, var(--glow), transparent 60%),
    radial-gradient(700px 400px at -10% 110%, var(--glow-2), transparent 60%), var(--bg); }
body::before { opacity: var(--grain); }
.card { background: linear-gradient(180deg, var(--card-top), var(--card-bot)); }
[data-theme="light"] .card { box-shadow: 0 1px 2px rgba(60,40,20,.05), 0 8px 24px rgba(60,40,20,.06); }
.btn-primary { background: linear-gradient(135deg, var(--btn-a), var(--btn-b)); color: var(--btn-ink); box-shadow: 0 10px 30px var(--btn-shadow); }
.devbar { background: var(--chrome); }
.toast { background: var(--toast); color: #f4ede3; }
[data-theme="light"] .sheet-bg { background: rgba(30,20,10,.35); }
[data-theme="light"] .mark svg path { stroke: #fff; }
[data-theme="light"] .hero .stream { color: #e9e1d4; }
[data-theme="light"] .empty .big-digits { color: #ece5da; -webkit-text-stroke: 1px #ddd2c2; }
[data-theme="light"] .pill.live { background: rgba(28,154,82,.08); }
[data-theme="light"] .pot { background: linear-gradient(160deg, rgba(60,150,255,.10), #ffffff 60%); }
[data-theme="light"] .digit-hero .big .on { text-shadow: none; }
.ring .bar { stroke: url(#g); }
.steps-accent .ring .bar { stroke: url(#gs); }
.steps-accent .bar-fill { background: linear-gradient(90deg, var(--ember), var(--ember-2)); }
.theme-btn { background: var(--surface); border: 1px solid var(--line); border-radius: 999px; width: 32px; height: 32px; cursor: pointer; display: grid; place-items: center; font-size: 15px; padding: 0; }
/* compact top bar on phones */
.brand, .steps-link { white-space: nowrap; }
.who { gap: 6px; }
@media (max-width: 440px) { .who > span:not(.avatar) { display: none; } }

.avatar-btn { cursor: pointer; padding: 0; font: inherit; font-weight: 700; font-size: 13px; color: var(--ember-2); }

/* next digit: shown faintly, not hidden */
.digits .next, .digit-hero .big .next { opacity: .35; animation: none; }

/* the deal */
.deal-list { margin: 0; padding-left: 18px; display: grid; gap: 9px; }
.deal-list li { line-height: 1.45; }
.deal-list b { color: var(--text); }
.consent { display: flex; gap: 10px; align-items: flex-start; margin: 4px 2px 14px; font-size: 14px; color: var(--muted); cursor: pointer; }
.consent input { width: 20px; height: 20px; margin-top: 1px; accent-color: var(--ember); flex: none; }
