/* Page frame, controls, dock, sheets, lists. Values come from tokens.css. */

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; font-size: 17px; font: -apple-system-body; -webkit-font-smoothing: antialiased; } /* Safari: follows Larger Text */
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 var(--fs-body)/1.35 var(--font);
  font-variant-numeric: tabular-nums;
  letter-spacing: -.01em;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
/* one comfortable column; on iPad or a desktop browser it stays phone-width and centred */
#screen { max-width: 560px; margin: 0 auto; min-height: 100dvh; padding-bottom: calc(110px + env(safe-area-inset-bottom)); }

button, input, select, textarea { font: inherit; color: inherit; }
::selection { background: color-mix(in srgb, var(--tint) 28%, transparent); }
input, textarea { caret-color: var(--tint); }
::placeholder { color: var(--text-2); opacity: 1; } /* browser default grey is 2.35:1 */
input[type="checkbox"] { accent-color: var(--tint); }
button { background: none; border: 0; padding: 0; }
a[href], button, summary, select, label[for], [role="button"] { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .45; }
:focus-visible { outline: 2px solid var(--tint); outline-offset: 2px; border-radius: 6px; }
.on-hero :focus-visible, .on-hero:focus-visible { outline-color: var(--on-hero); }

.ic { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.amount { font-weight: 600; white-space: nowrap; }
.income { color: var(--income); }
.muted { color: var(--text-2); }

/* grouped inset lists (iOS) */
.group-title { display: flex; justify-content: space-between; gap: var(--sp-3); margin: var(--sp-4) var(--sp-5) var(--sp-2); font-size: var(--fs-head); font-weight: 600; }
.group-title .muted { font-weight: 500; }
.group { background: var(--surface); border-radius: var(--r-row); margin: 0 var(--sp-3); overflow: hidden; box-shadow: var(--shadow-card); }
.row { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 48px; padding: 0 0 0 var(--sp-3); text-align: left; }
.row-body { flex: 1; min-width: 0; display: flex; align-items: center; gap: var(--sp-2); padding: 8px var(--sp-3) 8px 0; border-bottom: .5px solid var(--separator); min-height: 48px; }
.row:last-child .row-body { border-bottom: 0; }
.row:active { background: var(--fill); }
.row-text { flex: 1; min-width: 0; }
.row-text strong { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; font-weight: 400; overflow-wrap: anywhere; } /* full note is in the edit sheet */
.row-text small { display: block; font-size: var(--fs-small); color: var(--text-2); margin-top: 1px; overflow-wrap: anywhere; }
.tile { width: 30px; height: 30px; border-radius: var(--r-tile); display: grid; place-items: center; color: #fff; flex: none; }
.tile .ic { width: 17px; height: 17px; }

/* floating dock: dark bar with the add button in the middle */
.dock { position: fixed; left: 50%; bottom: calc(14px + env(safe-area-inset-bottom)); transform: translateX(-50%); width: min(536px, calc(100% - 24px)); z-index: 10; }
.tabbar { min-height: 62px; border-radius: 31px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 4px 8px; background: var(--bar); box-shadow: var(--shadow-float); }
.tabbar .half { display: flex; justify-content: space-around; min-width: 0; }
.tab { flex: 0 1 auto; min-width: var(--tap); padding: 0 4px; white-space: nowrap; letter-spacing: -.02em; min-height: 54px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; border-radius: 26px; font-size: min(var(--fs-tiny), 13px); font-weight: 600; color: var(--on-bar); }
.tab[aria-current="page"] { color: #fff; }
.tab:focus-visible, .add:focus-visible { outline-color: #fff; }
.add { width: 54px; height: 54px; margin: 0 4px; border-radius: 50%; display: grid; place-items: center; color: #fff; flex: none; background: var(--primary); box-shadow: 0 4px 12px rgba(46, 10, 20, .35); touch-action: none; -webkit-touch-callout: none; user-select: none; -webkit-user-select: none; }
.add:active { transform: scale(.94); }
.add .ic { width: 26px; height: 26px; stroke-width: 2.6; }

/* "Add again" menu over the add button */
.quick { position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translateX(-50%); width: min(300px, calc(100% - 32px)); z-index: 15; background: var(--bar); color: #fff; border-radius: 18px; padding: 6px; box-shadow: var(--shadow-float); animation: pop .22s var(--spring); }
.quick p { margin: 0; padding: 6px 10px 4px; font-size: var(--fs-tiny); color: var(--on-bar); }
.quick button { display: flex; width: 100%; min-height: var(--tap); justify-content: space-between; align-items: center; gap: var(--sp-2); padding: 6px 10px; border-radius: 12px; text-align: left; color: #fff; }
.quick button small { display: block; color: var(--on-bar); font-size: var(--fs-tiny); }
.quick button:active, .quick button:focus-visible { background: rgba(255, 255, 255, .1); outline: none; }
@keyframes pop { from { opacity: 0; transform: translateX(-50%) translateY(10px) scale(.92); } }

/* toast with an optional Undo */
.toast { position: fixed; left: 50%; bottom: calc(92px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 30; display: flex; align-items: center; gap: var(--sp-2); max-width: calc(100% - 32px); background: var(--bar); color: #fff; border-radius: 20px; padding: 4px 6px 4px 14px; font-size: var(--fs-small); box-shadow: var(--shadow-float); animation: rise-in .25s var(--ease-out); }
.toast span { padding: 8px 0; }
.toast button { min-height: 36px; padding: 0 10px; color: #ff9fbb; font-weight: 700; border-radius: 14px; }
@keyframes rise-in { from { opacity: 0; transform: translate(-50%, 16px); } }

/* bottom sheets (entry, account, settings) */
.sheet-wrap { position: fixed; inset: 0; z-index: 20; display: flex; align-items: flex-end; justify-content: center; background: var(--scrim); animation: fade .2s ease-out; }
.sheet { width: min(560px, 100%); max-height: calc(100dvh - 24px); overflow-y: auto; background: var(--bg); border-radius: var(--r-sheet) var(--r-sheet) 0 0;
  padding: var(--sp-3) 0 calc(var(--sp-5) + env(safe-area-inset-bottom)); animation: rise .32s var(--ease-out); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); padding: 0 var(--sp-3) var(--sp-2); }
.sheet-head h2 { margin: 0; font-size: var(--fs-sheet); font-weight: 600; text-align: center; flex: 1; }
.text-btn { min-height: var(--tap); min-width: var(--tap); padding: 0 var(--sp-2); color: var(--tint); font-weight: 500; border-radius: 10px; }
.text-btn.strong { font-weight: 700; }
.text-btn, .tab, .week button { transition: opacity .15s ease-out, transform .15s ease-out; }
.text-btn:active, .week button:active:not(:disabled) { opacity: .55; transition-duration: 0s; }
.tab:active { transform: scale(.94); }
.sheet-head h2, .empty strong { text-wrap: balance; }
.hint, .error, .banner p, .empty, .confirm p { text-wrap: pretty; }
.text-btn.danger { color: var(--wine-500); }
.sheet-wrap.closing { animation: fade .16s ease-in reverse forwards; pointer-events: none; }
.sheet-wrap.closing .sheet { animation: sink .16s ease-in forwards; }
@keyframes sink { to { transform: translateY(24px); opacity: 0; } }
@keyframes rise { from { transform: translateY(100%); } }
@keyframes fade { from { opacity: 0; } }

/* form rows inside grouped lists */
.field { display: flex; align-items: center; gap: var(--sp-3); min-height: 48px; padding: 0 var(--sp-3); border-bottom: .5px solid var(--separator); }
.field:last-child { border-bottom: 0; }
.field label, .field .label { flex: none; min-width: 84px; }
.field input, .field select { flex: 1; min-width: 0; min-height: var(--tap); border: 0; background: none; text-align: right; font-size: max(16px, var(--fs-body)); } /* under 16px iOS zooms the page on focus */
.field input:focus-visible, .field select:focus-visible { outline-offset: -2px; }
.error { color: var(--wine-500); font-size: var(--fs-small); margin: var(--sp-1) var(--sp-5) 0; }
@media (prefers-color-scheme: dark) { .error, .text-btn.danger { color: var(--wine-200); } }
.hint { color: var(--text-2); font-size: var(--fs-small); margin: var(--sp-2) var(--sp-5) 0; }

.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--fill); border-radius: 10px; padding: 2px; margin: 0 var(--sp-3); }
.seg button { min-height: var(--tap); border-radius: 8px; font-size: var(--fs-head); font-weight: 600; }
.seg button[aria-pressed="true"] { background: var(--seg-on); box-shadow: 0 1px 3px rgba(0,0,0,.12); }

.empty { text-align: center; color: var(--text-2); padding: var(--sp-5) var(--sp-5); }
.empty strong { display: block; color: var(--text); font-size: var(--fs-sheet); margin-bottom: var(--sp-1); }

.banner { display: flex; align-items: center; gap: var(--sp-2); margin: var(--sp-3) var(--sp-3) 0; padding: var(--sp-2) var(--sp-2) var(--sp-2) var(--sp-4); background: var(--surface); border-radius: var(--r-row); font-size: var(--fs-small); }
.banner p { flex: 1; margin: 0; }

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

/* screen heading (Stats, Accounts) */
.screen-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--sp-2); padding: calc(var(--sp-4) + env(safe-area-inset-top)) var(--sp-5) var(--sp-2); }
.screen-head h1 { margin: 0; font-size: var(--fs-hero); font-weight: 800; letter-spacing: -.02em; }
