/* Hero Charge — parent app styles. Mobile first (390px), comfortable up to 768px. */
:root {
  --bg: #F4F5F8;
  --ink: #141A22;
  --muted: #5F6B7A;
  --accent: #FF6A2B;
  --accent-soft: #FFE9DF;
  --volt: #5CFFA8;
  --starlight: #FF5FD2;
  --card: #FFFFFF;
  --line: #E4E7EC;
  --ok: #1FA86B;
  --bad: #E0343A;
  --radius: 18px;
  --tap: 44px;
  --font: 'Nunito Sans', system-ui, -apple-system, Segoe UI, sans-serif;
  --caps: 'Chakra Petch', 'Nunito Sans', sans-serif;
}
* { box-sizing: border-box; }
html { height: 100%; } body { margin: 0; min-height: 100%; }
body {
  background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 16px; line-height: 1.4;
  -webkit-font-smoothing: antialiased; padding-bottom: calc(72px + env(safe-area-inset-bottom));
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3 { margin: 0; line-height: 1.15; }
h1 { font-size: 26px; font-weight: 800; }
h2 { font-size: 18px; font-weight: 800; }
h3 { font-size: 15px; font-weight: 800; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.skip { position: absolute; left: -999px; top: 0; background: var(--ink); color: #fff; padding: 8px 12px; }
.skip:focus { left: 8px; z-index: 50; }
.caps { font-family: var(--caps); font-weight: 700; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.ico { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.ico.sm { width: 18px; height: 18px; }

/* Layout */
.topbar { position: sticky; top: 0; z-index: 10; background: rgba(244,245,248,.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.topbar-inner, .view { max-width: 560px; margin: 0 auto; padding: 0 16px; }
.topbar-inner { height: 52px; display: flex; align-items: center; justify-content: space-between; }
.brand { display: inline-flex; align-items: center; gap: 6px; font-weight: 800; font-size: 15px; }
.brand .ico { color: var(--accent); width: 18px; height: 18px; }
.live { font-family: var(--caps); font-size: 11px; letter-spacing: .1em; text-transform: uppercase; padding: 4px 10px; border-radius: 999px; background: #E9EBF0; color: var(--muted); }
.live[data-state="on"] { background: #DDF8EA; color: #157A4D; }
.view { padding-top: 16px; padding-bottom: 24px; outline: none; }
.stack { display: grid; gap: 12px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.screen-title { margin: 6px 0 14px; }

/* Cards */
.card { background: var(--card); border-radius: var(--radius); padding: 16px; box-shadow: 0 1px 2px rgba(20,26,34,.04), 0 6px 18px rgba(20,26,34,.04); }
.card + .card { margin-top: 12px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.card-head h2 { font-size: 16px; }

/* Buttons */
.btn { min-height: var(--tap); padding: 10px 16px; border-radius: 14px; border: 1px solid var(--line); background: #fff; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; gap: 8px; transition: transform .08s ease, background .15s ease; }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.dark { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--accent); }
.btn.danger { color: var(--bad); border-color: #F6C9CB; background: #FFF4F4; }
.btn.block { width: 100%; }
.btn.sm { min-height: 44px; padding: 6px 12px; font-size: 14px; border-radius: 12px; }
.icon-btn { width: var(--tap); height: var(--tap); border-radius: 12px; border: 1px solid var(--line); background: #fff; display: inline-flex; align-items: center; justify-content: center; }
.icon-btn.plain { border-color: transparent; background: transparent; color: var(--muted); }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-row .btn { flex: 1; }

/* Inputs */
.field { display: grid; gap: 6px; }
.field > span, .label { font-weight: 700; font-size: 14px; }
.input, textarea.input, select.input { width: 100%; min-height: var(--tap); padding: 10px 14px; border: 1px solid var(--line); border-radius: 14px; background: #fff; outline: none; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea.input { resize: vertical; min-height: 72px; }
.inline-input { border: 1px solid transparent; border-radius: 10px; padding: 8px 8px; min-height: 44px; width: 100%; background: transparent; font-weight: 700; }
.inline-input:hover { background: var(--bg); }
.inline-input:focus { background: #fff; border-color: var(--accent); outline: none; }
.hint { font-size: 13px; color: var(--muted); }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* Chips & segmented controls */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { min-height: 44px; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line); background: #fff; font-weight: 700; font-size: 14px; }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }
.chip.accent[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.seg button { min-width: 48px; min-height: 44px; padding: 0 10px; background: #fff; border: 0; font-weight: 700; font-size: 14px; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-pressed="true"] { background: var(--ink); color: #fff; }

/* Switch */
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; min-height: var(--tap); background: transparent; border: 0; padding: 6px 0; text-align: left; font-weight: 700; }
.switch .knob { flex: none; width: 50px; height: 30px; border-radius: 999px; background: #D7DBE2; position: relative; transition: background .15s ease; }
.switch .knob::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .15s ease; }
.switch[aria-checked="true"] .knob { background: var(--accent); }
.switch[aria-checked="true"] .knob::after { transform: translateX(20px); }
.switch-list .switch { border-bottom: 1px solid var(--line); }
.switch-list .switch:last-child { border-bottom: 0; }

/* Lists */
.list { display: grid; gap: 8px; }
.item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 14px; background: var(--bg); min-height: 56px; }
.item .ico-box { width: 40px; height: 40px; border-radius: 12px; background: #fff; display: inline-flex; align-items: center; justify-content: center; color: var(--ink); flex: none; }
.item.done .ico-box { background: #DDF8EA; color: var(--ok); }
.item.flagged .ico-box { background: #FDE3E4; color: var(--bad); }
.item .title { font-weight: 800; }
.item .sub { font-size: 13px; color: var(--muted); }
.state { font-family: var(--caps); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; padding: 4px 8px; border-radius: 8px; background: #fff; color: var(--muted); display: inline-flex; align-items: center; gap: 4px; }
.state.done { background: #DDF8EA; color: #157A4D; }
.state.flagged { background: #FDE3E4; color: var(--bad); }
.state.care { background: var(--accent-soft); color: #B23E0E; }
.tag { font-family: var(--caps); font-size: 10px; letter-spacing: .1em; text-transform: uppercase; padding: 3px 8px; border-radius: 6px; background: var(--accent-soft); color: #B23E0E; }
.tag.off { background: #E9EBF0; color: var(--muted); }

/* Hero header */
.hero-head { display: flex; align-items: center; gap: 14px; }
.sigil { width: 64px; height: 64px; flex: none; position: relative; display: grid; place-items: center; }
.sigil svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.sigil span { position: relative; font-family: var(--caps); font-size: 26px; font-weight: 700; color: var(--ink); }
.sigil.lg { width: 96px; height: 96px; }
.sigil.lg span { font-size: 40px; }
.meter { height: 12px; border-radius: 999px; background: #E9EBF0; overflow: hidden; }
.meter > i { display: block; height: 100%; border-radius: 999px; background: var(--accent); transition: width .3s ease; }
.meter.volt > i { background: #1FD37A; }
.meter.starlight > i { background: var(--starlight); }
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { background: var(--bg); border-radius: 14px; padding: 10px 12px; }
.stat b { display: block; font-size: 18px; font-weight: 800; }
.banner { border-radius: 14px; padding: 12px 14px; background: var(--accent-soft); color: #7A2E0C; font-weight: 700; display: flex; gap: 10px; align-items: center; }

/* Wishes / battery */
.wish { display: block; width: 100%; text-align: left; border: 2px solid transparent; border-radius: 16px; background: var(--bg); padding: 12px; }
.wish[aria-pressed="true"] { border-color: var(--accent); background: #FFF7F3; }
.wish.legend { background: linear-gradient(135deg, #FFF2E8, #FFE2CF); }
.battery { display: flex; align-items: center; gap: 6px; margin-top: 8px; }
.battery .cell { flex: 1; height: 18px; border: 2px solid var(--ink); border-radius: 6px; padding: 2px; position: relative; }
.battery .cell > i { display: block; height: 100%; border-radius: 3px; background: var(--ok); width: 0; transition: width .3s ease; }
.battery .cell.low > i { background: var(--accent); }
.battery .cell.full > i { background: #1FD37A; }
.battery .cap { width: 4px; height: 10px; background: var(--ink); border-radius: 0 2px 2px 0; }
.battery .pct { font-weight: 800; min-width: 44px; text-align: right; }
.wish-row { display: flex; align-items: center; gap: 8px; }
.wish-row .radio { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--muted); flex: none; display: grid; place-items: center; }
.wish[aria-pressed="true"] .radio { border-color: var(--accent); }
.wish[aria-pressed="true"] .radio::after { content: ""; width: 12px; height: 12px; border-radius: 50%; background: var(--accent); }
.stones { display: grid; grid-template-columns: repeat(12, 1fr); gap: 4px; margin-top: 10px; }
.stone { height: 14px; border-radius: 4px; background: #E4E7EC; }
.stone.done, .stone.rescued { background: #1FD37A; }
.stone.gift { background: var(--accent); }
.stone.current { background: var(--ink); }
.stone.missed { background: #F0A3A6; }

/* Theme cards (onboarding & settings) */
.theme-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.theme-card { border: 2px solid var(--line); border-radius: 18px; background: #fff; padding: 14px 10px; display: grid; justify-items: center; gap: 8px; min-height: 150px; }
.theme-card[aria-pressed="true"] { border-color: var(--ink); background: #FBFBFD; }
.theme-card .name { font-weight: 800; }
.theme-card .sub { font-size: 12px; color: var(--muted); }

/* Call log */
.call { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 14px; background: var(--bg); }
.call .ico-box { width: 36px; height: 36px; border-radius: 10px; background: #fff; display: grid; place-items: center; color: var(--accent); flex: none; }
.call.reply { background: #E8FBF1; }
.call.reply .ico-box { color: var(--ok); }
.call .meta { font-size: 12px; color: var(--muted); }
.sticker-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.sticker { aspect-ratio: 1; min-height: 44px; border-radius: 12px; border: 2px solid var(--line); background: #fff; display: grid; place-items: center; color: var(--ink); }
.sticker[aria-pressed="true"] { border-color: var(--accent); background: #FFF7F3; color: var(--accent); }
.sticker .ico { width: 24px; height: 24px; }

/* Icon picker */
.icon-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.icon-grid .sticker { min-height: 44px; }

/* Onboarding */
.onb { max-width: 420px; margin: 0 auto; padding-top: 24px; }
.onb .logo { display: inline-flex; align-items: center; justify-content: center; width: 56px; height: 56px; border-radius: 18px; background: var(--ink); color: var(--volt); margin-bottom: 14px; }
.steps { display: flex; gap: 6px; margin: 0 0 16px; }
.steps i { flex: 1; height: 4px; border-radius: 2px; background: #E4E7EC; }
.steps i.on { background: var(--accent); }
.code-box { font-family: var(--caps); font-size: 30px; letter-spacing: .14em; background: var(--bg); border-radius: 14px; padding: 14px; text-align: center; }
.code-input { font-family: var(--caps); font-size: 24px; letter-spacing: .3em; text-align: center; }

/* Tab bar */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; background: #fff; border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); display: flex; justify-content: center; }
.tabbar .tab { flex: 1; max-width: 140px; min-height: 60px; border: 0; background: transparent; color: var(--muted); display: grid; justify-items: center; gap: 2px; padding: 8px 0 6px; font-size: 11px; font-weight: 800; font-family: var(--caps); letter-spacing: .06em; text-transform: uppercase; }
.tabbar .tab[aria-current="page"] { color: var(--accent); }

/* Sheet */
.sheet-backdrop { position: fixed; inset: 0; z-index: 30; background: rgba(20,26,34,.45); display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: 100%; max-width: 560px; max-height: 92vh; background: var(--bg); border-radius: 22px 22px 0 0; display: flex; flex-direction: column; animation: up .2s ease; }
@keyframes up { from { transform: translateY(30px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 8px; }
.sheet-body { overflow: auto; padding: 4px 16px calc(20px + env(safe-area-inset-bottom)); }
.sheet-foot { position: sticky; bottom: 0; background: var(--bg); padding: 12px 0 0; }
.mission-edit { background: #fff; border-radius: 16px; padding: 12px; display: grid; gap: 10px; }
.mission-edit .top { display: flex; gap: 8px; align-items: center; }

/* Toasts */
.toasts { position: fixed; left: 16px; right: 16px; bottom: calc(84px + env(safe-area-inset-bottom)); z-index: 40; display: grid; gap: 8px; pointer-events: none; }
.toast { margin: 0 auto; max-width: 420px; background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 14px; font-weight: 700; box-shadow: 0 8px 24px rgba(0,0,0,.2); animation: up .2s ease; }
.toast.bad { background: var(--bad); }
.toast.ok { background: var(--ok); }

.divider { height: 1px; background: var(--line); margin: 14px 0; }
.empty { text-align: center; color: var(--muted); padding: 18px 8px; }
[hidden] { display: none !important; }
@media (min-width: 640px) { .theme-card { min-height: 170px; } .stat b { font-size: 20px; } }
