/* EarnIt. One stylesheet, no external fonts or assets. Light and dark, mobile first. */

/* ------------------------------------------------------------------ tokens */

:root {
  color-scheme: light;
  --bg: #F7F7F4;
  --surface: #FFFFFF;
  --fill: #F1F1EC;
  --fill-2: #E7E7E1;
  --line: #E4E3DC;
  --line-2: #D2D1C9;
  --ink: #161618;
  --ink-2: #55555C;
  --ink-3: #6B6B73;
  --field-line: #8E8D85;
  --switch-off: #8E8D85;
  --on-ink: #FFFFFF;
  --accent: #E8590C;
  --accent-ink: #B0440A;
  --accent-soft: #FDF0E6;
  --good: #1A7340;
  --good-bar: #2E9E5B;
  --good-soft: #E6F3EB;
  --bad: #B9322B;
  --bad-fill: #B9322B;
  --bad-soft: #FBEBE9;
  --pop: 0 20px 50px -12px rgba(22, 22, 24, .28), 0 2px 8px rgba(22, 22, 24, .06);
  --lift: 0 1px 2px rgba(22, 22, 24, .08);
  /* Charts: validated categorical slots 1-2 and a one-hue sequential ramp. */
  --viz-1: #2a78d6;
  --viz-2: #eb6834;
  --grid: #E9E8E2;
  --axis: #C9C8BF;
  --hm-0: #ECEBE5;
  --hm-1: #8DB8EE;
  --hm-2: #6da7ec;
  --hm-3: #2a78d6;
  --hm-4: #184f95;
  --r: 14px;
  --r-sm: 10px;
  --tabbar-h: 60px;
  --top-offset: 0px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111113;
  --surface: #1A1A1D;
  --fill: #232327;
  --fill-2: #2D2D32;
  --line: #2A2A2F;
  --line-2: #3A3A41;
  --ink: #F2F2F3;
  --ink-2: #B4B4BB;
  --ink-3: #9A9AA3;
  --field-line: #66666E;
  --switch-off: #707078;
  --on-ink: #111113;
  --accent: #F2762E;
  --accent-ink: #F6A06E;
  --accent-soft: #2E1E13;
  --good: #52C584;
  --good-bar: #3AAE6B;
  --good-soft: #14281C;
  --bad: #EF6B62;
  --bad-fill: #B93A31;
  --bad-soft: #331816;
  --pop: 0 24px 60px -12px rgba(0, 0, 0, .7);
  --lift: 0 1px 2px rgba(0, 0, 0, .5);
  --viz-1: #3987e5;
  --viz-2: #d95926;
  --grid: #26262B;
  --axis: #3A3A41;
  --hm-0: #232327;
  --hm-1: #1A55A3;
  --hm-2: #1c5cab;
  --hm-3: #3987e5;
  --hm-4: #86b6ef;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #111113;
    --surface: #1A1A1D;
    --fill: #232327;
    --fill-2: #2D2D32;
    --line: #2A2A2F;
    --line-2: #3A3A41;
    --ink: #F2F2F3;
    --ink-2: #B4B4BB;
    --ink-3: #9A9AA3;
    --field-line: #66666E;
    --switch-off: #707078;
    --on-ink: #111113;
    --accent: #F2762E;
    --accent-ink: #F6A06E;
    --accent-soft: #2E1E13;
    --good: #52C584;
    --good-bar: #3AAE6B;
    --good-soft: #14281C;
    --bad: #EF6B62;
    --bad-fill: #B93A31;
    --bad-soft: #331816;
    --pop: 0 24px 60px -12px rgba(0, 0, 0, .7);
    --lift: 0 1px 2px rgba(0, 0, 0, .5);
    --viz-1: #3987e5;
    --viz-2: #d95926;
    --grid: #26262B;
    --axis: #3A3A41;
    --hm-0: #232327;
    --hm-1: #1A55A3;
    --hm-2: #1c5cab;
    --hm-3: #3987e5;
    --hm-4: #86b6ef;
  }
}

/* -------------------------------------------------------------------- base */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
body {
  margin: 0;
  min-height: 100dvh;
  font: 16px/1.45 var(--font);
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}
body:has(dialog[open]) { overflow: hidden; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; }
a { color: inherit; }
h1, h2, h3 { text-wrap: balance; }
p { text-wrap: pretty; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

#main {
  max-width: 720px;
  margin: 0 auto;
  padding: 20px 16px calc(var(--tabbar-h) + 36px + env(safe-area-inset-bottom));
  outline: none;
}
body[data-route="welcome"] #main { max-width: 620px; padding-bottom: 56px; }
#main.enter > * { animation: page-in .25s ease-out; }

.ico { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ico .fill { fill: currentColor; stroke: none; }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: -999px; top: 8px; }
.skip-link:focus { left: 12px; z-index: 100; background: var(--surface); padding: 8px 12px; border-radius: 8px; }
.muted { color: var(--ink-3); }
.owe { color: var(--bad); font-weight: 600; }
.warn { color: var(--accent-ink); }
.noscript { padding: 24px; text-align: center; }
code, kbd { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .86em; background: var(--fill); padding: 1px 5px; border-radius: 5px; }
kbd { border: 1px solid var(--line-2); border-bottom-width: 2px; }

/* ----------------------------------------------------------------- buttons */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 0 16px;
  border: 1px solid transparent; border-radius: var(--r-sm);
  font-size: 15px; font-weight: 600; line-height: 1.1;
  text-decoration: none; white-space: nowrap; cursor: pointer;
  transition: background-color .15s, border-color .15s, transform .1s;
}
.btn:active { transform: scale(.98); }
.btn .ico { width: 16px; height: 16px; stroke-width: 2.4; }
.btn-primary { background: var(--ink); color: var(--on-ink); }
.btn-primary:hover { background: color-mix(in srgb, var(--ink) 86%, var(--bg)); }
.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--line-2); }
.btn-secondary:hover { background: var(--fill); }
.btn-quiet { background: transparent; color: var(--ink-2); }
.btn-quiet:hover { background: var(--fill); color: var(--ink); }
.btn-danger { background: var(--bad-fill); color: #fff; }
.btn-danger-text { color: var(--bad); }
.btn-inverse { background: var(--on-ink); color: var(--ink); }
.btn-sm { min-height: 34px; padding: 0 12px; font-size: 14px; }
.btn-lg { min-height: 50px; padding: 0 22px; font-size: 16px; }
.btn-block { width: 100%; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }
.link { padding: 0; border: 0; background: none; color: var(--ink); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--line-2); cursor: pointer; }
.link:hover { text-decoration-color: currentColor; }

.icon-btn {
  display: inline-grid; place-items: center; flex: none; width: 40px; height: 40px;
  border: 0; border-radius: var(--r-sm); background: transparent; color: var(--ink-2); cursor: pointer;
}
.icon-btn:hover { background: var(--fill); color: var(--ink); }
.icon-btn:disabled { opacity: .3; cursor: default; background: transparent; }
.icon-btn-sm { width: 40px; height: 40px; }
.icon-btn-sm .ico { width: 16px; height: 16px; }
.icon-btn svg:not(.ico) { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }

/* ------------------------------------------------------------------ tabbar */

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  background: var(--surface); /* browsers without color-mix */
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.brand { display: none; }
.tabs { display: grid; grid-template-columns: repeat(4, 1fr); max-width: 520px; height: var(--tabbar-h); margin: 0 auto; }
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--ink-3); font-size: 11px; font-weight: 600; text-decoration: none;
}
.tab .ico { width: 22px; height: 22px; stroke-width: 1.8; }
.tab[aria-current="page"] { color: var(--ink); }
.tab[aria-current="page"] .ico { stroke-width: 2.2; }

@media (min-width: 820px) {
  :root { --top-offset: 56px; }
  .tabbar {
    position: sticky; top: 0; bottom: auto;
    display: flex; align-items: center; justify-content: space-between; height: 56px;
    padding: 0 max(16px, calc((100% - 720px) / 2));
    border-top: 0; border-bottom: 1px solid var(--line);
  }
  .brand { display: flex; align-items: center; gap: 8px; color: var(--ink); text-decoration: none; font-weight: 700; font-size: 16px; }
  .brand-mark { width: 26px; height: 26px; border-radius: 7px; }
  .tabs { display: flex; gap: 2px; height: auto; margin: 0; max-width: none; }
  .tab { flex-direction: row; gap: 7px; height: 36px; padding: 0 12px; border-radius: var(--r-sm); font-size: 14px; color: var(--ink-2); }
  .tab .ico { width: 17px; height: 17px; }
  .tab:hover { background: var(--fill); color: var(--ink); }
  .tab[aria-current="page"] { background: var(--fill); color: var(--ink); }
  #main { padding-top: 28px; padding-bottom: 56px; }
}

/* ------------------------------------------------------------ page chrome */

.page-head { margin: 0 0 8px; }
.page-title { margin: 0; font-size: 28px; line-height: 1.15; letter-spacing: -.02em; font-weight: 700; }
.page-sub { margin: 6px 0 0; color: var(--ink-2); font-size: 15px; }

.section { margin-top: 28px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 34px; margin: 0 2px 8px; }
.section-head h2, .group-title {
  margin: 0; font-size: 13px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-3);
}
.section-meta { font-size: 13px; color: var(--ink-3); text-align: right; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); }
.pad { padding: 16px; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.card-head h2, .card-head h3 { margin: 0; font-size: 16px; font-weight: 650; }
.card-meta { font-size: 14px; font-weight: 600; color: var(--ink-2); white-space: nowrap; }
.card-meta-sub { font-size: 13px; color: var(--ink-3); }
.card-title { margin: 0; font-size: 16px; font-weight: 650; }
.hint { margin: 0; font-size: 14px; line-height: 1.5; color: var(--ink-2); }
.hint b { color: var(--ink); font-weight: 600; }

.rows > * + * { border-top: 1px solid var(--line); }

.banner {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  margin: 16px 0 0; padding: 10px 10px 10px 14px; border-radius: var(--r-sm);
  background: var(--accent-soft); color: var(--accent-ink); font-size: 14px;
}
.banner > span:first-child { flex: 1 1 240px; line-height: 1.45; }
.banner-note { background: var(--fill); color: var(--ink-2); }
.banner-note b { color: var(--ink); }
.banner-actions { display: flex; gap: 6px; margin-left: auto; }

.empty-state { padding: 20px; margin-top: 20px; }
.empty-state h2 { margin: 0 0 6px; font-size: 18px; font-weight: 650; }
.empty-state p { margin: 0 0 14px; color: var(--ink-2); font-size: 15px; }
.section .empty-state { margin-top: 0; padding: 16px; }
.section .empty-state p { font-size: 14px; }
.section .empty-state p:last-child { margin: 0; }

.local-note { display: flex; align-items: flex-start; justify-content: center; gap: 6px; margin: 36px auto 0; max-width: 420px; font-size: 13px; line-height: 1.5; color: var(--ink-3); text-align: center; }
.local-note .ico { width: 14px; height: 14px; margin-top: 2px; }
.local-note a { color: var(--ink-2); text-underline-offset: 3px; }

/* -------------------------------------------------------------------- today */

.today-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.date { margin: 0 0 2px; font-size: 14px; color: var(--ink-3); font-weight: 500; }
.streak {
  display: inline-flex; align-items: center; gap: 5px; flex: none; margin-top: 4px;
  padding: 6px 10px; border-radius: var(--r-sm); background: var(--accent-soft); color: var(--accent-ink);
  font-size: 13px; white-space: nowrap;
}
.streak .ico { width: 15px; height: 15px; color: var(--accent); }
.streak b { font-size: 15px; font-variant-numeric: tabular-nums; }

.daynav { display: inline-flex; align-items: center; gap: 2px; margin: 12px 0 0 -6px; }
.daynav-label { height: 32px; padding: 0 8px; border: 0; border-radius: 8px; background: transparent; font-size: 14px; font-weight: 600; color: var(--ink-2); cursor: pointer; }
.daynav-label:hover { background: var(--fill); color: var(--ink); }

/* balance rows */
.bal { display: flex; align-items: center; gap: 12px; padding: 12px 12px 12px 14px; }
.bal-emoji { display: grid; place-items: center; flex: none; width: 44px; height: 44px; border-radius: 12px; background: var(--fill); font-size: 26px; }
.bal-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.bal-name { font-weight: 600; }
.bal-meta { font-size: 13px; color: var(--ink-3); line-height: 1.4; }
.bal-count { display: inline-block; min-width: 28px; text-align: right; font-size: 26px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; color: var(--ink-3); }
.bal.has .bal-count { color: var(--ink); }
.bal.is-owed .bal-count { color: var(--bad); }

/* deals */
.deal-list { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
.deal { padding: 14px 14px 12px 16px; }
.deal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.deal-titles { min-width: 0; }
.deal-titles h3 { margin: 0; font-size: 16px; font-weight: 650; line-height: 1.3; }
.deal-titles p { margin: 1px 0 0; font-size: 13px; color: var(--ink-3); }
.deal-prize {
  display: inline-flex; align-items: center; gap: 4px; flex: none; height: 30px; padding: 0 10px;
  border-radius: 8px; background: var(--fill); font-weight: 650; font-size: 14px; font-variant-numeric: tabular-nums;
}
.deal-prize .ico { width: 14px; height: 14px; stroke-width: 3; }
.deal-prize.is-won { background: var(--good-soft); color: var(--good); }
.prize-emoji { font-size: 17px; line-height: 1; }
.reqs { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); }
.req { display: flex; align-items: center; gap: 12px; padding: 7px 0; }
.req-emoji { flex: none; width: 24px; font-size: 19px; text-align: center; }
.req-main { flex: 1; min-width: 0; }
.req-line { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 6px; font-size: 14px; }
.req-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.req-num { color: var(--ink-3); white-space: nowrap; font-variant-numeric: tabular-nums; }
.req-num b { display: inline-block; color: var(--ink); font-weight: 600; }
.bar { height: 6px; overflow: hidden; border-radius: 3px; background: var(--fill-2); }
.bar-fill { width: 0; height: 100%; border-radius: inherit; background: var(--accent); transition: width .5s cubic-bezier(.2, .8, .2, 1), background-color .3s; }
.req.is-done .bar-fill { background: var(--good-bar); }
.plus-btn {
  flex: none; width: 64px; height: 36px; padding: 0 6px;
  border: 1px solid var(--line-2); border-radius: var(--r-sm); background: var(--surface);
  font-size: 14px; font-weight: 650; font-variant-numeric: tabular-nums; cursor: pointer;
  transition: background-color .12s, transform .1s;
}
.plus-btn:hover { background: var(--fill); }
.plus-btn:active { transform: scale(.94); background: var(--fill-2); }
.req-check { display: grid; place-items: center; flex: none; width: 64px; color: var(--good); }
.req-check .ico { stroke-width: 2.6; }
.deal-foot { margin: 6px 0 0; font-size: 13px; color: var(--ink-3); }
.deal.is-done .deal-foot { color: var(--good); }

/* log list */
.log-row { display: flex; align-items: center; gap: 4px; padding: 6px 12px 6px 6px; }
.log-row.is-running { background: var(--bad-soft); }
.log-main {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; padding: 6px 8px;
  border: 0; border-radius: var(--r-sm); background: transparent; text-align: left; cursor: pointer;
}
.log-main:hover { background: var(--fill); }
.log-emoji { flex: none; width: 28px; font-size: 22px; text-align: center; }
.log-text { min-width: 0; display: flex; flex-direction: column; }
.log-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.log-total { display: inline-block; font-size: 13px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.log-row .plus-btn { margin-left: 4px; }

/* timer */
.timer-bar {
  position: sticky; top: calc(var(--top-offset) + 10px); z-index: 5;
  display: flex; align-items: center; gap: 12px; margin-top: 16px; padding: 10px 10px 10px 14px;
  border-radius: var(--r); background: var(--ink); color: var(--on-ink); box-shadow: var(--pop);
}
.timer-dot { width: 8px; height: 8px; border-radius: 50%; background: #FF5A4F; animation: pulse 1.2s infinite; flex: none; }
.timer-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.timer-name { font-size: 13px; opacity: .75; }
.timer-clock { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }

/* activity */
.activity { list-style: none; margin: 0; padding: 0; }
.act { display: flex; align-items: center; gap: 12px; padding: 8px 6px 8px 14px; font-size: 14px; }
.act-emoji { flex: none; width: 22px; text-align: center; font-size: 17px; }
.act-text { flex: 1; min-width: 0; }
.act-time { flex: none; color: var(--ink-3); font-size: 12px; font-variant-numeric: tabular-nums; }
.act.is-slip .act-text { color: var(--bad); }
.activity + .btn { margin-top: 6px; }

/* -------------------------------------------------------------------- setup */

.list-row {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 12px 12px 14px;
  border: 0; background: transparent; text-align: left; cursor: pointer;
}
.list-row:hover { background: var(--fill); }
.rows > .list-row:first-child { border-radius: var(--r) var(--r) 0 0; }
.rows > .list-row:last-child { border-radius: 0 0 var(--r) var(--r); }
.rows > .list-row:only-child { border-radius: var(--r); }
.list-row > .ico { color: var(--ink-3); width: 18px; height: 18px; }
.list-emoji { display: grid; place-items: center; flex: none; width: 38px; height: 38px; border-radius: 10px; background: var(--fill); font-size: 21px; }
.list-row:hover .list-emoji { background: var(--surface); }
.list-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.list-text b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-text small { color: var(--ink-3); font-size: 13px; }
.list-sub { font-size: 13px; color: var(--ink-3); }
.list-action { font-size: 14px; font-weight: 600; color: var(--ink-2); }
.deal-row .list-text { gap: 8px; }
.deal-row-top { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 10px; }
.setup-cols { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0 16px; }
@media (min-width: 760px) { .setup-cols { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.setup-foot { margin: 28px 2px 0; font-size: 14px; color: var(--ink-3); }

.recipe { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; }
.rchip {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px 2px 6px;
  border-radius: 6px; background: var(--fill); font-size: 13px; font-weight: 600; white-space: nowrap;
}
.rchip-name { font-weight: 400; color: var(--ink-2); }
.rchip-prize { background: var(--accent-soft); color: var(--accent-ink); }
.rchip-prize .rchip-name { color: inherit; }
.rsep { color: var(--ink-3); font-size: 13px; }

/* ------------------------------------------------------------------- forms */

.field { display: grid; gap: 6px; min-width: 0; margin: 0; padding: 0; border: 0; }
.field-label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.field-label em { font-style: normal; font-weight: 400; color: var(--ink-3); }
legend.field-label { padding: 0; margin-bottom: 6px; }
.field-inline { grid-template-columns: 1fr 130px; align-items: center; }
.input {
  width: 100%; min-height: 44px; padding: 9px 12px;
  border: 1px solid var(--field-line); border-radius: var(--r-sm);
  background: var(--surface); color: var(--ink); font: inherit; font-size: 16px;
  transition: border-color .15s, box-shadow .15s;
}
.input::placeholder { color: var(--ink-3); }
.input:focus { outline: none; border-color: var(--ink-2); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ink) 10%, transparent); }
.input-sm { min-height: 38px; padding: 6px 10px; }
.select {
  appearance: none; -webkit-appearance: none; padding-right: 34px; cursor: pointer; text-overflow: ellipsis;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%2385858D' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
.input-affix {
  display: flex; align-items: center; overflow: hidden;
  border: 1px solid var(--field-line); border-radius: var(--r-sm); background: var(--surface);
  transition: border-color .15s, box-shadow .15s;
}
.input-affix:focus-within { border-color: var(--ink-2); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ink) 10%, transparent); }
.input-affix .input { border: 0; box-shadow: none; min-width: 0; flex: 1; }
.affix { padding: 0 12px 0 0; color: var(--ink-3); font-size: 14px; white-space: nowrap; }
.affix:first-child { padding: 0 0 0 12px; }
.affix:empty { display: none; }
input[type="number"] { -moz-appearance: textfield; appearance: textfield; }
input[type="number"]::-webkit-outer-spin-button, input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.name-row { display: flex; align-items: flex-end; gap: 10px; }
.grow { flex: 1; min-width: 0; }
.emoji-btn {
  flex: none; width: 52px; height: 44px; border: 1px solid var(--line-2); border-radius: var(--r-sm);
  background: var(--fill); font-size: 24px; line-height: 1; cursor: pointer;
}
.emoji-btn:hover { background: var(--fill-2); }
.emoji-panel { display: grid; gap: 10px; max-height: 270px; overflow: auto; padding: 12px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--fill); }
.emoji-label { margin: 0 0 4px; font-size: 12px; font-weight: 600; color: var(--ink-3); }
.emoji-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); gap: 2px; }
.emoji-opt { height: 40px; border: 0; border-radius: 8px; background: transparent; font-size: 22px; cursor: pointer; }
.emoji-opt:hover { background: var(--surface); }

/* segmented controls: buttons (.seg-btn) or radios (.seg-opt) */
.seg { display: flex; gap: 2px; width: fit-content; max-width: 100%; padding: 3px; border-radius: var(--r-sm); background: var(--fill); }
.seg-btn, .seg-opt span {
  display: flex; align-items: center; justify-content: center; height: 34px; padding: 0 14px;
  border: 0; border-radius: 8px; background: transparent; color: var(--ink-2);
  font-size: 14px; font-weight: 600; white-space: nowrap; cursor: pointer;
}
.seg-btn:hover, .seg-opt span:hover { color: var(--ink); }
.seg-btn.is-on, .seg-opt input:checked + span { background: var(--surface); color: var(--ink); box-shadow: var(--lift); }
.seg-opt { position: relative; flex: 1; }
.seg-opt input { position: absolute; opacity: 0; pointer-events: none; }
.seg-opt input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 1px; }
.seg-radio { width: 100%; }

.radio-list { display: grid; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); overflow: hidden; }
.radio-row { display: flex; align-items: flex-start; gap: 12px; padding: 12px 14px; cursor: pointer; }
.radio-row + .radio-row { border-top: 1px solid var(--line); }
.radio-row:hover { background: var(--fill); }
.radio-row input { flex: none; width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--ink); }
.radio-row > span { display: flex; flex-direction: column; gap: 1px; }
.radio-row b { font-weight: 600; }
.radio-row small { color: var(--ink-3); font-size: 13px; }

.more { border-top: 1px solid var(--line); padding-top: 12px; }
.more > summary { cursor: pointer; font-size: 14px; font-weight: 600; color: var(--ink-2); list-style: none; width: fit-content; }
.more > summary::-webkit-details-marker { display: none; }
.more > summary::before { content: '+'; display: inline-block; width: 16px; color: var(--ink-3); }
.more[open] > summary::before { content: '−'; }
.more[open] > summary { margin-bottom: 12px; }
.more > :not(summary) + :not(summary) { margin-top: 12px; }

.form-error { margin: 0; padding: 10px 12px; border-radius: var(--r-sm); background: var(--bad-soft); color: var(--bad); font-size: 14px; font-weight: 600; }

/* deal editor */
[data-cost] { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.req-rows { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.req-row { display: grid; grid-template-columns: minmax(0, 1fr) 140px auto; gap: 8px; align-items: center; }
.add-req { justify-self: start; margin-left: -8px; }
.earn-row { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 8px; }
@media (max-width: 480px) {
  .req-row { grid-template-columns: minmax(0, 1fr) auto; }
  .req-row .select { grid-column: 1 / -1; }
  .field-inline { grid-template-columns: 1fr 110px; }
}
.preview { margin: 0; padding: 12px 14px; border-radius: var(--r-sm); background: var(--fill); color: var(--ink); font-size: 15px; line-height: 1.5; }

/* stepper (log sheet) */
.stepper { display: flex; align-items: center; justify-content: center; gap: 20px; padding: 4px 0 0; }
.stepper-btn {
  display: grid; place-items: center; width: 52px; height: 52px; flex: none;
  border: 1px solid var(--line-2); border-radius: 50%; background: var(--surface); cursor: pointer;
}
.stepper-btn:hover { background: var(--fill); }
.stepper-btn:active { transform: scale(.94); }
.stepper-btn .ico { width: 22px; height: 22px; }
.stepper-value { display: flex; flex-direction: column; align-items: center; }
.stepper-input {
  width: 140px; padding: 0; border: 0; background: transparent; color: var(--ink);
  font: inherit; font-size: 48px; font-weight: 700; letter-spacing: -.02em; text-align: center; font-variant-numeric: tabular-nums;
}
.stepper-input:focus { outline: none; }
.stepper-input:focus-visible { outline: 2px solid var(--ink); outline-offset: 4px; border-radius: 8px; }
.stepper-unit { min-height: 20px; color: var(--ink-3); font-size: 14px; }
.quick-chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 38px; padding: 0 14px;
  border: 1px solid var(--line-2); border-radius: 999px; background: var(--surface);
  font-size: 15px; font-weight: 500; cursor: pointer; transition: background-color .12s, border-color .12s;
}
.chip:hover { background: var(--fill); }
.chip.is-on { background: var(--ink); border-color: var(--ink); color: var(--on-ink); }
.chip-sm { height: 34px; padding: 0 12px; font-size: 14px; }
.chip-emoji { font-size: 17px; line-height: 1; }

.lead-sm { margin: 0; font-size: 16px; line-height: 1.5; }
.debt-box { padding: 12px 14px; border-radius: var(--r-sm); background: var(--bad-soft); font-size: 14px; line-height: 1.5; }
.debt-box p { margin: 0; }
.debt-box p + p { margin-top: 4px; color: var(--ink-2); }

/* ------------------------------------------------------------------ sheets */

dialog.sheet {
  position: fixed; inset: 0; width: 100%; height: 100%; max-width: 100%; max-height: 100%;
  margin: 0; padding: 0; border: 0; background: transparent; color: var(--ink); overflow: hidden;
}
dialog.sheet[open] { display: flex; align-items: flex-end; justify-content: center; }
dialog.sheet::backdrop { background: rgba(10, 10, 12, .42); animation: fade-in .2s; }
.sheet-card {
  display: flex; flex-direction: column; width: 100%; max-width: 540px; max-height: 92dvh;
  background: var(--surface); border-radius: 18px 18px 0 0; box-shadow: var(--pop);
  padding-bottom: env(safe-area-inset-bottom);
  animation: sheet-up .28s cubic-bezier(.2, .8, .2, 1);
}
dialog.sheet.closing { pointer-events: none; } /* no second tap while it animates away */
dialog.sheet.closing .sheet-card { animation: sheet-down .17s ease-in forwards; }
dialog.sheet.closing::backdrop { opacity: 0; transition: opacity .17s; }
.sheet-grip { width: 36px; height: 4px; margin: 8px auto 0; border-radius: 2px; background: var(--line-2); flex: none; }
.sheet-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 10px 12px 8px 20px; flex: none; }
.sheet-titles { padding-top: 6px; min-width: 0; }
.sheet-title { margin: 0; font-size: 19px; font-weight: 650; letter-spacing: -.01em; }
.sheet-sub { margin: 3px 0 0; color: var(--ink-3); font-size: 14px; }
.sheet-head .icon-btn { font-size: 15px; }
.sheet-body { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; padding: 8px 20px 20px; overflow: auto; overscroll-behavior: contain; }
.sheet-foot { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; padding: 12px 20px 16px; border-top: 1px solid var(--line); flex: none; }
.sheet-foot .spacer { flex: 1; }
.sheet-confirm .sheet-card { max-width: 440px; }
.confirm-msg { margin: 0; color: var(--ink-2); line-height: 1.5; }
@media (min-width: 640px) {
  dialog.sheet[open] { align-items: center; padding: 24px; }
  .sheet-card { border-radius: 16px; max-height: 88dvh; animation: pop-in .2s ease-out; }
  .sheet-wide .sheet-card { max-width: 600px; }
  dialog.sheet.closing .sheet-card { animation: pop-out .15s ease-in forwards; }
  .sheet-grip { display: none; }
  .sheet-head { padding-top: 14px; }
}

/* ------------------------------------------------------------------ toasts */

.toasts {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + 12px + env(safe-area-inset-bottom)); z-index: 60;
  width: min(480px, calc(100% - 24px)); transform: translateX(-50%); pointer-events: none;
}
body[data-route="welcome"] .toasts { bottom: 20px; }
@media (min-width: 820px) { .toasts { bottom: 24px; } }
.toast {
  display: flex; align-items: center; gap: 12px; padding: 12px 8px 12px 16px; pointer-events: auto;
  border-radius: var(--r); background: var(--ink); color: var(--on-ink); box-shadow: var(--pop);
  font-size: 14.5px; line-height: 1.4; animation: toast-in .25s cubic-bezier(.2, .8, .2, 1);
}
.toast.out { animation: toast-out .2s ease-in forwards; }
.toast-msg { flex: 1; min-width: 0; }
.toast-action {
  flex: none; min-height: 40px; padding: 0 12px; border: 0; border-radius: 8px; cursor: pointer;
  background: transparent; color: inherit; font-weight: 700; text-decoration: underline; text-underline-offset: 3px;
}
.toast-action:hover { background: color-mix(in srgb, currentColor 12%, transparent); }
.toast-win { box-shadow: inset 4px 0 0 var(--accent), var(--pop); }
.toast-error { background: var(--bad-fill); color: #fff; }

.confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 100; }

/* ---------------------------------------------------------------- insights */

.filter-row { margin: 24px 0 12px; }
.kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
@media (min-width: 620px) { .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.kpi { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; }
.kpi-label { font-size: 13px; color: var(--ink-3); }
.kpi-value { font-size: 24px; font-weight: 700; letter-spacing: -.01em; }
.kpi-sub { font-size: 12px; color: var(--ink-3); }
.group-title { margin: 32px 2px 8px; }
.viz-card { margin-bottom: 10px; }
.stat-line { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 6px 0 0; font-size: 13px; color: var(--ink-3); }
.stat-line b { color: var(--ink); font-weight: 600; }
.stat-line .owe b { color: var(--bad); }
.trend { margin: 4px 0 0; font-size: 13px; color: var(--ink-2); }

.viz { margin: 14px 0 0; }
.viz-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-bottom: 10px; font-size: 12.5px; color: var(--ink-2); }
.viz-key i { display: inline-block; width: 10px; height: 10px; margin-right: 6px; border-radius: 2px; vertical-align: -1px; }
.viz-body { display: flex; gap: 8px; }
.viz-y { display: flex; flex-direction: column; justify-content: space-between; min-width: 24px; height: 132px; font-size: 11px; color: var(--ink-3); text-align: right; font-variant-numeric: tabular-nums; }
.viz-y span { line-height: 12px; margin: -6px 0; }
.viz-main { flex: 1; min-width: 0; }
.viz-plot { position: relative; height: 132px; }
.viz-grid { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: space-between; pointer-events: none; }
.viz-grid i { display: block; height: 1px; background: var(--grid); }
.viz-grid i:last-child { background: var(--axis); }
.viz-cols { position: absolute; inset: 0; display: flex; align-items: flex-end; gap: 2px; }
.viz-col { flex: 1; min-width: 0; height: 100%; display: flex; align-items: flex-end; justify-content: center; border-radius: 4px; outline: none; }
.viz-col:hover, .viz-col.is-hover { background: color-mix(in srgb, var(--ink) 5%, transparent); }
.viz-col:focus-visible { box-shadow: inset 0 0 0 2px var(--accent); }
.viz-stack { display: flex; flex-direction: column; gap: 2px; width: 100%; max-width: 24px; min-height: 3px; overflow: hidden; border-radius: 4px 4px 0 0; }
.viz-seg { display: block; min-height: 2px; }
.viz-col.is-hover .viz-stack { filter: brightness(1.1); }
.viz-xs { display: flex; gap: 2px; margin-top: 6px; }
.viz-x { flex: 1; min-width: 0; font-size: 11px; color: var(--ink-3); text-align: center; white-space: nowrap; overflow: visible; }
.is-dense .viz-cols, .is-dense .viz-xs { gap: 1px; }
.viz-table summary { margin-top: 10px; font-size: 13px; font-weight: 600; color: var(--ink-2); cursor: pointer; width: fit-content; }
.table-scroll { max-height: 260px; overflow: auto; margin-top: 8px; border: 1px solid var(--line); border-radius: var(--r-sm); }
.viz-table table { width: 100%; border-collapse: collapse; font-size: 13px; }
.viz-table th, .viz-table td { padding: 7px 10px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
.viz-table th:first-child { text-align: left; }
.viz-table thead th { position: sticky; top: 0; background: var(--surface); color: var(--ink-2); font-weight: 600; }
.viz-table td { font-variant-numeric: tabular-nums; }
.viz-table tbody th { font-weight: 400; }

.tooltip {
  position: fixed; left: 0; top: 0; z-index: 80; min-width: 128px; padding: 8px 10px; pointer-events: none;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: var(--r-sm);
  box-shadow: var(--pop); font-size: 12.5px;
}
.tt-title { margin-bottom: 4px; font-size: 12px; font-weight: 600; color: var(--ink-2); }
.tt-row { display: flex; align-items: center; gap: 6px; line-height: 1.6; }
.tt-row b { font-size: 14px; font-variant-numeric: tabular-nums; }
.tt-row span { color: var(--ink-2); }
.tt-key { display: inline-block; width: 12px; height: 2px; border-radius: 1px; }

.hm { --cell: 15px; display: flex; gap: 6px; margin-top: 14px; overflow-x: auto; padding-bottom: 2px; }
@media (min-width: 560px) { .hm { --cell: 20px; } }
@media (min-width: 720px) { .hm { --cell: 24px; } }
.hm-days, .hm-grid { display: grid; grid-template-rows: repeat(7, var(--cell)); gap: 3px; }
.hm-days span { font-size: 10px; line-height: var(--cell); color: var(--ink-3); }
.hm-grid { grid-auto-flow: column; grid-auto-columns: var(--cell); }
.hm-cell { display: block; width: var(--cell); height: var(--cell); border-radius: 4px; background: var(--hm-0); }
.hm-cell.lv-0 { box-shadow: inset 0 0 0 1px var(--line-2); }
.hm-cell.lv-1 { background: var(--hm-1); }
.hm-cell.lv-2 { background: var(--hm-2); }
.hm-cell.lv-3 { background: var(--hm-3); }
.hm-cell.lv-4 { background: var(--hm-4); }
.hm-cell.is-future { background: transparent; box-shadow: inset 0 0 0 1px var(--line); }
.hm-cell.is-blank { background: transparent; }
.hm-grid .hm-cell:not(.is-blank):not(.is-future):hover { outline: 2px solid var(--ink); outline-offset: 1px; }
.hm-legend { display: flex; align-items: center; gap: 3px; margin: 10px 0 8px; font-size: 11.5px; color: var(--ink-3); }
.hm-legend .hm-cell { --cell: 11px; }
.hm-legend .hm-cell:first-child { margin-left: 4px; }
.hm-legend .hm-cell:last-child { margin-right: 4px; }

/* ---------------------------------------------------------------- settings */

.form-card { display: grid; gap: 14px; margin-top: 12px; }
.form-card > .btn { justify-self: start; }
.text-links { margin: 0; font-size: 14px; color: var(--ink-3); }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; cursor: pointer; }
.switch-row > span { display: flex; flex-direction: column; }
.switch-row b { font-weight: 600; }
.switch-row small { color: var(--ink-3); font-size: 13px; }
.switch {
  appearance: none; -webkit-appearance: none; position: relative; flex: none; width: 46px; height: 28px; margin: 0;
  border-radius: 999px; background: var(--switch-off); cursor: pointer; transition: background-color .2s;
}
.switch::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); transition: transform .2s;
}
.switch:checked { background: var(--good-bar); }
.switch:checked::after { transform: translateX(18px); }
.danger-zone .btn { justify-self: start; }
.status-ok { margin: 0; font-size: 14px; font-weight: 600; color: var(--good); }
.about { margin: 28px 0 8px; text-align: center; font-size: 13px; color: var(--ink-3); }

.privacy { display: grid; gap: 12px; }
.privacy-points { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.privacy-points li { display: flex; gap: 10px; font-size: 14px; line-height: 1.5; color: var(--ink-2); }
.privacy-points li .ico { width: 18px; height: 18px; margin-top: 1px; color: var(--good); stroke-width: 2.4; }
.privacy-points b { color: var(--ink); font-weight: 600; }
.verify { margin: 0; padding-left: 20px; font-size: 14px; line-height: 1.6; color: var(--ink-2); }
.verify li + li { margin-top: 2px; }

/* -------------------------------------------------------------- onboarding */

.onb { padding-top: 12px; }
.onb-brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 16px; }
.onb-brand img { border-radius: 7px; }
.onb-title { margin: 28px 0 10px; font-size: clamp(30px, 6.5vw, 40px); line-height: 1.1; letter-spacing: -.025em; font-weight: 750; }
.onb-lead { margin: 0; font-size: 17px; line-height: 1.55; color: var(--ink-2); }
.onb-form { margin-top: 28px; }
.step { padding: 22px 0; border-top: 1px solid var(--line); }
.step-title { display: flex; align-items: center; gap: 10px; margin: 0 0 14px; font-size: 18px; font-weight: 650; letter-spacing: -.01em; }
.step-n {
  display: grid; place-items: center; flex: none; width: 24px; height: 24px; border-radius: 50%;
  background: var(--ink); color: var(--on-ink); font-size: 13px; font-weight: 700;
}
.step-hint { margin: -6px 0 12px; font-size: 14px; color: var(--ink-3); }
.step-note { margin: 12px 0 0; }
.custom-reward { display: grid; gap: 10px; margin-top: 12px; }
.cost-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); }
.cost-row { display: flex; align-items: center; gap: 10px; min-height: 56px; padding: 8px 6px 8px 14px; }
.cost-row + .cost-row { border-top: 1px solid var(--line); }
.cost-emoji { flex: none; width: 24px; font-size: 20px; text-align: center; }
.cost-name { flex: 1; min-width: 0; font-weight: 500; }
.cost-row .input-bare { flex: 1; min-width: 0; min-height: 38px; padding: 6px 8px; border-color: transparent; background: var(--fill); }
.cost-amount { display: flex; align-items: center; gap: 6px; flex: none; }
.input-num { width: 64px; min-height: 38px; padding: 6px 8px; text-align: center; font-variant-numeric: tabular-nums; }
.cost-amount .select.input-bare { flex: none; width: 82px; padding-right: 26px; background-position: right 8px center; }
.cost-unit { width: 70px; font-size: 14px; color: var(--ink-3); }
.add-tasks { margin-top: 14px; }
.add-label { display: block; margin-bottom: 8px; font-size: 13px; font-weight: 600; color: var(--ink-3); }
.inline-choice { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.inline-label { font-size: 15px; font-weight: 600; }
.summary { margin-top: 4px; padding: 16px; border-radius: var(--r); background: var(--accent-soft); }
.summary-label { margin: 0 0 4px; font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--accent-ink); }
.summary-text { margin: 0; font-size: 16px; line-height: 1.5; }
.onb-form .form-error { margin-top: 12px; }
.onb-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; margin-top: 20px; }
.onb-actions .btn-primary { min-width: 160px; }
.onb-private { margin-top: 36px; padding: 16px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); }
.onb-private h2 { display: flex; align-items: center; gap: 8px; margin: 0 0 10px; font-size: 15px; font-weight: 650; }
.onb-private h2 .ico { width: 17px; height: 17px; }
@media (max-width: 420px) {
  .cost-unit { width: 62px; }
  .input-num { width: 56px; }
}

/* -------------------------------------------------------------- animation */

.bump { animation: bump .35s ease-out; }
@keyframes bump { 40% { transform: scale(1.25); } }
@keyframes page-in { from { opacity: 0; transform: translateY(4px); } }
@keyframes sheet-up { from { transform: translateY(100%); } }
@keyframes sheet-down { to { transform: translateY(100%); } }
@keyframes pop-in { from { opacity: 0; transform: translateY(8px) scale(.98); } }
@keyframes pop-out { to { opacity: 0; transform: translateY(6px) scale(.98); } }
@keyframes fade-in { from { opacity: 0; } }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(6px); } }
@keyframes pulse { 50% { opacity: .3; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}

/* Taps on controls shouldn't wait for (or trigger) double-tap zoom. */
button, .btn, .chip, .plus-btn, .stepper-btn, .seg-btn, .list-row, input, select { touch-action: manipulation; }

.onb-restore { margin: 18px 0 0; text-align: center; font-size: 14px; color: var(--ink-2); }
.btn-danger-text:hover { color: var(--bad); }
/* Hover tints only where there's a real hover; on phones they stick to the last tapped button. */
@media (hover: none) {
  .btn-secondary:hover, .plus-btn:hover, .stepper-btn:hover { background: var(--surface); }
  .btn-quiet:hover, .icon-btn:hover { background: transparent; }
}
