@font-face { font-family: 'Jakarta'; src: url(fonts/pj-400.woff2) format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Jakarta'; src: url(fonts/pj-500.woff2) format('woff2'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'Jakarta'; src: url(fonts/pj-700.woff2) format('woff2'); font-weight: 700; font-display: swap; }
@font-face { font-family: 'Jakarta'; src: url(fonts/pj-800.woff2) format('woff2'); font-weight: 800; font-display: swap; }

/* Candy pop — light */
:root {
  --bg: #F8F5FF; --card: #FFFFFF; --card-2: #F1ECFF; --line: #E6E0F7;
  --text: #1F1640; --muted: #6F6890; --faint: #9A93B8;
  --violet: #7C5CFF; --violet-ink: #5B3BE6; --on-violet: #FFFFFF;
  --pink: #FF4FA3; --pink-ink: #C2185B; --pink-soft: #FFE3F1;
  --sky: #38BDF8; --sky-ink: #0369A1; --sky-soft: #DDF3FE;
  --yellow: #FFD23F; --yellow-ink: #7A5A00; --yellow-soft: #FFF5CC;
  --mint: #14B8A6; --mint-ink: #0F766E; --mint-soft: #D5F5F0;
  --violet-soft: #ECE6FF;
  --shadow: 0 1px 2px rgba(48, 28, 120, .06), 0 6px 20px rgba(48, 28, 120, .06);
  --radius: 18px;
  color-scheme: light;
}
/* Candy pop — dark */
:root[data-theme="dark"] {
  --bg: #120F24; --card: #1E1938; --card-2: #282247; --line: #2F2852;
  --text: #EFEAFF; --muted: #A49CC8; --faint: #7A729E;
  --violet: #9B82FF; --violet-ink: #C4B5FF; --on-violet: #120F24;
  --pink: #FF6BB3; --pink-ink: #FFB3D6; --pink-soft: #3A1B37;
  --sky: #4CC6FA; --sky-ink: #A8E3FD; --sky-soft: #14304A;
  --yellow: #FFD84F; --yellow-ink: #FFE89A; --yellow-soft: #3A3115;
  --mint: #2DD4BF; --mint-ink: #99F0E3; --mint-soft: #123A39;
  --violet-soft: #2C2456;
  --shadow: none;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: 'Jakarta', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg); color: var(--text); font-size: 16px; line-height: 1.5;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--violet-ink); }
:focus-visible { outline: 3px solid var(--violet); outline-offset: 2px; border-radius: 8px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* Layout */
.app { display: grid; grid-template-columns: minmax(0, 1fr); min-height: 100dvh; }
.app > div { min-width: 0; }
.side { display: none; }
.main { padding: 16px 16px 112px; max-width: 760px; width: 100%; margin: 0 auto; }
.top { display: flex; align-items: center; gap: 10px; padding: 14px 16px 4px; max-width: 760px; margin: 0 auto; width: 100%; }
.top h1 { font-size: 22px; font-weight: 800; margin: 0; flex: 1; letter-spacing: -.01em; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; }
.logo { width: 34px; height: 34px; border-radius: 11px; background: var(--violet); display: grid; place-items: center; color: var(--on-violet); flex: none; }
.iconbtn { width: 42px; height: 42px; border-radius: 14px; border: 1px solid var(--line); background: var(--card); display: grid; place-items: center; }
.iconbtn svg, .nav svg, .btn svg { width: 20px; height: 20px; }

.bottom {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--card); border-top: 1px solid var(--line);
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
}
.bottom a { display: grid; justify-items: center; gap: 2px; padding: 6px 0; border-radius: 12px; color: var(--muted); text-decoration: none; font-size: 11.5px; font-weight: 500; }
.bottom a svg { width: 22px; height: 22px; }
.bottom a[aria-current="page"] { color: var(--violet-ink); background: var(--violet-soft); }

@media (min-width: 900px) {
  .app { grid-template-columns: 252px minmax(0, 1fr); }
  .side {
    display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100dvh; overflow-y: auto;
    padding: 20px 14px; background: var(--card); border-right: 1px solid var(--line);
  }
  .side .brand { padding: 0 8px 14px; }
  .nav a { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 12px; color: var(--text); text-decoration: none; font-weight: 500; font-size: 15px; }
  .nav a:hover { background: var(--card-2); }
  .nav a[aria-current="page"] { background: var(--violet-soft); color: var(--violet-ink); }
  .side h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--faint); margin: 16px 12px 6px; font-weight: 700; }
  .monthlinks { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 0 4px; }
  .monthlinks a { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 10px; text-decoration: none; color: var(--text); font-size: 14px; }
  .monthlinks a:hover { background: var(--card-2); }
  .monthlinks a[aria-current="page"] { background: var(--card-2); font-weight: 700; }
  .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
  .side-foot { margin-top: auto; padding: 12px 8px 0; font-size: 13px; color: var(--muted); }
  .kbd { border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 6px; padding: 0 6px; font-size: 12px; }
  .bottom, .top .brand-mobile { display: none; }
  .main { padding: 8px 32px 48px; }
  .cal .d { aspect-ratio: auto; height: 54px; }
  .mtabs { flex-wrap: wrap; }
  .top { padding: 24px 32px 4px; }
}

/* Cards */
.card { background: var(--card); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); border: 1px solid var(--line); margin-top: 14px; }
.card h2 { font-size: 17px; margin: 0 0 4px; font-weight: 700; }
.card .sub { color: var(--muted); font-size: 14px; margin: 0; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.grid2 > .card { margin-top: 0; }
.row { display: flex; align-items: center; gap: 12px; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.list { list-style: none; margin: 8px 0 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-top: 1px solid var(--line); }
.list li:first-child { border-top: 0; }
.list .grow { flex: 1; min-width: 0; }
.list .name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list .meta { color: var(--muted); font-size: 13px; }
.amt { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.empty { color: var(--muted); font-size: 14px; padding: 6px 0 2px; }
.swatch { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; flex: none; font-weight: 800; }
.swatch svg { width: 19px; height: 19px; }

/* Hero */
.hero { background: var(--violet); color: var(--on-violet); border: 0; padding: 20px 20px 18px; position: relative; overflow: hidden; }
.hero::after { content: ''; position: absolute; width: 170px; height: 170px; right: -60px; top: -70px; border-radius: 50%; background: var(--pink); }
.hero::before { content: ''; position: absolute; width: 90px; height: 90px; right: 28px; bottom: -48px; border-radius: 50%; background: var(--yellow); }
.hero > * { position: relative; z-index: 1; }
.hero .label { font-size: 14px; font-weight: 600; opacity: .9; }
.hero .big { font-size: 46px; font-weight: 800; letter-spacing: -.02em; line-height: 1.1; margin: 4px 0 2px; font-variant-numeric: tabular-nums; }
.hero .small { font-size: 14px; opacity: .92; }
.hero.over { background: var(--pink); }
.hero.over::after { background: var(--violet); }
.hero.short { background: var(--card-2); color: var(--text); }
.hero.pinkhero { background: var(--pink); color: #fff; }
.hero.pinkhero::after { background: var(--violet); }
.hero .how { margin-top: 10px; background: rgba(255, 255, 255, .22); border: 0; color: inherit; border-radius: 999px; padding: 6px 12px; font-size: 13px; font-weight: 600; }
[data-theme="dark"] .hero .how { background: rgba(0, 0, 0, .18); }
.hero.short .how { background: var(--violet-soft); }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 14px; }
.stat { border-radius: 16px; padding: 12px; }
.stat b { display: block; font-size: 18px; font-variant-numeric: tabular-nums; }
.stat span { font-size: 12.5px; font-weight: 600; }
.s-pink { background: var(--pink-soft); color: var(--pink-ink); }
.s-sky { background: var(--sky-soft); color: var(--sky-ink); }
.s-yellow { background: var(--yellow-soft); color: var(--yellow-ink); }
.s-mint { background: var(--mint-soft); color: var(--mint-ink); }
.s-violet { background: var(--violet-soft); color: var(--violet-ink); }

.next { display: flex; align-items: center; gap: 12px; }
.next .swatch { background: var(--yellow); color: #3A2E00; }

.quick { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.chip { border: 1px solid var(--line); background: var(--card-2); border-radius: 999px; padding: 8px 14px; font-weight: 600; font-size: 14px; }
.chip:hover { border-color: var(--violet); }
.chip.on { background: var(--violet); color: var(--on-violet); border-color: var(--violet); }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 14px; padding: 11px 16px; font-weight: 700; background: var(--violet); color: var(--on-violet); text-decoration: none; }
.btn.soft { background: var(--violet-soft); color: var(--violet-ink); }
.btn.ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); }
.btn.pink { background: var(--pink); color: #fff; }
.btn.small { padding: 7px 12px; font-size: 14px; border-radius: 11px; }
.btn.block { width: 100%; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.fab { position: fixed; right: 18px; bottom: calc(84px + env(safe-area-inset-bottom)); z-index: 21; width: 58px; height: 58px; border-radius: 20px; border: 0; background: var(--pink); color: #fff; display: grid; place-items: center; box-shadow: 0 8px 24px rgba(255, 79, 163, .35); }
.fab svg { width: 26px; height: 26px; }
@media (min-width: 900px) { .fab { bottom: 28px; right: 28px; } }

/* Month tabs */
.mtabs { display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px 8px; scrollbar-width: none; }
.mtabs::-webkit-scrollbar { display: none; }
.mtab { flex: none; border-radius: 14px; padding: 8px 14px; font-weight: 700; text-decoration: none; border: 2px solid transparent; font-size: 14px; }
.mtab[aria-current="page"] { border-color: var(--text); }
.mhead { border-radius: var(--radius); padding: 18px 20px; margin-top: 8px; }
.mhead h2 { margin: 0; font-size: 26px; font-weight: 800; }
.mhead .stats { margin-top: 12px; }
.mhead .stat { background: rgba(255, 255, 255, .25); color: inherit; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-top: 10px; text-align: center; font-size: 13px; }
.cal .dow { color: var(--faint); font-weight: 700; font-size: 11.5px; padding-bottom: 2px; }
.cal .d { aspect-ratio: 1; border-radius: 10px; display: grid; place-items: center; position: relative; background: var(--card-2); font-variant-numeric: tabular-nums; }
.cal .d.today { outline: 2px solid var(--violet); }
.cal .d .pips { position: absolute; bottom: 4px; display: flex; gap: 2px; }
.cal .d .pips i { width: 5px; height: 5px; border-radius: 50%; }
.legend { display: flex; gap: 14px; font-size: 12.5px; color: var(--muted); margin-top: 8px; flex-wrap: wrap; }
.legend i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; }
.bar { height: 10px; border-radius: 999px; background: var(--card-2); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 999px; }

/* Pills */
.pill { font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }

/* Dialog */
dialog { border: 0; padding: 0; background: var(--card); color: var(--text); border-radius: 24px; width: min(460px, calc(100vw - 24px)); max-height: calc(100dvh - 32px); box-shadow: 0 20px 60px rgba(0, 0, 0, .3); }
dialog::backdrop { background: rgba(18, 15, 36, .5); }
@media (max-width: 899px) {
  dialog { margin: auto auto 0; width: 100vw; max-width: 100vw; border-radius: 24px 24px 0 0; padding-bottom: env(safe-area-inset-bottom); }
}
.dlg { padding: 20px 20px 18px; }
.dlg header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.dlg h2 { margin: 0; font-size: 20px; font-weight: 800; }
.field { display: grid; gap: 6px; margin-top: 12px; }
.field label, .field .lab { font-size: 14px; font-weight: 600; color: var(--muted); }
.field input, .field select, .field textarea { width: 100%; border: 1.5px solid var(--line); background: var(--bg); border-radius: 13px; padding: 11px 13px; font-size: 16px; }
.field input:focus, .field select:focus { border-color: var(--violet); outline: none; }
.field .hint { font-size: 13px; color: var(--faint); }
.money { font-size: 28px !important; font-weight: 800; }
.err { color: var(--pink-ink); font-size: 14px; font-weight: 600; min-height: 1em; margin-top: 8px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.breakdown { list-style: none; margin: 4px 0 0; padding: 0; }
.breakdown li { display: flex; justify-content: space-between; padding: 8px 0; border-top: 1px dashed var(--line); }
.breakdown li.total { font-weight: 800; border-top: 2px solid var(--text); }

/* Command palette */
.cmd input { width: 100%; border: 0; border-bottom: 1px solid var(--line); background: transparent; padding: 18px 20px; font-size: 18px; outline: none; }
.cmd ul { list-style: none; margin: 0; padding: 8px; max-height: 50vh; overflow-y: auto; }
.cmd li button { width: 100%; text-align: left; border: 0; background: transparent; padding: 11px 12px; border-radius: 12px; display: flex; gap: 10px; align-items: center; }
.cmd li button[aria-selected="true"] { background: var(--violet-soft); color: var(--violet-ink); }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(156px + env(safe-area-inset-bottom)); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 14px; font-weight: 600; font-size: 14px; z-index: 50; opacity: 0; transition: opacity .2s; pointer-events: none; display: flex; gap: 10px; align-items: center; }
.toast.show { opacity: 1; pointer-events: auto; }
.toast button { background: transparent; border: 0; color: var(--yellow); font-weight: 800; }
@media (min-width: 900px) { .toast { bottom: 32px; } }

.demo-bar { background: var(--yellow); color: #3A2E00; font-size: 14px; font-weight: 600; padding: 9px 16px; text-align: center; }
.demo-bar a { color: #3A2E00; font-weight: 800; }

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