/* Screen layouts introduced in Phase 3. Colours come only from the theme tokens. */

/* Home · Daily hero (desktop and tablet; phones keep the compact budget summary). */
.home-hero { display:grid; grid-template-columns:minmax(0,2fr) minmax(0,1fr); gap:16px; margin-bottom:24px; }
.home-hero-side { display:grid; gap:16px; align-content:stretch; }
.home-hero-side .metric { margin:0; }
#app .home-hero-budget { display:flex; flex-direction:column; gap:14px; margin:0; padding:24px; }
.home-hero-budget .hero-top { display:flex; justify-content:space-between; gap:12px; flex-wrap:wrap; color:var(--muted); font-size:var(--text-sm); }
.home-hero-budget .hero-remaining { display:flex; align-items:baseline; gap:10px; flex-wrap:wrap; }
.home-hero-budget .hero-remaining strong { font-family:var(--font-money); font-size:var(--text-hero); font-weight:700; line-height:1.05; letter-spacing:-.02em; color:var(--text); }
.home-hero-budget .hero-remaining > span { color:var(--muted); font-size:var(--text-md); }
.home-hero-budget .budget-progress { display:block; width:100%; height:8px; margin:0; }
.home-hero-budget .hero-foot { display:flex; justify-content:space-between; gap:12px; flex-wrap:wrap; color:var(--muted); font-size:var(--text-sm); }
.home-hero-budget .hero-actions { display:flex; justify-content:space-between; align-items:center; gap:12px; flex-wrap:wrap; margin-top:auto; padding-top:12px; border-top:1px solid var(--divider); }
.home-hero-budget .hero-actions p { margin:0; color:var(--text); font-size:var(--text-sm); }
.home-hero-budget[data-over-budget=true] .hero-remaining strong { color:var(--warning); }
@media (max-width:899px) { .home-hero { grid-template-columns:1fr; } .home-hero-side { grid-template-columns:1fr 1fr; } }
@media (max-width:639px) { .home-hero { display:none; } }

/* With the budget in the hero, "Where it went" stands alone beside the ledger, so it gets a full card. */
@media (min-width:640px) {
  #app .main-layout > aside > .categories-card { padding:24px; background:var(--experience-surface); border:1px solid var(--border); border-radius:var(--radius-card); }
}

/* Add transaction · step one: one-tap category tiles under the amount. Step two lives in Details. */
.quick-categories { display:grid; grid-template-columns:repeat(7,minmax(0,1fr)); gap:8px; margin:0 24px 8px; }
.quick-category { display:flex; flex-direction:column; align-items:center; justify-content:center; gap:6px; min-height:72px; padding:10px 6px; border:1px solid var(--border); border-radius:var(--radius-sm); background:var(--seg-bg); color:var(--text); cursor:pointer; transition:background-color var(--motion-enter) var(--motion-ease),border-color var(--motion-enter) var(--motion-ease); }
.quick-category span { display:grid; place-items:center; width:32px; height:32px; border-radius:var(--radius-pill); background:var(--subtle); color:var(--muted); }
/* Every tile shows its icon circle, in every theme: light tiles sit on --subtle, so the circle takes the surface tone there. */
html[data-theme=light] .quick-category span { background:var(--surface); }
.quick-category .icon { width:16px; height:16px; }
.quick-category small { max-width:100%; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-size:var(--text-xs); font-weight:500; }
@media (hover:hover) and (pointer:fine){.quick-category:hover{ border-color:var(--control-border); }}
.quick-category[aria-pressed=true] { background:var(--seg-active-bg); border-color:var(--seg-active-text); color:var(--seg-active-text); }
.quick-category[aria-pressed=true] span { background:var(--surface); color:var(--seg-active-text); }
.quick-category-more { border-style:dashed; color:var(--muted); }
.quick-category-more .icon { transform:rotate(90deg); }
.entry-details { margin:4px 0 0; }
.entry-details > summary { display:flex; align-items:center; gap:8px; min-height:44px; cursor:pointer; font-weight:600; list-style:none; }
.entry-details > summary::-webkit-details-marker { display:none; }
.entry-details > summary > span:not(.disclosure-chevron) { color:var(--muted); font-size:var(--text-sm); font-weight:400; }
.entry-details[open] > summary { margin-bottom:12px; }
@media (max-width:639px) { .quick-categories { margin:0 16px 8px; grid-template-columns:repeat(4,minmax(0,1fr)); } .quick-category { min-height:64px; } }
@media (prefers-reduced-motion:reduce) { .quick-category { transition:none; } }

/* Stats · the chart itself is the inspector. The slider stays for keyboard users and appears when focused. */
.stats-flow-plot { cursor:crosshair; touch-action:pan-y; }
.stats-chart-scrubber { position:relative; display:block; }
.stats-chart-scrubber > span { color:var(--muted); font-size:var(--text-xs); }
.stats-chart-scrubber input:not(:focus-visible) { position:absolute; width:1px; height:1px; margin:0; opacity:0; pointer-events:none; }
.stats-chart-note { margin:4px 0 0; color:var(--muted); font-size:var(--text-xs); }
@media (min-width:640px) { .story-chart-option > summary { display:none; } }
.stats-flow-switch.segmented { display:inline-flex; gap:2px; width:auto; }
.stats-flow-switch.segmented > button { padding-inline:16px; }

/* Accounts · 30-day balance trend on every card; the summary shows only what adds information. */
.account-trend { display:flex; align-items:center; gap:10px; margin:6px 0 10px; color:var(--muted); font-size:var(--text-xs); }
.account-sparkline { flex:1; min-width:0; height:28px; overflow:visible; }
.account-sparkline polyline { fill:none; stroke:var(--muted); stroke-width:1.75; stroke-linejoin:round; stroke-linecap:round; vector-effect:non-scaling-stroke; }
.account-trend[data-direction=up] polyline { stroke:var(--income); }
.account-trend[data-direction=down] polyline { stroke:var(--expense); }
.account-trend[data-direction=up] span { color:var(--income); }
.account-trend[data-direction=down] span { color:var(--expense); }
.account-trend span { flex:none; font-weight:500; }
@media (min-width:640px) { #app .accounts-summary[data-items="2"] { grid-template-columns:repeat(2,minmax(0,1fr)); } }

/* Home · savings goals card in the Daily sidebar. */
#app .home-goals-card { margin-top:16px; }
@media (min-width:640px) { #app .main-layout > aside > .home-goals-card { padding:24px; background:var(--experience-surface); border:1px solid var(--border); border-radius:var(--radius-card); } }
.home-goal-list { display:grid; gap:4px; }
.home-goal { display:grid; gap:6px; width:100%; padding:12px 0; border:0; border-top:1px solid var(--divider); background:none; color:var(--text); text-align:left; cursor:pointer; }
.home-goal:first-child { border-top:0; }
.home-goal-top { display:flex; justify-content:space-between; gap:12px; font-size:var(--text-sm); }
.home-goal-top span { color:var(--muted); }
.home-goal .bar-track { width:100%; height:6px; }
.home-goal-amounts { color:var(--muted); font-size:var(--text-xs); }
@media (hover:hover) and (pointer:fine){.home-goal:hover strong{ text-decoration:underline; text-underline-offset:3px; }}
@media (max-width:639px) { #app .home-goals-card { padding-inline:0; background:transparent; border:0; border-top:1px solid var(--border); border-radius:0; box-shadow:none; } }

/* Home · first-run setup checklist. */
#app .setup-card { margin:0 0 24px; padding:24px; }
.setup-head { display:flex; justify-content:space-between; align-items:flex-start; gap:12px; }
.setup-head h2 { margin:4px 0 0; }
.setup-progress { height:6px; margin:16px 0 8px; border-radius:var(--radius-pill); background:var(--subtle); overflow:hidden; }
.setup-progress span { display:block; height:100%; width:0; border-radius:inherit; background:var(--seg-active-text); transition:width var(--motion-value) var(--motion-ease); }
.setup-progress span[data-step="1"] { width:33.4%; } .setup-progress span[data-step="2"] { width:66.7%; } .setup-progress span[data-step="3"] { width:100%; }
.setup-steps { display:grid; gap:0; margin:0; padding:0; list-style:none; }
.setup-step { display:grid; grid-template-columns:32px minmax(0,1fr) auto; align-items:center; gap:14px; padding:14px 0; border-top:1px solid var(--divider); }
.setup-step:first-child { border-top:0; }
.setup-step strong { display:block; font-size:var(--text-md); }
.setup-step p { margin:2px 0 0; color:var(--muted); font-size:var(--text-sm); }
.setup-check { display:grid; place-items:center; width:32px; height:32px; border-radius:var(--radius-pill); border:1px solid var(--border); color:var(--muted); font-size:var(--text-sm); font-weight:600; }
.setup-check .icon { width:16px; height:16px; }
.setup-step[data-done=true] .setup-check,.setup-complete .setup-check { border-color:transparent; background:var(--seg-active-bg); color:var(--seg-active-text); animation:select-pop var(--motion-move) var(--motion-spring); }
.setup-step[data-done=true] strong { color:var(--muted); text-decoration:line-through; text-decoration-color:var(--border); }
.setup-step[data-next=true] .setup-check { border-color:var(--seg-active-text); color:var(--seg-active-text); }
.setup-complete { display:grid; grid-template-columns:32px minmax(0,1fr) auto; align-items:center; gap:14px; }
.setup-complete h2 { margin:0; font-size:var(--text-lg); }
.setup-complete p { margin:2px 0 0; color:var(--muted); font-size:var(--text-sm); }
@media (max-width:639px) {
  #app .setup-card { margin:16px; padding:18px; }
  .setup-step { grid-template-columns:32px minmax(0,1fr); }
  .setup-step > .button { grid-column:2; justify-self:start; }
}
@media (prefers-reduced-motion:reduce) { .setup-progress span { transition:none; } .setup-step[data-done=true] .setup-check,.setup-complete .setup-check { animation:none; } }

/* Stats · Overview tells the story; Details holds the analysis tables, open and ready to read. */
.stats-view-switch.segmented { grid-column:1/-1; justify-self:start; display:inline-flex; gap:2px; margin:4px 0 8px; }
.stats-view-switch.segmented > button { padding-inline:18px; }
.stats-studio[data-stats-view=overview] :is(.stats-summary-details,.stats-longer-history,.stats-more-insights,.stats-budget-block) { display:none; }
/* Fixed commitments and flexible-spending report. */
.stats-studio>.report-summary { grid-column:1/-1; }
.report-summary { color:var(--text); }
.report-headline { max-width:80ch; font-size:var(--text-lg); font-weight:500; line-height:1.7; margin-block:0 20px; }
.report-tiles { display:grid; grid-template-columns:repeat(auto-fit,minmax(180px,1fr)); gap:20px; margin:0; }
.report-tiles>div { min-width:0; }
.report-tiles dt { color:var(--muted); font-size:var(--text-sm); margin-block-end:6px; }
.report-tiles dd { margin:0; font-size:var(--text-lg); font-weight:600; overflow-wrap:anywhere; }
.report-tiles small { display:block; margin-block-start:6px; color:var(--muted); font-size:var(--text-2xs); }
.report-trend-switch { display:inline-flex; margin-block:8px 16px; }
.report-trend-switch button { min-height:44px; padding-inline:16px; }
.report-plot { width:100%; height:auto; display:block; touch-action:pan-y; }
.report-breakdown-layout { display:grid; grid-template-columns:minmax(120px,210px) minmax(0,1fr); gap:20px; align-items:start; margin-block-start:16px; }
.report-breakdown .story-donut { width:100%; max-width:210px; }
.report-cumulative { min-width:0; }
.home-panel>.report-insights { margin-block:16px; }
@media(max-width:639px) {
 .report-tiles { grid-template-columns:1fr; gap:16px; }
 .report-tiles>div { padding-block-end:12px; border-bottom:1px solid var(--divider); }
 .report-headline { font-size:var(--text-md); }
 .report-breakdown-layout { grid-template-columns:1fr; gap:12px; }
 .report-breakdown .story-donut { width:150px; margin-inline:auto; }
 .report-category-row { font-size:var(--text-sm); }
}
/* Details presents tables, commitments and plans; Overview retains the main report. */
.report-deeper { grid-column:1/-1; display:grid; gap:24px; min-width:0; }
.report-deeper>.card { min-width:0; }
.report-matrix-scroll { max-width:100%; overflow:auto; }
.stats-studio:is([data-stats-view=details],[data-stats-view=weeks])>:is(.report-summary,.stats-hero,.stats-month-review,.stats-trend,.stats-analyzer,.stats-budget-instrument,.stats-insights,.stats-budget-block) { display:none; }
.home-month-review { margin-block:12px; }
@media(max-width:639px) { .report-deeper { gap:16px; }.review-record { grid-template-columns:minmax(0,1fr); gap:4px; }.review-record>strong { text-align:start; } }
/* Keep wide table contents inside their own scrolling regions on narrow screens. */
.report-deeper { overflow-x:clip; }
.report-deeper .table-scroll { width:100%; max-width:100%; min-width:0; contain:inline-size; overscroll-behavior:contain; }
:root:has(.stats-studio[data-stats-view=details]) { overflow-x:clip; }
.report-deeper .table-scroll { max-height:min(65vh,560px); }

/* Phone grid (Apple-style grouped layout). One 16px screen margin, 16px inside every card, so reading
   always starts on the same line; every section is a card; nothing is boxed twice. */
@media (max-width:639px) {
  #app .home-panel > .report-insights { margin-inline:16px; }
  /* Sections that were flat on phones become cards like the rest. */
  #app :is(.main-layout > aside > .categories-card,.main-layout > aside > .home-goals-card),
  html[data-theme] #app[data-route=stats] .stats-studio > :is(.stats-hero,.stats-trend,.stats-analyzer),
  html[data-theme] #app[data-home-view=insights] .two-column > .card:last-child {
    padding:16px; background:var(--experience-surface); border:1px solid var(--border); border-radius:var(--radius-md); box-shadow:none;
  }
  html[data-theme] #app[data-route=stats] .stats-studio > :is(.stats-hero,.stats-trend,.stats-analyzer) { margin-block:0 12px; }
  #app .main-layout > aside > :is(.categories-card,.home-goals-card) { margin:12px 0 0; }
  /* Calendar rows share the card inset; the day grid keeps a slightly tighter 12px so cells stay wide. */
  #app .calendar-card > :is(.calendar-controls,.calendar-month-summary,.calendar-selection-summary,.calendar-legend,.calendar-footer) { padding-inline:16px; }
  #app .calendar-card > :is(.calendar-weekdays,.calendar-grid) { padding-inline:12px; }
  #app .calendar-card > :is(.calendar-weekly-totals,.calendar-breakdown) { margin-inline:16px; padding-inline:0; }
  /* 16px inside cards (20px stays on desktop); list cards keep their full-bleed rows. */
  #app :is(.card:not(.ledger):not(.calendar-card),.note-panel,.setup-card) { padding-inline:16px; }
  #app :is(.card,.metric,.note-panel,.setup-card,.stats-disclosure-section) { border-radius:var(--radius-md); }
  /* A list inside a card is not boxed again: its rows align with the card's text. */
  #app :is(.card,.week,.stats-disclosure-section) .card.ledger { margin:0; padding:0; border:0; border-radius:0; background:none; box-shadow:none; }
  #app :is(.card,.week,.stats-disclosure-section) .card.ledger > .section-heading { padding-inline:0; }
  #app :is(.card,.week,.stats-disclosure-section) .card.ledger :is(.transaction,.ledger-day-heading) { padding-inline:0; }
  /* Two summary figures sit side by side rather than leaving a half-width orphan. */
  #app .accounts-summary[data-items="2"] { grid-template-columns:repeat(2,minmax(0,1fr)); }
  #app .accounts-summary[data-items="2"] > .metric { grid-column:auto; margin:0; padding:16px; }
}
@media (max-width:639px) {
  /* Large titles, as on iOS: one size on every screen. */
  html[data-theme] #app[data-route] .page-heading h1 { font-size:var(--text-4xl); line-height:1.15; letter-spacing:-.02em; }
  /* The entry sheet fills the screen and keeps Save at the bottom; the × closes it, so Cancel is not repeated. */
  dialog.entry-dialog[open] { display:flex; flex-direction:column; }
  dialog.entry-dialog > #transaction-form { flex:1 0 auto; }
  dialog.entry-dialog #transaction-form > .dialog-footer [data-action=close] { display:none; }
  dialog.entry-dialog #transaction-form > .dialog-footer .button.primary { flex:0 1 auto; width:100%; }
}
@media (max-width:639px) {
  #app .home-panel > .home-month-review { margin:12px 16px 0; }
  #app .accounts-summary[data-items="2"] .metric-value { font-size:var(--text-3xl); }
}

/* ---- Phone space (B) ---- */
.topbar-title { display:none; }
@media (max-width:639px) {
  /* B1: once scrolled, the large title hands over to a compact bar; Home keeps month and tabs pinned. */
  /* The bar is sticky from the start and keeps its height, so content never jumps when it turns compact (it used to switch to position:fixed). */
  #app:not([data-route=home]) .topbar { position:sticky; top:0; z-index:30; border-bottom:1px solid transparent; transition:background-color var(--motion-enter) var(--motion-ease),border-color var(--motion-enter) var(--motion-ease); }
  #app:not([data-route=home]) .topbar-date { transition:opacity var(--motion-enter) var(--motion-ease); }
  #app:not([data-route=home])[data-scrolled=true] .topbar { background:color-mix(in srgb,var(--bg) 92%,transparent); border-bottom-color:var(--divider); -webkit-backdrop-filter:blur(16px); backdrop-filter:blur(16px); }
  #app:not([data-route=home])[data-scrolled=true] .topbar-date { opacity:0; }
  #app:not([data-route=home]) .topbar-title { display:block; position:absolute; left:50%; top:50%; font-size:var(--text-lg); font-weight:600; color:var(--text); opacity:0; transform:translate(-50%,-30%); transition:opacity var(--motion-enter) var(--motion-ease),transform var(--motion-enter) var(--motion-ease); pointer-events:none; }
  #app:not([data-route=home])[data-scrolled=true] .topbar-title { opacity:1; transform:translate(-50%,-50%); }
  #app[data-route=home] .mobile-home-header { position:sticky; top:0; z-index:25; background:var(--bg); }
  #app[data-route=home] .view-tabs { position:sticky; top:56px; z-index:24; }
  #app[data-route=home][data-scrolled=true] .mobile-home-header { box-shadow:0 1px 0 var(--divider); }

  /* B2: accounts read as one grouped list, one compact row per account. */
  #app .account-grid { gap:0; border:1px solid var(--border); border-radius:var(--radius-md); background:var(--experience-surface); overflow:hidden; }
  #app .account-grid > .account-card { display:grid; grid-template-columns:40px minmax(0,1fr) auto auto; grid-template-areas:"icon name name balance" "icon kind trend trend"; align-items:center; gap:2px 12px; min-height:72px; margin:0; padding:12px 16px; border:0; border-top:1px solid var(--divider); border-radius:0; background:none; box-shadow:none; text-align:left; }
  #app .account-grid > .account-card:first-child { border-top:0; }
  #app .account-card > .split:first-child { display:contents; }
  #app .account-card .account-symbol { grid-area:icon; width:40px; height:40px; }
  #app .account-card .badge { grid-area:kind; justify-self:start; padding:0; border:0; background:none; color:var(--muted); font-size:var(--text-xs); text-transform:capitalize; }
  #app .account-card h2 { grid-area:name; margin:0; font-size:var(--text-md); }
  #app .account-card .account-balance { grid-area:balance; justify-self:end; font-size:var(--text-lg); }
  #app .account-card .account-trend { grid-area:trend; justify-self:end; margin:0; gap:6px; }
  #app .account-card .account-sparkline { flex:none; width:44px; height:16px; }
  #app .account-card .account-owed { grid-column:2 / -1; font-size:var(--text-2xs); }
  #app .account-card > .split:last-child { display:none; }

  /* B5: tighter rows; the date header already says the day and the row itself is the tap target. */
  #app .ledger-grouped .mobile-date { display:none; }
  #app .transaction::after { display:none; }
  #app[data-route=home][data-home-view=daily] .transaction { min-height:60px; padding-block:10px; }

  /* B6: totals become one compact three-up row; search is hidden on Insights unless filters are active. */
  html[data-theme] #app[data-route=home]:is([data-home-view=monthly],[data-home-view=insights]) .home-panel > .metrics { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:0; padding:0; }
  html[data-theme] #app[data-route=home]:is([data-home-view=monthly],[data-home-view=insights]) .home-panel > .metrics > .metric { display:flex; flex-direction:column; align-items:flex-start; grid-column:auto; gap:4px; min-height:0; padding:14px 12px; border:0; border-left:1px solid var(--divider); border-radius:0; }
  html[data-theme] #app[data-route=home]:is([data-home-view=monthly],[data-home-view=insights]) .home-panel > .metrics > .metric:first-child { border-left:0; }
  html[data-theme] #app[data-route=home]:is([data-home-view=monthly],[data-home-view=insights]) .home-panel > .metrics .metric-value { order:2; font-size:var(--text-xl); }
  html[data-theme] #app[data-route=home]:is([data-home-view=monthly],[data-home-view=insights]) .home-panel > .metrics :is(.metric-icon,.muted.small) { display:none; }
  #app[data-home-view=insights] .home-panel > .toolbar:not(:has(.count)) { display:none; }

  /* B7: section switch scrolls in one row. */
  #app .settings-jump.segmented { display:flex; flex-wrap:nowrap; overflow-x:auto; scrollbar-width:none; grid-template-columns:none; }
  #app .settings-jump.segmented::-webkit-scrollbar { display:none; }
  #app .settings-jump.segmented > button { flex:0 0 auto; }

  /* B9: plain weekday row. */
  #app .calendar-studio .calendar-weekdays span { background:none; border:0; color:var(--muted); font-weight:500; }

  /* B4: remembered defaults as one tappable line. */
  #app .entry-defaults { margin:0 0 12px; }
}
/* B10: the page footer adds nothing on any size. */
#app .page-footer { display:none; }
.entry-defaults { display:flex; align-items:center; justify-content:space-between; gap:12px; width:100%; min-height:44px; padding:0 14px; border:1px solid var(--border); border-radius:var(--radius-sm); background:var(--subtle); color:var(--text); font-size:var(--text-sm); text-align:left; cursor:pointer; }
.entry-defaults b { color:var(--seg-active-text); font-weight:600; }
/* B7: settings dropdowns share one size; install help collapses. */
.setting-row select,#calendar-week-start,#theme { min-height:44px; padding-inline:12px; border-radius:var(--radius-sm); font-size:var(--text-md); }
.settings-install-help { margin-top:8px; }
.settings-install-help > summary { min-height:44px; color:var(--link); font-size:var(--text-sm); cursor:pointer; }
@media (max-width:639px) {
  /* B8: Stats opens tighter: controls, view switch and first card sit on a 12px rhythm. */
  html[data-theme] #app[data-route=stats] .stats-studio { row-gap:12px; }
  #app .stats-compact-controls { margin-bottom:0; }
  #app .stats-view-switch.segmented { margin:0; }
  #app :is(.card:not(.ledger):not(.calendar-card),.note-panel,.setup-card) { padding-block:16px; }
}

/* ---- Details (C) ---- */
@media (max-width:639px) {
  /* C2: one add button on phones (the tab bar); contextual "Add to <day>" stays in the calendar day panel. */
  #app .ledger > .section-heading > .icon-button[data-action=add],
  #app .calendar-card .calendar-add { display:none; }
  /* C4 (revised in E6): the chip row fades only at an edge that has more chips beyond it. */
  #app .mobile-category-chips[data-more-end=true] { -webkit-mask-image:linear-gradient(90deg,#000 calc(100% - 40px),transparent); mask-image:linear-gradient(90deg,#000 calc(100% - 40px),transparent); }
  #app .mobile-category-chips[data-more-start=true] { -webkit-mask-image:linear-gradient(90deg,transparent,#000 40px); mask-image:linear-gradient(90deg,transparent,#000 40px); }
  #app .mobile-category-chips[data-more-start=true][data-more-end=true] { -webkit-mask-image:linear-gradient(90deg,transparent,#000 40px,#000 calc(100% - 40px),transparent); mask-image:linear-gradient(90deg,transparent,#000 40px,#000 calc(100% - 40px),transparent); }
  /* C6: one smooth budget bar on phones in every theme (the segmented battery stays in Stats). */
  html[data-theme=dark] #app .mobile-budget-summary .budget-battery { display:none; }
  html[data-theme] #app .mobile-budget-summary .mobile-pace > svg:not(.icon) { display:block; }
}
/* C5: "Today" is a quiet text action, lighter than the card title beside it. */
/* Today is a ghost button like the other calendar header actions. */
#app .calendar-today { min-height:44px; padding:0 12px; border:0; border-radius:var(--radius-sm); background:transparent; box-shadow:none; color:var(--text); font-size:var(--text-sm); font-weight:500; transition:background-color var(--motion-press) var(--motion-ease); }
#app .calendar-today:active { background:var(--subtle); }
@media (hover:hover) and (pointer:fine){#app .calendar-today:hover { background:var(--subtle); }}
/* C7: transfers carry a ⇄ marker so meaning never depends on colour alone (decorative for screen readers). */
.transaction-amount.transfer::before { content:'⇄\2009' / ''; color:var(--muted); font-weight:400; }

/* ---- Phone review (E) ---- */
/* E1: the header carries one cloud icon with a state mark; it never holds words. */
.cloud-status-alert { stroke:var(--error); stroke-width:2.2; }
#app .mobile-home-header .mobile-status { overflow:hidden; }
@media (max-width:639px) {
  /* E3: each date is its own tile again: a 4px gutter, one tile radius, today as a filled date and amounts that fit. */
  #app .calendar-studio .calendar-grid,
  #app .calendar-studio .calendar-weekdays { gap:4px; }
  #app .calendar-studio .calendar-day { min-height:60px; padding:6px 2px; border-radius:var(--radius-sm); }
  #app .calendar-studio .calendar-day.today .calendar-date-number { display:grid; place-items:center; min-width:24px; height:24px; padding-inline:4px; border-radius:var(--radius-pill); background:var(--text); color:var(--bg); text-decoration:none; }
  #app .calendar-studio .calendar-day small { max-width:100%; overflow:hidden; text-overflow:clip; letter-spacing:-.02em; }
}
/* E4: Category by month reads on a phone: the category column stays put, months are one word, rows share a baseline and a fade says "more". */
.report-matrix :is(th,td) { vertical-align:middle; }
.report-matrix thead th:not(:first-child) { text-align:end; white-space:nowrap; }
/* The pinned column paints the card's own (translucent) surface over the page so it matches the card exactly. */
.report-matrix :is(thead,tbody,tfoot) th:first-child { position:sticky; left:0; z-index:1; background:linear-gradient(var(--experience-surface),var(--experience-surface)),var(--bg); }
.report-matrix-toggle { background:none; text-align:start; }
.report-matrix tfoot th { font-weight:600; }
.report-subtitle { margin-top:4px; }
.report-note { margin-top:4px; }
.report-note > summary { display:inline-flex; align-items:center; min-height:44px; color:var(--link); font-size:var(--text-sm); cursor:pointer; }
.report-note > p { margin:0 0 8px; }
@media (max-width:639px) {
  #app .report-matrix { min-width:0; width:max-content; }
  #app .report-matrix :is(thead,tbody,tfoot) th:first-child { min-width:0; width:128px; max-width:128px; padding-inline-start:0; box-shadow:1px 0 0 var(--divider); }
  #app .report-matrix td { min-width:84px; padding-inline:4px; }
  #app .report-matrix-scroll[data-more-end=true] { -webkit-mask-image:linear-gradient(90deg,#000 calc(100% - 32px),transparent); mask-image:linear-gradient(90deg,#000 calc(100% - 32px),transparent); }
}
@media (max-width:639px) {
  /* Earlier months tuck under the pinned column; a soft edge shows while any are hidden. */
  #app .report-matrix-scroll[data-more-start=true] .report-matrix :is(thead,tbody,tfoot) th:first-child { box-shadow:1px 0 0 var(--divider),8px 0 8px -6px color-mix(in srgb,var(--text) 22%,transparent); }
}
@media (max-width:639px) {
  /* E5: the no-budget summary leads with the month; its one action spans the card so the label stays on one line. */
  #app[data-route=home] .mobile-unset-overview .button { width:100%; max-width:none; justify-content:space-between; text-align:left; }
}
@media (min-width:640px) { .report-swipe-hint { display:none; } }
@media (max-width:639px) {
  /* E7: the large title names the screen; the sentence under it repeats it, so phones drop it. */
  #app .page-heading > div > p { display:none; }
}
/* E8: the Light marker stays on screen titles; card titles are plain so the page has one accent moment, not one per card. */
html[data-theme=light] #app :is(.section-heading h2,.card > h2) { background:none; }
/* E9: an observation ends in one row: its action on the left, a quiet "Hide…" on the right. */
.report-insight { display:flex; flex-wrap:wrap; align-items:center; column-gap:12px; }
.report-insight > :is(h3,p) { flex:1 0 100%; }
.report-insight > .text-button { flex:1 1 auto; justify-content:flex-start; }
.report-insight-more { flex:none; }
.report-insight-more[open] { flex:1 0 100%; }
.report-insight-more > summary { justify-content:flex-end; font-size:var(--text-sm); list-style:none; }
.report-insight-more > summary::-webkit-details-marker { display:none; }
.report-insight-more > .button { margin:4px 8px 0 0; }
@media (max-width:639px) {
  /* E10: Review this month is a full-width row on the grid, not a floating half-width button. */
  #app .home-month-review > .button { display:flex; align-items:center; justify-content:space-between; width:100%; min-height:48px; padding-inline:16px; }
  #app .home-month-review > .button > .icon { width:16px; height:16px; color:var(--muted); }
}
@media (max-width:639px) {
  /* E11: the Stats empty state is centred like the other empty states, so the symbol's halo sits inside the margins. */
  #app .stats-empty { margin-inline:auto; padding:40px 16px; text-align:center; }
  #app .stats-empty .empty-symbol { margin:18px auto 32px; }
  #app .stats-empty h2 { font-size:var(--text-2xl); }
  #app .stats-empty-actions { justify-content:center; }
}
/* E12: inside the Home summary card the remaining figure is text, not a second glass panel (no nested cards). */
html[data-theme=grey-glass] #app .mobile-budget-summary .mobile-remaining { background:none; border:0; box-shadow:none; -webkit-backdrop-filter:none; backdrop-filter:none; }

/* ---- Second pass (F) ---- */
/* F1: money moved to the UI face (see --font-money in experience.css); large display amounts tighten slightly. */
#app :is(.mobile-remaining strong,.mobile-unset-overview strong,.stats-hero-number,.home-hero .hero-remaining strong) { letter-spacing:-.03em; }
/* F2: the Overview summary leads with one figure; the tiles carry the detail and the full sentence waits under "How this is counted". */
.report-lead { display:flex; flex-wrap:wrap; align-items:baseline; gap:4px 8px; margin:0 0 16px; font-size:var(--text-3xl); font-weight:600; letter-spacing:-.02em; }
.report-lead > span:first-child { font-size:var(--text-md); font-weight:500; color:var(--muted); letter-spacing:0; }
.report-lead > small { flex-basis:100%; font-size:var(--text-sm); font-weight:500; color:var(--muted); letter-spacing:0; }
.report-summary .report-note .report-headline { max-width:none; margin:0 0 8px; font-size:var(--text-sm); font-weight:400; line-height:1.6; }
@media (max-width:639px) {
  #app .report-tiles { grid-template-columns:1fr; gap:0; }
  #app .report-tiles > div { display:grid; grid-template-columns:minmax(0,1fr) auto; align-items:baseline; column-gap:12px; padding-block:12px; border-bottom:1px solid var(--divider); }
  #app .report-tiles dt { margin:0; }
  #app .report-tiles dd { grid-column:2; grid-row:1; font-size:var(--text-md); text-align:end; }
  #app .report-tiles small { grid-column:1 / -1; margin-block-start:2px; }
}
@media (max-width:639px) {
  /* F3: on Home the header's filter icon is the one filter control; the toolbar keeps just the search field. */
  #app[data-route=home] .home-panel .toolbar > .filter-button { display:none; }
}
/* F4: one divider between the day total and its list; the two calendar disclosures share one heading style. */
.calendar-day-content .ledger .transaction-list > .transaction:first-child,
.calendar-day-content .ledger > .transaction:first-of-type { border-top:0; }
#app .calendar-studio :is(.calendar-weekly-totals,.calendar-breakdown) > summary { display:flex; align-items:center; gap:8px; min-height:44px; font-size:var(--text-sm); font-weight:600; letter-spacing:0; text-transform:none; color:var(--text); }
#app .calendar-studio :is(.calendar-weekly-totals,.calendar-breakdown) > summary > span { margin-left:auto; font-size:var(--text-xs); font-weight:400; letter-spacing:0; text-transform:none; color:var(--muted); }
/* F5: Fixed payments and Category budgets read as short lists: three figures up top, one block per commitment on phones, short buttons. */
.report-mini-stats { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:12px; margin:8px 0 12px; }
.report-mini-stats > div { min-width:0; }
.report-mini-stats dt { color:var(--muted); font-size:var(--text-xs); }
.report-mini-stats dd { margin:2px 0 0; font-size:var(--text-lg); font-weight:600; overflow-wrap:anywhere; }
@media (max-width:639px) {
  #app .report-deeper .report-fixed-table { overflow:visible; max-height:none; }
  #app .report-fixed-table :is(table,tbody,tr,th,td) { display:block; width:auto; min-width:0; }
  #app .report-fixed-table thead { display:none; }
  #app .report-fixed-table tr { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:8px 12px; padding-block:12px; border-top:1px solid var(--divider); }
  #app .report-fixed-table tr > th { grid-column:1 / -1; display:grid; grid-template-columns:minmax(0,1fr) auto; align-items:center; column-gap:12px; padding:0; border:0; background:none; }
  #app .report-fixed-table tr > th > :not(.text-button) { grid-column:1; }
  #app .report-fixed-table tr > th > .text-button { grid-column:2; grid-row:1 / span 2; }
  #app .report-fixed-table tr > td { padding:0; border:0; }
  #app .report-fixed-table td::before { content:attr(data-label); display:block; color:var(--muted); font-size:var(--text-xs); }
  #app .report-fixed-table small { display:block; color:var(--muted); font-size:var(--text-xs); }
  #app .report-fixed-table th .text-button { min-height:44px; padding-inline:0; }
}
.report-limit-list li > .button + .text-button { margin-inline-start:8px; }
/* F6: when sync needs attention, a small dot on the Settings tab points to Data & sync (the header icon carries the words). */
:root[data-sync-attention=true] .nav-item[href="#settings"] { position:relative; }
:root[data-sync-attention=true] .nav-item[href="#settings"]:not(:has(.nav-badge))::after { content:''; position:absolute; top:8px; left:calc(50% + 8px); width:8px; height:8px; border-radius:50%; background:var(--error); box-shadow:0 0 0 2px var(--surface); }

/* ---- Scrolling (G) ---- */
@media (max-width:639px) {
  /* G1: on phones only the sticky bars blur; cards stay translucent over the glow but are not re-blurred on every scroll frame. */
  html[data-theme=grey-glass] #app :is(.card,.metric,.account-card,.private-overview,.stats-studio>.card,.stats-scope) { -webkit-backdrop-filter:none; backdrop-filter:none; }
  /* G2: page backgrounds scroll with the page instead of repainting a fixed image each frame. */
  body,html[data-theme] body { background-attachment:scroll; }
}
/* G3: the fixed Grey Glass glow sits on its own compositor layer, so scrolling never repaints it. */
html[data-theme=grey-glass] .workspace::before { transform:translateZ(0); }
@media (hover:none) {
  /* G4: a finger that starts a scroll should not make rows and chips "press"; the press shows only after a short hold. */
  :is(.transaction,.calendar-day,.quick-category,.home-goal,.merchant-chip,.chip,.mobile-category-chips button,.category-row):active { transition-delay:90ms; }
}

/* ---- Loans (H) ---- */
/* H3: the summary shows what interest costs now and what was repaid this month, beside the total. */
.private-overview-figures { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:12px; flex-basis:100%; margin:12px 0 0; padding-top:12px; border-top:1px solid var(--divider); }
.private-overview-figures dt { color:var(--muted); font-size:var(--text-xs); }
.private-overview-figures dd { margin:2px 0 0; color:var(--text); font-size:var(--text-lg); font-weight:600; font-variant-numeric:tabular-nums; }
.private-overview-figures dd small { margin-left:2px; color:var(--muted); font-size:var(--text-xs); font-weight:500; }
/* H1/H6: rows carry the rate and daily cost; the costliest loan is tagged in words, not colour alone. */
.private-cost-tag { justify-self:start; width:fit-content; margin-top:4px; padding:2px 8px; border:1px solid var(--expense); border-radius:var(--radius-pill); color:var(--expense); font-size:var(--text-2xs); font-weight:600; }
/* H4: the row's repayment button is a quiet outline; Add loan stays the one primary action. */
.private-card-footer .private-row-pay { min-height:44px; padding-inline:14px; background:transparent; color:var(--text); border:1px solid var(--control-border); box-shadow:none; font-size:var(--text-sm); }
/* H5/H7: "As of" is a quiet note; the payoff estimate is one readable sentence. */
.private-asof-note { display:block; margin-top:4px; }
.private-asof-note .text-button { min-height:44px; padding:0; color:var(--link); }
.private-actions-menu .private-asof { display:block; margin-bottom:8px; }
.private-payoff-estimate { margin:12px 0 0; padding:12px 16px; border-radius:var(--radius-sm); background:var(--subtle); color:var(--text); font-size:var(--text-sm); line-height:1.5; }
/* H9: a just-cleared loan's milestone rises in once (off with reduced motion). */
.private-milestone-card.is-new { animation:milestone-in var(--motion-value) var(--motion-ease) both; }
.private-milestone-card.is-new .private-milestone-icon { animation:milestone-check var(--motion-value) var(--motion-spring) var(--motion-press) both; }
@keyframes milestone-in { from { opacity:0; } to { opacity:1; } }
@keyframes milestone-check { from { transform:scale(.4); } to { transform:none; } }
@media (prefers-reduced-motion:reduce) { .private-milestone-card.is-new,.private-milestone-card.is-new .private-milestone-icon { animation:none; } }
@media (max-width:639px) { #app .private-detail-balance,dialog .private-detail-balance { flex-wrap:wrap; } dialog .private-detail-balance > .private-asof-note { flex-basis:100%; margin-top:0; } }
/* One press response everywhere: a 2% press over the press duration. */
:is(.button,.icon-button,.chip,.filter-chip,.quick-category,.home-goal,.merchant-chip,.mobile-category-chips button,.segmented > button,.segmented > [role=tab],.stats-segment button,.transaction,.calendar-day,.account-card,.category-row,.report-insight-main,.report-category-row,.private-reminder,.private-loan-open):active { transform:scale(.98); transition-duration:var(--motion-press); transition-timing-function:var(--motion-ease); }
@media(prefers-reduced-motion:reduce) { :is(.button,.icon-button,.chip,.filter-chip,.quick-category,.home-goal,.merchant-chip,.mobile-category-chips button,.segmented > button,.segmented > [role=tab],.stats-segment button,.transaction,.calendar-day,.account-card,.category-row,.report-insight-main,.report-category-row,.private-reminder,.private-loan-open):active { transform:none; } }
/* Every tappable control is at least 44 px tall. */
.segmented > button,.segmented > [role=tab],.filter-chip,.chip,.stats-scope-period select,.stats-scope-date input { min-height:44px; }
.report-insight-more summary .disclosure-chevron { display:none; }
/* Menus grow out of the button that opened them. */
@keyframes menu-morph { from { opacity:0; clip-path:inset(0 55% 75% 0 round 22px); transform:translateY(-4px); } to { opacity:1; clip-path:inset(0 0 0 0 round var(--radius-sm)); transform:none; } }
@keyframes menu-morph-end { from { opacity:0; clip-path:inset(0 0 75% 55% round 22px); transform:translateY(-4px); } to { opacity:1; clip-path:inset(0 0 0 0 round var(--radius-sm)); transform:none; } }
:is(.report-view-menu,.private-actions-menu)[open] > div { animation:menu-morph var(--motion-enter) var(--motion-ease) backwards; }
.private-session-menu[open] > :not(summary) { animation:menu-morph-end var(--motion-enter) var(--motion-ease) backwards; }
/* The selected filter's highlight slides between options. */
.private-filters,.mobile-category-chips { position:relative; isolation:isolate; }
:is(.private-filters,.mobile-category-chips) > button { position:relative; z-index:1; }
.filter-slide { position:absolute; z-index:0; box-sizing:border-box; pointer-events:none; }
:is(.private-filters,.mobile-category-chips) > button.is-sliding { background:transparent !important; border-color:transparent !important; box-shadow:none !important; }
@media(prefers-reduced-motion:reduce) { :is(.report-view-menu,.private-actions-menu)[open] > div,.private-session-menu[open] > :not(summary) { animation:none; } }
.private-sort-menu[open] > div { animation-name:menu-morph-end; }
/* Category picker: a page that slides in inside the Add sheet (same sheet, same height, one handle), with a back arrow. */
dialog[data-category-picker=true] { overflow:hidden; }
dialog[data-category-picker=true] .category-chooser { position:absolute; inset:0; z-index:21; display:flex; flex-direction:column; height:auto; max-height:none; min-height:0; margin:0; background:var(--sheet-surface,var(--surface)); border-radius:inherit; box-shadow:-12px 0 28px rgba(0,0,0,.12); animation:chooser-push var(--motion-dialog) var(--motion-ease) backwards; }
@keyframes chooser-push { from { transform:translateX(100%); } }
.chooser-grabber { display:none; }
dialog[data-bottom-sheet] .chooser-grabber { display:flex; flex:none; justify-content:center; align-items:center; height:22px; margin:-12px 0 -6px; cursor:grab; touch-action:none; color:var(--muted); }
.chooser-grabber span { width:34px; height:4px; border-radius:10px; background:currentColor; opacity:.6; }
.chooser-heading .chooser-back { display:inline-grid; place-items:center; flex:none; width:44px; height:44px; min-height:44px; margin-left:-10px; padding:0; border:0; border-radius:var(--radius-control); background:transparent; color:var(--text); cursor:pointer; }
.chooser-back .icon { width:22px; height:22px; transform:scaleX(-1); }
.chooser-back:active { background:var(--subtle); }
@media(hover:hover) { .chooser-back:hover { background:var(--subtle); } }
.chooser-back:focus-visible { outline:2px solid var(--brand); outline-offset:-2px; }
.category-chooser .chooser-heading { touch-action:none; }
.chooser-recent { display:flex; gap:8px; overflow-x:auto; padding:2px 0 8px; scrollbar-width:none; }
.chooser-chip { display:inline-flex; align-items:center; gap:6px; min-height:44px; padding:6px 14px; border:1px solid var(--border); border-radius:var(--radius-pill); background:var(--surface); color:var(--text); font:inherit; font-size:var(--text-sm); white-space:nowrap; cursor:pointer; }
.chooser-chip .icon { width:16px; height:16px; }.chooser-chip[aria-pressed=true],.chooser-tile[aria-pressed=true] { border-color:var(--brand); color:var(--brand); }
.chooser-chip-parent { border-color:var(--brand); color:var(--brand); font-weight:600; }.chooser-chip-add { border-style:dashed; color:var(--muted); }
:is(.chooser-chip,.chooser-tile) .chooser-selected-mark { display:none; }
.chooser-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(80px,1fr)); grid-auto-flow:row dense; gap:8px; margin:8px 0 12px; }
.chooser-tile { display:grid; justify-items:center; align-content:start; gap:4px; min-height:84px; padding:12px 4px 8px; border:1px solid var(--divider); border-radius:var(--radius-sm); background:var(--subtle); color:var(--text); font:inherit; font-size:var(--text-xs); text-align:center; cursor:pointer; }
.chooser-tile .icon { width:22px; height:22px; }.chooser-tile span { overflow-wrap:anywhere; line-height:1.3; }.chooser-tile small { color:var(--muted); font-size:var(--text-2xs); }
.chooser-tile[aria-expanded=true] { border-color:var(--brand); background:color-mix(in srgb,var(--brand) 12%,var(--surface)); }
.chooser-expansion { grid-column:1 / -1; display:flex; flex-wrap:wrap; gap:8px; padding:10px; border-radius:var(--radius-sm); background:var(--subtle); animation:chooser-expand var(--motion-enter) var(--motion-ease) backwards; }
@keyframes chooser-expand { from { opacity:0; transform:translateY(-4px); } }
.quick-category.is-suggested { border-color:var(--brand); }.quick-suggested { display:block; font-style:normal; font-size:var(--text-2xs); color:var(--brand); line-height:1.2; }
@media(prefers-reduced-motion:reduce) { dialog[data-category-picker=true] .category-chooser,.chooser-expansion { animation:none; transition:none; } }
#app .calendar-studio .calendar-grid { touch-action:pan-y; }

@media(max-width:639px){
 #app[data-route=accounts] .account-grid>.account-card{grid-template-columns:36px minmax(0,1fr) auto;grid-template-areas:"icon name balance" "icon kind balance";min-height:62px;padding-block:8px}
 #app[data-route=accounts] .account-card .account-symbol{width:36px;height:36px}
 #app[data-route=accounts] .account-card .account-trend{display:none}
 #app[data-route=accounts] .account-card h2{overflow-wrap:anywhere}
 #app[data-route=accounts] .account-card .account-balance{margin:0;white-space:nowrap}
}
