:root {
  --bg: #16140f;
  --panel: #211d16;
  --panel-2: #1a1711;
  --panel-grad-a: #2a2218;
  --panel-grad-b: #1c180f;
  --ember: #f08a4b;
  --ember-dim: #b85c2c;
  --teal: #4fb6c9;
  --green: #6fc28a;
  --text: #f3f0ea;
  --muted: #9a9384;
  --dim: #6f685c;
  --line: rgba(244, 240, 234, 0.08);
  --line-2: rgba(244, 240, 234, 0.12);
  --ember-line: rgba(240, 138, 75, 0.25);
  --display: 'Space Grotesk', sans-serif;
  --body: 'IBM Plex Sans', sans-serif;
  --mono: 'IBM Plex Mono', monospace;
  --maxw: 480px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: #0c0b08;
  color: var(--text);
  font-family: var(--body);
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}
.boot { display: flex; height: 100vh; align-items: center; justify-content: center; color: var(--muted); font-family: var(--mono); font-size: 13px; letter-spacing: .1em; }

#app { min-height: 100%; }

/* App frame — centered phone-width column, full-bleed on phones */
.frame {
  max-width: var(--maxw);
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  position: relative;
}
@media (min-width: 520px) {
  body { padding: 0; }
  .frame { min-height: 100vh; box-shadow: 0 0 0 1px rgba(255,255,255,.04); }
}

.scroll { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding-bottom: 20px; }
.pad { padding: 14px 20px 0; }
.pad-x { padding-left: 20px; padding-right: 20px; }

/* Status / safe areas */
.safe-top { height: env(safe-area-inset-top, 0px); }

/* Typography */
.eyebrow { font: 500 11px var(--mono); letter-spacing: .18em; color: var(--ember); text-transform: uppercase; }
.eyebrow.teal { color: var(--teal); }
.eyebrow.green { color: var(--green); }
.eyebrow.muted { color: var(--muted); }
.h1 { font: 700 24px var(--display); letter-spacing: -.02em; margin: 5px 0 0; }
.h2 { font: 700 22px var(--display); letter-spacing: -.01em; line-height: 1.15; margin: 0; }
.mono-label { font: 600 12px var(--mono); letter-spacing: .06em; color: var(--muted); text-transform: uppercase; }
.muted { color: var(--muted); }
.dim { color: var(--dim); }
.body-text { font: 400 15px/1.55 var(--body); color: #cfc9bd; }
.center { text-align: center; }

/* Buttons */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 9px;
  min-height: 52px; border-radius: 13px; border: none; cursor: pointer;
  font: 600 16px var(--body); width: 100%; padding: 14px 16px;
}
.btn-primary { background: var(--ember); color: var(--bg); }
.btn-primary:active { background: #e07b3c; }
.btn-ghost { background: transparent; border: 1px solid var(--line-2); color: #cfc9bd; }
.btn-panel { background: var(--panel); border: 1px solid var(--line); color: var(--text); }
.btn:disabled { opacity: .5; }
.btn-sm { min-height: 40px; font-size: 14px; padding: 8px 14px; width: auto; border-radius: 10px; }

/* Cards */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 15px; padding: 14px; }
.card.ember { border-color: var(--ember-line); }
.card.green { border-color: rgba(111,194,138,.25); }
.card.grad { background: linear-gradient(135deg, var(--panel-grad-a), var(--panel-grad-b)); border-color: var(--ember-line); }
.card.tap { cursor: pointer; transition: transform .08s; }
.card.tap:active { transform: scale(.985); }

.row { display: flex; align-items: center; gap: 13px; }
.row.between { justify-content: space-between; }
.col { display: flex; flex-direction: column; }
.grow { flex: 1; min-width: 0; }
.gap8 { gap: 8px; } .gap10 { gap: 10px; } .gap12 { gap: 12px; }
.mt6{margin-top:6px}.mt8{margin-top:8px}.mt10{margin-top:10px}.mt12{margin-top:12px}.mt14{margin-top:14px}.mt16{margin-top:16px}.mt18{margin-top:18px}.mt22{margin-top:22px}
.wrap { display: flex; flex-wrap: wrap; gap: 8px; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Stat chips */
.stats { display: flex; gap: 9px; }
.stat { flex: 1; background: var(--panel); border: 1px solid var(--line); border-radius: 13px; padding: 12px; }
.stat .n { font: 700 20px var(--display); }
.stat .l { font: 400 11px var(--body); color: var(--muted); margin-top: 1px; }
.stat .n.ember { color: var(--ember); } .stat .n.teal { color: var(--teal); } .stat .n.green { color: var(--green); }

/* Search input */
.searchbar {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 13px 14px; display: flex; align-items: center; gap: 10px;
}
.searchbar.active { border-color: rgba(240,138,75,.45); }
.searchbar input {
  flex: 1; background: transparent; border: none; outline: none;
  color: var(--text); font: 500 15px var(--body); min-width: 0;
}
.searchbar input::placeholder { color: var(--dim); }

/* Chips */
.chips { display: flex; gap: 7px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  font: 500 13px var(--body); background: var(--panel); color: #cfc9bd;
  border: 1px solid var(--line); border-radius: 20px; padding: 8px 14px;
  white-space: nowrap; cursor: pointer; min-height: 36px; display: flex; align-items: center;
}
.chip.active { background: var(--ember); color: var(--bg); border-color: transparent; }

/* Tag pills */
.tag { font: 500 11px var(--mono); color: var(--muted); background: var(--panel); border-radius: 7px; padding: 4px 9px; letter-spacing: .04em; }
.tag.teal { color: var(--teal); background: rgba(79,182,201,.12); }
.tag.ember { color: var(--ember); background: rgba(240,138,75,.12); }
.tag.green { color: var(--green); background: rgba(111,194,138,.14); }
.tag.draft { color: #d8b27a; background: rgba(216,178,122,.12); }

/* Progress bars */
.bar { height: 6px; background: var(--bg); border-radius: 3px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--ember); border-radius: 3px; transition: width .3s; }
.bar > span.green { background: var(--green); }
.bar > span.teal { background: var(--teal); }

/* Result / list rows */
.lrow { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 14px; display: flex; gap: 13px; align-items: center; cursor: pointer; }
.lrow:active { background: #262019; }
.icon-badge { width: 40px; height: 40px; border-radius: 11px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.icon-badge.ember { background: rgba(240,138,75,.13); }
.icon-badge.teal { background: rgba(79,182,201,.13); }
.icon-badge.green { background: rgba(111,194,138,.13); }
.thumb { width: 54px; height: 54px; border-radius: 12px; overflow: hidden; flex-shrink: 0; background: var(--bg); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* Callouts */
.callout { border-radius: 13px; padding: 12px 13px; display: flex; gap: 10px; font: 400 13.5px/1.45 var(--body); }
.callout svg { flex-shrink: 0; margin-top: 1px; }
.callout strong { color: var(--text); }
.callout.note { background: rgba(79,182,201,.08); border: 1px solid rgba(79,182,201,.25); color: #c8dde2; }
.callout.caution { background: rgba(240,138,75,.09); border: 1px solid rgba(240,138,75,.3); color: #e9d8c8; }
.callout.safety { background: rgba(229,84,84,.1); border: 1px solid rgba(229,84,84,.35); color: #f0cfc6; }

/* Formula block */
.formula { background: linear-gradient(135deg, var(--panel-grad-a), var(--panel-grad-b)); border: 1px solid var(--ember-line); border-radius: 14px; padding: 14px; }
.formula .lbl { font: 500 10px var(--mono); letter-spacing: .1em; color: var(--ember); }
.formula .eq { font: 600 17px var(--mono); color: var(--text); margin-top: 8px; line-height: 1.4; }

/* Hero image */
.hero { border-radius: 14px; overflow: hidden; border: 1px solid var(--line); background: var(--panel-2); position: relative; }
.hero img { width: 100%; height: 170px; object-fit: cover; display: block; }
.hero .cap { position: absolute; bottom: 8px; left: 10px; font: 500 10px var(--mono); color: #cfc9bd; background: rgba(22,20,15,.72); border-radius: 5px; padding: 3px 7px; }

/* Numbered steps */
.step { display: flex; gap: 12px; }
.step .num { width: 26px; height: 26px; border-radius: 50%; background: var(--ember); color: var(--bg); font: 600 13px var(--display); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.step .txt { font: 400 14.5px/1.45 var(--body); color: #cfc9bd; padding-top: 2px; }

/* Bottom nav */
.nav {
  display: flex; justify-content: space-around; align-items: center;
  padding: 10px 8px calc(16px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--line); background: var(--panel-2);
}
.nav a { display: flex; flex-direction: column; align-items: center; gap: 3px; color: var(--dim); text-decoration: none; padding: 4px 10px; min-width: 56px; }
.nav a.active { color: var(--ember); }
.nav a span { font: 500 10px var(--body); }

/* Sticky header inside scroll */
.topbar { display: flex; align-items: center; gap: 12px; padding: 14px 20px 6px; }
.back { background: none; border: none; padding: 4px; cursor: pointer; display: flex; }

/* Footer action bar */
.footbar { padding: 12px 20px calc(18px + env(safe-area-inset-bottom,0px)); border-top: 1px solid var(--line); background: var(--panel-2); display: flex; align-items: center; gap: 11px; }

/* Avatar */
.avatar { width: 42px; height: 42px; border-radius: 13px; background: linear-gradient(150deg, var(--ember), var(--ember-dim)); display: flex; align-items: center; justify-content: center; font: 600 15px var(--display); color: var(--bg); flex-shrink: 0; }

/* Login */
.login { flex: 1; display: flex; flex-direction: column; justify-content: center; padding: 0 30px; text-align: center; }
.lock { width: 64px; height: 64px; border-radius: 18px; border: 1px solid rgba(240,138,75,.4); margin: 0 auto 20px; display: flex; align-items: center; justify-content: center; background: rgba(240,138,75,.08); }
.field-label { font: 500 11px var(--mono); color: var(--muted); letter-spacing: .08em; margin-bottom: 7px; text-transform: uppercase; }
.input { background: var(--panel); border: 1px solid var(--line-2); border-radius: 13px; padding: 15px 16px; font: 500 16px var(--body); color: var(--text); width: 100%; outline: none; }
.input:focus { border-color: rgba(240,138,75,.45); }
.pin-dots { display: flex; gap: 12px; align-items: center; padding: 16px; }
.pin-dots .d { width: 12px; height: 12px; border-radius: 50%; border: 1.5px solid #4a443a; }
.pin-dots .d.on { background: var(--text); border-color: var(--text); }
.err { color: #e57; font: 500 13px var(--body); }

/* Chat */
.bubble { max-width: 86%; border-radius: 16px; padding: 12px 13px; font: 400 14.5px/1.5 var(--body); }
.bubble.me { align-self: flex-end; background: var(--ember); color: var(--bg); border-bottom-right-radius: 4px; }
.bubble.ai { align-self: flex-start; background: var(--panel); border: 1px solid var(--line); color: #cfc9bd; border-bottom-left-radius: 4px; white-space: pre-wrap; }
.composer { padding: 10px 14px calc(12px + env(safe-area-inset-bottom,0px)); border-top: 1px solid var(--line); background: var(--bg); }
.composer-box { background: var(--panel); border: 1px solid var(--line-2); border-radius: 24px; padding: 7px 7px 7px 16px; display: flex; align-items: center; gap: 10px; }
.composer-box input { flex: 1; background: transparent; border: none; outline: none; color: var(--text); font: 400 15px var(--body); min-width: 0; }
.send { width: 40px; height: 40px; border-radius: 50%; background: var(--ember); border: none; display: flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0; }

/* Did-this-work prompt */
.loop-card { background: linear-gradient(135deg, #1c2620, #16140f); border: 1px solid rgba(111,194,138,.3); border-radius: 14px; padding: 14px; }

/* Spinner */
.spinner { width: 18px; height: 18px; border: 2px solid rgba(255,255,255,.2); border-top-color: var(--ember); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.typing { display: flex; gap: 4px; padding: 4px 0; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite; }
.typing i:nth-child(2){animation-delay:.2s}.typing i:nth-child(3){animation-delay:.4s}
@keyframes blink { 0%,60%,100%{opacity:.3} 30%{opacity:1} }

/* Badge celebration */
.badge-circle { position: relative; width: 150px; height: 150px; margin: 26px auto; }
.badge-core { width: 104px; height: 104px; border-radius: 50%; background: linear-gradient(150deg, #f5a05f, #c5662f); display: flex; align-items: center; justify-content: center; box-shadow: 0 14px 36px -8px rgba(240,138,75,.5); }
.confetti { position: absolute; inset: 0; }

/* Empty state */
.empty { text-align: center; color: var(--muted); padding: 40px 20px; font: 400 14px var(--body); }

/* Toast */
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: 90px; background: #2a2218; color: var(--text); border: 1px solid var(--ember-line); border-radius: 12px; padding: 12px 16px; font: 500 13.5px var(--body); z-index: 50; max-width: 90%; box-shadow: 0 10px 30px -10px rgba(0,0,0,.6); }

/* Decision option buttons */
.opt { background: var(--panel); border: 1px solid var(--line-2); border-radius: 12px; padding: 15px; text-align: center; font: 600 15px var(--body); cursor: pointer; flex: 1; }
.opt.primary { background: var(--ember); color: var(--bg); border-color: transparent; }
.opt:active { transform: scale(.98); }

/* Ranked cause rows */
.cause { display: flex; align-items: center; gap: 11px; background: var(--panel); border-radius: 11px; padding: 11px 13px; }
.cause .rank { font: 600 13px var(--display); width: 14px; }
.cause .lbl { font: 500 13.5px var(--body); flex: 1; }
.cause .pill { font: 500 11px var(--mono); }

a.link { color: var(--teal); text-decoration: none; }
