
  :root {
    --bg: #f6f5f2;
    --surface: #ffffff;
    --ink: #1b1b1a;
    --muted: #6d6b66;
    --line: #e4e2dc;
    --neg: #c2352b;
    --pos: #1f7a50;
    --accent: #1d6b47;
    --accent-ink: #ffffff;
    --chip: #ecebe6;
    --raised: #ffffff;
    --focus: #3a6ff0;
    /* The same rounded system face the Mac apps use for money. */
    --display: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    /* Category hues, matched to the Mac apps' system colors. */
    --h-purple: #8e3fb8; --h-blue: #1f6fd1; --h-orange: #b85f0c; --h-indigo: #4d4bc4;
    --h-brown: #86663f; --h-pink: #c22f4e; --h-teal: #127c8f;
    color-scheme: light dark;
  }
  @media (prefers-color-scheme: dark) {
    :root {
      --bg: #121212;
      --surface: #1c1c1c;
      --ink: #f1f0ec;
      --muted: #a09e98;
      --line: #2c2c2b;
      --neg: #ff6b5e;
      --pos: #4cc98f;
      --accent: #4cc98f;
      --accent-ink: #0d2a1c;
      --chip: #262626;
      --raised: #3a3a39;
      --focus: #7aa2ff;
      --h-purple: #c98bff; --h-blue: #6aa8ff; --h-orange: #ffad5c; --h-indigo: #9997ff;
      --h-brown: #cfae86; --h-pink: #ff7d98; --h-teal: #5fd3e6;
    }
  }
  [data-hue] { --tint: var(--muted); }
  [data-hue="purple"] { --tint: var(--h-purple); }
  [data-hue="blue"] { --tint: var(--h-blue); }
  [data-hue="orange"] { --tint: var(--h-orange); }
  [data-hue="indigo"] { --tint: var(--h-indigo); }
  [data-hue="brown"] { --tint: var(--h-brown); }
  [data-hue="pink"] { --tint: var(--h-pink); }
  [data-hue="teal"] { --tint: var(--h-teal); }
  [data-hue="green"] { --tint: var(--pos); }
  * { box-sizing: border-box; }
  html, body { margin: 0; }
  body {
    background: var(--bg);
    color: var(--ink);
    font: 16px/1.4 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
    padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
    caret-color: var(--accent);
    accent-color: var(--accent);
    overflow-x: hidden;
  }
  ::selection { background: color-mix(in srgb, var(--accent) 28%, transparent); }
  main { max-width: 520px; margin: 0 auto; padding: 16px 16px 48px; }
  [hidden] { display: none !important; }
  .num { font-variant-numeric: tabular-nums; }
  .ic { width: 18px; height: 18px; flex: none; }

  /* ---------- top bar ---------- */
  .top { display: flex; justify-content: space-between; align-items: center; height: 32px; }
  .brand { display: inline-flex; align-items: center; gap: 8px; font: 700 17px/1 var(--display); letter-spacing: -0.01em; }
  .brand img { width: 26px; height: 26px; border-radius: 7px; }
  .sync { font-size: 13px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
  .sync::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--pos); transition: background-color 200ms; }
  .sync.off::before { background: var(--neg); }
  .sync.busy::before { background: var(--muted); animation: pulse 900ms ease-in-out infinite; }
  @keyframes pulse { 50% { transform: scale(.55); opacity: .5; } }

  /* ---------- hero ---------- */
  .hero { padding: 22px 0 18px; }
  .hero .label { color: var(--muted); font-size: 15px; font-weight: 500; }
  .balance {
    font: 700 clamp(50px, 16vw, 76px)/1.1 var(--display);
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.03em;
    margin-top: 2px;
    min-height: 1.1em;
    transition: color 500ms ease;
  }
  .balance.neg { color: var(--neg); }
  .odo { display: inline-flex; white-space: nowrap; }
  .odo-col {
    display: inline-block; height: 1.1em; overflow: hidden;
    -webkit-mask-image: linear-gradient(transparent, #000 16%, #000 84%, transparent);
            mask-image: linear-gradient(transparent, #000 16%, #000 84%, transparent);
  }
  .odo-strip { display: block; transition: transform 950ms var(--ease-out); }
  .odo-strip > span, .odo-sym { display: block; height: 1.1em; line-height: 1.1em; text-align: center; }
  .odo-sym { display: inline-block; }

  .hero-foot { display: grid; grid-template-columns: 1fr 84px; gap: 12px; align-items: center; margin-top: 2px; }
  .hero-foot .pk-btn { width: 84px; height: 90px; }
  .hero-foot .pk { transform: scale(.8); transform-origin: 0 0; }
  .hero .sub { color: var(--muted); font-size: 14px; }
  .forecast { margin-top: 10px; display: flex; flex-wrap: wrap; align-items: center; gap: 2px 8px; font-size: 15px; }
  .forecast .ic { width: 16px; height: 16px; color: var(--muted); }
  .forecast b { font-weight: 650; }
  .forecast .neg { color: var(--neg); }
  .forecast .detail { color: var(--muted); font-size: 13px; flex-basis: 100%; }

  /* ---------- the pocket character ---------- */
  .pk-btn { appearance: none; background: none; border: 0; padding: 0; margin: 0; cursor: pointer; border-radius: 18px; justify-self: end; touch-action: manipulation; }
  .pk { position: relative; width: 104px; height: 112px; }
  .pk-slot { position: absolute; inset: 0; perspective: 520px; }
  .coin { position: absolute; left: 41px; top: 2px; width: 50px; height: 50px; transform-style: preserve-3d; }
  .coin-body { position: absolute; inset: 0; transform-style: preserve-3d; animation: coin-idle 3.6s ease-in-out infinite alternate; }
  .pk.paused .coin-body, .pk.paused .sweat, .pk.paused .zz span { animation-play-state: paused; }
  .coin-fly .coin-body { animation: none; }
  @keyframes coin-idle { from { transform: rotateY(-28deg) translateY(0); } to { transform: rotateY(28deg) translateY(-2px); } }
  .coin-face {
    position: absolute; inset: 0; border-radius: 50%;
    display: grid; place-items: center;
    backface-visibility: hidden; -webkit-backface-visibility: hidden;
    background: radial-gradient(circle at 34% 28%, #fff4c4 0 7%, #ffd866 32%, #eba83a 76%, #d48e2a);
    box-shadow: inset 0 0 0 3px rgb(176 112 26 / .45), inset 0 -5px 7px rgb(150 90 10 / .25);
    font: 800 27px/1 var(--display); color: #a86a16;
    transform: translateZ(3px);
  }
  .coin-face.back { transform: rotateY(180deg) translateZ(3px); }
  .coin-edge { position: absolute; inset: 0; border-radius: 50%; background: #c98a22; }
  .pk-front {
    position: absolute; left: 4px; top: 38px; width: 96px; height: 74px; overflow: visible;
    transform-origin: 50% 100%;
    filter: drop-shadow(0 6px 7px rgb(0 0 0 / .13));
  }
  .pk .part { opacity: 0; transition: opacity 140ms ease; }
  .pk[data-face="happy"]   :is(.e-dot, .m-smile),
  .pk[data-face="worried"] :is(.e-dot, .m-wavy, .brows, .sweat),
  .pk[data-face="joy"]     :is(.e-joy, .m-grin),
  .pk[data-face="oof"]     :is(.e-oof, .m-o),
  .pk[data-face="hope"]    :is(.e-star, .m-smile),
  .pk[data-face="sleep"]   :is(.e-sleep, .m-sleep) { opacity: 1; }
  .look { transition: transform 260ms var(--ease-out); }
  .blink { transform-box: fill-box; transform-origin: center; }
  .pk[data-face="worried"] .sweat { animation: sweat 2.6s ease-in-out infinite; }
  @keyframes sweat { 0%, 30% { transform: translateY(0); } 70% { transform: translateY(18px); opacity: 1; } 100% { transform: translateY(26px); opacity: 0; } }
  .pk-fx { position: absolute; inset: 0; pointer-events: none; }
  .bubble {
    position: absolute; right: -2px; bottom: calc(100% + 2px);
    white-space: nowrap; pointer-events: none;
    background: var(--surface); color: var(--ink);
    border: 1px solid var(--line); border-radius: 14px;
    padding: 6px 11px; font-size: 13px; font-weight: 650;
    box-shadow: 0 8px 18px rgb(0 0 0 / .12);
    transform-origin: 75% 100%;
  }
  .bubble::after {
    content: ""; position: absolute; right: 30px; bottom: -6px; width: 10px; height: 10px;
    background: var(--surface); border-right: 1px solid var(--line); border-bottom: 1px solid var(--line);
    transform: rotate(45deg);
  }
  .float-amt { position: absolute; left: 4px; top: 40px; font: 750 15px/1 var(--display); white-space: nowrap; color: var(--pos); }
  .float-amt.neg { color: var(--neg); }
  .mini-coin {
    position: absolute; left: 58px; top: 20px; width: 14px; height: 14px; border-radius: 50%;
    background: radial-gradient(circle at 35% 30%, #fff4c4 0 10%, #ffd866 40%, #e2a136);
    box-shadow: inset 0 0 0 1.5px rgb(176 112 26 / .5);
  }
  .zz { position: absolute; right: 2px; top: 6px; font: 700 15px/1 var(--display); color: var(--muted); }
  .zz span { position: absolute; opacity: 0; animation: zz 3s ease-out infinite; }
  .zz span:nth-child(2) { animation-delay: 1s; font-size: 12px; }
  .zz span:nth-child(3) { animation-delay: 2s; font-size: 10px; }
  @keyframes zz { 0% { opacity: 0; transform: translate(0, 10px); } 25% { opacity: 1; } 100% { opacity: 0; transform: translate(14px, -22px); } }

  /* ---------- flying amount chip ---------- */
  .fly { position: fixed; left: 0; top: 0; z-index: 60; pointer-events: none; }
  .fly-chip {
    display: inline-block; padding: 6px 12px; border-radius: 999px;
    background: var(--surface); border: 1px solid var(--line);
    box-shadow: 0 10px 22px rgb(0 0 0 / .16);
    font: 750 15px/1.2 var(--display); white-space: nowrap; color: var(--ink);
  }
  .fly-chip.pos { color: var(--pos); }

  /* ---------- form ---------- */
  .card { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 14px; transition: box-shadow 260ms ease, border-color 260ms ease; }
  .card.is-editing { border-color: color-mix(in srgb, var(--focus) 55%, var(--line)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 16%, transparent); }
  .card-title { font: 600 15px/1.2 var(--display); color: var(--ink); margin: 0 0 10px 2px; }
  .composer { padding: 14px 14px 6px; }
  .composer-top { display: flex; flex-direction: column; }
  .amount-field {
    display: flex; align-items: baseline; gap: 4px; margin-top: 12px; padding: 0 4px;
    font: 600 40px/1.15 var(--display); letter-spacing: -0.02em; cursor: text;
  }
  .amount-field .cur { color: var(--muted); opacity: .7; transition: color 200ms ease, opacity 200ms ease; }
  .amount-field input {
    font: inherit; letter-spacing: inherit; font-variant-numeric: tabular-nums;
    background: transparent; border: 0; border-radius: 0; padding: 0; min-height: 0;
  }
  .amount-field input::placeholder { color: var(--muted); opacity: .45; }
  .amount-field input:focus { background: transparent; }
  .amount-field input { color: inherit; transition: color 200ms ease; }
  .amount-field:focus-within .cur { opacity: 1; }
  .composer:has(.seg[data-sign="1"]) .amount-field { color: var(--pos); }
  .composer:has(.seg[data-sign="1"]) .amount-field .cur { color: var(--pos); }
  .details-btn {
    appearance: none; border: 0; background: none; font: inherit; color: var(--ink); cursor: pointer;
    display: flex; align-items: center; gap: 8px; width: calc(100% + 28px); margin: 10px -14px 0; padding: 12px 14px;
    border-top: 1px solid var(--line); font-size: 15px; text-align: left;
  }
  .details-btn::after {
    content: ""; width: 7px; height: 7px; margin: 0 4px 3px 2px; flex: none;
    border-right: 1.75px solid var(--muted); border-bottom: 1.75px solid var(--muted);
    transform: rotate(45deg); transition: transform 300ms var(--ease-out);
  }
  .details-btn[aria-expanded="true"]::after { transform: translateY(3px) rotate(-135deg); }
  .details-sum { margin-left: auto; color: var(--muted); }
  .details-in { padding: 2px 0 12px; }
  .details-in .chips { margin-top: 0; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; }
  .details-in .chips button { padding: 7px 2px; white-space: nowrap; }
  .detail-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; margin-top: 12px; }
  .seg { position: relative; display: grid; grid-template-columns: 1fr 1fr; background: var(--chip); border-radius: 11px; padding: 3px; gap: 3px; }
  .seg::before {
    content: ""; position: absolute; top: 3px; bottom: 3px; left: 3px; width: calc(50% - 4.5px);
    border-radius: 8px; background: var(--raised); box-shadow: 0 1px 3px rgb(0 0 0 / .14);
    transition: transform 320ms var(--ease-out), background-color 320ms ease;
  }
  .seg[data-sign="1"]::before { transform: translateX(calc(100% + 3px)); background: color-mix(in srgb, var(--pos) 15%, var(--raised)); }
  .seg button { position: relative; z-index: 1; appearance: none; border: 0; background: transparent; color: var(--muted); font: inherit; font-size: 15px; font-weight: 600; padding: 7px 8px; border-radius: 8px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px; transition: color 200ms ease; }
  .seg button .ic { width: 16px; height: 16px; }
  .seg button[aria-pressed="true"] { color: var(--ink); }
  .seg button[data-sign="1"][aria-pressed="true"] { color: var(--pos); }
  .chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
  .chips button { appearance: none; flex: none; border: 1px solid transparent; background: var(--chip); color: var(--ink); font: inherit; font-size: 14px; padding: 6px 12px; border-radius: 999px; cursor: pointer; transition: background-color 180ms ease, color 180ms ease, transform 120ms ease; }
  .chips button:active { transform: scale(.94); }
  .chips button[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
  .fields { display: grid; grid-template-columns: 120px 1fr; gap: 8px; margin-top: 10px; }
  .fields2 { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin-top: 8px; align-items: end; }
  .composer .fields2 { margin-top: 6px; }
  .cap { display: block; font-size: 12px; color: var(--muted); margin: 0 0 4px 4px; }
  input {
    width: 100%; min-width: 0; font: inherit; font-size: 17px; color: var(--ink);
    background: var(--bg); border: 1px solid transparent; border-radius: 11px; padding: 11px 12px;
    transition: border-color 160ms ease, background-color 160ms ease;
  }
  input::placeholder { color: var(--muted); opacity: 1; }
  input:focus { outline: none; border-color: var(--focus); background: var(--surface); }
  input[type="date"] { font-size: 16px; min-height: 46px; }
  .btn {
    appearance: none; border: 0; font: inherit; font-weight: 650; font-size: 16px; border-radius: 11px;
    padding: 11px 18px; min-height: 46px; cursor: pointer; background: var(--accent); color: var(--accent-ink);
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    transition: transform 120ms ease, background-color 200ms ease, opacity 200ms ease;
  }
  .btn:active:not(:disabled) { transform: scale(.96); }
  .btn:disabled { opacity: .55; cursor: default; }
  .btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
  .btn.danger { background: transparent; color: var(--neg); border: 1px solid var(--line); }
  .btn .ic { width: 22px; height: 22px; }
  .check-draw path { stroke-dasharray: 24; stroke-dashoffset: 24; animation: draw 380ms var(--ease-out) 40ms forwards; }
  @keyframes draw { to { stroke-dashoffset: 0; } }
  .reveal { display: grid; grid-template-rows: 0fr; opacity: 0; transition: grid-template-rows 320ms var(--ease-out), opacity 220ms ease; }
  .reveal.open { grid-template-rows: 1fr; opacity: 1; }
  .reveal > div { min-height: 0; overflow: hidden; padding: 0 4px; margin: 0 -4px; }
  .reveal > div > * { margin-block: 4px; } /* room for focus rings, inside the clipped area */
  .times { padding-top: 4px; }
  .edit-actions { display: flex; gap: 8px; padding-top: 4px; }
  .edit-actions .btn { flex: 1; }
  .hint { color: var(--muted); font-size: 13px; margin: 4px 2px 0; }
  .form-msg { color: var(--neg); font-size: 14px; margin: 8px 2px 0; }
  .form-msg:empty { display: none; }
  :focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
  .shake { animation: shake 360ms ease; }
  @keyframes shake { 20%, 60% { transform: translateX(-5px); } 40%, 80% { transform: translateX(5px); } }

  /* ---------- lists ---------- */
  .section { margin-top: 28px; }
  .section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin: 0 2px 8px; }
  .section-head h2 { font: 650 19px/1.25 var(--display); letter-spacing: -0.01em; color: var(--ink); margin: 0; }
  .section-head .meta { font-size: 13px; color: var(--muted); text-align: right; }
  .day { margin-top: 18px; }
  .day:first-child { margin-top: 0; }
  .day-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin: 0 4px 6px; }
  .day h3 { font-size: 13px; font-weight: 600; color: var(--muted); margin: 0; }
  .day-net { font-size: 13px; color: var(--muted); }
  .day-net.pos { color: var(--pos); }
  .rows { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; overflow: hidden; }
  .tx {
    position: relative;
    display: grid; grid-template-columns: 32px 1fr auto; column-gap: 12px; row-gap: 1px; align-items: center;
    width: 100%; text-align: left; appearance: none; background: none; border: 0;
    padding: 10px 14px; font: inherit; color: inherit;
    transition: background-color 160ms ease;
  }
  .tx::before { content: ""; position: absolute; top: 0; right: 0; left: 58px; border-top: 1px solid var(--line); }
  button.tx { cursor: pointer; }
  .tx:first-child::before { display: none; }
  button.tx:hover { background: color-mix(in srgb, var(--bg) 70%, transparent); }
  button.tx:active { background: var(--bg); }
  .tx.editing { background: color-mix(in srgb, var(--focus) 12%, transparent); }
  .ico {
    width: 32px; height: 32px; border-radius: 9px; flex: none;
    display: grid; place-items: center; color: var(--tint, var(--muted));
    background: color-mix(in srgb, var(--tint, var(--muted)) 14%, transparent);
  }
  .ico .ic { width: 17px; height: 17px; }
  .tx .ico { grid-row: span 2; }
  .tx .what { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .tx .amt { font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
  .tx .pos { color: var(--pos); }
  .tx .note { grid-column: 2; font-size: 12px; color: var(--muted); }
  .tx .note.right { grid-column: 3; text-align: right; }
  .tx .note.neg { color: var(--neg); }
  .tx .note .ic { width: 12px; height: 12px; vertical-align: -1px; margin-right: 3px; }
  .tx.fresh { animation: row-in 900ms var(--ease-out) both; }
  @keyframes row-in {
    0% { clip-path: inset(0 100% 0 0); background-color: color-mix(in srgb, var(--accent) 18%, transparent); }
    45% { clip-path: inset(0 0 0 0); background-color: color-mix(in srgb, var(--accent) 18%, transparent); }
    100% { clip-path: inset(0 0 0 0); background-color: transparent; }
  }
  .empty { color: var(--muted); text-align: center; padding: 24px 0; font-size: 14px; }

  /* ---------- lock ---------- */
  .lock { padding-top: 12vh; }
  .lock .pk-sleep { margin: 0 0 18px -6px; transform: scale(1.25); transform-origin: left bottom; }
  .lock h1 { font: 700 34px/1.1 var(--display); letter-spacing: -0.025em; margin: 26px 0 18px; }
  .lock p { color: var(--muted); margin: 0 0 18px; }
  .lock input { background: var(--surface); border-color: var(--line); }
  .lock input:focus { border-color: var(--focus); }

  .foot { margin-top: 36px; text-align: center; }
  .link { appearance: none; background: none; border: 0; color: var(--muted); font: inherit; font-size: 13px; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; display: inline-flex; align-items: center; gap: 5px; }
  .link .ic { width: 14px; height: 14px; }

  @media (prefers-reduced-motion: reduce) {
    .coin-body, .sweat, .zz span, .sync.busy::before { animation: none !important; }
    .odo-strip { transition: none; }
    .seg::before { transition: background-color 200ms ease; }
    .look { transition: none; }
    .reveal { transition: opacity 200ms ease; }
    .tx.fresh { animation-name: row-flash; }
    @keyframes row-flash { from { background-color: color-mix(in srgb, var(--accent) 18%, transparent); } to { background-color: transparent; } }
    .shake { animation: none; }
  }

  /* =================== v2 =================== */
  .top-right { display: flex; align-items: center; gap: 6px; }
  .icon-btn { appearance: none; border: 0; background: transparent; color: var(--muted); width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; cursor: pointer; transition: background-color 160ms ease, color 160ms ease; }
  .icon-btn:hover { background: var(--chip); color: var(--ink); }
  .icon-btn .ic { width: 20px; height: 20px; }

  .runway { margin-top: 10px; display: flex; flex-wrap: wrap; align-items: center; gap: 2px 7px; font-size: 15px; }
  .runway .ic { width: 16px; height: 16px; color: var(--muted); }
  .runway b { font-weight: 650; }
  .runway.warn b { color: var(--neg); }

  /* quick add */
  .quick { display: flex; gap: 8px; overflow-x: auto; margin: 0 -16px 12px; padding: 2px 16px 4px; scrollbar-width: none; scroll-snap-type: x proximity; scroll-padding-inline: 16px; }
  .quick::-webkit-scrollbar { display: none; }
  .quick:empty { display: none; }
  .qchip { flex: none; appearance: none; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; font-size: 14px; font-weight: 600; padding: 6px 12px 6px 6px; border-radius: 999px; display: inline-flex; align-items: center; gap: 8px; cursor: pointer; scroll-snap-align: start; transition: transform 120ms ease, border-color 160ms ease; }
  .qchip:hover { border-color: color-mix(in srgb, var(--ink) 25%, var(--line)); }
  .qchip:active { transform: scale(.95); }
  .qchip .qi { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; color: var(--tint); background: color-mix(in srgb, var(--tint) 14%, transparent); }
  .qchip .qi .ic { width: 15px; height: 15px; }
  .qchip .qa { color: var(--muted); font-weight: 500; font-variant-numeric: tabular-nums; }
  .qchip kbd { font: 500 11px/1 ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--muted); border: 1px solid var(--line); border-radius: 4px; padding: 2px 4px; }
  @media (hover: none) { .qchip kbd { display: none; } }

  /* category picker */
  .cats { display: flex; gap: 6px; overflow-x: auto; margin: 10px -14px 0; padding: 2px 14px; scrollbar-width: none;
    -webkit-mask-image: linear-gradient(90deg, transparent, #000 14px, #000 calc(100% - 24px), transparent);
            mask-image: linear-gradient(90deg, transparent, #000 14px, #000 calc(100% - 24px), transparent); }
  .cats::-webkit-scrollbar { display: none; }
  .cat { flex: none; appearance: none; border: 1px solid var(--line); background: transparent; color: var(--ink); font: inherit; font-size: 13px; padding: 5px 10px 5px 7px; border-radius: 999px; display: inline-flex; align-items: center; gap: 5px; cursor: pointer; transition: background-color 160ms ease, color 160ms ease, border-color 160ms ease, transform 120ms ease; }
  .cat:active { transform: scale(.95); }
  .cat .ic { width: 15px; height: 15px; color: var(--tint); transition: color 160ms ease; }
  .cat[aria-pressed="true"] { background: color-mix(in srgb, var(--tint) 14%, var(--surface)); color: var(--tint); border-color: color-mix(in srgb, var(--tint) 45%, transparent); font-weight: 600; }

  .checks { display: flex; flex-direction: column; gap: 8px; padding-top: 10px; }
  .check { display: flex; align-items: center; gap: 9px; font-size: 14px; color: var(--ink); cursor: pointer; }
  .check input { width: 18px; height: 18px; margin: 0; padding: 0; flex: none; accent-color: var(--accent); }
  .check[hidden] { display: none !important; }

  /* tabs */
  .tabs { position: sticky; top: 0; z-index: 5; display: grid; grid-template-columns: repeat(3, 1fr); margin: 28px -16px 0; padding: 4px 16px 0; background: var(--bg); border-bottom: 1px solid var(--line); }
  .tab { appearance: none; border: 0; background: none; font: inherit; font-size: 15px; font-weight: 600; color: var(--muted); padding: 10px 0 12px; cursor: pointer; display: inline-flex; justify-content: center; align-items: center; gap: 6px; transition: color 200ms ease; }
  .tab[aria-selected="true"] { color: var(--ink); }
  .tab .count { min-width: 18px; height: 18px; border-radius: 9px; padding: 0 5px; background: var(--accent); color: var(--accent-ink); font-size: 11px; font-weight: 700; display: inline-grid; place-items: center; }
  .tab-ink { position: absolute; left: 16px; bottom: -1px; height: 2px; width: calc((100% - 32px) / 3); background: var(--ink); border-radius: 2px; transition: transform 340ms var(--ease-out); }
  .panel .section:first-child { margin-top: 18px; }

  /* filter chip over history */
  .filter { display: inline-flex; align-items: center; gap: 6px; margin: 0 2px 10px; padding: 4px 4px 4px 11px; border-radius: 999px; background: var(--ink); color: var(--bg); font-size: 13px; font-weight: 600; }
  .filter button { appearance: none; border: 0; background: transparent; color: inherit; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; cursor: pointer; }
  .filter .ic { width: 14px; height: 14px; }

  /* rows with inline actions (Got it / Skip) */
  .occ > .tx::before { display: block; }
  .occ:first-child > .tx::before { display: none; }
  .occ-in { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 0 14px 12px 58px; }
  .occ-in .cap { margin-left: 2px; }
  .occ-in .acts { grid-column: 1 / -1; display: flex; gap: 8px; }
  .occ-in .btn { flex: 1; min-height: 40px; padding: 8px 12px; font-size: 15px; }
  .occ-in input { font-size: 16px; padding: 9px 10px; }
  .tag { font-size: 11px; font-weight: 600; color: var(--muted); border: 1px solid var(--line); border-radius: 6px; padding: 0 5px; margin-left: 6px; vertical-align: 1px; white-space: nowrap; }
  .tag.due { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
  .tx.paused .what, .tx.paused .amt { opacity: .55; }
  .more { appearance: none; border: 0; border-top: 1px solid var(--line); background: none; width: 100%; padding: 11px; font: inherit; font-size: 14px; font-weight: 600; color: var(--muted); cursor: pointer; }
  .more:hover { color: var(--ink); }

  /* plan: range + chart */
  .plan-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
  .plan-title { font: 700 22px/1.2 var(--display); letter-spacing: -0.01em; margin: 0; }
  .plan-title.warn { color: var(--neg); }
  .plan-sub { color: var(--muted); font-size: 14px; margin: 4px 0 0; }
  .range { flex: none; display: inline-grid; grid-auto-flow: column; background: var(--chip); border-radius: 10px; padding: 3px; gap: 2px; }
  .range button { appearance: none; border: 0; background: none; font: inherit; font-size: 13px; font-weight: 650; color: var(--muted); padding: 5px 9px; border-radius: 7px; cursor: pointer; transition: background-color 160ms ease, color 160ms ease; }
  .range button[aria-pressed="true"] { background: var(--raised); color: var(--ink); box-shadow: 0 1px 2px rgb(0 0 0 / .12); }
  .chart { position: relative; margin-top: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 10px 8px 6px; transition: opacity 200ms ease; }
  .chart.loading { opacity: .55; }
  .chart svg { display: block; width: 100%; height: 176px; overflow: visible; touch-action: pan-y; }
  .chart svg:focus-visible { outline: 2px solid var(--focus); outline-offset: 4px; border-radius: 12px; }
  .chart .tick { font-size: 11px; fill: var(--muted); font-variant-numeric: tabular-nums; }
  .chart .grid { stroke: var(--line); stroke-width: 1; }
  .chart .zero { stroke: var(--muted); stroke-width: 1; opacity: .7; }
  .chart .line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
  .chart .line.draw { stroke-dasharray: var(--len); stroke-dashoffset: var(--len); animation: draw 1100ms var(--ease-out) 80ms forwards; }
  .chart .wash { fill: var(--accent); opacity: .1; }
  .chart .redzone { fill: var(--neg); opacity: .06; }
  .chart .dot { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }
  .chart .dot.neg { fill: var(--neg); }
  .chart .endlabel { font-size: 12px; font-weight: 650; fill: var(--ink); font-variant-numeric: tabular-nums; paint-order: stroke; stroke: var(--surface); stroke-width: 4px; stroke-linejoin: round; }
  .chart .xhair { stroke: var(--muted); stroke-width: 1; }
  .tip { position: absolute; top: 0; left: 0; pointer-events: none; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 7px 10px; box-shadow: 0 8px 18px rgb(0 0 0 / .12); font-size: 12px; white-space: nowrap; z-index: 2; }
  .tip b { display: block; font-size: 15px; font-variant-numeric: tabular-nums; }
  .tip span { display: block; color: var(--muted); }

  /* insights */
  .scope { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; }
  .month-nav { display: flex; align-items: center; gap: 2px; }
  .month-nav b { font: 650 17px/1 var(--display); min-width: 120px; text-align: center; }
  .month-nav .icon-btn:disabled { opacity: .3; cursor: default; background: none; }
  .stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 14px; }
  .stat { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 10px 10px 10px 12px; min-width: 0; }
  .stat .k { font-size: 12px; color: var(--muted); }
  .stat .v { font: 650 19px/1.25 var(--display); margin-top: 2px; white-space: nowrap; overflow: hidden; font-variant-numeric: tabular-nums; }
  .stat .v.neg { color: var(--neg); }
  .delta { font-size: 13px; color: var(--muted); margin: 10px 2px 0; display: flex; align-items: center; gap: 6px; }
  .delta .ic { width: 15px; height: 15px; }
  .bars { margin-top: 14px; }
  .bar-row { display: grid; grid-template-columns: 1fr auto; gap: 6px 10px; align-items: center; width: 100%; appearance: none; background: none; border: 0; border-top: 1px solid var(--line); padding: 11px 14px; font: inherit; color: inherit; text-align: left; cursor: pointer; transition: background-color 160ms ease; }
  .bar-row:first-child { border-top: 0; }
  .bar-row:hover { background: color-mix(in srgb, var(--bg) 70%, transparent); }
  .bar-name { display: flex; align-items: center; gap: 8px; font-weight: 600; min-width: 0; }
  .bar-name { gap: 10px; }
  .bar-name .ico { width: 28px; height: 28px; border-radius: 8px; }
  .bar-name .ico .ic { width: 15px; height: 15px; }
  .bar-val { font-weight: 650; font-variant-numeric: tabular-nums; }
  .bar-track { grid-column: 1 / -1; height: 10px; }
  .bar-fill { height: 8px; min-width: 3px; background: var(--tint); border-radius: 4px; transform-origin: left center; animation: grow 800ms var(--ease-out) both; }
  .bar-meta { grid-column: 1 / -1; font-size: 12px; color: var(--muted); margin-top: -2px; }
  @keyframes grow { from { transform: scaleX(0); } }

  /* toast with undo */
  .toast { position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom)); z-index: 70; display: flex; align-items: center; gap: 14px; background: var(--ink); color: var(--bg); padding: 10px 10px 10px 16px; border-radius: 14px; box-shadow: 0 12px 30px rgb(0 0 0 / .25); font-size: 14px; font-weight: 550; max-width: calc(100vw - 32px); transform: translate(-50%, calc(100% + 40px)); transition: transform 380ms var(--ease-out); }
  .toast.show { transform: translate(-50%, 0); }
  .toast button { appearance: none; border: 0; background: color-mix(in srgb, var(--bg) 20%, transparent); color: var(--bg); font: inherit; font-weight: 700; padding: 7px 12px; border-radius: 9px; cursor: pointer; }
  .toast button:empty { display: none; }

  /* sheets */
  dialog.sheet { border: 0; padding: 0; background: var(--bg); color: var(--ink); width: min(520px, calc(100vw - 32px)); max-height: 88vh; border-radius: 22px; box-shadow: 0 24px 60px rgb(0 0 0 / .3); }
  dialog.sheet::backdrop { background: rgb(0 0 0 / .38); }
  @media (max-width: 560px) {
    dialog.sheet { margin: auto 0 0; width: 100vw; max-width: 100vw; border-radius: 22px 22px 0 0; }
  }
  dialog.sheet[open] { animation: sheet-in 380ms var(--ease-out); }
  @keyframes sheet-in { from { transform: translateY(28px); opacity: 0; } }
  .sheet-in { padding: 18px 16px calc(24px + env(safe-area-inset-bottom)); overflow: auto; max-height: 88vh; }
  .sheet-head { display: flex; justify-content: space-between; align-items: center; }
  .sheet-head h2 { font: 700 22px/1.2 var(--display); margin: 0; }
  .sheet h3 { font: 650 17px/1.25 var(--display); color: var(--ink); margin: 24px 2px 4px; }
  .sheet .lead { color: var(--muted); font-size: 14px; margin: 0 2px 10px; }
  .code { font: 750 46px/1 var(--display); letter-spacing: .1em; text-align: center; padding: 18px 0 8px; font-variant-numeric: tabular-nums; }
  .code-note { text-align: center; color: var(--muted); font-size: 13px; margin: 0 0 12px; }
  .dev-row { display: grid; grid-template-columns: 32px 1fr auto; gap: 2px 12px; align-items: center; padding: 10px 14px; border-top: 1px solid var(--line); }
  .dev-row:first-child { border-top: 0; }
  .dev-row .ico { grid-row: span 2; }
  .dev-row .note { font-size: 12px; color: var(--muted); }
  .dev-row .icon-btn { grid-row: span 2; }
  .preset-row { display: grid; grid-template-columns: 26px 1fr 92px 36px; gap: 8px; align-items: center; padding: 8px 10px 8px 14px; border-top: 1px solid var(--line); }
  .preset-row:first-child { border-top: 0; }
  .preset-row .ic { width: 18px; height: 18px; color: var(--muted); }
  .preset-row input { padding: 8px 10px; font-size: 15px; background: var(--bg); }
  .kbd-list { display: grid; grid-template-columns: auto 1fr; gap: 10px 14px; font-size: 14px; align-items: center; }
  .kbd-list kbd { font: 600 12px/1 ui-monospace, SFMono-Regular, Menlo, monospace; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 6px; padding: 4px 7px; background: var(--surface); justify-self: start; }
  .btn.wide { width: 100%; }
  .btn.subtle { background: var(--chip); color: var(--ink); }
  .foot-hint { margin-top: 10px; color: var(--muted); font-size: 12px; text-align: center; }
  @media (hover: none) { .foot-hint { display: none; } }

  /* lock / pairing */
  #pairCode { font: 700 26px/1 var(--display); letter-spacing: .25em; text-align: center; }
  #pairForm .fields2 { align-items: stretch; }
  .alt { margin-top: 22px; color: var(--muted); font-size: 14px; }
  .alt summary { cursor: pointer; width: fit-content; }
  .alt form { margin-top: 10px; }
  .alt form > input { margin-bottom: 0; }
  .alt .fine-print a { color: var(--accent); }

  @media (prefers-reduced-motion: reduce) {
    .bar-fill, dialog.sheet[open] { animation: none; }
    .chart .line.draw { animation: none; stroke-dasharray: none; }
    .toast { transition: opacity 200ms ease; opacity: 0; transform: translate(-50%, 0); }
    .toast.show { opacity: 1; }
    .tab-ink { transition: none; }
  }
  .toast:not(.show) { pointer-events: none; }
  .section-head { flex-wrap: wrap; }
  .bar-track, .bar-fill { display: block; }
  .bar-track { height: 8px; background: color-mix(in srgb, var(--tint) 12%, transparent); border-radius: 4px; }
  .stat .v { font-size: clamp(14px, 3.9vw, 20px); letter-spacing: -0.015em; text-overflow: clip; }

  /* ---------- loading + confirmation states ---------- */
  .skel {
    display: block; border-radius: 8px;
    background: linear-gradient(90deg, var(--chip) 25%, color-mix(in srgb, var(--chip) 45%, var(--surface)) 37%, var(--chip) 63%);
    background-size: 400% 100%;
    animation: shimmer 1.4s ease-in-out infinite;
  }
  @keyframes shimmer { from { background-position: 100% 50%; } to { background-position: 0 50%; } }
  .skel-row { display: grid; grid-template-columns: 32px 1fr 64px; gap: 7px 12px; align-items: center; padding: 12px 14px; border-top: 1px solid var(--line); }
  .skel-row:first-child { border-top: 0; }
  .skel-row .c { width: 32px; height: 32px; border-radius: 9px; grid-row: span 2; }
  .skel-row .l1 { height: 12px; width: 62%; }
  .skel-row .l2 { height: 10px; width: 34%; }
  .skel-row .a { height: 12px; grid-row: span 2; }
  .balance .skel { height: .78em; width: 4.4em; border-radius: 16px; margin-top: .16em; }
  .sub .skel { height: 12px; width: 180px; margin-top: 4px; }
  .chart .skel { height: 176px; border-radius: 12px; }
  .spin { width: 15px; height: 15px; flex: none; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin 700ms linear infinite; }
  @keyframes spin { to { transform: rotate(360deg); } }
  .dev-row { transition: background-color 200ms ease; }
  .dev-row.confirming { background: color-mix(in srgb, var(--neg) 7%, transparent); }
  .dev-confirm { grid-column: 2 / -1; display: flex; flex-direction: column; gap: 8px; padding-top: 8px; }
  .dev-confirm p { margin: 0; font-size: 14px; color: var(--ink); }
  .dev-confirm .acts { display: flex; gap: 8px; }
  .dev-confirm .btn { min-height: 36px; padding: 6px 14px; font-size: 14px; }
  .btn.danger-solid { background: var(--neg); color: #fff; }
  .inline-err { color: var(--neg); font-size: 13px; }
  .inline-err:empty { display: none; }
  @media (prefers-reduced-motion: reduce) { .skel { animation: none; } }
  .dev-row .what { grid-column: 2; grid-row: 1; }
  .dev-row .note { grid-column: 2 / -1; grid-row: 2; }
  .dev-row .icon-btn { grid-column: 3; grid-row: 1 / span 2; }
  .dev-row .ico { grid-column: 1; grid-row: 1 / span 2; }
  .dev-row .dev-confirm { grid-row: 3; }

  /* lock screen steps */
  .steps { margin: 0 0 22px; padding: 0; list-style: none; counter-reset: step; display: grid; gap: 12px; }
  .steps li { counter-increment: step; display: grid; grid-template-columns: 28px 1fr; gap: 12px; align-items: start; font-size: 17px; line-height: 1.4; }
  .steps li > span { padding-top: 2px; }
  .steps li::before {
    content: counter(step); width: 28px; height: 28px; border-radius: 50%;
    display: grid; place-items: center; font: 700 15px/1 var(--display);
    background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent);
  }
  .steps .hint-inline { color: var(--muted); }
  .fine-print { color: var(--muted); font-size: 13px; margin: 10px 2px 0; }

  /* Desktop: keep entry controls beside the selected view. */
  @media (min-width: 960px) {
    main { max-width: 1160px; padding: 28px 32px 64px; }
    .lock { max-width: 488px; margin: 0 auto; }
    #home {
      display: grid;
      grid-template-columns: minmax(0, 420px) minmax(0, 1fr);
      grid-template-areas:
        "top top"
        "hero hero"
        "quick tabs"
        "entry panel"
        "hint hint";
      column-gap: 36px;
      align-items: start;
    }
    #home > * { min-width: 0; }
    .top { grid-area: top; }
    .hero { grid-area: hero; position: relative; padding: 32px 140px 28px 0; }
    .hero-foot { display: block; margin-top: 14px; }
    .hero-foot .pk-btn { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); }
    .quick { grid-area: quick; flex-wrap: wrap; overflow: visible; margin: 0 0 16px; padding: 0; }
    #txForm { grid-area: entry; }
    .cats { flex-wrap: wrap; overflow: visible; margin: 10px 0 0; padding: 2px 0; }
    .tabs { grid-area: tabs; position: relative; align-self: end; margin: 0 0 16px; padding: 0; }
    .tab-ink { left: 0; width: calc(100% / 3); }
    .panel { grid-area: panel; }
    .panel .section:first-child, .panel > .section[hidden] + .section { margin-top: 0; }
    .foot-hint { grid-area: hint; margin-top: 24px; }
  }
