:root {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang SC", "Hiragino Sans GB", sans-serif;
  color: var(--ink); background: var(--page); font-synthesis: none; -webkit-font-smoothing: antialiased;
  color-scheme: light dark;
  --ink: #232936; --page: #f4f6fa; --desktop: #e9edf3; --header: #f4f6fae8; --control: #e9edf4;
  --blue: #4265d6; --muted: #5e6b7d; --line: #e9edf3; --surface: #fff; --green: #287d68;
  --glass: rgba(255, 255, 255, .78); --glass-edge: 1px solid rgba(255, 255, 255, .95);
  --glass-shadow: 0 8px 32px #293b6810, inset 0 1px 0 #fff;
}
/* Hide scroll indicators without disabling touch, wheel or keyboard scrolling. */
* { box-sizing: border-box; scrollbar-width: none; }
::-webkit-scrollbar { display: none; width: 0; height: 0; }
body { margin: 0; -webkit-tap-highlight-color: transparent; }
button, input, select { font: inherit; }
button, a, input { touch-action: manipulation; }
button { cursor: pointer; color: inherit; }
button, fieldset { border: 0; margin: 0; }
button:disabled { cursor: default; opacity: .45; }
a { color: inherit; text-decoration: none; }
button:focus-visible, a:focus-visible, input:focus-visible { outline: 3px solid #87a7ed; outline-offset: 3px; }
main:focus, dialog:focus { outline: none; }
:root:not([data-input="keyboard"]) :is(button, a, input):focus { outline: none; }
[hidden] { display: none !important; }
svg { display: block; width: 22px; height: 22px; flex-shrink: 0; }
button svg { margin: auto; }
h1, h2, h3, p { margin: 0; }
.app-shell { max-width: 560px; min-height: 100svh; margin: auto; background: var(--page); overflow-x: clip; }
.app-header { display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 5; padding: calc(22px + env(safe-area-inset-top)) 24px 22px; background: var(--header); backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px); }
.brand { display: flex; align-items: center; gap: 11px; }
.brand > span { font-size: 23px; font-weight: 650; letter-spacing: 1px; line-height: 1.15; }
.brand small { display: block; font-size: 11px; font-weight: 450; letter-spacing: 1.6px; color: var(--muted); margin-top: 5px; }
.brand img { width: 42px; height: 42px; border-radius: 13px; box-shadow: 0 3px 8px #4265d617; }
.header-actions { display: flex; align-items: center; gap: 9px; }
.icon-button { display: flex; align-items: center; justify-content: center; width: 44px; height: 44px; padding: 0; border-radius: 50%; background: var(--surface); }
.storage-status { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 12px; border-radius: 999px; border: var(--glass-edge); background: #ffffff9e; color: var(--green); font-size: 12px; font-weight: 500; }
.storage-status::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.storage-status[data-state="offline"], .storage-status[data-state="error"] { color: #986a22; }
.transaction.needs-category .transaction-copy strong { color: var(--blue); }
main { padding: 0 24px calc(124px + env(safe-area-inset-bottom)); }
.loading { padding: 80px 0; text-align: center; color: var(--muted); }
.month-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 7px 0 23px; }
.month-picker { position: relative; display: flex; align-items: center; gap: 10px; min-height: 44px; }
.month-picker h1 { font-size: 30px; font-weight: 650; letter-spacing: -1px; }
.month-picker h1 span { display: block; margin-bottom: 3px; font-size: 12px; font-weight: 500; letter-spacing: .5px; color: var(--muted); }
.month-picker svg { width: 15px; height: 15px; margin-top: 15px; color: var(--muted); }
.period-trigger { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: 12px; background: transparent; }
.month-actions { display: flex; align-items: center; padding: 2px; gap: 1px; border-radius: 999px; background: var(--glass); border: var(--glass-edge); box-shadow: 0 2px 10px #293b6805; }
.month-actions .icon-button { width: 40px; height: 40px; background: transparent; }
.month-actions svg { width: 17px; height: 17px; }
.text-button { background: transparent; color: var(--blue); padding: 12px 10px; font-size: 12px; border-radius: 999px; }
.summary { padding: 26px 19px 19px; border-radius: 30px; background: linear-gradient(135deg, #fff 20%, #f9faff 100%); border: 1px solid #fff; box-shadow: 0 6px 24px #354b7d06; }
.summary-label { text-align: center; color: var(--muted); font-size: 12px; font-weight: 500; letter-spacing: .7px; }
.summary-label svg { width: 16px; height: 16px; color: #6f81ad; }
.summary-amount { display: flex; align-items: baseline; justify-content: center; gap: 7px; margin-top: 11px; font-variant-numeric: tabular-nums; }
.summary-amount small { font-size: 25px; font-weight: 450; color: #69748a; }
.summary-amount strong { font-size: clamp(36px, 12vw, 54px); font-weight: 550; letter-spacing: -2px; line-height: 1.2; overflow-wrap: anywhere; min-width: 0; }
.summary-amount.long-amount strong { font-size: clamp(23px, 6.7vw, 36px); letter-spacing: -1.2px; }
.summary-details { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); margin: 24px 0 0; gap: 10px; }
.summary-details > div { min-width: 0; padding: 14px 10px; border: 1px solid var(--line); border-radius: 22px; background: color-mix(in srgb, var(--page) 72%, transparent); text-align: center; }
.summary-details dt { display: flex; align-items: center; justify-content: center; gap: 5px; font-size: 12px; color: var(--muted); margin-bottom: 7px; }
.summary-dot { width: 5px; height: 5px; border-radius: 50%; }
.income-dot { background: #81b9a7; }
.expense-dot { background: #8c9ed4; }
.summary-details dd { margin: 0; font-size: clamp(14px, 4.4vw, 19px); font-weight: 550; font-variant-numeric: tabular-nums; letter-spacing: -.4px; overflow-wrap: anywhere; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 29px 2px 17px; }
.section-heading h2 { font-size: 17px; font-weight: 650; letter-spacing: -.3px; }
.ledger-heading { margin-bottom: 14px; }
.entry-count { color: var(--muted); font-size: 12px; }
.filter-tabs { display: flex; gap: 0; padding: 4px; margin-bottom: 24px; border-radius: 999px; background: var(--control); }
.filter-tabs button { flex: 1; white-space: nowrap; min-height: 38px; padding: 8px 6px; border-radius: 999px; color: #646f80; font-size: 12px; background: transparent; }
.filter-tabs button[aria-pressed="true"] { color: var(--ink); font-weight: 600; }
.day-group { margin-bottom: 23px; }
.day-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin: 0 3px 11px; color: var(--muted); }
.day-heading h3 { font-size: 12px; font-weight: 550; }
.day-heading h3 span { font-size: 12px; font-weight: 400; }
.day-heading p { font-size: 12px; font-variant-numeric: tabular-nums; text-align: right; }
.transaction-list { overflow: hidden; border-radius: 26px; background: var(--surface); }
.transaction-item { position: relative; overflow: hidden; max-height: 140px; touch-action: pan-y pinch-zoom; }
.transaction-front { position: relative; z-index: 1; display: flex; align-items: stretch; padding: 0 9px 0 17px; background: var(--surface); transform: translateX(var(--swipe-offset, 0px)); }
.transaction-item.is-open { --swipe-offset: calc(-1 * var(--row-reveal)); }
.transaction-item + .transaction-item .transaction-front::before { content: ""; position: absolute; left: 17px; right: 17px; top: 0; height: 1px; background: #f0f2f6; }
.transaction { display: flex; align-items: center; flex: 1; min-width: 0; gap: 12px; min-height: 77px; padding: 16px 0; text-align: left; background: transparent; }
.transaction-more { display: flex; align-items: center; justify-content: center; flex-shrink: 0; align-self: center; width: 44px; height: 44px; margin-left: 2px; padding: 0; border-radius: 999px; color: #9ba6b9; background: transparent; }
.transaction-more svg { width: 17px; height: 17px; }
.transaction-actions { position: absolute; inset: 5px 5px 5px auto; display: flex; width: calc(var(--row-reveal) - 10px); }
.row-action { display: flex; flex: 1; flex-direction: column; align-items: center; justify-content: center; gap: 5px; min-width: 0; padding: 8px 3px; border-radius: 22px; font-size: 12px; }
.row-action svg { width: 21px; height: 21px; margin: 0; }
.row-delete { color: white; background: #c6505d; }
.transaction-front, .transaction-actions { -webkit-user-select: none; user-select: none; }
.transaction-item.is-dragging .transaction-front { transition: none; will-change: transform; }
.transaction-item.is-removing { max-height: 0; opacity: 0; }
.category-icon { display: flex; align-items: center; justify-content: center; flex-shrink: 0; width: 43px; height: 43px; border-radius: 50%; color: var(--category); background: var(--tint); }
.category-icon svg { width: 21px; height: 21px; }
.transaction-copy { min-width: 0; flex: 1; }
.transaction-copy strong { display: block; font-size: 14px; font-weight: 550; }
.transaction-copy small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 5px; color: var(--muted); font-size: 12px; }
.transaction-amount { flex-shrink: 0; font-size: 17px; font-weight: 600; letter-spacing: -.4px; font-variant-numeric: tabular-nums; }
.transaction-amount.income { color: var(--green); }
.transaction-amount.transfer { color: var(--muted); }
.empty-state { padding: 30px 15px 25px; text-align: center; }
.empty-icon { display: flex; align-items: center; justify-content: center; width: 66px; height: 66px; margin: 0 auto 19px; border: 1px solid #fff; border-radius: 24px; color: #8c9cc5; background: #e9eef8; }
.empty-icon svg { width: 30px; height: 30px; }
.empty-state h3 { margin-bottom: 8px; font-size: 16px; font-weight: 600; }
.empty-state p { color: var(--muted); font-size: 12px; line-height: 1.9; }
.empty-state .text-button { margin-top: 12px; }
.empty-state .secondary-button { width: max-content; min-width: 116px; min-height: 42px; margin: 19px auto 0; gap: 5px; padding: 10px 17px; font-size: 12px; background: #e5ebfa; color: var(--blue); }
.empty-state .secondary-button svg { width: 16px; height: 16px; margin: 0; }
.bottom-dock { display: flex; align-items: center; position: fixed; z-index: 10; bottom: calc(15px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); width: min(calc(100% - 48px), 340px); }
.bottom-nav { --segment-inset: 5px; --segment-fill: #e8edfbdf; position: relative; display: flex; align-items: center; flex: 1; min-width: 0; padding: 5px; border-radius: 999px; border: var(--glass-edge); background: var(--glass); box-shadow: var(--glass-shadow); backdrop-filter: blur(28px) saturate(1.6); -webkit-backdrop-filter: blur(28px) saturate(1.6); }
.bottom-nav a { position: relative; display: flex; align-items: center; justify-content: center; flex-direction: column; flex: 1; min-width: 0; gap: 3px; min-height: 52px; padding: 5px 7px; border-radius: 999px; color: var(--muted); font-size: 11px; font-weight: 500; }
.bottom-nav a > span { display: flex; align-items: center; justify-content: center; }
.bottom-nav a[aria-current="page"] { color: var(--blue); font-weight: 650; }
.bottom-nav svg { width: 21px; height: 21px; }
.header-add { flex-shrink: 0; width: 44px; height: 44px; color: white; background: linear-gradient(150deg, #7391f2, #4265d6 72%); border: 1px solid #ffffff8f; box-shadow: 0 6px 22px #4265d632, inset 0 1px 2px #ffffff60; }
.header-add svg { width: 22px; height: 22px; stroke-width: 1.8; }
.stats-switch { margin: 4px 0 22px; }
.stats-panel { padding: 28px 20px 24px; border: 1px solid #fff; border-radius: 30px; background: var(--surface); }
.donut { position: relative; width: 192px; height: 192px; border-radius: 50%; margin: 0 auto 23px; }
.donut::before { content: ""; position: absolute; inset: 18px; border-radius: 50%; background: var(--surface); }
.donut-label { display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 9px; position: absolute; inset: 0; color: var(--muted); font-size: 12px; }
.donut-label strong { max-width: 145px; overflow-wrap: anywhere; text-align: center; color: var(--ink); font-size: 23px; font-weight: 600; letter-spacing: -.6px; font-variant-numeric: tabular-nums; }
.stats-footnote { text-align: center; color: var(--muted); font-size: 12px; line-height: 1.8; }
.rank-list { padding: 22px 18px; border-radius: 26px; background: var(--surface); }
.rank-row { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.rank-row:last-child { margin-bottom: 0; }
.rank-detail { flex: 1; min-width: 0; }
.rank-line { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; font-size: 13px; }
.rank-line small { margin-left: 6px; color: var(--muted); font-size: 10px; }
.rank-line strong { white-space: nowrap; font-size: 13px; font-weight: 550; font-variant-numeric: tabular-nums; }
.rank-bar { overflow: hidden; height: 4px; margin-top: 10px; border-radius: 999px; background: #eff2f7; }
.rank-bar span { display: block; height: 100%; border-radius: inherit; background: var(--category); }
.page-title { margin: 9px 2px 23px; font-size: 29px; font-weight: 650; letter-spacing: -.9px; }
.storage-card { padding: 25px 23px 20px; border-radius: 30px; border: 1px solid #fff; background: linear-gradient(135deg, #fff, #f8faff); }
.storage-card > svg { width: 33px; height: 33px; margin-bottom: 19px; color: #647ebf; stroke-width: 1.45; }
.storage-card h2 { margin-bottom: 10px; font-size: 18px; font-weight: 600; letter-spacing: -.4px; }
.storage-card p { color: var(--muted); font-size: 12px; line-height: 1.9; }
.storage-meta { display: flex; align-items: center; gap: 7px; margin-top: 19px; padding-top: 17px; border-top: 1px solid var(--line); color: var(--green); font-size: 12px; }
.status-dot { flex-shrink: 0; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.storage-meta[data-state="error"], .storage-meta[data-state="offline"] { color: #986a22; }
.settings-group { margin-top: 28px; }
.settings-group > h2 { margin: 0 0 12px 4px; color: var(--muted); font-size: 12px; font-weight: 500; }
.settings-list { padding: 0 18px; border-radius: 26px; background: var(--surface); }
.settings-row { display: flex; align-items: center; gap: 12px; min-height: 81px; width: 100%; padding: 17px 0; background: transparent; text-align: left; }
.settings-row + .settings-row { border-top: 1px solid var(--line); }
.settings-row > svg { width: 21px; height: 21px; color: #647ebf; }
.settings-row > span { flex: 1; min-width: 0; }
.settings-row strong { display: block; font-size: 14px; font-weight: 550; }
.settings-row small { display: block; margin-top: 6px; color: var(--muted); font-size: 12px; line-height: 1.6; }
.settings-row .row-chevron { width: 15px; height: 15px; color: #9ba5b7; }
.settings-note { padding: 13px 5px 0; color: var(--muted); font-size: 12px; line-height: 1.9; }
.app-version { margin: 31px 0 10px; color: var(--muted); font-size: 12px; text-align: center; }
dialog { padding: 0; color: var(--ink); border: 1px solid #ffffffdc; background: #fcfdff; box-shadow: 0 20px 80px #17284924; }
dialog::backdrop { background: #1c2b493d; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.entry-dialog { width: min(calc(100% - 16px), 520px); max-width: 100%; max-height: calc(var(--sheet-viewport, 100dvh) - 16px - env(safe-area-inset-top)); overflow: hidden; overscroll-behavior: contain; scroll-padding: 24px; border-radius: 34px; position: fixed; inset: auto 0 calc(8px + var(--keyboard-offset, 0px)); margin: 0 auto; padding: 11px 23px max(24px, env(safe-area-inset-bottom)); }
body:has(dialog[open]) { overflow: hidden; }
.sheet-grip { width: 32px; height: 4px; margin: 0 auto 9px; border-radius: 999px; background: #d9dee8; }
.sheet-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 15px; }
.sheet-header h2 { font-size: 19px; font-weight: 650; letter-spacing: -.5px; }
.sheet-header .icon-button { width: 44px; height: 44px; color: #7b8595; background: #eef1f6; box-shadow: inset 0 1px 0 #fff; }
.sheet-header svg { width: 19px; height: 19px; }
.type-switch { position: relative; display: flex; padding: 4px; border-radius: 999px; background: var(--control); }
.type-switch label { position: relative; flex: 1; text-align: center; }
.type-switch input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; margin: 0; cursor: pointer; }
.type-switch label > span { display: block; padding: 11px 8px; border-radius: 999px; color: var(--muted); font-size: 13px; font-weight: 500; }
.type-switch input:checked + span { color: var(--ink); font-weight: 600; }
:root[data-input="keyboard"] .type-switch input:focus-visible + span { outline: 3px solid #87a7ed; }
.amount-field { display: block; margin: 24px 0 22px; }
.amount-field > span { color: var(--muted); font-size: 12px; }
.amount-field > div { display: flex; align-items: center; gap: 10px; margin-top: 8px; padding-bottom: 15px; border-bottom: 1px solid #e1e7f1; }
.amount-field b { color: #6d7990; font-size: 26px; font-weight: 450; }
.amount-field input { min-width: 0; width: 100%; padding: 0; color: var(--ink); background: transparent; outline: none; border: 0; font-size: 43px; font-weight: 550; letter-spacing: -1.5px; font-variant-numeric: tabular-nums; }
.amount-field input::placeholder { color: #b8c1d2; }
.amount-field:focus-within > div { border-color: #7f99e2; }
.category-field { min-width: 0; padding: 0; margin: 0 0 21px; }
.category-field legend { display: flex; align-items: center; justify-content: space-between; width: 100%; margin-bottom: 10px; color: var(--muted); font-size: 12px; }
.category-options { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.category-option { display: flex; flex-direction: column; align-items: center; justify-content: center; position: relative; gap: 3px; min-height: 66px; padding: 7px 2px; border: 1px solid transparent; border-radius: 24px; background: #f0f3f8; font-size: 12px; cursor: pointer; }
.category-option input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.category-option .category-icon { width: 28px; height: 28px; background: transparent; }
.category-option .category-icon svg { width: 18px; height: 18px; }
.category-option:has(input:checked) { color: var(--blue); background: #e9eefc; border-color: #bacaf2; box-shadow: inset 0 1px 0 #fff; }
.category-option input:checked ~ span:last-child { font-weight: 600; }
:root[data-input="keyboard"] .category-option:has(input:focus-visible) { outline: 3px solid #87a7ed; outline-offset: 2px; }
#entry-form[data-legacy-transfer="true"] .category-options { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-row { display: flex; align-items: center; justify-content: space-between; gap: 20px; min-height: 54px; border-top: 1px solid var(--line); }
.form-row > span, .form-row label { flex-shrink: 0; font-size: 13px; }
.form-row input { min-width: 0; width: 100%; max-width: 75%; padding: 10px 0; color: #56637a; background: transparent; border: 0; text-align: right; font-size: 16px; -webkit-appearance: none; }
.form-row input::placeholder { color: #8c96a8; font-size: 13px; }
.primary-button, .secondary-button, .danger-button { display: flex; align-items: center; justify-content: center; min-height: 50px; padding: 14px 20px; border-radius: 999px; font-size: 14px; font-weight: 600; }
.primary-button { color: white; background: var(--blue); box-shadow: inset 0 1px 0 #ffffff30; }
.secondary-button { background: #e9edf5; }
.danger-button { color: white; background: #bd4b53; }
.save-button { width: 100%; margin-top: 0; background: linear-gradient(140deg, #6583e6, #4265d6 75%); }
.delete-button { display: block; margin: 11px auto 0; padding: 12px 16px; color: #b34a50; background: transparent; border-radius: 999px; font-size: 12px; }
.form-error { margin: 9px 0 0; color: #b24747; font-size: 12px; line-height: 1.7; }
.global-error { margin: 0 24px 20px; padding: 14px; border-radius: 20px; color: #a43e3e; background: #fceaea; font-size: 12px; line-height: 1.7; }
.confirm-dialog { width: min(calc(100% - 40px), 360px); border-radius: 30px; padding: 27px 24px 22px; }
.confirm-dialog h2 { font-size: 19px; font-weight: 650; }
.confirm-dialog > p { margin-top: 12px; color: var(--muted); font-size: 13px; line-height: 1.9; }
.confirm-actions { display: flex; gap: 10px; margin-top: 24px; }
.confirm-actions button { flex: 1; padding-left: 12px; padding-right: 12px; }
.help-dialog { width: min(calc(100% - 32px), 420px); border-radius: 30px; padding: 22px; }
.help-dialog h2 { font-size: 17px; }
.help-dialog > .primary-button { width: 100%; margin-top: 0; }
.install-steps { padding-left: 23px; margin: 22px 0; font-size: 14px; line-height: 1.9; }
.install-steps li { margin-bottom: 13px; padding-left: 3px; }
.help-note { margin-top: 12px; color: var(--muted); font-size: 12px; line-height: 1.9; }
.toast { position: fixed; z-index: 100; left: 50%; bottom: calc(103px + env(safe-area-inset-bottom)); transform: translateX(-50%); width: max-content; max-width: min(calc(100% - 40px), 420px); padding: 13px 19px; border: 1px solid #ffffff20; border-radius: 24px; color: white; background: #29354def; backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); font-size: 12px; line-height: 1.7; text-align: center; pointer-events: none; }
noscript { display: block; padding: 30px; text-align: center; }

.segmented { --segment-inset: 4px; position: relative; min-width: 0; touch-action: pan-y pinch-zoom; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.segmented > [data-segment-option] { position: relative; z-index: 1; touch-action: pan-y pinch-zoom; }
.segment-thumb { position: absolute; z-index: 0; top: var(--segment-inset); bottom: var(--segment-inset); left: var(--segment-inset); width: calc((100% - 2 * var(--segment-inset)) / var(--segment-count, 2)); border-radius: 999px; border: 1px solid #fffffff2; background: linear-gradient(160deg, #ffffffa6, #ffffff10), var(--segment-fill, var(--surface)); box-shadow: 0 2px 6px #344c7710, inset 0 1px 1px #fff; backdrop-filter: blur(12px) saturate(1.3); -webkit-backdrop-filter: blur(12px) saturate(1.3); transform: translateX(var(--segment-x, calc(var(--segment-index, 0) * 100%))) scaleX(var(--segment-stretch, 1)) scaleY(var(--segment-height, 1)); pointer-events: none; }
.bottom-nav.segmented { --segment-inset: 5px; }

.segmented.is-segment-dragging .segment-thumb { transition: none; will-change: transform; box-shadow: 0 4px 14px #344c7724, inset 0 1px 1px #fff; }
.page-transition-ghost { position: fixed; z-index: 2; overflow: hidden; background: var(--page); pointer-events: none; }
.stats-controls { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; margin: 4px 0 22px; }
.stats-controls .type-switch label > span { padding: 11px 6px; }
.year-chart { margin-top: 19px; padding: 21px 20px 20px; border-radius: 26px; background: var(--surface); }
.year-chart .section-heading { margin: 0 0 20px; }
.year-chart .section-heading h2 { font-size: 14px; }
.month-bars { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 7px; }
.month-bar-item { min-width: 0; text-align: center; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.month-bar-track { position: relative; height: 83px; margin-bottom: 10px; border-radius: 999px; background: #f3f5fa; overflow: hidden; }
.month-bar { position: absolute; left: 0; right: 0; bottom: 0; border-radius: 999px; background: #9aafe5; }
.year-chart[data-kind="income"] .month-bar { background: #82b19e; }
@media (max-width: 360px) { .stats-controls { gap: 8px; } .year-chart { padding-left: 16px; padding-right: 16px; } .month-bars { gap: 5px; } }
@media (prefers-reduced-motion: reduce) { .segment-thumb { transform: translateX(var(--segment-x, calc(var(--segment-index, 0) * 100%))); } }

@media (min-width: 600px) {
  body { padding: 30px 0; background: var(--desktop); }
  .app-shell { min-height: calc(100svh - 60px); border: 1px solid #ffffffa6; border-radius: 36px; box-shadow: 0 12px 60px #23324b08; }
  .app-header { border-radius: 36px 36px 0 0; padding-top: 28px; }
  main { min-height: calc(100svh - 160px); }
  .bottom-dock { bottom: 26px; }
  .entry-dialog { inset: 0; margin: auto; max-height: calc(100dvh - 40px); }
}
@media (max-width: 360px) {
  .app-header { padding-left: 18px; padding-right: 18px; }
  main { padding-left: 18px; padding-right: 18px; }
  .month-picker h1 { font-size: 28px; }
  .summary { padding: 24px 13px 13px; border-radius: 28px; }
  .summary-details { gap: 12px; }
  .summary-details > div { padding-left: 7px; padding-right: 7px; }
  .transaction-front { padding-left: 13px; padding-right: 5px; }
  .transaction { gap: 9px; }
  .transaction-amount { font-size: 15px; }
  .transaction .category-icon { width: 38px; height: 38px; }
  .bottom-dock { width: calc(100% - 36px); }
  .bottom-nav a { padding-left: 4px; padding-right: 4px; }
  .entry-dialog { padding-left: 19px; padding-right: 19px; }
  .category-options { gap: 7px; }
  .category-option { gap: 3px; padding-left: 3px; padding-right: 3px; }
}
@media (prefers-reduced-motion: no-preference) {

  .segment-thumb { transition: none; }
  .transaction-front { transition: transform .2s cubic-bezier(.2, .8, .2, 1); }
  .transaction-item { transition: max-height .18s ease-out, opacity .15s ease-out; }
  .toast:not([hidden]) { animation: toast-in .18s ease-out; }
  .bottom-nav a, .header-add, .category-option { transition: background-color .18s, color .18s, transform .18s; }
  .header-add:active, .primary-button:active, .secondary-button:active { transform: scale(.97); }
  button:active { filter: brightness(.97); }
  @keyframes sheet-in { from { transform: translateY(22px); opacity: .4; } to { transform: translateY(0); opacity: 1; } }
  @keyframes toast-in { from { opacity: 0; translate: 0 6px; } to { opacity: 1; translate: 0 0; } }
}
@media (prefers-reduced-transparency: reduce) {
  .bottom-nav { background: var(--surface); backdrop-filter: none; -webkit-backdrop-filter: none; }
  .app-header { background: var(--page); backdrop-filter: none; -webkit-backdrop-filter: none; }
  dialog::backdrop { backdrop-filter: none; -webkit-backdrop-filter: none; }
}

/* Keep occasional controls in small capsules and leave the ledger itself quiet. */
.ledger-heading-actions { display: flex; align-items: center; gap: 8px; }
.search-toggle { width: 40px; height: 40px; background: transparent; color: var(--muted); }
.search-toggle svg { width: 19px; height: 19px; }
.ledger-search { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 18px; }
.search-field { display: flex; flex: 1 1 100%; align-items: center; gap: 9px; min-width: 0; padding: 0 15px; border-radius: 999px; background: var(--surface); color: var(--muted); }
.search-field svg { width: 18px; height: 18px; }
.search-field input { width: 100%; min-width: 0; min-height: 46px; padding: 10px 0; font-size: 16px; color: var(--ink); background: transparent; border: 0; outline: none; }
.search-field:focus-within { outline: 2px solid #87a7ed; outline-offset: 2px; }
.search-range { display: flex; flex: 1; padding: 4px; border-radius: 999px; background: var(--control); }
.search-range button { flex: 1; min-height: 34px; padding: 6px 8px; border-radius: 999px; color: var(--muted); background: transparent; font-size: 12px; white-space: nowrap; }
.search-range button[aria-pressed="true"] { color: var(--ink); font-weight: 600; }
.ledger-search .text-button { margin-left: auto; }
.ledger-chips:empty { display: none; }
.ledger-chips { margin-bottom: 15px; }
.filter-chip { display: inline-flex; align-items: center; gap: 9px; min-height: 38px; padding: 8px 13px; border-radius: 999px; background: var(--control); color: var(--blue); font-size: 13px; }
.filter-chip svg { width: 14px; height: 14px; }
.rank-row { width: 100%; background: transparent; color: inherit; text-align: left; }
.month-bar-item { padding: 0; border-radius: 12px; background: transparent; }
.month-bar-item:active .month-bar-track { outline: 2px solid var(--blue); outline-offset: 3px; }
.backup-status { padding: 0 3px; margin: -1px 0 14px; font-size: 12px; line-height: 1.8; color: var(--muted); }
.backup-status span { display: block; }
.backup-status.is-due span, .storage-status[data-state="backup"] { color: #88601d; }
#entry-form { display: flex; flex-direction: column; max-height: calc(var(--sheet-viewport, 100dvh) - 64px - env(safe-area-inset-top)); }
#entry-form > .sheet-header, #entry-form > .type-switch, .entry-actions, .sheet-grip { flex-shrink: 0; }
.entry-fields { overflow-y: auto; min-height: 0; overscroll-behavior: contain; scroll-padding: 12px; padding: 0 3px 3px; margin: 0 -3px; }
.entry-actions { padding-top: 15px; background: inherit; }
.draft-status { display: flex; flex-shrink: 0; align-items: center; justify-content: space-between; padding: 8px 3px 0; color: var(--muted); font-size: 12px; }
.draft-status button { min-height: 36px; padding: 6px 12px; border-radius: 999px; background: var(--control); color: var(--muted); font-size: 12px; }
.amount-field { margin-bottom: 0; }
.amount-field > div { padding-bottom: 10px; }
.amount-tools { margin: 10px 0 17px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.amount-field input { font-size: clamp(30px, 9vw, 43px); }
.amount-field input[readonly] { cursor: text; }
.amount-pad { padding-bottom: 12px; }
.keypad-toolbar { display: flex; align-items: center; justify-content: space-between; margin: -5px 0 6px; }
.keypad-toolbar button { display: flex; align-items: center; gap: 6px; min-height: 32px; padding: 4px 10px; border-radius: 999px; color: var(--muted); background: transparent; font-size: 12px; }
.keypad-toolbar span { font-size: 17px; line-height: 1; margin-top: -5px; }
.keypad-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 7px; }
.keypad-grid button { min-height: 43px; padding: 5px; border-radius: 999px; color: var(--ink); background: var(--surface); box-shadow: inset 0 1px 0 #ffffff40, 0 2px 5px #23324b04; font-size: 23px; font-weight: 450; font-variant-numeric: tabular-nums; touch-action: manipulation; }
.keypad-grid .keypad-function { color: var(--blue); background: var(--control); }
.keypad-grid .keypad-equals { color: white; background: #526fd0; }
.calendar-dialog { position: fixed; inset: auto 0 calc(8px + env(safe-area-inset-bottom)); width: min(calc(100% - 24px), 400px); max-height: calc(100dvh - 32px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); margin: 0 auto; padding: 11px 19px 17px; border-radius: 32px; overflow-y: auto; overscroll-behavior: contain; }
.calendar-dialog .sheet-header { margin-bottom: 12px; }
.calendar-dialog .sheet-header h2 { font-size: 19px; }
/* Five visible rows, one shared selection capsule, compositor-native inertia. */
.date-wheel-labels { display: flex; margin: 0 -3px 4px; color: var(--muted); font-size: 12px; text-align: center; }
.date-wheel-labels span { flex: 1; }
.date-wheels { position: relative; display: flex; justify-content: center; margin: 0 -3px; isolation: isolate; }
.date-wheel-highlight { position: absolute; inset: 88px 0 auto; height: 44px; border-radius: 18px; background: var(--control); box-shadow: inset 0 1px 0 #ffffff0c; pointer-events: none; }
.date-wheel { flex: 1; min-width: 0; height: 220px; padding: 88px 0; overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y; scroll-snap-type: y mandatory; scrollbar-width: none; mask-image: linear-gradient(transparent, #000 35%, #000 65%, transparent); -webkit-mask-image: linear-gradient(transparent, #000 35%, #000 65%, transparent); }
.date-wheel::-webkit-scrollbar { display: none; }
.date-wheels[data-columns="1"] .date-wheel { max-width: 200px; }
.date-wheel-row { height: 44px; display: flex; align-items: center; justify-content: center; gap: 5px; scroll-snap-align: center; font-size: 22px; font-weight: 500; font-variant-numeric: tabular-nums; color: var(--muted); cursor: pointer; user-select: none; }
.date-wheel-row.is-selected { color: var(--ink); }
.calendar-footer { display: flex; align-items: center; gap: 12px; margin-top: 14px; }
.calendar-footer button { height: 46px; border-radius: 999px; font-size: 15px; font-weight: 550; }
.calendar-today { flex: 1; background: var(--control); color: var(--muted); }
.calendar-done { flex: 2; background: var(--control); color: var(--blue); }
.date-trigger { min-height: 44px; padding: 9px 13px; border-radius: 999px; background: var(--control); color: var(--ink); font-size: 14px; }

@media (max-height: 640px) {
  .entry-dialog .sheet-header { margin-bottom: 10px; }
  .keypad-grid { gap: 5px; }
  .keypad-grid button { min-height: 36px; font-size: 21px; }
  .entry-actions { padding-top: 8px; }
  .amount-pad { padding-bottom: 8px; }
}
@media (max-height: 540px) {
  #entry-form:has(.amount-pad:not([hidden])) > :is(.sheet-grip, .sheet-header, .type-switch, .draft-status) { display: none; }
  #entry-form:has(.amount-pad:not([hidden])) .entry-fields > :is(.category-field, .form-row, #transfer-note, #amount-result) { display: none; }
  #entry-form:has(.amount-pad:not([hidden])) .amount-field { margin: 0; }
  #entry-form:has(.amount-pad:not([hidden])) .amount-field > span { display: none; }
  #entry-form:has(.amount-pad:not([hidden])) .amount-field > div { margin-top: 0; padding-bottom: 8px; }
  #entry-form:has(.amount-pad:not([hidden])) .amount-field input { font-size: 32px; }
  #entry-form:has(.amount-pad:not([hidden])) .entry-actions { padding-top: 6px; }
  #entry-form:has(.amount-pad:not([hidden])) .save-button { min-height: 44px; padding: 10px; }
  .keypad-toolbar { margin-bottom: 3px; }
  .keypad-toolbar button { min-height: 28px; }
  .amount-pad { padding-bottom: 6px; }
}
@media (prefers-reduced-motion: no-preference) {

  .keypad-grid button { transition: transform .1s, background-color .1s; }
  .keypad-grid button:active { transform: scale(.94); background: var(--control); }
}
#pin-category { min-height: 36px; padding: 5px 10px; border-radius: 999px; background: transparent; color: var(--muted); font-size: 12px; }
#pin-category[aria-pressed="true"] { color: var(--blue); background: var(--control); }
.category-option.is-favorite::after { content: ""; position: absolute; right: 7px; top: 7px; width: 4px; height: 4px; border-radius: 50%; background: var(--blue); pointer-events: none; }
.undo-bar { position: fixed; z-index: 101; left: 50%; bottom: calc(103px + env(safe-area-inset-bottom)); transform: translateX(-50%); display: flex; align-items: center; gap: 18px; width: max-content; max-width: calc(100% - 32px); padding: 7px 9px 7px 18px; border: var(--glass-edge); border-radius: 999px; background: var(--glass); box-shadow: var(--glass-shadow); backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px); font-size: 13px; }
.undo-bar button { min-height: 40px; padding: 9px 15px; border-radius: 999px; color: var(--blue); background: var(--control); font-size: 13px; font-weight: 600; }
body:has(.undo-bar:not([hidden])) .toast { bottom: calc(165px + env(safe-area-inset-bottom)); }

@media (prefers-color-scheme: dark) {
  :root { --ink: #eeeff1; --page: #111214; --desktop: #0c0d0f; --header: #111214e8; --surface: #1e2023; --control: #282a2e; --muted: #a4a7ae; --line: #303237; --blue: #b2c2f3; --green: #9bc8b6; --glass: rgba(35,37,41,.88); --glass-edge: 1px solid #ffffff0d; --glass-shadow: 0 8px 32px #00000028, inset 0 1px 0 #ffffff0c; }
  .app-shell { border-color: #ffffff12; }
  .brand img { box-shadow: 0 3px 12px #0003; }
  .storage-status, .month-actions, .summary, .stats-panel, .year-chart, .storage-card, .segment-thumb { border-color: #ffffff12; }
  .storage-status { background: #2833429e; }
  .summary, .storage-card { background: linear-gradient(135deg, #252f40, #202737); }
  .summary-label svg, .summary-amount small, .month-picker svg { color: var(--muted); }
  .bottom-nav { --segment-fill: #3b4b70dd; }
  .segment-thumb { background: linear-gradient(160deg, #ffffff0d, #ffffff02), var(--segment-fill, var(--surface)); box-shadow: 0 2px 7px #0003, inset 0 1px 1px #ffffff0c; }
  .segmented.is-segment-dragging .segment-thumb { box-shadow: 0 4px 14px #0004, inset 0 1px 1px #ffffff12; }
  .filter-tabs button, .type-switch label > span { color: var(--muted); }
  .filter-tabs button[aria-pressed="true"], .type-switch input:checked + span { color: var(--ink); }
  .category-icon { background: color-mix(in srgb, var(--category) 16%, var(--surface)); }
  .category-option { background: #26282c; }
  .category-option .category-icon { background: transparent; }
  .category-option:has(input:checked) { background: #343a48; border-color: #7b88a8; box-shadow: inset 0 1px 0 #ffffff0a; }
  .transaction-item + .transaction-item .transaction-front::before, .rank-bar, .month-bar-track { background: var(--line); }
  .transaction-more { color: #9aabc3; }
  dialog { background: #191b1e; border-color: #ffffff0e; box-shadow: 0 20px 70px #0005; }
  dialog::backdrop { background: #00000050; }
  .toast { background: #303238f5; border-color: #ffffff0a; }
  .sheet-header .icon-button, .empty-icon, .secondary-button { background: var(--control); color: var(--muted); box-shadow: none; }
  .sheet-grip { background: #51545a; }
  .amount-field > div { border-color: var(--line); }
  .amount-field b, .form-row input { color: #b9bdc5; }
  .amount-field input::placeholder, .form-row input::placeholder { color: #858993; }
  .primary-button:not(.save-button) { background: #4c6fce; color: #fff; }
  .delete-button, .form-error { color: #f5a3a7; }
  .backup-status.is-due span, .storage-status[data-state="backup"] { color: #e3bd79; }
  .empty-state .secondary-button { color: var(--blue); background: var(--control); }
  .global-error { color: #ffc0c0; background: #4a2c36; }
}

@media (prefers-reduced-transparency: reduce) { .undo-bar { background: var(--surface); backdrop-filter: none; -webkit-backdrop-filter: none; } }

/* A single central axis for the overview; rows retain readable label/value alignment. */
.app-header { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); padding-bottom: 18px; }
.brand { grid-column: 2; justify-content: center; gap: 8px; }
.brand img { width: 34px; height: 34px; border-radius: 11px; }
.brand > span { font-size: 21px; text-align: center; }
.brand small { display: none; }
.header-actions { grid-column: 3; justify-content: flex-end; }
.storage-status { padding: 0 8px; min-height: 30px; font-size: 10px; gap: 4px; white-space: nowrap; }
.month-heading { display: grid; grid-template-columns: 44px minmax(0, 1fr) 44px; gap: 8px; margin: 10px 0 20px; }
.month-picker { grid-column: 2; grid-row: 1; justify-content: center; text-align: center; }
.month-picker h1 { font-size: 28px; line-height: 1.25; }
.month-picker h1 span { margin-bottom: 4px; }
.month-picker > svg { position: absolute; left: calc(50% + 51px); bottom: 10px; margin: 0; width: 12px; }
.year-picker > svg { left: calc(50% + 66px); }
.month-actions { display: contents; }
.month-actions .text-button { display: none; }
.month-actions .icon-button { grid-row: 1; width: 40px; height: 40px; background: var(--glass); border: var(--glass-edge); align-self: center; }
.month-actions .icon-button:nth-last-child(2) { grid-column: 1; }
.month-actions .icon-button:last-child { grid-column: 3; justify-self: end; }
.summary { padding: 24px 20px 22px; border-radius: 28px; background: var(--surface); box-shadow: none; }
.summary-label { font-size: 13px; letter-spacing: 0; }
.summary-amount { position: relative; display: block; margin-top: 12px; text-align: center; }
.summary-amount small { position: absolute; right: calc(100% + 7px); bottom: 5px; font-size: 17px; }
.summary-amount { width: max-content; max-width: calc(100% - 38px); margin-left: auto; margin-right: auto; }
.summary-amount strong { display: block; font-size: clamp(36px, 11vw, 48px); font-weight: 600; letter-spacing: -1.6px; }
.summary-details { gap: 0; margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line); }
.summary-details > div { padding: 0 8px; border: 0; border-radius: 0; background: transparent; }
.summary-details > div + div { border-left: 1px solid var(--line); }
.summary-details dt { margin-bottom: 7px; }
.summary-details dd { font-size: clamp(14px, 4.4vw, 19px); font-weight: 550; }
.ledger-add svg { width: 23px; height: 23px; margin: 0; stroke-width: 1.65; }
/* Equal touch targets flank the title, away from the navigation. */
.ledger-heading { display: grid; grid-template-columns: 44px minmax(0, 1fr) 44px; align-items: center; min-height: 48px; margin: 27px 0 18px; }
.ledger-title { text-align: center; }
.ledger-title h2 { font-size: 16px; }
.ledger-title .entry-count { display: block; margin-top: 4px; font-size: 11px; }
.ledger-heading .search-toggle, .ledger-add { width: 44px; height: 44px; padding: 0; background: var(--glass); border: var(--glass-edge); box-shadow: 0 2px 8px #293b6805; color: var(--muted); }
.ledger-add { color: var(--ink); }
.page-title { text-align: center; font-size: 26px; }
.storage-card { text-align: center; }
.storage-card > svg { margin-left: auto; margin-right: auto; }
.storage-meta { justify-content: center; }
.sheet-header { position: relative; justify-content: center; min-height: 44px; }
.sheet-header h2 { text-align: center; }
.sheet-header > button { position: absolute; right: 0; }
.segment-thumb { backdrop-filter: none; -webkit-backdrop-filter: none; will-change: transform; }
.segmented.is-segment-dragging .segment-thumb { box-shadow: 0 2px 6px #344c7710, inset 0 1px 1px #ffffff80; }
@media (prefers-color-scheme: dark) {
  .summary { background: var(--surface); }
  .segmented.is-segment-dragging .segment-thumb { box-shadow: 0 2px 7px #0003, inset 0 1px 1px #ffffff0c; }
}
@media (max-width: 360px) {
  .summary { padding: 22px 14px 19px; }
  .storage-status { padding: 0 6px; font-size: 9px; }
  .brand { gap: 6px; }
}

#stats-view .section-heading { flex-direction: column; align-items: center; gap: 6px; }
.settings-group > h2, .backup-status { text-align: center; margin-left: 0; }
.sheet-header h2 { max-width: calc(100% - 88px); }

/* Glass belongs to stationary surfaces; the moving thumb only transforms. */
:root { --panel-glass: rgba(255,255,255,.64); --panel-edge: rgba(255,255,255,.9); --panel-shadow: 0 10px 28px #344c7710, inset 0 1px 0 #ffffffef, inset 0 -1px 0 #ffffff70; }
.app-shell { background-image: radial-gradient(ellipse 210px 270px at 12% 420px, #91b2ee14, transparent), radial-gradient(ellipse 220px 280px at 95% 620px, #b7b2ee16, transparent); }
.summary, .stats-panel, .storage-card { background: linear-gradient(135deg, #ffffff70, #ffffff0a 55%), var(--panel-glass); border: 1px solid var(--panel-edge); box-shadow: var(--panel-shadow); backdrop-filter: blur(16px) saturate(1.15); -webkit-backdrop-filter: blur(16px) saturate(1.15); border-radius: 32px; }
.transaction-list, .settings-list, .rank-list, .year-chart { background: var(--panel-glass); border: 1px solid var(--panel-edge); box-shadow: inset 0 1px 0 #ffffffa0, 0 6px 22px #344c7707; }
.transaction-front { background: color-mix(in srgb, var(--surface) 78%, var(--page)); }
.bottom-nav { background: linear-gradient(150deg, #ffffff38, #ffffff05), var(--glass); box-shadow: 0 10px 28px #344c7718, inset 0 1px 1px #ffffffdd, inset 0 -1px 1px #ffffff80; }
.filter-tabs, .type-switch, .search-range { background: color-mix(in srgb, var(--control) 76%, transparent); box-shadow: inset 0 1px 2px #344c7708, 0 1px 0 #ffffff90; }
.month-actions .icon-button { box-shadow: inset 0 1px 1px #ffffffd0, 0 3px 10px #344c7706; }
@media (prefers-color-scheme: dark) {
  :root { --panel-glass: rgba(30,32,35,.9); --panel-edge: #ffffff09; --panel-shadow: 0 6px 22px #00000012, inset 0 1px 0 #ffffff06; }
  .summary, .stats-panel, .storage-card { background: linear-gradient(135deg, #ffffff03, #ffffff00 65%), var(--panel-glass); }
  .transaction-list, .settings-list, .rank-list, .year-chart { box-shadow: inset 0 1px 0 #ffffff0c, 0 6px 22px #00000010; }
  .bottom-nav { background: linear-gradient(150deg, #ffffff0b, #ffffff00), var(--glass); box-shadow: 0 10px 28px #00000035, inset 0 1px 1px #ffffff21, inset 0 -1px 1px #ffffff08; }
  .filter-tabs, .type-switch, .search-range { box-shadow: inset 0 1px 2px #00000015, 0 1px 0 #ffffff0a; }
  .month-actions .icon-button { box-shadow: inset 0 1px 1px #ffffff10, 0 3px 10px #00000010; }
}
@media (prefers-reduced-transparency: reduce) {
  .summary, .stats-panel, .storage-card, .transaction-list, .settings-list, .rank-list, .year-chart, .bottom-nav { background: var(--surface); backdrop-filter: none; -webkit-backdrop-filter: none; }
}

/* The ledger starts at the month, below the iPhone status area. */
main { padding-top: calc(18px + env(safe-area-inset-top)); }

/* One continuous glass lens; the spring owns its transform during taps and drags. */
.segment-thumb { transition: none; transform-origin: center; }
.segmented > [data-segment-option], .type-switch label > span { transition: color .12s ease; }
.bottom-nav { --segment-fill: #cdd9fb66; }
@media (prefers-color-scheme: dark) { .bottom-nav { --segment-fill: #ffffff10; } }
@media (prefers-reduced-motion: reduce) {
  .segmented > [data-segment-option], .type-switch label > span { transition: none; }
}

/* A quiet overview: the balance breathes; only the two supporting totals have glass. */
#ledger-view .month-heading { margin-bottom: 12px; }
#ledger-view .summary { padding: 18px 0 0; border: 0; border-radius: 0; background: none; box-shadow: none; backdrop-filter: none; -webkit-backdrop-filter: none; }
#ledger-view .summary-label { font-size: 12px; font-weight: 400; }
#ledger-view .summary-amount { margin-top: 13px; }
#ledger-view .summary-amount strong { font-weight: 500; font-size: clamp(38px, 12.8vw, 52px); letter-spacing: -1.8px; }
#ledger-view .summary-amount.long-amount strong { font-size: clamp(23px, 6.7vw, 36px); letter-spacing: -1px; }
#ledger-view .summary-amount small { font-size: 16px; bottom: 6px; color: var(--muted); }
#ledger-view .summary-details { margin: 24px 0 0; padding: 18px 8px; border: 1px solid var(--panel-edge); border-radius: 28px; background: var(--panel-glass); box-shadow: inset 0 1px 0 #ffffff80; }
#ledger-view .summary-details dt { font-size: 11px; margin-bottom: 6px; }
#ledger-view .summary-details dd { font-size: clamp(15px, 4.5vw, 19px); }
#ledger-view .filter-tabs { margin-bottom: 22px; }
@media (prefers-color-scheme: dark) {
  .app-shell { background-image: none; }
  #ledger-view .summary-details { box-shadow: none; }
  .bottom-nav { box-shadow: 0 8px 24px #0003, inset 0 1px 0 #ffffff0b; background: var(--glass); }
  .segment-thumb { background: linear-gradient(150deg, #ffffff05, transparent), var(--segment-fill, #34363a); border-color: #ffffff0a; }
  .segment-thumb, .segmented.is-segment-dragging .segment-thumb { box-shadow: 0 2px 6px #0002, inset 0 1px 0 #ffffff09; }
  .month-actions .icon-button, .ledger-heading .search-toggle, .ledger-add { background: #222427; border-color: #ffffff07; box-shadow: none; }
  .empty-icon { border-color: #ffffff07; background: #24262a; }
  .transaction-more { color: var(--muted); }
  .sheet-header .icon-button { background: #292b2f; }
  .keypad-grid button { box-shadow: none; }
  .income-dot { background: #93baa9; }
  .expense-dot { background: #9ca8c7; }
}
@media (prefers-reduced-motion: no-preference) {
  .ledger-add { transition: transform .14s ease, background-color .14s ease; }
  .ledger-add:active { transform: scale(.93); }
}

/* Sheet motion uses the same transform for entry, interactive pull and exit. */
.sheet-grip { display: block; width: 52px; height: 22px; padding: 0; margin: -4px auto 0; background: transparent; border-radius: 999px; touch-action: none; }
.sheet-grip::before { content: ""; display: block; width: 32px; height: 4px; margin: auto; border-radius: 999px; background: color-mix(in srgb, var(--muted) 45%, transparent); }
.sheet-header { touch-action: pan-x; user-select: none; }
.sheet-header h2 { max-width: 100%; }
.entry-dialog[open], .calendar-dialog[open], .help-dialog[open] { will-change: transform; }
.is-sheet-closing { pointer-events: none; }
.is-sheet-closing::backdrop { animation: sheet-backdrop-out var(--sheet-exit-duration, 220ms) linear forwards; }
@keyframes sheet-backdrop-out { from { opacity: var(--sheet-backdrop-opacity, 1); } to { opacity: 0; } }
.help-dialog { position: fixed; inset: auto 0 calc(8px + env(safe-area-inset-bottom)); margin: 0 auto; max-height: calc(100dvh - 32px - env(safe-area-inset-top)); overflow-y: auto; }


/* Period selection opens next to its trigger, retaining the page as context. */
.calendar-dialog.calendar-anchored { top: var(--calendar-top); bottom: auto; left: var(--calendar-left); right: auto; width: min(calc(100% - 32px), 360px); max-height: var(--calendar-height); margin: 0; padding: 14px 18px 16px; border-radius: 26px; transform-origin: var(--calendar-origin); box-shadow: 0 16px 50px #00000026; }
.calendar-anchored::backdrop { background: #00000014; backdrop-filter: none; -webkit-backdrop-filter: none; }
.calendar-anchored .sheet-grip { display: none; }
.calendar-anchored .date-wheel-labels { padding-top: 3px; }
.month-picker svg { transition: transform 180ms ease; }
.month-picker:has([aria-expanded="true"]) svg { transform: rotate(180deg); }
@media (prefers-reduced-motion: reduce) { .month-picker svg { transition: none; } }

.calendar-anchored[open] { will-change: transform, opacity; }
.calendar-anchored[open]:not(.is-sheet-closing)::backdrop { animation: period-backdrop-in var(--popover-duration, 260ms) cubic-bezier(.4,0,.2,1) both; }
.calendar-anchored.is-sheet-closing::backdrop { animation-timing-function: cubic-bezier(.4,0,.2,1); }
@keyframes period-backdrop-in { from { opacity: 0; } to { opacity: 1; } }

/* The date owns the center; secondary destinations sit quietly beside it. */
.page-navigation { align-items: center; }
.page-icon { display: flex; align-items: center; justify-content: center; width: 44px; height: 44px; border-radius: 50%; color: var(--muted); background: transparent; text-decoration: none; }
.page-icon svg { width: 21px; height: 21px; }
.page-icon-left { grid-column: 1; grid-row: 1; }
.page-icon-right { grid-column: 3; grid-row: 1; }
.page-navigation > .page-title { grid-column: 2; grid-row: 1; margin: 0; font-size: 22px; }
.ledger-heading .search-toggle { grid-column: 3; }
.heading-spacer { width: 44px; }
main { padding-bottom: calc(112px + env(safe-area-inset-bottom)); }
main[data-view="stats"], main[data-view="settings"] { padding-bottom: calc(30px + env(safe-area-inset-bottom)); }
.floating-add-wrap { position: fixed; z-index: 10; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom)); width: 62px; height: 62px; transform: translate3d(-50%, 0, 0); opacity: 1; will-change: transform, opacity; }
.floating-add { width: 62px; height: 62px; display: flex; align-items: center; justify-content: center; padding: 0; border-radius: 50%; color: var(--blue); background: var(--glass); border: var(--glass-edge); box-shadow: 0 6px 22px #293b681a, inset 0 1px 1px #ffffff80; backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); }
.floating-add span { display: flex; }
.floating-add svg { width: 28px; height: 28px; stroke-width: 1.7; }
.floating-add:active { transform: scale(.94); }
.floating-add-wrap.is-scroll-hidden { pointer-events: none; }
@media (prefers-color-scheme: dark) { .floating-add { box-shadow: 0 6px 22px #0004, inset 0 1px 0 #ffffff12; } }
@media (prefers-reduced-motion: reduce) { .floating-add-wrap { transition: none; } .floating-add:active { transform: none; } }
@media (prefers-reduced-transparency: reduce) { .floating-add { background: var(--surface); backdrop-filter: none; -webkit-backdrop-filter: none; } }

.ledger-heading { grid-template-columns: 64px minmax(0, 1fr) 64px; }
.ledger-heading .search-toggle { justify-self: end; }
.stats-entry { display: flex; align-items: center; justify-content: flex-start; gap: 6px; min-height: 44px; color: var(--muted); text-decoration: none; font-size: 12px; border-radius: 999px; }
.stats-entry svg { width: 17px; height: 17px; }

/* Spare categories share the sheet lifecycle; changes apply immediately. */
.optional-category { position: relative; display: flex; align-items: center; gap: 12px; min-height: 66px; cursor: pointer; }
.optional-category + .optional-category { border-top: 1px solid var(--line); }
.optional-category > span:nth-child(2) { flex: 1; font-size: 14px; }
.optional-category input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.category-toggle { width: 44px; height: 27px; border-radius: 999px; padding: 3px; background: var(--control); box-shadow: inset 0 0 0 1px var(--line); pointer-events: none; }
.category-toggle::after { content: ''; display: block; width: 21px; height: 21px; border-radius: 50%; background: var(--surface); box-shadow: 0 1px 3px #0003; transition: transform .18s ease; }
.optional-category input:checked + .category-toggle { background: var(--blue); }
.optional-category input:checked + .category-toggle::after { background: white; transform: translateX(17px); }
:root[data-input="keyboard"] .optional-category:has(input:focus-visible) { outline: 2px solid var(--blue); outline-offset: 2px; border-radius: 18px; }
#category-hint { margin: 10px 2px 0; font-size: 11px; }
.category-option > span:last-child { text-align: center; line-height: 1.35; }
@media (prefers-reduced-motion: reduce) { .category-toggle::after { transition: none; } }
/* Leave both rows of everyday categories visible above the amount keypad. */
@media (min-height: 641px) {
  #entry-form:has(.amount-pad:not([hidden])) .amount-field { margin-top: 12px; }
  #entry-form:has(.amount-pad:not([hidden])) .amount-tools { margin: 5px 0 8px; }
  #entry-form:has(.amount-pad:not([hidden])) .category-option { min-height: 54px; padding: 5px 2px; border-radius: 21px; }
  #entry-form:has(.amount-pad:not([hidden])) .category-option .category-icon { width: 23px; height: 23px; }
}
