/* Cliento. One file, sections marked. No inline styles anywhere (CSP). */

/* ---------- 1. Tokens ---------- */
/* The taka sign only (U+09F3), Anek Bangla, variable weight so it matches the digits beside it. */
@font-face {
  font-family: "Cliento Taka";
  src: url("../fonts/AnekBangla-taka.woff2") format("woff2");
  unicode-range: U+09F3;
  font-weight: 100 800;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: light;
  --bg: #FFFFFF;
  --raised: #FFFFFF;
  --page: #F7F7F7;
  --fill: #F7F7F7;
  --seg-on: #FFFFFF;
  --text: #222222;
  --muted: #6A6A6A;
  --line: #EBEBEB;
  --line-strong: #B0B0B0;
  --grab: #D8D8D8;
  --accent: #E0224B;        /* rose text and lines on the page: 4.7 to 1 on white */
  --accent-fill: #E0224B;   /* rose under white text, the same in both themes: 4.7 to 1 */
  --accent-press: #C21A3E;  /* a pressed rose fill */
  --green: #008A05;
  --red: #C13515;
  --low: #C9190B;
  --scrim: rgba(0, 0, 0, 0.4);
  --glass: rgba(255, 255, 255, 0.86);
  --font: "Cliento Taka", -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  --col: 430px;
  --tab-h: 64px;
  --ease-sheet: cubic-bezier(0.32, 0.72, 0, 1);
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #121212;
    --raised: #1E1E1E;
    --page: #0B0B0B;
    --fill: #262626;
    --seg-on: #3A3A3C;
    --text: #F5F5F5;
    --muted: #A3A3A3;
    --line: #2E2E2E;
    --line-strong: #5A5A5A;
    --grab: #4A4A4A;
    --accent: #FF5A76;
    --accent-press: #C21A3E;
    --green: #4CC764;
    --red: #FF8566;
    --low: #FF6B57;
    --scrim: rgba(0, 0, 0, 0.6);
    --glass: rgba(18, 18, 18, 0.86);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121212;
  --raised: #1E1E1E;
  --page: #0B0B0B;
  --fill: #262626;
  --seg-on: #3A3A3C;
  --text: #F5F5F5;
  --muted: #A3A3A3;
  --line: #2E2E2E;
  --line-strong: #5A5A5A;
  --grab: #4A4A4A;
  --accent: #FF5A76;
  --accent-press: #C21A3E;
  --green: #4CC764;
  --red: #FF8566;
  --low: #FF6B57;
  --scrim: rgba(0, 0, 0, 0.6);
  --glass: rgba(18, 18, 18, 0.86);
}

/* ---------- 2. Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3, p, ul { margin: 0; padding: 0; }
ul { list-style: none; }
a { color: inherit; text-decoration: none; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.vh { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.muted { color: var(--muted); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.icon { width: 24px; height: 24px; flex: none; stroke-width: 2; }
.icon-sm { width: 18px; height: 18px; }
.icon-lg { width: 32px; height: 32px; }

/* ---------- 3. Layout ---------- */
.app {
  position: relative;
  max-width: var(--col);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  background: var(--bg);
}
body.has-tabs .app { padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + 32px); }
main {
  padding: calc(env(safe-area-inset-top) + 4px) 20px 0;
  animation: screen-in 240ms var(--ease-out) backwards;
}
@keyframes screen-in { from { opacity: 0; transform: translateY(6px); } }

@media (min-width: 431px) {
  body { background: var(--page); }
  .app { box-shadow: 0 0 0 1px var(--line), 0 24px 80px rgba(0, 0, 0, 0.06); }
}

.top { display: flex; align-items: center; justify-content: space-between; min-height: 56px; }
.page-title { font-size: 32px; line-height: 1.1; font-weight: 700; letter-spacing: -0.03em; margin: 4px 0 16px; }
.top-gap { margin-top: 60px; }
.month-btn { display: inline-flex; align-items: center; gap: 4px; min-height: 44px; margin-left: -4px; padding: 0 4px; font-size: 17px; font-weight: 600; letter-spacing: -0.01em; border-radius: 12px; }
.avatar { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; background: var(--fill); font-size: 16px; font-weight: 600; }
.back-btn { display: grid; place-items: center; width: 44px; height: 44px; margin-left: -10px; border-radius: 50%; }

/* ---------- 4. Tab bar ---------- */
.tabbar {
  position: fixed;
  z-index: 40;
  bottom: 0;
  left: 0;
  right: 0;
  width: min(100%, var(--col));
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  align-items: center;
  height: calc(var(--tab-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--bg);
  background: var(--glass);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  backdrop-filter: blur(20px) saturate(180%);
  border-top: 1px solid var(--line);
}
.tab { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 52px; color: var(--muted); font-size: 11px; font-weight: 500; letter-spacing: 0.01em; transition: transform 120ms var(--ease-out), color 160ms; }
.tab.is-active { color: var(--accent); }
.tab:active { transform: scale(0.94); }
.tab-add { justify-content: flex-start; }
.plus { display: grid; place-items: center; width: 56px; height: 56px; margin-top: -14px; border-radius: 50%; background: var(--accent-fill); color: #fff; box-shadow: 0 6px 16px rgba(224, 34, 75, 0.35); transition: transform 120ms var(--ease-out), background 160ms; }
.tab-add:active { transform: none; }
.tab-add:active .plus { transform: scale(0.94); background: var(--accent-press); }
.icon-plus { width: 28px; height: 28px; stroke-width: 2.25; }

/* ---------- 5. Home ---------- */
.hero { padding-top: 12px; }
.hero-fig { --lh: 1.04; transform-origin: left center; transition: color 450ms; font-size: 56px; line-height: var(--lh); font-weight: 700; letter-spacing: -0.035em; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.hero-fig.is-long { font-size: 40px; }
.cur { margin-right: 0.08em; color: var(--muted); font-size: 0.55em; font-weight: 600; letter-spacing: 0; }
/* The big amount on Home: the taka sign's box is the real glyph's own advance (AnekBangla-taka.woff2, uni09F3 at weight 600:
   1069 of 2000 units), so the amount keeps its width while the font is late and the stand-in glyph shows. */
.hero-fig[data-roll] .cur { display: inline-block; width: 0.5345em; width: round(up, 0.5345em, 0.015625px); } /* up to the 1/64 px a text run is laid out in */
.is-over .cur { color: inherit; }
.hero-fig.is-over { color: var(--red); }
.hero-fig.is-above { color: var(--green); }
.hero-fig.is-below { color: var(--low); }
.is-above .cur, .is-below .cur { color: inherit; }
.cur { transition: color 450ms; }
.hero-over { display: block; margin-bottom: 4px; font-size: 20px; font-weight: 600; letter-spacing: 0; }
.hero-cap { margin-top: 6px; color: var(--muted); font-size: 16px; }
.hero-line { margin-top: 2px; }
.line-btn { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0; border: 0; background: none; color: var(--muted); font: inherit; font-size: 15px; transition: color 450ms; }
.line-btn.is-above { color: var(--green); }
.line-btn.is-below { color: var(--low); }
.line-dot { width: 8px; height: 8px; flex: none; border-radius: 50%; background: currentColor; }
.hero-line + .bar { margin-top: 14px; }
.hero-line + .empty-month { margin-top: 14px; }
.sheet-lead { color: var(--muted); font-size: 16px; line-height: 1.4; }

/* The rolling amount (js/roll.js). Each digit is a window one line high over a strip of 0-9; the glyphs are drawn by CSS so the page text stays the server's. */
.roll-wait .hero-fig[data-roll]:not([data-rolled]) { visibility: hidden; } /* js/early.js: no blink of the final number before the roll */
.roll { display: inline; }
.roll-col { display: inline-block; vertical-align: top; height: calc(var(--lh) * 1em); overflow: hidden; padding: 0 0.05em; margin: 0 -0.05em; }
.roll-strip { display: block; will-change: transform; }
.roll-d { display: block; height: calc(var(--lh) * 1em); line-height: var(--lh); font-style: normal; }
.roll-sep { font-style: normal; }
.roll-d::before, .roll-sep::before { content: attr(data-d); }
.roll-sr { display: inline-block; vertical-align: top; width: 0; height: 0; overflow: hidden; white-space: nowrap; }
@media (prefers-reduced-motion: reduce) { .hero-fig, .cur, .line-btn { transition: none; } }
.bar { display: block; margin-top: 28px; }
.bar-track { fill: var(--line); }
.bar-fill { fill: var(--text); }
.bar.is-over .bar-fill { fill: var(--red); }
.inout { display: flex; justify-content: space-between; margin-top: 10px; }
.inout-btn { display: inline-flex; align-items: center; gap: 6px; min-width: 44px; min-height: 44px; font-size: 16px; border-radius: 12px; }
.inout-btn.is-right { justify-content: flex-end; } /* a wider box keeps Out on the right edge */
.inout-label { color: var(--muted); }
.inout-val { font-weight: 600; font-variant-numeric: tabular-nums; }
.empty-month { margin-top: 28px; display: flex; flex-direction: column; align-items: flex-start; gap: 16px; }
.empty-month p { color: var(--muted); font-size: 17px; }

.section { margin-top: 36px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 4px; }
.section-head h2 { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; }
.link-strong { display: inline-flex; align-items: center; min-height: 44px; font-size: 15px; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }

/* ---------- 6. Rows ---------- */
.rows { margin: 0 -12px; }
.row-item { position: relative; }
.row-item + .row-item::before { content: ""; position: absolute; top: 0; left: 68px; right: 12px; height: 1px; background: var(--line); }
.row { display: flex; align-items: center; gap: 16px; min-height: 68px; padding: 12px; border-radius: 14px; transition: background 140ms, transform 120ms var(--ease-out); }
.row:active { background: var(--fill); transform: scale(0.985); }
.row-icon { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; background: var(--fill); flex: none; }
.row-icon .icon { width: 20px; height: 20px; }
.row-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.row-title { font-size: 16px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-sub { color: var(--muted); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-amount { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; flex: none; font-variant-numeric: tabular-nums; }
.row-taka { font-size: 16px; font-weight: 600; }
.row-usd { color: var(--muted); font-size: 13px; }
.row-amount.is-in .row-taka { color: var(--green); }
.rows-sheet .row-item + .row-item::before { left: 12px; }
.row-month { justify-content: space-between; min-height: 56px; }
.icon-check { width: 20px; height: 20px; }
.total-row { display: flex; justify-content: space-between; align-items: baseline; padding: 16px 0 0; margin-top: 4px; border-top: 1px solid var(--line); font-size: 16px; }
.total-row strong { font-size: 20px; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }

.day { margin-top: 8px; }
.day-head { display: flex; align-items: baseline; justify-content: space-between; padding: 20px 0 2px; }
.day-head h2 { font-size: 15px; font-weight: 600; }
.day-net { color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; }
.empty-line { color: var(--muted); text-align: center; padding: 56px 0; font-size: 16px; }
.placeholder { display: flex; flex-direction: column; align-items: center; gap: 16px; padding: 72px 0; color: var(--muted); text-align: center; }
.placeholder-icon { display: grid; place-items: center; width: 72px; height: 72px; border-radius: 50%; background: var(--fill); color: var(--text); }

/* ---------- 7. Activity controls ---------- */
.search { position: relative; margin: 4px 0 12px; }
.search-input { width: 100%; height: 48px; padding: 0 16px 0 46px; border: 1px solid var(--line); border-radius: 14px; background: var(--fill); font-size: 16px; -webkit-appearance: none; appearance: none; }
.search-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.search-input::-webkit-search-cancel-button { -webkit-appearance: none; }
.icon-search { position: absolute; left: 16px; top: 14px; width: 20px; height: 20px; color: var(--muted); pointer-events: none; }
.chips-row { display: flex; gap: 8px; margin: 0 -20px; padding: 4px 20px 8px; overflow-x: auto; scrollbar-width: none; -webkit-mask-image: linear-gradient(to right, transparent 0, #000 20px, #000 calc(100% - 20px), transparent 100%); mask-image: linear-gradient(to right, transparent 0, #000 20px, #000 calc(100% - 20px), transparent 100%); }
.chips-row .chip:focus-visible { outline-offset: -3px; }
.chips-row::-webkit-scrollbar { display: none; }

.chip { flex: none; position: relative; display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 16px; border: 1px solid var(--line); border-radius: 22px; background: transparent; color: var(--text); font-size: 15px; font-weight: 500; transition: transform 120ms var(--ease-out), background 160ms, color 160ms, border-color 160ms; }
.chip:active { transform: scale(0.96); }
.chip.is-on, .chip:has(input:checked) { background: var(--text); border-color: var(--text); color: var(--bg); font-weight: 600; }
.chip:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- 8. Buttons and fields ---------- */
.btn { display: flex; align-items: center; justify-content: center; width: 100%; min-height: 54px; padding: 0 22px; border: 0; border-radius: 14px; font-size: 17px; font-weight: 600; transition: transform 120ms var(--ease-out), background 160ms, opacity 160ms; }
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--accent-fill); color: #fff; }
.btn-primary:active { background: var(--accent-press); }
.btn-primary:disabled { opacity: 0.4; transform: none; }
.btn-outline { width: auto; min-height: 48px; border: 1.5px solid var(--text); background: transparent; color: var(--text); border-radius: 12px; font-size: 16px; }
.btn-secondary { background: var(--fill); color: var(--text); }
.btn-link { display: flex; align-items: center; justify-content: center; width: 100%; min-height: 48px; border: 0; background: none; font-size: 16px; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.btn-link.is-danger { color: var(--red); }

.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { color: var(--muted); font-size: 14px; }
.input { width: 100%; height: 56px; padding: 0 16px; border: 1px solid var(--line-strong); border-radius: 12px; background: var(--bg); font-size: 17px; }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.form-error, .field-error { color: var(--red); font-size: 14px; margin-top: 6px; }

.auth { padding: calc(env(safe-area-inset-top) + 56px) 4px 40px; }
.auth-mark { display: grid; place-items: center; width: 64px; height: 64px; border-radius: 16px; background: var(--accent-fill); color: #fff; font-size: 38px; line-height: 1; font-weight: 700; }
.auth-mark span { transform: translateY(1px); }
.auth-title { margin-top: 24px; font-size: 32px; line-height: 1.1; font-weight: 700; letter-spacing: -0.03em; }
.auth-sub { margin-top: 8px; color: var(--muted); font-size: 17px; }
.auth-form { display: flex; flex-direction: column; gap: 16px; margin-top: 32px; }
.auth-reset { padding-top: 24px; border-top: 1px solid var(--line); }
.auth-h2 { font-size: 20px; font-weight: 700; letter-spacing: -0.02em; }
.settings-form { margin-top: 24px; }
.notice { padding-top: 96px; text-align: center; }
.notice h1 { font-size: 22px; letter-spacing: -0.02em; }
.notice p { margin-top: 16px; text-decoration: underline; }

/* ---------- 9. Entry form ---------- */
.entry-form { display: flex; flex-direction: column; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; padding: 3px; border-radius: 14px; background: var(--fill); }
.seg-item { position: relative; display: block; }
.seg-item span { display: flex; align-items: center; justify-content: center; min-height: 44px; border-radius: 11px; color: var(--muted); font-size: 15px; font-weight: 500; transition: background 180ms, color 180ms, box-shadow 180ms; }
.seg-item input:checked + span { background: var(--seg-on); color: var(--text); font-weight: 600; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.14); }
.seg-item input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 1px; }
.seg-cur { width: 100px; flex: none; }
.seg-cur .seg-item span { font-size: 18px; }

.amount-row { display: flex; align-items: center; gap: 10px; margin: 18px 0 4px; }
.amount-sym { font-size: 32px; line-height: 1; font-weight: 600; color: var(--muted); }
.amount-input { flex: 1; min-width: 0; height: 60px; padding: 0; border: 0; background: transparent; font-size: 44px; font-weight: 700; letter-spacing: -0.03em; outline: none; caret-color: var(--accent); }
.amount-input::placeholder { color: var(--line-strong); }

.chips-group { margin: 12px 0 4px; padding: 0; border: 0; min-width: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.field-row { display: flex; align-items: center; gap: 12px; min-height: 56px; border-bottom: 1px solid var(--line); transition: border-color 160ms; }
.field-row:focus-within { border-bottom-color: var(--accent); }
.lbl { flex: none; width: 84px; color: var(--muted); font-size: 15px; }
.line-input { flex: 1; min-width: 0; height: 56px; padding: 0; border: 0; background: transparent; font-size: 17px; outline: none; }
.line-input::placeholder { color: var(--line-strong); }
input[list]::-webkit-calendar-picker-indicator { display: none !important; }
.date-row { padding: 14px 0 6px; min-height: 0; border-bottom: 0; }
.chip-date { gap: 6px; overflow: hidden; }
.chip-date .icon { width: 18px; height: 18px; }
.date-over { position: static; min-height: 44px; padding: 0 12px; border: 1px solid var(--line); border-radius: 22px; background: transparent; font-size: 15px; }
.js .date-over { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; border: 0; padding: 0; cursor: pointer; }
.chip-date > .icon, .chip-date > span { display: none; }
.js .chip-date > .icon, .js .chip-date > span { display: inline-flex; }
.date-ctl > button { display: none; }
.js .date-ctl > button { display: inline-flex; }
.js .chip-date:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.date-ctl { flex: 1; display: flex; flex-wrap: wrap; gap: 8px; }
.form-actions { position: sticky; bottom: 0; margin: 8px -20px 0; padding: 24px 20px calc(env(safe-area-inset-bottom) + 16px); background: linear-gradient(to bottom, transparent, var(--raised) 24px); }
.form-actions .btn-link { margin-top: 6px; }
.signin-note { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 16px; padding: 12px 16px; border-radius: 14px; background: var(--fill); }
.signin-note p { font-size: 15px; font-weight: 500; }
.invest-summary { padding: 8px 0 20px; text-align: center; }
.invest-name { font-size: 20px; font-weight: 600; }
.invest-amt { margin: 6px 0; font-size: 40px; font-weight: 700; letter-spacing: -0.03em; }

/* ---------- 10. Sheets ---------- */
.sheet-host { position: fixed; inset: 0; z-index: 100; pointer-events: none; }
.scrim { position: fixed; inset: 0; background: var(--scrim); pointer-events: auto; animation: fade-in 260ms ease-out backwards; transition: opacity 220ms ease-out; }
.scrim.is-closing { opacity: 0; animation: none; }
@keyframes fade-in { from { opacity: 0; } }
.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: var(--vv-bottom, 0px);
  width: min(100%, var(--col));
  margin: 0 auto;
  max-height: calc(var(--vv-h, 100dvh) - env(safe-area-inset-top) - 12px);
  display: flex;
  flex-direction: column;
  background: var(--raised);
  border-radius: 22px 22px 0 0;
  box-shadow: 0 -10px 50px rgba(0, 0, 0, 0.18);
  pointer-events: auto;
  will-change: transform;
  animation: sheet-in 380ms var(--ease-sheet) backwards;
}
@keyframes sheet-in { from { transform: translateY(100%); } }
.sheet.is-closing { animation: none; transform: translateY(100%); transition: transform 280ms var(--ease-sheet); }
.sheet.is-settling { transition: transform 380ms var(--ease-sheet); }
.sheet-grip { position: relative; flex: none; touch-action: none; cursor: grab; padding-top: 8px; user-select: none; -webkit-user-select: none; }
.grab { display: block; width: 36px; height: 5px; margin: 0 auto; border-radius: 3px; background: var(--grab); }
.sheet-title { padding: 14px 56px 14px; text-align: center; font-size: 16px; font-weight: 600; letter-spacing: -0.01em; }
.sheet-title.has-sub { padding-bottom: 2px; }
.sheet-sub { padding: 0 56px 12px; text-align: center; color: var(--muted); font-size: 13px; }
.sheet-close { position: absolute; left: 8px; top: 16px; display: grid; place-items: center; width: 44px; height: 44px; border: 0; background: none; border-radius: 50%; }
.sheet-close .icon { width: 20px; height: 20px; }
.sheet-scroll { overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; padding: 0 20px calc(env(safe-area-inset-bottom) + 24px); }
.sheet-scroll:has(.form-actions) { padding-bottom: 0; }
.sheet-scroll .rows { margin: 0 -12px; }
.sheet-open { overflow: hidden; }
.sheet-page { padding-top: 24px; }

/* ---------- 11. Toast ---------- */
.toast-host { position: fixed; z-index: 120; left: 0; right: 0; bottom: calc(env(safe-area-inset-bottom) + var(--tab-h) + 28px); display: flex; justify-content: center; padding: 0 20px; pointer-events: none; }
.toast, .flash {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 8px 0 18px;
  border-radius: 14px;
  background: var(--text);
  color: var(--bg);
  font-size: 15px;
  font-weight: 500;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.22);
  animation: toast-in 260ms var(--ease-out) backwards;
  transition: opacity 200ms ease-out, transform 200ms ease-out;
}
.toast.is-leaving { opacity: 0; transform: translateY(8px); }
.toast-undo { min-height: 44px; padding: 0 12px; border: 0; background: none; color: inherit; font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }
.toast-dot { opacity: 0.5; }
.flash { position: fixed; z-index: 120; left: 50%; bottom: calc(env(safe-area-inset-bottom) + var(--tab-h) + 28px); transform: translateX(-50%); padding-right: 18px; }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px); } }

/* ---------- 12. Pointer-capable devices ---------- */
@media (hover: hover) and (pointer: fine) {
  .row:hover { background: var(--fill); }
  .chip:hover { border-color: var(--text); }
  .tab:hover { color: var(--text); }
  .tab.is-active:hover { color: var(--accent); }
}

/* ---------- 13. Reduced motion: fades only ---------- */
@media (prefers-reduced-motion: reduce) {
  main { animation: fade-in 200ms ease-out backwards; }
  .sheet { animation: fade-in 200ms ease-out backwards; }
  .sheet.is-closing { transform: none; opacity: 0; transition: opacity 160ms ease-out; }
  .sheet.is-settling { transition: none; }
  .toast, .flash { animation: fade-in 200ms ease-out backwards; }
  .toast.is-leaving { transform: none; }
  .btn:active, .chip:active, .tab:active, .row:active, .tab-add:active .plus { transform: none; }
}

/* ---------- 14. Invest, Giving, Settings ---------- */
.small { font-size: 14px; }
.top-label { font-size: 17px; font-weight: 600; letter-spacing: -0.01em; }
.text-btn { display: inline-flex; align-items: center; min-height: 44px; color: var(--accent); font-size: 16px; font-weight: 600; border-radius: 12px; }
.profit-line { margin-top: 12px; font-size: 16px; }
.profit { font-weight: 600; font-variant-numeric: tabular-nums; }
.profit.is-up, .row-pct.is-up { color: var(--green); }
.profit.is-down, .row-pct.is-down { color: var(--red); }
.profit.is-flat, .row-pct.is-flat { color: var(--muted); }
.closed-line { margin-top: 6px; font-size: 14px; }
.row-pct { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.rows-flush { margin-top: 28px; }
.eyebrow { color: var(--muted); font-size: 14px; }
.inv-name { margin: 2px 0 18px; font-size: 28px; line-height: 1.1; font-weight: 700; letter-spacing: -0.03em; }
.inv-hero { padding-top: 4px; }
.more-btn { margin-left: auto; margin-right: -10px; }
.actions-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 28px; }
.act { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; min-height: 92px; padding: 14px 4px; border-radius: 16px; background: var(--fill); font-size: 13px; font-weight: 600; text-align: center; transition: transform 120ms var(--ease-out); }
.act:active { transform: scale(0.97); }
.act-icon { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: var(--bg); }
.act-icon .icon { width: 20px; height: 20px; }

main[data-screen="giving"] { background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 9%, transparent) 0, transparent 420px); }
.giving-hero { padding: 8px 0 24px; }
.give-icon { display: grid; place-items: center; width: 56px; height: 56px; margin-bottom: 18px; border-radius: 50%; background: color-mix(in srgb, var(--accent) 13%, var(--bg)); color: var(--accent); }
.by-list { margin-top: 4px; }
.by-row { padding: 12px 0; }
.by-line { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.by-name { font-size: 16px; font-weight: 500; }
.by-amt { font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums; }
.by-bar { display: block; margin-top: 8px; }
.give-fill { fill: color-mix(in srgb, var(--accent) 75%, var(--bg)); }
.section-tight { margin-top: 24px; }

.group { margin-top: 30px; }
.group-title { margin-bottom: 4px; color: var(--muted); font-size: 13px; font-weight: 600; letter-spacing: 0.01em; }
.group-note { margin: 8px 0 14px; }
.set-row { display: flex; align-items: center; gap: 14px; width: 100%; min-height: 56px; padding: 0; border: 0; border-bottom: 1px solid var(--line); background: none; color: var(--text); font-size: 16px; text-align: left; transition: border-color 160ms; }
.set-row:focus-within { border-bottom-color: var(--accent); }
.set-icon { display: grid; place-items: center; width: 36px; height: 36px; flex: none; border-radius: 50%; background: var(--fill); }
.set-icon .icon { width: 18px; height: 18px; }
.set-label { flex: 1; font-weight: 500; }
.set-value { display: flex; align-items: center; gap: 8px; }
.set-input { width: 92px; height: 44px; padding: 0; border: 0; background: transparent; font-size: 17px; font-weight: 600; text-align: right; outline: none; }
.set-button { cursor: pointer; }
.set-details > summary { list-style: none; cursor: pointer; }
.set-details > summary::-webkit-details-marker { display: none; }
.chev { color: var(--muted); transition: transform 200ms var(--ease-out); }
.set-details[open] .chev { transform: rotate(90deg); }
.cat-list { padding: 4px 0 10px; }
.cat-row { display: flex; align-items: center; gap: 0; min-height: 52px; }
.cat-row.is-hidden .cat-name { color: var(--muted); }
.cat-name { flex: 1; min-width: 0; height: 44px; padding: 0 2px; border: 0; background: transparent; font-size: 16px; outline: none; }
.cat-name:focus { box-shadow: 0 1px 0 var(--accent); }
.icon-btn { display: grid; place-items: center; width: 44px; height: 44px; flex: none; border: 0; border-radius: 50%; background: none; color: var(--muted); }
.icon-btn .icon { width: 20px; height: 20px; }
.icon-btn:disabled { opacity: 0.25; }
.icon-btn:not(:disabled):active { background: var(--fill); }
.cat-add { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.cat-add .cat-name { padding: 0 14px; border: 1px solid var(--line); border-radius: 22px; }
.pw-form { display: flex; flex-direction: column; gap: 4px; padding: 4px 0 18px; }
.pw-form .btn { margin-top: 12px; }
.file-input { min-height: 44px; margin: 8px 0 4px; font-size: 15px; }
.seg-2, .seg-3 { margin: 0 0 12px; }
.group .seg-3 { margin: 6px 0 0; }
.seg-cur.is-locked { opacity: 0.45; pointer-events: none; }
.newinv { margin-top: 8px; }
.cur-row .seg-cur { margin: 8px 0 8px auto; }
.fixed-cur { margin: 6px 0 10px; }
.lead { margin: 14px 0; font-size: 17px; line-height: 1.45; }
.set-links { margin: 4px 0 8px; }
.btn-danger { background: var(--red); color: var(--bg); }
.confirm-form { display: flex; flex-direction: column; gap: 6px; margin-top: 24px; }

/* ---------- 15. Accounts, PIN, Loans ---------- */
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.hint { color: var(--muted); font-size: 13px; }
.badge { display: inline-block; margin-left: 6px; padding: 1px 8px; border-radius: 10px; background: var(--fill); color: var(--muted); font-size: 12px; font-weight: 600; vertical-align: 1px; }
.badge-off { background: color-mix(in srgb, var(--red) 14%, var(--bg)); color: var(--red); }
.pin-field { margin: 0; padding: 0; border: 0; min-width: 0; }
.pin-field .field-label { padding: 0; margin-bottom: 8px; }
.pin-boxes { display: flex; gap: 8px; }
.pin-box { flex: 1; min-width: 0; height: 60px; padding: 0; border: 1px solid var(--line-strong); border-radius: 14px; background: var(--bg); color: var(--text); font-size: 28px; font-weight: 700; text-align: center; -webkit-text-security: disc; transition: border-color 160ms, box-shadow 160ms; }
.pin-box:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.auth-links { display: flex; flex-wrap: wrap; gap: 4px 20px; margin-top: 20px; }
.auth-foot { margin-top: 18px; font-size: 14px; }
.auth-foot a { text-decoration: underline; text-underline-offset: 3px; }
.auth .back-btn { margin-left: -10px; margin-top: -32px; }
.prose p { margin-top: 8px; font-size: 16px; line-height: 1.5; }
.prose .auth-h2 { margin-top: 24px; }
.code-input { text-transform: uppercase; letter-spacing: 0.08em; font-weight: 600; }
.code-screen .btn { margin-top: 12px; }
.code-box { margin: 28px 0 16px; padding: 22px 12px; border-radius: 18px; background: var(--fill); font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 26px; font-weight: 700; letter-spacing: 0.06em; text-align: center; user-select: all; -webkit-user-select: all; }
.code-note { margin: 12px 0 20px; text-align: center; }
.is-danger-text { color: var(--red); }

.person { padding: 14px 0; border-bottom: 1px solid var(--line); }
.person-head { display: flex; align-items: center; gap: 14px; }
.person-head .row-sub { display: block; font-size: 13px; }
.person.is-off .set-label { color: var(--muted); }
.person-actions { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 8px; margin: 10px 0 0 50px; }
.person-delete summary { list-style: none; cursor: pointer; }
.person-delete summary::-webkit-details-marker { display: none; }
.person-delete .pw-form { padding-top: 10px; min-width: 240px; }

.duo { display: flex; gap: 20px; padding-top: 12px; }
.duo-col { flex: 1; min-width: 0; }
.duo-fig { font-size: 34px; line-height: 1.05; font-weight: 700; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.duo-fig.is-long { font-size: 26px; }
.row-loan { flex-wrap: wrap; row-gap: 8px; }
.row-progress { display: block; flex: none; width: calc(100% - 60px); margin-left: 60px; }
.is-late { color: var(--red); }
.loan-of { margin-top: 4px; font-size: 15px; }
.loan-bar { margin-top: 18px; }
.due-line { margin-top: 12px; font-size: 16px; font-weight: 500; }
.actions-n { grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); }

.emi-block { margin-top: 28px; }
.emi-row { display: flex; align-items: center; }
.emi-row .row { flex: 1; min-width: 0; }
.emi-pay { flex: none; margin-left: 4px; }
.pill { min-height: 44px; min-width: 72px; padding: 0 16px; border: 1.5px solid var(--text); border-radius: 22px; background: transparent; color: var(--text); font-size: 14px; font-weight: 600; transition: transform 120ms var(--ease-out); }
.pill:active { transform: scale(0.96); }
.pill:disabled { opacity: 0.4; }

.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 56px; border-bottom: 1px solid var(--line); }
.switch-text { font-size: 16px; }
.switch { appearance: none; -webkit-appearance: none; position: relative; flex: none; width: 52px; height: 44px; margin: 0; background: none; cursor: pointer; }
.switch::before { content: ""; position: absolute; left: 0; top: 6px; width: 52px; height: 32px; border-radius: 16px; background: var(--line-strong); transition: background 200ms; }
.switch::after { content: ""; position: absolute; top: 8px; left: 2px; width: 28px; height: 28px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3); transition: transform 200ms var(--ease-sheet); }
.switch:checked::before { background: var(--text); }
.switch:checked::after { transform: translateX(20px); }
.switch:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.emi-toggle { align-self: flex-start; margin-top: 14px; }
.emi-fields { margin-top: 8px; }
@media (prefers-reduced-motion: reduce) { .switch::after, .switch::before { transition: none; } }
.auth-foot a { display: inline-flex; align-items: center; min-height: 44px; }
.emi-pay { margin-right: 12px; }

/* ---------- 16. The keypad sheet (fast entry) ---------- */
.sheet-kp { border-radius: 28px 28px 0 0; }
.sheet-kp .sheet-scroll { padding: 0; overflow-x: hidden; }
.kp-form { display: flex; flex-direction: column; }
.kp-top { display: flex; align-items: center; gap: 6px; height: 44px; padding: 0 14px 0 8px; touch-action: none; }
.kp-x { display: grid; place-items: center; width: 44px; height: 44px; flex: none; border-radius: 50%; color: var(--text); }
.kp-x .icon { width: 22px; height: 22px; }
.kp-pills { gap: 6px; margin-left: auto; min-width: 0; }
.kp-pill-wrap { position: relative; }
.kp-pill { position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 5px; min-width: 44px; height: 32px; max-width: 132px; padding: 0 12px; border: 0; border-radius: 16px; background: var(--fill); color: var(--text); font-size: 13px; font-weight: 500; white-space: nowrap; transition: background 160ms; }
.kp-pill::after { content: ""; position: absolute; left: 0; right: 0; top: -6px; bottom: -6px; } /* a 44px hit area around a 32px pill */
.kp-pill .icon { width: 15px; height: 15px; }
.kp-pill-sign { font-size: 15px; font-weight: 600; }
.kp-pill-text { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.kp-pill.has-note { font-weight: 600; }
.kp-pill:active { background: var(--line); }
.kp-done { flex: none; height: 44px; margin-left: 2px; padding: 0 4px 0 8px; border: 0; background: none; color: var(--accent); font-size: 16px; font-weight: 700; }
.kp-menu { position: absolute; z-index: 5; top: calc(100% + 6px); left: 0; min-width: 168px; padding: 6px; border-radius: 14px; background: var(--raised); box-shadow: 0 0 0 1px var(--line), 0 12px 32px rgba(0, 0, 0, 0.16); animation: fade-in 140ms ease-out; }
.kp-menu-item { position: relative; display: flex; align-items: center; width: 100%; min-height: 44px; padding: 0 12px; border: 0; border-radius: 10px; background: none; color: var(--text); font-size: 15px; font-weight: 500; text-align: left; cursor: pointer; }
.kp-menu-item:active, .kp-menu-item:focus-visible { background: var(--fill); }
.kp-menu-pick input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; border: 0; padding: 0; cursor: pointer; }

.kp-seg { position: relative; display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); flex: none; height: 36px; margin: 6px 16px 0; padding: 3px; border-radius: 12px; background: var(--fill); }
.kp-seg-item { position: relative; display: flex; align-items: center; justify-content: center; min-width: 0; border-radius: 9px; color: var(--muted); font-size: 13px; font-weight: 600; white-space: nowrap; transition: background 180ms, color 180ms, box-shadow 180ms; }
.kp-seg-item.is-on { background: var(--seg-on); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12); }
.kp-seg-item::after { content: ""; position: absolute; left: 0; right: 0; top: -7px; bottom: -7px; } /* 44px to tap */
.kp-title { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 42px; padding: 0 20px; text-align: center; }
.kp-title-main { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 16px; font-weight: 600; letter-spacing: -0.01em; }
.kp-title-sub { color: var(--muted); font-size: 13px; }

.kp-amtbox { position: relative; flex: none; height: 118px; }
.kp-amt { position: absolute; left: 12px; right: 12px; top: 50%; height: 64px; margin-top: -34px; display: flex; align-items: baseline; justify-content: center; font-size: 52px; font-weight: 700; letter-spacing: -0.03em; line-height: 64px; font-variant-numeric: tabular-nums; white-space: nowrap; transition: transform 240ms cubic-bezier(0.2, 0.8, 0.2, 1), opacity 160ms; cursor: text; }
.kp-amtbox.has-again .kp-amt, .kp-amtbox:has(.kp-rate:not([hidden]), .kp-note-slot:not([hidden])) .kp-amt { transform: translateY(-20px); } /* the band below is in use */
.kp-sym { margin-right: 4px; color: var(--muted); font-size: 30px; font-weight: 600; letter-spacing: 0; }
.kp-amt.is-zero .kp-num { color: var(--line-strong); }
.kp-amt.is-s1 { font-size: 44px; }
.kp-amt.is-s2 { font-size: 36px; }
.kp-amt.is-s3 { font-size: 28px; }
.kp-amt.is-dim { opacity: 0.45; }
.kp-shake { animation: kp-shake 320ms ease-out; }
@keyframes kp-shake { 20% { translate: -7px 0; } 45% { translate: 6px 0; } 70% { translate: -3px 0; } 100% { translate: 0 0; } }
.kp-band { position: absolute; left: 0; right: 0; bottom: 0; height: 40px; display: flex; align-items: center; justify-content: center; }
.kp-again { position: absolute; inset: 0; display: flex; align-items: center; gap: 8px; padding: 0 20px; overflow-x: auto; scrollbar-width: none; animation: fade-in 180ms ease-out; }
.kp-again::-webkit-scrollbar { display: none; }
.kp-again-label { flex: none; color: var(--muted); font-size: 12px; font-weight: 500; }
.kp-chip { position: relative; flex: none; display: inline-flex; align-items: center; height: 32px; max-width: 220px; padding: 0 12px; border: 1px solid var(--line); border-radius: 16px; background: transparent; color: var(--text); font-size: 13px; font-weight: 500; white-space: nowrap; transition: background 140ms; }
.kp-chip-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.kp-chip:active { background: var(--fill); }
.kp-chip-lg { height: 44px; max-width: 100%; padding: 0 16px; border-radius: 22px; font-size: 15px; } /* a long name ends in an ellipsis in its .kp-chip-text */
.kp-chip-quiet { color: var(--muted); }
.kp-rate { position: relative; gap: 0.28em; min-height: 40px; padding: 0 12px; border: 0; border-radius: 0; background: none; color: var(--muted); font-size: 14px; font-weight: 500; font-variant-numeric: tabular-nums; }
.kp-rate.is-editing { color: var(--text); box-shadow: inset 0 -2px 0 var(--accent); }
.kp-rate::after { content: ""; position: absolute; left: 0; right: 0; top: -2px; bottom: -2px; } /* 44px to tap */
.kp-note-slot { position: absolute; inset: -6px 20px 2px; display: flex; } /* 44px high, reaching up into the space the amount gave up */
.kp-note-slot input { flex: 1; min-width: 0; height: 44px; padding: 0 16px; border: 1px solid var(--accent); border-radius: 22px; background: var(--raised); color: var(--text); font-size: 16px; outline: none; }

.kp-errors { flex: none; padding: 0 20px 2px; color: var(--red); font-size: 13px; font-weight: 500; text-align: center; }
.kp-qrow { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex: none; min-height: 23px; padding: 6px 20px 2px; }
.kp-qrow:has(.kp-delete) { padding: 13px 20px; } /* a row tall enough to hold Delete's 44px hit area */
.kp-qrow-end { justify-content: flex-end; }
.kp-q { min-width: 0; color: var(--muted); font-size: 13px; font-weight: 500; }
.kp-delete { position: relative; flex: none; margin: 0 -2px; padding: 0 2px; border: 0; background: none; color: var(--red); font-size: 14px; font-weight: 600; line-height: 18px; }
.kp-delete::after { content: ""; position: absolute; left: 0; right: 0; top: -13px; bottom: -13px; } /* 44px to tap, inside its own row (the 2px side padding makes it 45 wide) */
/* The who step: the picked category leads the row and goes back to the tiles */
.kp-qrow:has(.kp-back:not([hidden])) { justify-content: flex-start; gap: 8px; }
.kp-back { position: relative; display: inline-flex; align-items: baseline; gap: 2px; flex: 0 1 auto; min-width: 0; max-width: 60%; padding: 0; border: 0; background: none; color: var(--text); font-size: 13px; font-weight: 600; }
.kp-back .icon { align-self: center; width: 16px; height: 16px; flex: none; }
.kp-back-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Editing an investment entry: Put in or Take out, a smaller twin of the kind switch */
.kp-qrow:has(.kp-flow:not([hidden])) { align-items: center; } /* Delete centred on the switch */
.kp-flow { display: inline-grid; grid-template-columns: 1fr 1fr; align-self: center; height: 30px; padding: 2px; border-radius: 10px; background: var(--fill); }
.kp-flow-item { position: relative; min-width: 72px; padding: 0 10px; border: 0; border-radius: 8px; background: none; color: var(--muted); font-size: 12px; font-weight: 600; white-space: nowrap; transition: background 180ms, color 180ms; }
.kp-flow-item[aria-checked="true"] { background: var(--seg-on); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12); }
.kp-flow-item::after { content: ""; position: absolute; left: 0; right: 0; top: -9px; bottom: -9px; } /* 44px to tap */
.kp-back::after { content: ""; position: absolute; left: 0; right: 0; top: -13px; bottom: -13px; } /* 44px to tap */

.kp-targets { flex: none; padding: 0 12px; }
.kp-page { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); grid-auto-rows: minmax(78px, auto); row-gap: 2px; }
.kp-paged { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; }
.kp-paged .kp-page { flex: 0 0 calc(100% - 16px); scroll-snap-align: start; } /* the next page peeks in 16px */
.kp-tile { display: flex; flex-direction: column; align-items: center; justify-content: flex-start; min-width: 0; min-height: 78px; padding: 6px 2px 4px; border: 0; border-radius: 14px; background: none; color: var(--text); text-align: center; }
.kp-ti { display: grid; place-items: center; width: 48px; height: 48px; flex: none; border-radius: 50%; background: var(--fill); transition: transform 100ms ease-out, background 100ms; }
.kp-ti .icon { width: 22px; height: 22px; }
.kp-tile:active .kp-ti { transform: scale(0.92); background: var(--line); }
.kp-tile[aria-pressed="true"] .kp-ti { background: var(--text); color: var(--bg); }
.kp-tl { display: -webkit-box; max-width: 100%; margin-top: 5px; margin-bottom: -1px; padding: 1px 0; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 2; font-size: 12px; font-weight: 500; line-height: 14px; overflow-wrap: anywhere; } /* 1px of padding keeps the tails of g, p and y inside the clip; the margins give the layout its pixel back */
.kp-ts { max-width: 100%; margin-bottom: -1px; padding-bottom: 1px; overflow: hidden; color: var(--muted); font-size: 12px; line-height: 14px; text-overflow: ellipsis; white-space: nowrap; font-variant-numeric: tabular-nums; } /* the same pixel for the y of "you owe" */
.kp-ts:has(.kp-ts-n) { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; white-space: normal; } /* "৳1,32,000 left": the word goes under the amount when the tile is narrow */
.kp-ts-n { white-space: nowrap; }
.kp-tile:has(.kp-ts) .kp-tl { -webkit-line-clamp: 1; }
.kp-grid::-webkit-scrollbar { display: none; }
.kp-who { display: flex; flex-direction: column; padding: 4px 0 0; } /* names in one sideways row, Someone new and Skip in a second */
.kp-who-names, .kp-who-acts { display: flex; align-items: center; gap: 8px; flex: none; height: 44px; padding: 0 8px; } /* rows of 40px chips, 44px each to tap */
.kp-who-names { margin: 0 -12px; padding: 0 20px; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none; } /* the row runs to the sheet's edges, so the next name peeks in */
.kp-targets:has(> .kp-panel:not([hidden]) [data-asks="1"]) { min-height: 92px; } /* as tall as the who step (4 + 44 + 44): picking who never moves the keypad */
.kp-who-names::-webkit-scrollbar { display: none; }
.kp-chip-who { height: 40px; max-width: min(240px, 72%); padding: 0 16px; border-radius: 20px; font-size: 15px; } /* a long name ends in an ellipsis in its .kp-chip-text */
.kp-chip-who::after { content: ""; position: absolute; left: 0; right: 0; top: -2px; bottom: -2px; } /* 44px to tap around a 40px chip */
.kp-who-acts .kp-chip-who { max-width: none; }
.kp-who-new { display: flex; gap: 8px; width: 100%; padding: 4px 8px 0; }
.kp-who-new input { flex: 1; min-width: 0; height: 44px; padding: 0 14px; border: 1px solid var(--line-strong); border-radius: 22px; background: var(--raised); color: var(--text); font-size: 16px; }
.kp-who-new input:focus { outline: none; border-color: var(--accent); }
.kp-who-save { flex: none; min-height: 44px; padding: 0 18px; border: 0; border-radius: 22px; background: var(--accent-fill); color: #fff; font-size: 15px; font-weight: 600; }
.kp-main { flex: none; width: auto; margin: 8px 16px 6px; }

.kp-pad { display: none; grid-template-columns: repeat(3, 1fr); flex: none; padding: 4px 12px calc(12px + env(safe-area-inset-bottom)); }
.kp-key { display: flex; align-items: center; justify-content: center; height: 54px; padding: 0; border: 0; border-radius: 14px; background: none; color: var(--text); font-size: 26px; font-weight: 500; font-variant-numeric: tabular-nums; transition: background 180ms; touch-action: manipulation; -webkit-user-select: none; user-select: none; }
.kp-key .icon { width: 26px; height: 26px; stroke-width: 1.75; }
.kp-key.is-hit { background: var(--line); transition: none; }
.kp-fields { display: flex; flex-direction: column; gap: 12px; padding: 16px 20px 8px; }
.kp-field { display: flex; align-items: center; gap: 12px; min-height: 48px; font-size: 16px; }
.kp-field > span { width: 96px; flex: none; color: var(--muted); font-size: 15px; }
.kp-field input:not([type="radio"]) { flex: 1; min-width: 0; height: 44px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 12px; background: var(--bg); color: var(--text); font-size: 16px; }
.kp-field label { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; margin-right: 16px; }
.kp-form .signin-note { margin: 4px 16px; }

/* The plain form (no JavaScript, or the sheet opened as a whole page): the tiles still save; the fields below them hold the date,
   currency, rate, note and who. Only a sheet the app opened (.sheet-kp) is wired to the keypad, so only there are the fields swapped for it. */
.kp-pills, .kp-band .kp-rate, .kp-num, .kp-sym, .kp-field[data-nojs-hide] { display: none; }
.kp-amount { width: 100%; height: 64px; padding: 0; border: 0; background: transparent; color: var(--text); caret-color: var(--accent); font-size: 44px; font-weight: 700; text-align: center; outline: none; }
.sheet-kp .kp-pills { display: flex; }
.sheet-kp .kp-band .kp-rate:not([hidden]) { display: inline-flex; align-items: center; }
.sheet-kp .kp-num, .sheet-kp .kp-sym { display: inline; }
.sheet-kp .kp-amount { position: absolute; inset: 0; height: 100%; color: transparent; caret-color: transparent; font-size: 16px; opacity: 0; cursor: text; }
.sheet-kp .kp-pad { display: grid; }
.sheet-kp .kp-fields { display: none; }
.sheet-kp .kp.is-typing .kp-pad { display: none; }
.sheet-kp .kp.is-typing .kp-main { margin-bottom: calc(12px + env(safe-area-inset-bottom)); }
.sheet-kp .kp.is-typing .kp-targets { padding-bottom: calc(12px + env(safe-area-inset-bottom)); } /* the keypad stepped aside: room under the targets */

/* Short screens: give up space in this order (js/entry.js fitKeypad). 1: a compact layout that keeps Again (46px keys, the amount
   box only as tall as the number and the Again band, tighter gaps). 2: the Again row. 3: one sideways row of targets. */
.kp.fit-1 .kp-key { height: 46px; font-size: 24px; }
.kp.fit-1 .kp-pad { padding-top: 2px; padding-bottom: calc(8px + env(safe-area-inset-bottom)); }
.kp.fit-1 .kp-seg { margin-top: 4px; }
.kp.fit-1 .kp-amtbox { height: 104px; }
.kp.fit-1 .kp-qrow:not(:has(.kp-delete)) { padding-top: 4px; }
.kp.fit-2 .kp-again { display: none; }
.kp.fit-2 .kp-amtbox { height: 84px; }
.kp.fit-2 .kp-amtbox.has-again .kp-amt { transform: none; }
.kp.fit-1 .kp-amtbox:has(.kp-rate:not([hidden])) { height: 120px; } /* the rate line under the number */
.kp-amtbox:has(.kp-note-slot:not([hidden])), .kp.fit-1 .kp-amtbox:has(.kp-note-slot:not([hidden])) { height: 130px; } /* the keypad steps aside while the note is typed */
.kp.fit-3 .kp-grid { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; } /* one sideways row, in order 1, 2, 3 */
.kp.fit-3 .kp-page { display: contents; }
.kp.fit-3 .kp-tile { flex: 0 0 calc((100% - 16px) / 5); scroll-snap-align: start; }

@media (max-width: 389px) {
  .kp[data-edit] .kp-pill .icon { display: none; } /* room for Done beside the three pills */
}
@media (max-width: 359px) {
  .kp-seg { margin: 6px 12px 0; }
  .kp-seg-item { font-size: 12.5px; letter-spacing: -0.01em; }
  .kp-pill { padding: 0 10px; }
  .kp-pill-word { display: none; }
  .kp-targets { padding: 0 8px; }
  .kp-tile { padding-left: 0; padding-right: 0; }
  .kp-tl { letter-spacing: -0.02em; } /* "Phone and internet" keeps to two lines in a 58px tile */
}

@media (prefers-reduced-motion: reduce) {
  .kp-amt, .kp-ti, .kp-key, .kp-seg-item, .kp-flow-item { transition: none; }
  .kp-amtbox.has-again .kp-amt { transition: none; }
  .kp-shake { animation: kp-flash 420ms ease-out; }
  .kp-tile:active .kp-ti { transform: none; }
  .kp-menu, .kp-again { animation: none; }
}
@keyframes kp-flash { 0%, 60% { color: var(--red); } }
.kp-chip:not(.kp-chip-lg)::after { content: ""; position: absolute; left: 0; right: 0; top: -6px; bottom: -6px; } /* 44px to tap around a 32px chip */

/* ---------- 17. Round 2 ---------- */
/* The sheet of one loan: "EMI ৳11,000" and "All ৳54,000" sit where the Again row sits; a dollar loan keeps its rate line beside them */
.kp-fill { display: flex; align-items: center; gap: 8px; flex: 0 1 auto; min-width: 0; padding: 0 20px; overflow-x: auto; scrollbar-width: none; animation: fade-in 180ms ease-out; }
.kp-fill::-webkit-scrollbar { display: none; }
.kp-amtbox:has(.kp-fill:not([hidden])) .kp-amt { transform: translateY(-20px); }
.kp-band:has(.kp-fill:not([hidden])):has(.kp-rate:not([hidden])) .kp-fill { padding-right: 0; }
.kp-band:has(.kp-fill:not([hidden])) .kp-rate { flex: none; }

/* Pay it off on a loan's page: a real form whose button is one of the actions, with the amount under its label */
.act-form { display: contents; }
button.act { width: 100%; border: 0; color: var(--text); font-family: inherit; cursor: pointer; }
.actions-n .act { justify-content: flex-start; } /* the icons line up across the row, whatever is under the labels */
.act-text { display: flex; flex-direction: column; align-items: center; gap: 1px; min-width: 0; max-width: 100%; }
.act-sub { max-width: 100%; overflow: hidden; color: var(--muted); font-size: 12px; font-weight: 500; line-height: 16px; text-overflow: ellipsis; white-space: nowrap; font-variant-numeric: tabular-nums; }
button.act:disabled { opacity: 0.5; }

/* Month arrows beside the month name: 44px each, a hidden one keeps its place */
.month-nav { display: flex; align-items: center; min-width: 0; margin-left: -12px; }
.top .back-btn + .month-nav { margin-left: 0; margin-right: -12px; }
.month-nav .month-btn { margin-left: 0; }
.month-arrow { display: grid; place-items: center; width: 44px; height: 44px; flex: none; border-radius: 50%; color: var(--text); transition: background 140ms; }
.month-arrow:active { background: var(--fill); }
.month-arrow.is-off { visibility: hidden; }
.icon-arrow { width: 20px; height: 20px; }

/* New loan: three fields, one switch, the rest under More. The switch shows its fields by CSS, so it works without JavaScript */
.loan-new .lbl { width: 96px; }
.who-to, .loan-new:has(input[name="direction"][value="lent"]:checked) .who-from { display: none; }
.loan-new:has(input[name="direction"][value="lent"]:checked) .who-to { display: inline; }
.who-chips { display: flex; gap: 8px; margin: 0 -20px; padding: 12px 20px 4px; overflow-x: auto; scrollbar-width: none; }
.who-chips::-webkit-scrollbar { display: none; }
.chip-sm { min-height: 32px; max-width: 200px; padding: 0 14px; border-radius: 16px; font-size: 14px; }
.chip-sm::after { content: ""; position: absolute; left: 0; right: 0; top: -6px; bottom: -6px; } /* 44px to tap */
.chip-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; line-height: 20px; padding-bottom: 1px; } /* the pixel keeps the tails of g, p and y */
html:not(.js) .who-chips { display: none; } /* the chips fill the field by script; without it they would do nothing */
.loan-new .amount-row { margin-top: 12px; }
.monthly-fields { display: none; padding: 4px 0 6px; }
.loan-new:has(input[name="monthly"]:checked) .monthly-fields { display: block; }
.mini-fields { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 12px; }
.mini-field { display: flex; flex-direction: column; min-width: 0; border-bottom: 1px solid var(--line); transition: border-color 160ms; }
.mini-field:focus-within { border-bottom-color: var(--accent); }
.mini-field > span { padding-top: 8px; color: var(--muted); font-size: 13px; line-height: 17px; }
.mini-field .line-input { flex: none; height: 44px; } /* a column: without flex none the field would shrink to its text */
.mini-note { margin-top: 8px; }
.loan-more { margin-top: 4px; }
.loan-more > summary { list-style: none; cursor: pointer; }
.loan-more > summary::-webkit-details-marker { display: none; }
.more-row { display: flex; align-items: center; justify-content: space-between; min-height: 52px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 15px; font-weight: 600; }
.loan-more[open] .chev { transform: rotate(90deg); }
.more-cap { padding-top: 14px; color: var(--muted); font-size: 15px; }
.more-cap + .date-row { padding-top: 8px; }
.loan-new:not(:has(input[name="currency"][value="USD"]:checked)) .rate-row,
.loan-new:not(:has(input[name="currency"][value="USD"]:checked)) .rate-row + .field-error { display: none !important; }

/* New investment: the name, then the seven types as keypad targets; a tap on one saves */
.inv-q { margin: 18px 0 4px; color: var(--text); font-size: 13px; font-weight: 500; }
.inv-types { margin: 0 -8px 8px; }
.inv-new .kp-tile { cursor: pointer; }
.inv-new .kp-tile:disabled { opacity: 0.5; }
.inv-new .kp-tile:active .kp-ti { transform: scale(0.92); background: var(--line); }

/* Sign in remembers who you are */
.welcome { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.welcome-line { font-size: 17px; }
.welcome-line strong { font-weight: 700; }
.welcome-not { min-height: 44px; padding: 0; border: 0; background: none; color: var(--muted); font-size: 15px; font-weight: 500; text-decoration: underline; text-underline-offset: 3px; } /* 44px to tap, its own box */

/* Erase my book */
.set-icon-danger { color: var(--red); }
.erase-goes { margin-top: 4px; font-size: 20px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.25; }
.erase .sheet-lead { margin-top: 10px; }
.erase-warn { margin-top: 12px; padding: 12px 14px; border-radius: 14px; background: color-mix(in srgb, var(--red) 10%, var(--bg)); color: var(--text); font-size: 15px; }
.erase-copy { gap: 6px; margin-top: 8px; }
.erase-form { margin-top: 4px; padding-bottom: 8px; }
.btn-danger:disabled { opacity: 0.4; }

/* Owner only: the address the server sees */
.visitor-list { margin: 0; padding: 4px 0 14px; }
.visitor-row { display: flex; flex-direction: column; gap: 2px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.visitor-row dt { color: var(--muted); font-size: 13px; }
.visitor-row dd { margin: 0; font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 15px; overflow-wrap: anywhere; }

@media (prefers-reduced-motion: reduce) {
  .kp-fill { animation: none; }
  .month-arrow { transition: none; }
}
/* A sheet opened as a whole page (no JavaScript): its sticky Save stays above the tab bar instead of under it */
body.has-tabs .sheet-page .form-actions { bottom: calc(var(--tab-h) + env(safe-area-inset-bottom)); }
/* Settings: a row with two lines (Bring back what you erased, then when and how long), the icon centred on both */
.set-label-2 { display: flex; flex-direction: column; gap: 2px; min-width: 0; padding: 9px 0; }
.set-line { overflow-wrap: break-word; } /* very large text: the label wraps onto a second line, never an ellipsis */
.set-how { white-space: normal; } /* the iPhone row's how to install is never cut */
.set-label-2 .row-sub { font-weight: 400; }
