/* =========================================================
   Daybook: personal tracker
   Cream + navy + royal blue, pastel blobs, soft serif headings.
   ========================================================= */

:root {
  --bg: #F6F1E7;
  --surface: #FFFCF6;
  --surface-2: #F0E8D8;
  --hover: #F3ECDF;
  --track: #EAE1CF;
  --border: #EBE3D3;
  --border-strong: #DCD1BC;
  --text: #1C2340;
  --text-2: #5E6483;
  --text-3: #9A9CB0;
  --ink: #1C2340;
  --ink-text: #FFF8EC;
  --on-pastel: #1C2340;
  --nav-bg: #1C2340;
  --blue: #3652A3;
  --blue-deep: #2B4389;
  --blue-text: #C3CEF1;
  --pos: #2F8A57;
  --danger: #D2553F;
  --danger-soft: #FBE1D9;
  --warn: #B87312;
  --warn-soft: #FBEBC9;
  --ok-soft: #DCEFE3;
  --orange-a: #F39F38;
  --orange-b: #F8CF8A;
  --butter: #F7D27E; --butter-soft: #FBE9C0;
  --mint: #BFE3D3;   --mint-soft: #DCEFE6;
  --sky: #A9D5F2;    --sky-soft: #D8ECF9;
  --lilac: #D6C9F4;  --lilac-soft: #EAE3FA;
  --pink: #F7C3D6;   --pink-soft: #FBE1EA;
  --focus: rgba(28, 35, 64, .12);
  --shadow-lg: 0 30px 70px -20px rgba(28, 35, 64, .38), 0 2px 8px rgba(28, 35, 64, .08);
  --radius: 26px;
  --font: "DM Sans", "Noto Sans Bengali", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Fraunces", "Noto Serif Bengali", Georgia, "Times New Roman", serif;
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #121730;
  --surface: #1A2042;
  --surface-2: #222A52;
  --hover: #232B55;
  --track: #2A3361;
  --border: #252D57;
  --border-strong: #37417A;
  --text: #F6F0E4;
  --text-2: #B3B8D3;
  --text-3: #7A81A7;
  --ink: #F6F0E4;
  --ink-text: #1C2340;
  --nav-bg: #0B0F26;
  --pos: #74D19C;
  --danger: #F59380;
  --danger-soft: rgba(245, 147, 128, .15);
  --warn: #F4BC5C;
  --warn-soft: rgba(244, 188, 92, .15);
  --ok-soft: rgba(116, 209, 156, .15);
  --focus: rgba(246, 240, 228, .16);
  --shadow-lg: 0 30px 70px -14px rgba(0, 0, 0, .6);
  color-scheme: dark;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scrollbar-gutter: stable; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
body.no-scroll { overflow: hidden; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; margin: 0; cursor: pointer; text-align: inherit; -webkit-tap-highlight-color: transparent; }
button:disabled { cursor: default; opacity: .3; }
a { color: inherit; text-decoration: none; -webkit-tap-highlight-color: transparent; }
input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, p { margin: 0; }
svg { display: block; flex: none; }
.num { font-variant-numeric: tabular-nums lining-nums; }
:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }
::selection { background: var(--butter); color: var(--on-pastel); }
.neg { color: var(--danger); }
.pos { color: var(--pos); }
.serif, .page-head h1, .card-title, .sheet-head h2, .welcome-top h2, .hb-title, .brand,
.hero-value, .stat-value, .tile-value, .amount-input, .amount-cur, .cta-title, .tip-title, .section-title {
  font-family: var(--font-display);
  font-variation-settings: "SOFT" 100, "WONK" 0;
  font-optical-sizing: auto;
}

/* ---------- Blobs ---------- */
.blob { position: relative; display: inline-grid; place-items: center; flex: none; color: var(--on-pastel); }
.blob > svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.blob-in { position: relative; display: grid; place-items: center; }
.blob.tri .blob-in { margin-top: 14%; }
.face { display: block; flex: none; }

/* ---------- App layout ---------- */
.app { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; min-height: 100dvh; }
.main { min-width: 0; }
.view { max-width: 1160px; margin: 0 auto; padding: 32px 40px 80px; }

.sidebar {
  position: sticky; top: 0;
  height: 100vh; height: 100dvh;
  display: flex; flex-direction: column;
  padding: 26px 16px 18px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 10px; margin-bottom: 28px; font-size: 26px; font-weight: 650; letter-spacing: -.02em; color: var(--blue); }
[data-theme="dark"] .brand { color: var(--text); }
.brand-mark { width: 34px; height: 34px; }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  width: 100%; height: 46px; padding: 0 16px;
  border-radius: 999px;
  color: var(--text-2); font-size: 15px; font-weight: 500;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--hover); color: var(--text); }
.nav-item.on { background: var(--ink); color: var(--ink-text); }
.sidebar .btn-block { margin-top: 18px; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
.side-month {
  position: relative; overflow: hidden;
  padding: 16px 18px; border-radius: 22px;
  background: var(--surface-2);
  display: flex; flex-direction: column; gap: 8px;
}
.side-month .label { font-size: 12.5px; }
.side-month-val { position: relative; font-size: 18px; font-weight: 650; letter-spacing: -.01em; font-family: var(--font-display); font-variation-settings: "SOFT" 100; }
.side-month-val span { color: var(--text-3); font-weight: 500; font-size: 14px; font-family: var(--font); }
.side-month .bar { position: relative; height: 6px; background: rgba(28, 35, 64, .1); }
[data-theme="dark"] .side-month .bar { background: rgba(255, 255, 255, .1); }
.side-deco { position: absolute; right: -18px; top: -20px; opacity: .85; pointer-events: none; }
.side-month > :not(.side-deco) { position: relative; }

/* Floating tab bar (mobile) */
.tabbar {
  display: none;
  position: fixed; z-index: 30;
  left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom));
  height: 68px; padding: 0 8px;
  border-radius: 34px;
  background: var(--nav-bg);
  box-shadow: 0 16px 34px -12px rgba(28, 35, 64, .5);
  grid-template-columns: repeat(5, 1fr);
  align-items: center;
}
.tab { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 0; font-size: 11px; font-weight: 500; color: rgba(255, 248, 236, .5); transition: color .15s; }
.tab.on { color: #FFF8EC; }
.tab-add { justify-self: center; width: 52px; height: 52px; border-radius: 50%; background: #FFF8EC; color: #1C2340; display: grid; place-items: center; }

/* ---------- Page header ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin: 8px 0 26px; }
.page-titles { min-width: 0; }
.eyebrow { font-size: 14px; font-weight: 500; color: var(--text-2); margin-bottom: 4px; }
.page-head h1 { font-size: 42px; line-height: 1.08; font-weight: 650; letter-spacing: -.025em; }
.head-actions { display: flex; align-items: center; gap: 8px; flex: none; }

/* ---------- Grid ---------- */
.grid { display: grid; gap: 18px; }
.cols-2 { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); align-items: start; }
.stack { display: flex; flex-direction: column; gap: 18px; min-width: 0; }

/* ---------- Card ---------- */
.card { background: var(--surface); border-radius: var(--radius); box-shadow: 0 0 0 1px var(--border); padding: 22px; min-width: 0; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; min-height: 34px; }
.card-title { font-size: 21px; font-weight: 650; letter-spacing: -.015em; line-height: 1.2; }
.card-sub { font-size: 13.5px; color: var(--text-2); margin-top: 3px; }
.label { font-size: 13.5px; font-weight: 500; color: var(--text-2); }
.link-btn { font-size: 14px; font-weight: 500; color: var(--text-2); padding: 6px 10px; margin: -2px -10px 0 0; border-radius: 999px; white-space: nowrap; transition: background .15s, color .15s; }
.link-btn:hover { color: var(--text); background: var(--hover); }
.section-title { font-size: 23px; font-weight: 650; letter-spacing: -.015em; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 14px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 40px; padding: 0 18px;
  border-radius: 999px; border: 1.5px solid var(--border-strong);
  background: transparent; color: var(--text);
  font-size: 14px; font-weight: 600; white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s, opacity .15s;
}
.btn:hover { background: var(--hover); }
.btn-primary { background: var(--ink); color: var(--ink-text); border-color: var(--ink); }
.btn-primary:hover { background: var(--ink); opacity: .9; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-sm { height: 34px; padding: 0 14px; font-size: 13px; }
.btn-lg { height: 52px; padding: 0 26px; font-size: 15.5px; }
.btn-block { width: 100%; }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); }
.btn-done { background: var(--ok-soft); border-color: transparent; color: var(--pos); }
.btn-done:hover { background: var(--ok-soft); opacity: .8; }
.icon-btn { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; color: var(--text-2); flex: none; transition: background .15s, color .15s; }
.icon-btn:hover:not(:disabled) { background: var(--hover); color: var(--text); }
.icon-btn.sm { width: 30px; height: 30px; }
.circle-btn { width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; border: 1.5px solid var(--border-strong); color: var(--text); flex: none; transition: background .15s; }
.circle-btn:hover { background: var(--hover); }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 34px; padding: 0 14px;
  border-radius: 999px; border: 1.5px solid var(--border-strong);
  background: transparent;
  font-size: 13.5px; font-weight: 500; color: var(--text-2); white-space: nowrap;
  transition: background .15s, color .15s, border-color .15s;
}
.chip:hover { color: var(--text); background: var(--hover); }
.chip.on { background: var(--ink); border-color: var(--ink); color: var(--ink-text); }

/* ---------- Today: blue hero ---------- */
.hero-blue {
  position: relative; overflow: hidden;
  background: var(--blue); color: #FFF8EC;
  border-radius: 34px;
  padding: 22px 24px 30px;
  margin-bottom: 18px;
}
.hb-deco { position: absolute; inset: 0; pointer-events: none; }
.hb-deco svg { width: 100%; height: 100%; }
.hb-top { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.hb-user { display: flex; align-items: center; gap: 12px; font-size: 17px; font-weight: 500; min-width: 0; }
.hb-user span:last-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hb-avatar { position: relative; width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; border: 1.5px solid rgba(255, 248, 236, .28); font-weight: 600; flex: none; }
.hb-avatar::after { content: ""; position: absolute; top: 3px; right: 3px; width: 9px; height: 9px; border-radius: 50%; background: #F0625A; box-shadow: 0 0 0 2px var(--blue); }
.hb-actions { display: flex; gap: 10px; }
.hb-actions .circle-btn { border-color: rgba(255, 248, 236, .28); color: #FFF8EC; }
.hb-actions .circle-btn:hover { background: rgba(255, 255, 255, .08); }
.hb-center { position: relative; display: flex; flex-direction: column; align-items: center; text-align: center; padding: 6px 0 0; }
.hb-mark { color: #FFF8EC; margin-bottom: 8px; }
.hb-title { font-size: 46px; line-height: 1.08; font-weight: 650; letter-spacing: -.02em; }
.hb-sub { margin-top: 10px; font-size: 17px; color: var(--blue-text); }
.mood-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 22px; max-width: 640px; }
.mood-chip {
  display: inline-flex; align-items: center; gap: 9px;
  height: 50px; padding: 0 20px 0 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .1);
  color: #FFF8EC; font-size: 16px; font-weight: 500;
  transition: background .15s, color .15s;
}
.mood-chip:hover { background: rgba(255, 255, 255, .17); }
.mood-chip.on { background: #FFF8EC; color: #1C2340; }

/* ---------- Today: orange CTA, mini tiles, tips ---------- */
.cta {
  position: relative; overflow: hidden;
  display: flex; align-items: center; gap: 16px;
  padding: 16px 20px 16px 16px;
  border-radius: 30px;
  background: linear-gradient(100deg, var(--orange-a) 0%, var(--orange-b) 100%);
  color: var(--on-pastel);
  transition: filter .15s;
}
.cta:hover { filter: saturate(1.06) brightness(1.02); }
.cta.over { background: linear-gradient(100deg, #EE7A62 0%, #F6B9A6 100%); }
.cta.calm { background: linear-gradient(100deg, #8FC6EC 0%, #CBE5F6 100%); }
.cta-star { width: 60px; height: 60px; border-radius: 50%; background: #FFF8EC; display: grid; place-items: center; flex: none; color: #F39F38; }
.cta.over .cta-star { color: #E26450; }
.cta.calm .cta-star { color: var(--blue); }
.cta-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.cta-title { font-size: 22px; font-weight: 650; letter-spacing: -.015em; line-height: 1.15; }
.cta-sub { font-size: 14px; color: rgba(28, 35, 64, .72); }
.cta-bar { height: 6px; border-radius: 99px; background: rgba(28, 35, 64, .12); overflow: hidden; margin-top: 6px; max-width: 420px; }
.cta-bar > span { display: block; height: 100%; border-radius: inherit; background: var(--on-pastel); }
.cta-chev { flex: none; }

.duo { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.ptile {
  position: relative; overflow: hidden;
  border-radius: var(--radius); padding: 18px 20px;
  color: var(--on-pastel);
  display: flex; flex-direction: column; gap: 6px; min-width: 0;
}
.ptile .label { color: rgba(28, 35, 64, .7); }
.ptile .stat-foot { color: rgba(28, 35, 64, .65); }
.ptile-deco { position: absolute; right: -20px; bottom: -26px; opacity: .6; pointer-events: none; }
.ptile > :not(.ptile-deco) { position: relative; }
.t-butter { background: var(--butter-soft); }
.t-mint { background: var(--mint-soft); }
.t-sky { background: var(--sky-soft); }
.t-lilac { background: var(--lilac-soft); }
.t-pink { background: var(--pink-soft); }
.stat-value { display: block; position: relative; font-size: 34px; line-height: 1.05; font-weight: 650; letter-spacing: -.02em; }
.stat-value .of { font-size: 22px; color: inherit; opacity: .45; font-weight: 600; }
.stat-foot { position: relative; font-size: 13.5px; color: var(--text-2); }
.stat-row { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 12px; }

.cat-circles { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.cat-circle { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; min-width: 0; padding: 4px 0; border-radius: 20px; transition: background .15s; }
.cat-circle:hover { background: var(--hover); }
.cat-circle .blob { width: 84px; height: 84px; }
.cat-circle-name { font-size: 14px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.cat-circle-amt { font-size: 13px; font-weight: 600; margin-top: -6px; }

.tip {
  position: relative; overflow: hidden;
  background: var(--surface-2);
  border-radius: 30px; padding: 22px 24px 24px;
  min-height: 210px;
  display: flex; flex-direction: column; align-items: flex-start; gap: 6px;
}
.tip > * { position: relative; }
.tip-kicker { font-size: 14px; color: var(--text-2); }
.tip-title { font-size: 25px; line-height: 1.15; font-weight: 650; letter-spacing: -.015em; max-width: 58%; }
.tip-sub { font-size: 14px; color: var(--text-2); max-width: 58%; }
.tip .btn { margin-top: auto; }
.tip-deco { position: absolute; right: 0; top: 0; bottom: 0; width: 38%; pointer-events: none; }
.tip-deco .blob { position: absolute; }

/* ---------- Money tiles ---------- */
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; margin-bottom: 18px; }
.tile { display: flex; flex-direction: column; gap: 6px; }
.tile-value { font-size: 30px; font-weight: 650; letter-spacing: -.02em; line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; position: relative; }
.tile-foot { font-size: 13.5px; color: rgba(28, 35, 64, .62); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; position: relative; }
.tile-foot .link-btn { margin: -6px -10px; color: var(--on-pastel); }
.tile .neg { color: #B53A26; }
.tile .pos { color: #23704A; }

.month-switch { display: flex; align-items: center; gap: 4px; background: var(--ink); color: var(--ink-text); border-radius: 999px; padding: 4px; }
.month-switch .icon-btn { width: 40px; height: 40px; color: var(--ink-text); }
.month-switch .icon-btn:hover:not(:disabled) { background: rgba(255, 255, 255, .12); color: var(--ink-text); }
[data-theme="dark"] .month-switch .icon-btn:hover:not(:disabled) { background: rgba(28, 35, 64, .1); }
.month-label { min-width: 132px; text-align: center; font-size: 15px; font-weight: 600; }

/* ---------- Progress ---------- */
.bar { height: 8px; border-radius: 99px; background: var(--track); overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: inherit; background: var(--ink); transition: width .4s ease; }
.bar.warn > span { background: var(--orange-a); }
.bar.over > span { background: var(--danger); }
.mini-bar { display: block; height: 5px; border-radius: 99px; background: var(--track); overflow: hidden; margin-top: 8px; max-width: 240px; }
.mini-bar > span { display: block; height: 100%; border-radius: inherit; background: var(--text-3); }
.mini-bar.tone-danger > span { background: var(--danger); }
.mini-bar.tone-warn > span { background: var(--orange-a); }
.mini-bar.tone-ok > span { background: var(--pos); }
.ring circle { transition: stroke-dashoffset .5s ease; }

/* ---------- Lists ---------- */
.list { display: flex; flex-direction: column; margin: 0 -10px; }
.item { display: flex; align-items: center; gap: 14px; width: 100%; min-width: 0; padding: 9px 10px; border-radius: 20px; text-align: left; }
button.item, .item[role="button"] { cursor: pointer; transition: background .12s; }
button.item:hover, .item[role="button"]:hover, .item.is-active { background: var(--hover); }
.item-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.item-title { font-size: 15px; font-weight: 600; line-height: 1.35; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-sub { font-size: 13.5px; color: var(--text-2); line-height: 1.35; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-end { display: flex; flex-direction: column; align-items: flex-end; flex: none; }
.item-amt { font-size: 15px; font-weight: 600; flex: none; white-space: nowrap; }
.item .btn { flex: none; }
.act { min-width: 104px; }
.act-sm { min-width: 84px; }
.show-more { display: flex; justify-content: center; margin-top: 10px; }
.tone-danger { color: var(--danger) !important; }
.tone-warn { color: var(--warn) !important; }
.tone-ok { color: var(--pos) !important; }
.avatar { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; flex: none; font-size: 14px; font-weight: 600; background: var(--surface-2); color: var(--text-2); }

.day-group + .day-group { margin-top: 8px; }
.day-head { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; font-weight: 600; color: var(--text-3); padding: 10px 0 2px; }

/* ---------- Habits ---------- */
.habit-list { display: flex; flex-direction: column; gap: 2px; margin: 0 -10px; }
.habit-row { display: flex; align-items: center; gap: 14px; padding: 5px 10px; border-radius: 20px; transition: background .12s; }
.habit-row:hover { background: var(--hover); }
.habit-name { flex: 1; min-width: 0; font-size: 15px; font-weight: 500; padding: 8px 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; transition: color .15s; }
.habit-row.done .habit-name { color: var(--text-3); text-decoration: line-through; text-decoration-color: var(--border-strong); }
.check {
  width: 30px; height: 30px; border-radius: 50%;
  border: 1.75px dashed var(--border-strong);
  display: grid; place-items: center; flex: none;
  color: transparent;
  transition: background .15s, border-color .15s, color .15s;
}
.check:hover { border-color: var(--text-3); border-style: solid; }
.check.on { background: var(--c); border: 1.75px solid var(--c); color: var(--on-pastel); }
.check.lg { width: 44px; height: 44px; }
.streak { display: inline-flex; align-items: center; gap: 3px; font-size: 14px; font-weight: 600; color: var(--text-2); flex: none; }
.streak svg { color: var(--orange-a); }

.habit-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; margin-bottom: 18px; }
.habit-summary .hs-item { flex-direction: row; align-items: center; justify-content: flex-start; gap: 16px; min-width: 0; padding: 20px 22px; }
.hs-item > div { display: flex; flex-direction: column; gap: 4px; min-width: 0; position: relative; }
.hs-item .stat-foot { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.habit-card { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; align-items: center; gap: 16px; padding: 16px 20px; }
.habit-info { display: flex; flex-direction: column; min-width: 0; text-align: left; padding: 2px 0; }
.habit-title { font-size: 16px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.habit-meta { font-size: 13.5px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.habit-info:hover .habit-title { text-decoration: underline; text-decoration-color: var(--border-strong); text-underline-offset: 3px; }
.week-dots { display: flex; gap: 6px; }
.wd { display: flex; flex-direction: column; align-items: center; gap: 5px; width: 28px; }
.wd-l { font-size: 11.5px; font-weight: 500; color: var(--text-3); line-height: 1; }
.wd.today .wd-l { color: var(--text); font-weight: 700; }
.wd-dot { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; border: 1.5px solid var(--border-strong); color: var(--on-pastel); transition: background .15s, border-color .15s; }
.wd:hover .wd-dot { border-color: var(--text-3); }
.wd.on .wd-dot { background: var(--c); border-color: var(--c); }
.wd.rest:not(.on) .wd-dot { border-style: dashed; opacity: .55; }
.streak-box { display: flex; align-items: center; justify-content: flex-end; gap: 4px; min-width: 48px; font-size: 16px; font-weight: 650; }
.streak-box svg { color: var(--orange-a); }
.streak-box.zero, .streak-box.zero svg { color: var(--text-3); }

.mood-week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.mood-day { display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 11.5px; color: var(--text-3); font-weight: 500; }
.mood-day.today { color: var(--text); font-weight: 700; }
.mood-empty { width: 34px; height: 34px; border-radius: 50%; border: 1.5px dashed var(--border-strong); }

/* Heatmap */
.heatmap { display: flex; flex-direction: column; gap: 6px; --hc: var(--blue); }
.hm-months, .hm-grid { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 3px; }
.hm-months { font-size: 11.5px; color: var(--text-3); height: 15px; line-height: 15px; }
.hm-months span { white-space: nowrap; overflow: visible; }
.hm-col { display: grid; grid-template-rows: repeat(7, auto); gap: 3px; }
.hm-cell { display: block; aspect-ratio: 1; border-radius: 4px; background: var(--track); }
.hm-cell.ln { opacity: .45; }
.hm-cell.hx { background: transparent; }
.hm-cell.l1 { background: color-mix(in srgb, var(--hc) 28%, var(--track)); }
.hm-cell.l2 { background: color-mix(in srgb, var(--hc) 52%, var(--track)); }
.hm-cell.l3 { background: color-mix(in srgb, var(--hc) 76%, var(--track)); }
.hm-cell.l4 { background: var(--hc); }
[data-theme="dark"] .heatmap, [data-theme="dark"] .hm-legend { --hc: #8EA6F0; }
.hm-legend { --hc: var(--blue); display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 12px; color: var(--text-3); margin-top: 10px; }
.hm-scale { display: flex; align-items: center; gap: 3px; }
.hm-scale i { width: 10px; height: 10px; border-radius: 3px; }

.rate-list { display: flex; flex-direction: column; gap: 14px; }
.rate-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 7px 12px; align-items: center; }
.rate-row .bar { grid-column: 2 / -1; height: 8px; }
.rate-row .blob { grid-row: span 2; }
.rate-name { font-size: 14.5px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rate-val { font-size: 13.5px; font-weight: 600; color: var(--text-2); }

.mini-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.mini-stats > div { border-radius: 20px; padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; color: var(--on-pastel); }
.mini-stats > div:nth-child(1) { background: var(--butter-soft); }
.mini-stats > div:nth-child(2) { background: var(--mint-soft); }
.mini-stats > div:nth-child(3) { background: var(--lilac-soft); }
.mini-stats .num { font-size: 26px; font-weight: 650; letter-spacing: -.02em; font-family: var(--font-display); font-variation-settings: "SOFT" 100; }
.mini-stats span:last-child { font-size: 12.5px; opacity: .7; }

/* ---------- Chart ---------- */
.chart { position: relative; height: 176px; display: flex; align-items: flex-end; gap: 4px; margin-top: 10px; }
.chart-col { position: relative; flex: 1; height: 100%; display: flex; align-items: flex-end; min-width: 0; }
.chart-col > span { display: block; width: 100%; background: var(--ink); border-radius: 99px; transition: opacity .15s; }
.chart-col.zero > span { height: 5px !important; background: var(--track); }
.chart-col.today > span { background: var(--orange-a); }
.chart-col.future > span { background: var(--track); opacity: .6; }
.chart:hover .chart-col:not(:hover) > span { opacity: .4; }
.chart-col:hover::after {
  content: attr(data-tip);
  position: absolute; left: 50%; bottom: calc(100% - 4px); transform: translateX(-50%);
  background: var(--ink); color: var(--ink-text);
  font-size: 12px; font-weight: 600; white-space: nowrap;
  padding: 6px 10px; border-radius: 999px; z-index: 3; pointer-events: none;
}
.chart-col:first-child:hover::after { left: 0; transform: none; }
.chart-col:last-child:hover::after { left: auto; right: 0; transform: none; }
.chart-line { position: absolute; left: 0; right: 0; height: 0; border-top: 2px dashed var(--orange-a); pointer-events: none; z-index: 1; opacity: .9; }
.chart-x { display: flex; gap: 4px; margin-top: 10px; font-size: 12px; color: var(--text-3); }
.chart-x span { flex: 1; min-width: 0; text-align: center; overflow: visible; white-space: nowrap; }
.chart-legend { display: flex; gap: 16px; font-size: 13px; color: var(--text-2); }
.chart-legend span { display: inline-flex; align-items: center; gap: 7px; }
.chart-legend i { display: inline-block; width: 16px; border-top: 2px dashed var(--orange-a); }

.stacked { display: flex; gap: 4px; height: 12px; margin: 2px 0 12px; }
.stacked span { display: block; height: 100%; border-radius: 99px; min-width: 6px; }

/* ---------- Dues ---------- */
.tiles-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.view-switch { display: flex; width: max-content; max-width: 100%; margin: -10px 0 20px; }
.seg a { height: 40px; padding: 0 18px; border-radius: 999px; font-size: 14px; font-weight: 600; color: var(--text-2); display: inline-flex; align-items: center; justify-content: center; gap: 8px; transition: background .15s, color .15s; }
.seg a:hover { color: var(--text); }
.seg a.on { background: var(--ink); color: var(--ink-text); }
.quick-actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; margin-bottom: 18px; }
.qa { display: flex; align-items: center; gap: 14px; padding: 14px 18px 14px 14px; border-radius: 24px; background: var(--surface); box-shadow: 0 0 0 1px var(--border); text-align: left; min-width: 0; transition: background .15s; }
.qa:hover { background: var(--hover); }
.qa > span:last-child { display: flex; flex-direction: column; min-width: 0; }
.qa b { font-size: 16px; font-weight: 650; }
.qa small { font-size: 13px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.filter-row { margin: -4px 0 8px; }
.av-txt { font-weight: 700; letter-spacing: .02em; color: var(--on-pastel); line-height: 1; }
.due-hint { margin-top: -8px; }

.person-top { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px; margin-top: -18px; }
.person-top .blob { margin-bottom: 6px; }
.person-name { font-size: 28px; font-weight: 650; letter-spacing: -.02em; line-height: 1.15; font-variation-settings: "SOFT" 100; }
.person-bal-label { font-size: 15px; color: var(--text-2); }
.person-bal-amt { font-size: 40px; font-weight: 650; letter-spacing: -.02em; line-height: 1.1; font-family: var(--font-display); font-variation-settings: "SOFT" 100; }
.ledger-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.ledger-btn { height: 58px; border-radius: 22px; display: flex; align-items: center; justify-content: center; gap: 10px; font-size: 16px; font-weight: 650; color: var(--on-pastel); transition: filter .15s; }
.ledger-btn:hover { filter: brightness(.97); }
.ledger-btn.gave { background: var(--pink-soft); }
.ledger-btn.got { background: var(--mint-soft); }
.person-actions { justify-content: center; margin-top: -4px; }

.calc-row { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; margin-top: -8px; }
.calc-key { height: 42px; border-radius: 999px; background: var(--surface-2); color: var(--text); font-size: 20px; font-weight: 600; text-align: center; transition: background .15s; }
.calc-key:hover { background: var(--hover); }
.calc-key.eq { background: var(--ink); color: var(--ink-text); }
.calc-preview { margin-top: -10px; font-size: 15px; font-weight: 600; color: var(--text-2); }
.calc-preview:empty { display: none; }

.split-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.split-chip svg { display: none; }
.split-chip.on svg { display: block; }
.split-add { display: flex; gap: 8px; }
.split-add .input { flex: 1; height: 44px; }
.split-add .btn { height: 44px; }
.split-preview { background: var(--surface-2); border-radius: 22px; padding: 14px 18px; display: flex; flex-direction: column; gap: 8px; font-size: 14.5px; }
.sp-head, .sp-row { display: flex; justify-content: space-between; gap: 12px; }
.sp-head { padding-bottom: 8px; border-bottom: 1px solid var(--border-strong); color: var(--text-2); }
.sp-head b { color: var(--text); font-size: 16px; }
.sp-row b { font-weight: 650; }

/* ---------- Accounts & sync ---------- */
.account-box { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 12px 14px; padding: 16px; border-radius: 24px; background: var(--surface-2); }
.account-box.guest { align-items: start; }
.account-actions { grid-column: 1 / -1; }
.account-box.guest { background: var(--sky-soft); color: var(--on-pastel); }
.account-box.guest .hint { color: rgba(28, 35, 64, .7); }
.account-box.guest .btn:not(.btn-primary) { border-color: rgba(28, 35, 64, .25); color: var(--on-pastel); }
.account-main { display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1; }
.account-main b { font-size: 16px; font-weight: 650; }
.account-main .quick-row { margin-top: 8px; }
.sync-line { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--text-2); }
.sync-line i { width: 8px; height: 8px; border-radius: 50%; background: #3FAE7C; flex: none; }
.sync-line.busy i { background: var(--orange-a); }
.sync-line.warn i { background: #E0A33A; }
.sync-line.bad i { background: var(--danger); }
.side-sync { padding: 2px 10px; font-size: 13px; display: flex; align-items: center; gap: 8px; }
.side-sync.link-btn { margin: 0; justify-content: flex-start; padding: 8px 10px; }
.install-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 18px; background: var(--butter-soft); color: var(--on-pastel); font-size: 14px; }
.install-row span { flex: 1; }
.form-error { padding: 10px 14px; border-radius: 14px; background: var(--danger-soft); color: var(--danger); font-size: 14px; font-weight: 500; }
.form-note { padding: 10px 14px; border-radius: 14px; background: var(--butter-soft); color: var(--on-pastel); font-size: 14px; }
.center-link { align-self: center; margin: -4px 0 0; }
.pw-field .input { padding-right: 52px; }
.pw-toggle { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; color: var(--text-3); }
.pw-toggle:hover { color: var(--text); background: var(--hover); }
.hb-avatar.dot-none::after { display: none; }
.hb-avatar.dot-ok::after { background: #5FD39B; }
.hb-avatar.dot-busy::after { background: #F8CF8A; }
.hb-avatar.dot-bad::after { background: #F0625A; }

/* ---------- Debts ---------- */
.debt-sum { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 8px; }
.debt-sum > div { border-radius: 20px; padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; min-width: 0; color: var(--on-pastel); }
.debt-sum > div:first-child { background: var(--mint-soft); }
.debt-sum > div:last-child { background: var(--pink-soft); }
.debt-sum .label { color: rgba(28, 35, 64, .7); }
.debt-sum .big { font-size: 24px; font-weight: 650; letter-spacing: -.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-family: var(--font-display); font-variation-settings: "SOFT" 100; }
.debt-sum .pos { color: #23704A; }
.debt-sum .neg { color: #B53A26; }
.item.settled .item-title, .item.settled .item-amt { color: var(--text-3); text-decoration: line-through; text-decoration-color: var(--border-strong); }
.more-toggle { display: flex; align-items: center; gap: 6px; font-size: 13.5px; font-weight: 500; color: var(--text-2); padding: 10px 0 0; }
.more-toggle:hover { color: var(--text); }

/* ---------- Shopping ---------- */
.card.list-card { background: var(--surface-2); box-shadow: none; }
.inline-add { display: flex; gap: 8px; margin-bottom: 8px; }
.inline-add .input { flex: 1; height: 46px; border-radius: 999px; padding: 0 18px; background: var(--surface); }
.inline-add .btn { width: 46px; height: 46px; padding: 0; flex: none; }
.shop-list { display: flex; flex-direction: column; margin: 0 -10px; }
.shop-item { display: flex; align-items: center; gap: 4px; padding-right: 6px; border-radius: 18px; transition: background .12s; }
.shop-item:hover { background: rgba(28, 35, 64, .04); }
[data-theme="dark"] .shop-item:hover { background: rgba(255, 255, 255, .04); }
.shop-toggle { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; padding: 9px 10px; text-align: left; }
.tick { width: 24px; height: 24px; border-radius: 50%; border: 1.75px solid var(--border-strong); display: grid; place-items: center; color: transparent; flex: none; background: var(--surface); transition: background .15s, border-color .15s; }
.shop-item.done .tick { background: var(--ink); border-color: var(--ink); color: var(--ink-text); }
.shop-name { flex: 1; min-width: 0; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.shop-item.done .shop-name { color: var(--text-3); text-decoration: line-through; }
.shop-more { display: block; padding: 8px 10px; font-size: 13.5px; color: var(--text-2); font-weight: 500; }
.shop-more:hover { color: var(--text); }
.shop-sep { height: 1px; background: var(--border-strong); opacity: .6; margin: 6px 10px; }
@media (hover: hover) {
  .shop-del { opacity: 0; transition: opacity .15s; }
  .shop-item:hover .shop-del, .shop-del:focus-visible { opacity: 1; }
}

/* ---------- Empty states ---------- */
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px; padding: 18px 12px 16px; color: var(--text-3); }
.empty > .blob, .empty > svg { margin-bottom: 8px; }
.empty-title { font-size: 15px; font-weight: 600; color: var(--text); }
.empty-sub { font-size: 13.5px; color: var(--text-2); max-width: 290px; }
.empty .btn, .empty .quick-row { margin-top: 12px; }
.empty .quick-row { justify-content: center; }
.muted-note { font-size: 13.5px; color: var(--text-3); padding: 8px 0 2px; }

/* ---------- Forms ---------- */
.form { display: flex; flex-direction: column; gap: 18px; }
.field { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.input, .select {
  width: 100%; height: 50px; padding: 0 18px;
  border-radius: 16px; border: 1.5px solid var(--border);
  background: var(--bg);
  font-size: 15px; outline: none;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.input::placeholder { color: var(--text-3); }
.input:focus, .select:focus { border-color: var(--text); background: var(--surface); box-shadow: 0 0 0 4px var(--focus); }
.input.invalid { border-color: var(--danger); box-shadow: 0 0 0 4px var(--danger-soft); }
input[type="date"].input { padding-right: 12px; }
input[type="number"].input { -moz-appearance: textfield; }
input[type="number"]::-webkit-inner-spin-button, input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.select {
  appearance: none; -webkit-appearance: none; padding-right: 40px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239A9CB0' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center;
}
.input-prefix, .input-suffix { position: relative; }
.input-prefix > span, .input-suffix > span { position: absolute; top: 50%; transform: translateY(-50%); color: var(--text-3); font-size: 15px; pointer-events: none; }
.input-prefix > span { left: 18px; }
.input-prefix > .input { padding-left: 42px; }
.input-suffix > span { right: 18px; }
.input-suffix > .input { padding-right: 60px; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
.hint { font-size: 13px; color: var(--text-3); line-height: 1.45; }
.center { text-align: center; }
.check-line { display: flex; align-items: center; gap: 10px; font-size: 14.5px; color: var(--text-2); cursor: pointer; }
.check-line input { width: 18px; height: 18px; accent-color: var(--ink); margin: 0; }

.amount-field { display: flex; align-items: baseline; gap: 8px; padding: 4px 0 14px; border-bottom: 1.5px solid var(--border); cursor: text; transition: border-color .15s; }
.amount-field:focus-within { border-color: var(--text); }
.amount-field.invalid { border-color: var(--danger); }
.amount-cur { font-size: 30px; font-weight: 600; color: var(--text-3); }
.amount-input { flex: 1; min-width: 0; border: 0; outline: none; background: transparent; padding: 0; font-size: 50px; line-height: 1.1; font-weight: 650; letter-spacing: -.02em; font-variant-numeric: tabular-nums lining-nums; }
.amount-input::placeholder { color: var(--border-strong); }

.seg { display: inline-flex; padding: 4px; gap: 2px; border-radius: 999px; background: var(--surface-2); }
.seg button { height: 40px; padding: 0 16px; border-radius: 999px; font-size: 14px; font-weight: 600; color: var(--text-2); display: inline-flex; align-items: center; justify-content: center; gap: 7px; transition: background .15s, color .15s; }
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--ink); color: var(--ink-text); }
.seg-full { display: flex; }
.seg-full button { flex: 1; }

.cat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.cat-opt { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 4px 10px; border-radius: 20px; border: 1.5px solid transparent; font-size: 12.5px; font-weight: 500; color: var(--text-2); text-align: center; transition: border-color .15s, background .15s, color .15s; }
.cat-opt:hover { background: var(--hover); }
.cat-opt.on { border-color: var(--text); color: var(--text); background: var(--surface-2); }
.cat-opt span:last-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }

.day-picker { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.day-btn { height: 44px; border-radius: 999px; border: 1.5px solid var(--border-strong); font-size: 13.5px; font-weight: 600; color: var(--text-2); text-align: center; transition: background .15s, color .15s, border-color .15s; }
.day-btn:hover { background: var(--hover); }
.day-btn.on { background: var(--ink); border-color: var(--ink); color: var(--ink-text); }
.swatches { display: flex; gap: 12px; flex-wrap: wrap; padding: 3px; }
.swatch { width: 34px; height: 34px; border-radius: 50%; background: var(--c); transition: box-shadow .15s; }
.swatch.on { box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--text); }
.quick-row { display: flex; gap: 6px; flex-wrap: wrap; }
.data-box { display: flex; flex-direction: column; gap: 12px; padding: 16px; border-radius: 22px; background: var(--surface-2); }

/* ---------- Sheet (modal) ---------- */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background: rgba(18, 22, 46, .42);
  opacity: 0; transition: opacity .2s ease;
}
.sheet-backdrop.open { opacity: 1; }
.sheet {
  width: 100%; max-width: 540px; max-height: calc(100dvh - 48px);
  overflow-y: auto; overscroll-behavior: contain;
  background: var(--surface);
  border-radius: 32px; padding: 26px 28px 28px;
  box-shadow: var(--shadow-lg);
  transform: translateY(12px);
  transition: transform .24s cubic-bezier(.2, .8, .2, 1);
}
.sheet-backdrop.open .sheet { transform: none; }
.sheet-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.sheet-head h2 { font-size: 28px; font-weight: 650; letter-spacing: -.02em; line-height: 1.15; }
.sheet-head .icon-btn { width: 42px; height: 42px; border: 1.5px solid var(--border-strong); margin: -2px -4px 0 0; }
.sheet-actions { display: flex; gap: 10px; justify-content: space-between; align-items: center; margin-top: 4px; }
.sheet-actions .btn-primary { margin-left: auto; min-width: 160px; }
.welcome-top { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; padding-top: 4px; }
.welcome-top h2 { font-size: 34px; font-weight: 650; letter-spacing: -.02em; line-height: 1.1; margin-top: 6px; }
.welcome-top p { color: var(--text-2); font-size: 15px; max-width: 380px; }
.welcome-art { display: flex; align-items: flex-end; justify-content: center; gap: 0; margin-bottom: 4px; }
.welcome-art .blob:nth-child(1) { transform: rotate(-8deg) translateY(4px); margin-right: -10px; }
.welcome-art .blob:nth-child(3) { transform: rotate(8deg) translateY(6px); margin-left: -10px; }
.welcome-art .blob:nth-child(2) { z-index: 1; }

/* ---------- Toast ---------- */
#toast-root { position: fixed; left: 0; right: 0; bottom: 26px; z-index: 60; display: flex; justify-content: center; pointer-events: none; padding: 0 16px; }
.toast {
  pointer-events: auto;
  display: flex; align-items: center; gap: 14px;
  max-width: 100%;
  background: var(--nav-bg); color: #FFF8EC;
  padding: 8px 8px 8px 20px; border-radius: 999px;
  font-size: 14.5px; font-weight: 500;
  box-shadow: var(--shadow-lg);
  opacity: 0; transform: translateY(8px);
  transition: opacity .2s ease, transform .2s ease;
}
.toast.no-undo { padding: 12px 22px; }
.toast.show { opacity: 1; transform: none; }
.toast button { font-weight: 600; color: #1C2340; background: #FFF8EC; padding: 7px 14px; border-radius: 999px; }
.toast button:hover { opacity: .9; }

/* ---------- Visibility helpers ---------- */
@media (min-width: 861px) { .only-mobile { display: none !important; } }

/* ---------- Responsive ---------- */
@media (max-width: 1180px) {
  .view { padding: 28px 28px 72px; }
  .cat-circles { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .cat-circles > :nth-child(n+5) { display: none; }
}
@media (max-width: 1020px) {
  .cols-2 { grid-template-columns: minmax(0, 1fr); }
  .reflow > .stack { display: contents; }
  .reflow .slot { order: var(--o, 0); min-width: 0; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { display: none; }
  .tabbar { display: grid; }
  .only-desktop { display: none !important; }
  .view { padding: calc(18px + env(safe-area-inset-top)) calc(16px + env(safe-area-inset-right)) calc(110px + env(safe-area-inset-bottom)) calc(16px + env(safe-area-inset-left)); }
  .page-head { margin: 6px 0 20px; align-items: center; }
  .page-head h1 { font-size: 36px; }
  #toast-root { bottom: calc(96px + env(safe-area-inset-bottom)); }
  /* Today: full-bleed blue hero with a cream sheet over it */
  .view.is-today { padding-top: 0; }
  .hero-blue { margin: 0 -16px; border-radius: 0; padding: calc(16px + env(safe-area-inset-top)) 18px 58px; }
  .today-body { position: relative; margin: -30px -16px 0; padding: 26px 16px 0; background: var(--bg); border-radius: 32px 32px 0 0; }
  .today-body::before { content: ""; position: absolute; top: 10px; left: 50%; width: 40px; height: 4px; margin-left: -20px; border-radius: 99px; background: var(--border-strong); }
}
@media (max-width: 640px) {
  .grid, .stack { gap: 14px; }
  .card { padding: 18px; border-radius: 24px; }
  .hb-title { font-size: 36px; }
  .hb-sub { font-size: 16px; }
  .mood-row { gap: 8px; margin-top: 18px; }
  .mood-chip { height: 44px; font-size: 15px; padding: 0 16px 0 7px; gap: 8px; }
  .duo { gap: 12px; }
  .ptile { padding: 16px; }
  .stat-value { font-size: 28px; }
  .cta { padding: 12px 16px 12px 12px; gap: 12px; border-radius: 26px; }
  .cta-star { width: 52px; height: 52px; }
  .cta-title { font-size: 19px; }
  .cta-sub { font-size: 13px; }
  .cat-circles { display: flex; overflow-x: auto; gap: 14px; margin: 0 -16px; padding: 0 16px 4px; scrollbar-width: none; }
  .cat-circles::-webkit-scrollbar { display: none; }
  .cat-circles > :nth-child(n+5) { display: flex; }
  .cat-circle { width: 86px; flex: none; }
  .cat-circle .blob { width: 78px; height: 78px; }
  .tip { min-height: 200px; padding: 20px; }
  .tip-title { font-size: 22px; }
  .tiles { gap: 12px; margin-bottom: 14px; }
  .tile-value { font-size: 24px; }
  .habit-summary { gap: 10px; margin-bottom: 14px; }
  .habit-summary .hs-item { flex-direction: column; align-items: stretch; gap: 8px; padding: 14px; }
  .hs-item > div { width: 100%; }
  .hs-item .ring { display: none; }
  .hs-item .stat-value { font-size: 24px; }
  .habit-card { grid-template-columns: auto minmax(0, 1fr) auto; row-gap: 14px; column-gap: 12px; padding: 16px; }
  .habit-card .streak-box { grid-row: 1; grid-column: 3; }
  .habit-card .week-dots { grid-row: 2; grid-column: 1 / -1; justify-content: space-between; }
  .wd { width: auto; flex: 1; }
  .tiles-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tiles-3 > :last-child { grid-column: 1 / -1; }
  .view-switch { width: 100%; margin: -6px 0 16px; }
  .view-switch a { flex: 1; }
  .quick-actions { gap: 10px; margin-bottom: 14px; }
  .qa { flex-direction: column; align-items: center; text-align: center; gap: 8px; padding: 14px 6px 12px; border-radius: 22px; }
  .qa > span:last-child { align-items: center; }
  .qa b { font-size: 14px; }
  .qa small { display: none; }
  .filter-row { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin-left: -18px; margin-right: -18px; padding: 0 18px; }
  .filter-row::-webkit-scrollbar { display: none; }
  .filter-row .chip { flex: none; }
  .page-head:has(.month-switch) { flex-direction: column; align-items: stretch; gap: 14px; }
  .page-head:has(.month-switch) .head-actions { width: 100%; }
  .month-switch { justify-content: space-between; flex: 1; }
  .month-label { min-width: 0; }
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .sheet-backdrop { align-items: flex-end; padding: 0; }
  .sheet {
    max-width: none; max-height: 92dvh;
    border-radius: 32px 32px 0 0;
    padding: 10px 20px calc(20px + env(safe-area-inset-bottom));
    transform: translateY(100%);
  }
  .sheet::before { content: ""; display: block; width: 40px; height: 4px; border-radius: 99px; background: var(--border-strong); margin: 0 auto 16px; }
  .sheet-head h2 { font-size: 25px; }
  .sheet-actions .btn-primary { flex: 1; min-width: 0; }
  .amount-input { font-size: 44px; }
  .cat-opt { padding: 10px 2px 8px; font-size: 12px; }
}
/* ---------- iPhone / installed-app polish ---------- */
/* Solid strip behind the status bar so content never scrolls under the clock. */
.statusbar-bg { position: fixed; top: 0; left: 0; right: 0; height: env(safe-area-inset-top); background: var(--bg); z-index: 40; pointer-events: none; transition: background-color .2s ease; }
.statusbar-bg.on-hero { background: transparent; }
button, a, .item[role="button"] { touch-action: manipulation; }
.tabbar, .nav, .btn, .chip, .mood-chip, .tab, .cat-opt, .day-btn { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
@media (max-width: 860px) {
  /* iOS zooms into any field smaller than 16px; keep them at 16px. */
  .input, .select, .inline-add .input { font-size: 16px; }
}
@media (display-mode: standalone) {
  html, body { overscroll-behavior-y: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
