@font-face {
  font-family: "Pixelify Sans";
  src: url("fonts/PixelifySans.ttf") format("truetype");
  font-weight: 400 700;
  font-display: swap;
}

@font-face {
  font-family: "Terminus TTF";
  src: url("fonts/TerminusTTF.ttf") format("truetype");
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "Terminus TTF";
  src: url("fonts/TerminusTTF-Bold.ttf") format("truetype");
  font-weight: 700;
  font-display: swap;
}

:root {
  color-scheme: light;
  font-family: "Terminus TTF", ui-monospace, monospace;
  --display-font: "Pixelify Sans", "Terminus TTF", monospace;
  font-size: 16px;
  line-height: 1.32;
  color: #283c2e;
  background: #f3f0e3;
  --forest: #203a2e;
  --ink: #34533d;
  --muted: #485d47;
  --edge: #536b4e;
  --paper: #fcfaef;
  --lime: #d5e5ab;
  --soft-shadow: #dbd8c0;
  --expense-ink: #62583e;
  --income-ink: #315c41;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100dvh;
  background-image: radial-gradient(#e8e3cf 1px, transparent 1px);
  background-size: 12px 12px;
}
[hidden] { display: none !important; }
button, input { font: inherit; }
button { cursor: pointer; }
button, .navigation a { transition: background-color .16s ease-out, border-color .16s ease-out; }
button:disabled { cursor: default; }
a { color: inherit; text-decoration: none; }
:where(a, button, input, select):focus-visible { outline: 3px solid #8ca648; outline-offset: 3px; }
h1, h2, p, ul { margin: 0; }
h1, h2, .brand, .balance, .envelope-money, .work-stopwatch { font-family: var(--display-font); }
canvas { image-rendering: pixelated; }
[data-icon] { display: inline-grid; flex: none; place-items: center; }
.pixel-glyph { display: block; width: 20px; height: 20px; background: currentColor; mask-size: 100% 100%; image-rendering: pixelated; }

.container { width: min(1040px, calc(100% - 64px)); margin-inline: auto; }
.topbar {
  background: #f8f6eb;
  color: var(--forest);
  border-bottom: 3px solid #b9c0a3;
  box-shadow: 0 3px 0 #e5e0cf;
}
.topbar-inner { display: flex; justify-content: space-between; align-items: center; gap: 20px; min-height: 76px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--forest); font-size: 30px; font-weight: 700; }
.brand-mark { width: 36px; height: 36px; background: var(--forest); color: var(--lime); box-shadow: 3px 3px 0 #c9ccb1; }
.brand-mark .pixel-glyph { width: 24px; height: 24px; }
.navigation { display: flex; gap: 7px; }
.navigation a {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 6px 13px;
  border: 2px solid transparent;
  color: #445940;
  font-size: 1.12rem;
}
.navigation a:hover { background: #e8ebd9; }
.navigation a[aria-current] { border-color: #a6b78a; background: #dce7c5; color: #263c24; box-shadow: 2px 2px 0 #d5dac1; }
.topbar-end { display: flex; align-items: center; gap: 11px; }
.today { color: var(--muted); font-size: 1rem; white-space: nowrap; }

main.container { padding-bottom: 40px; }
[data-screen]:not([hidden]) { animation: screen-in .21s ease-out; }
@keyframes screen-in { from { opacity: .66; translate: 0 4px; } }
.heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 32px 0 19px; }
h1 { font-size: clamp(2.25rem, 5vw, 3.25rem); line-height: 1; font-weight: 700; }
h1:focus { outline: none; }
.payday {
  display: flex;
  gap: 8px;
  align-items: center;
  border: 2px solid #819064;
  background: #e4e8c9;
  box-shadow: 2px 2px 0 var(--soft-shadow);
  padding: 7px 10px;
  color: #3d5438;
  white-space: nowrap;
}
.payday .pixel-glyph { width: 16px; height: 16px; }
.payday:hover { filter: brightness(.96); }
.payday-forecast { display: grid; grid-template-columns: 1fr auto; align-items: baseline; gap: 6px 12px; margin: 13px 0; }
.payday-forecast dd { margin: 0; font-weight: 700; }
.frame { border: 2px solid var(--edge); box-shadow: 4px 4px 0 var(--soft-shadow); }
.budget {
  display: grid;
  grid-template-columns: minmax(0, .74fr) minmax(0, 1fr);
  gap: 16px;
  margin-top: 8px;
}
.budget-content { display: grid; align-content: center; justify-items: start; min-height: 318px; padding: 25px 27px; background: var(--paper); color: var(--ink); }
.budget .today-balance h2 { color: var(--muted); font: 700 1.15rem "Terminus TTF", monospace; }
.balance {
  font-size: clamp(2.9rem, 7.4vw, 5rem);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -.055em;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
  margin: 5px 0 16px;
}
.garden-window { position: relative; min-height: 100%; overflow: hidden; }
.garden { position: absolute; inset: 0; display: block; width: 100%; height: 100%; object-fit: cover; object-position: right 54%; }
.budget-meter { width: 100%; }
progress {
  display: block;
  width: 100%;
  height: 14px;
  appearance: none;
  border: 2px solid #91a46c;
  padding: 2px;
  background: #425b43;
  color: var(--lime);
}
progress::-webkit-progress-bar { background: #425b43; }
progress::-webkit-progress-value { background: repeating-linear-gradient(90deg, #d8e991 0 8px, #b7cc6b 8px 10px); }
progress::-moz-progress-bar { background: repeating-linear-gradient(90deg, #d8e991 0 8px, #b7cc6b 8px 10px); }
.budget .budget-meter p { margin-top: 8px; color: var(--muted); font-size: 1rem; }

.button {
  min-height: 50px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border: 2px solid var(--edge);
  padding: 9px 14px;
  font-size: 1.22rem;
  font-weight: 700;
  line-height: 1.05;
}
.button:active:not(:disabled) { translate: 2px 2px; box-shadow: 1px 1px 0 var(--button-shadow); }
.button-bright {
  --button-shadow: #15281d;
  min-height: 76px;
  width: 100%;
  margin-top: 23px;
  border-color: #91a975;
  background: var(--lime);
  color: #253c23;
  box-shadow: 4px 4px 0 var(--button-shadow), inset 0 2px 0 #edf2cd;
}
.button-bright:hover { background: #e4eec3; }

.history-top { justify-content: space-between; }
.history-toggle { display: grid; flex: none; place-items: center; width: 42px; min-height: 42px; padding: 0; font-size: 1.45rem; }
.history-toggle span { display: inline-block; transition: rotate .24s ease; }
.history-toggle[aria-expanded="true"] span { rotate: 180deg; }
.operations-content { display: grid; grid-template-rows: 0fr; opacity: 0; transition: grid-template-rows .28s ease, opacity .22s ease; }
.operations-content.is-open { grid-template-rows: 1fr; opacity: 1; }
.operations-inner { overflow: hidden; min-height: 0; }
.operations-inner > .switcher { margin: 6px 0; }

.category-toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.category-toolbar p { margin: 0 auto 0 0; }
.category-empty { color: var(--muted); grid-column: 1 / -1; padding-block: 8px; }
.category-creator { display: grid; gap: 6px; margin: 4px 0 12px; }
.category-creator .amount-help:empty { margin: 0; }
.category-create-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.category-editor-tools { display: grid; gap: 8px; margin-top: 10px; justify-items: start; }
.expense-category-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.expense-category-actions button:disabled { opacity: .42; }
.categories.is-editing .category[data-category-id] { cursor: grab; touch-action: none; user-select: none; -webkit-touch-callout: none; }
.categories .category-drag-source { opacity: .36; }
#expense-dialog .category-drop-target { outline: 3px solid var(--edge); outline-offset: 2px; }
#expense-dialog .category-drag-ghost {
  position: fixed;
  inset: 0 auto auto 0;
  z-index: 3;
  pointer-events: none;
  box-shadow: 5px 6px 0 var(--soft-shadow);
}
.expense-category-icon-field { min-width: 0; margin: 4px 0 0; padding: 8px; border: 1px solid var(--edge); }
.expense-category-icon-field legend { padding-inline: 4px; }
.expense-category-icons { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 5px; }
.expense-category-icons label { position: relative; display: grid; place-items: center; min-height: 44px; cursor: pointer; }
.expense-category-icons input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.expense-category-icons input:checked + .tile { outline: 2px solid var(--edge); outline-offset: 2px; }
.expense-category-icons input:focus-visible + .tile { outline: 3px solid var(--edge); outline-offset: 3px; }
@media (max-width: 420px) { .expense-category-icons { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.button-outline { --button-shadow: #cbd2b8; border-color: #879974; background: #edf0e1; color: var(--ink); box-shadow: 3px 3px 0 var(--button-shadow); }
.button-outline:hover { background: #e2ebd3; }

.stats-heading { align-items: end; }
.stats-range { color: var(--muted); text-align: right; }
.stats-toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; margin-bottom: 17px; }
.switcher { display: inline-flex; gap: 3px; max-width: 100%; padding: 3px; border: 1px solid #b6c1a4; background: #eaeadd; }
.switcher button, .small-button { min-height: 36px; padding: 4px 10px; border: 1px solid transparent; background: transparent; color: var(--ink); white-space: nowrap; }
.switcher button:hover, .small-button:hover { background: #e0e7ce; }
.switcher button[aria-pressed="true"] { border-color: #a1b191; background: #d9e5c7; color: var(--forest); }
.switcher-compact button { min-height: 32px; }
.small-button { border-color: #a1b191; background: #edf0e1; }
.custom-range { display: flex; gap: 7px; flex-wrap: wrap; align-items: center; }
.custom-range label { display: flex; gap: 5px; align-items: center; color: var(--muted); }
.custom-range input { min-height: 36px; min-width: 0; max-width: 100%; padding: 3px 5px; border: 1px solid #a1b191; background: var(--paper); color: var(--forest); }
.stats-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin: 0 0 16px; }
.summary-card { min-width: 0; display: grid; align-content: start; gap: 3px; padding: 13px 16px; background: var(--paper); }
.summary-card dt { font-size: 1.12rem; }
.summary-card dd { margin: 0; }
.summary-expense { background: #f1ecda; }
.summary-income { background: #e8efda; }
.summary-meta { color: var(--muted); font-size: .95rem; }
.stats-balance { font-size: clamp(1.7rem, 3.5vw, 2.45rem); line-height: 1.08; font-weight: 700; overflow-wrap: anywhere; }
.income-value { color: var(--income-ink); }
.expense-value { color: var(--expense-ink); }
.stats-layout { display: grid; grid-template-columns: minmax(0, 1.38fr) minmax(0, 1fr); gap: 16px; align-items: stretch; }
.panel { min-width: 0; background: var(--paper); padding: 20px 23px 13px; }
.panel h2 { font-size: 1.35rem; margin-bottom: 8px; }
.section-top { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.section-top h2 { margin: 0; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 11px; color: var(--muted); font-size: .9rem; }
.chart-legend span { display: inline-flex; align-items: center; gap: 5px; }
.chart-legend span::before { content: ""; width: 9px; height: 9px; flex: none; background: var(--chart-color); }
.expense-key { --chart-color: #a49d7a; --chart-stripe: #8c8463; }
.income-key { --chart-color: #80a478; --chart-stripe: #668961; }
.chart-bars {
  --plot-height: 164px;
  display: grid;
  grid-template-columns: repeat(var(--bars, 7), minmax(0, 1fr));
  border-bottom: 1px solid #d8dec9;
  background: repeating-linear-gradient(to top, #e7e9d9 0 1px, transparent 1px 31px);
}
.chart-column { min-width: 0; display: grid; grid-template-rows: var(--plot-height) 24px; align-items: end; border: 0; padding: 0 2px; background: transparent; color: var(--muted); }
.chart-column:hover, .chart-column[aria-pressed="true"] { background: #dce8cc77; color: var(--forest); }
.chart-column:focus-visible { outline-offset: -3px; }
.chart-pair { height: 100%; display: flex; align-items: end; justify-content: center; gap: 2px; }
.chart-bar { width: min(29%, 20px); min-height: 2px; background: repeating-linear-gradient(to top, var(--chart-color) 0 5px, var(--chart-stripe) 5px 6px); }
.chart-date { align-self: center; white-space: nowrap; font-size: .85rem; }
.chart-date-short { display: none; }
.chart-detail { min-height: 28px; margin-top: 9px; color: var(--muted); font-size: .93rem; }
.breakdown, .rows, .envelopes { padding: 0; list-style: none; }
.breakdown { display: grid; gap: 2px; margin-top: 8px; }
.breakdown-button { width: 100%; display: grid; gap: 4px; padding: 5px 4px; text-align: left; border: 1px solid transparent; background: transparent; color: inherit; }
.breakdown-button:hover, .breakdown-button[aria-pressed="true"] { border-color: #c0ccac; background: #edf0dd; }
.breakdown-label { display: flex; justify-content: space-between; gap: 8px; }
.breakdown-label strong { white-space: nowrap; }
.breakdown-track { display: block; height: 7px; background: #e9e9d9; }
.breakdown-track span { display: block; height: 100%; background: repeating-linear-gradient(90deg, var(--chart-color) 0 7px, var(--chart-stripe) 7px 8px); }
.stats-history { margin-top: 16px; }
.stats-clear { margin-bottom: 7px; }
.history-day { margin-top: 7px; padding: 3px 7px; background: #eef0e0; color: var(--muted); font-size: .92rem; }
.stats-empty { color: var(--muted); padding: 11px 0; }
.row { min-height: 65px; display: flex; align-items: center; gap: 12px; padding: 8px 0; }
.row + .row { border-top: 2px dashed #ddd9be; }
.tile {
  flex: 0 0 40px;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 2px solid currentColor;
  background: var(--tile-bg, #e6eccd);
  color: var(--tile-ink, #3e5a3a);
  box-shadow: 2px 2px 0 #d6d0b6;
}
.tile .pixel-glyph { width: 22px; height: 22px; }
.row-content { display: grid; align-content: center; flex: 1; gap: 1px; min-width: 0; }
.row-content strong, .row-money { font-size: 1.12rem; }
.row-content small { color: var(--muted); font-size: 1rem; }
.row-money { white-space: nowrap; }

.envelope-actions { display: flex; flex-wrap: wrap; gap: 9px; margin-bottom: 17px; }
.envelope-actions .button { width: auto; min-height: 45px; font-size: 1.06rem; }
.envelopes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.envelope { display: grid; grid-template-rows: auto minmax(45px, 1fr) auto; justify-items: start; gap: 10px; padding: 17px; background: var(--paper); }
.envelope-main { grid-column: 1 / -1; grid-template: auto auto / auto minmax(0, 1fr) auto; align-items: center; background: #edf0e1; }
.envelope-main .envelope-deposit { grid-column: 2 / -1; width: auto; min-height: 43px; font-size: 1.08rem; }
.envelope h2 { font-size: 1.35rem; }
.envelope-info { min-width: 0; }
.envelope-info h2, .row-content strong { overflow-wrap: anywhere; }
.envelope p { color: var(--muted); }
.envelope-money { font-size: clamp(1.8rem, 4vw, 2.75rem); line-height: 1.04; overflow-wrap: anywhere; }
.day-note { display: flex; align-items: center; gap: 8px; margin-top: 19px; color: var(--muted); font-size: 1rem; }
.transfer-history { margin-top: 17px; }

dialog {
  width: min(455px, calc(100% - 32px));
  max-height: calc(100dvh - 32px);
  margin: auto;
  overflow: auto;
  padding: 21px;
  border: 3px solid var(--edge);
  background: var(--paper);
  color: inherit;
  box-shadow: 6px 6px 0 #142b1d99, inset 0 0 0 3px #e0e1be;
}
dialog[open] { animation: dialog-in .19s ease-out; }
@keyframes dialog-in { from { opacity: 0; scale: .985; } }
dialog::backdrop { background: #172d20b0; }
.dialog-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 17px; }
.dialog-top h2 { font-size: 1.65rem; line-height: 1; }
.settings-section { min-width: 0; margin: 0 0 12px; padding: 11px 12px 13px; border: 1px solid #a1b191; background: #eef0e1; }
.settings-section legend { padding: 0 6px; color: var(--ink); }
.settings-label { margin-bottom: 7px; font-size: 1.12rem; font-weight: 650; }
.icon-button { display: grid; place-items: center; width: 38px; height: 38px; padding: 0; border: 2px solid #768a5a; background: #e8ebd0; color: var(--ink); box-shadow: 2px 2px 0 #c9cdab; }
.icon-button:hover, .category-chip:hover { background: #dce6bb; }
.field-label { display: block; margin: 0 0 8px; color: var(--muted); font-size: 1rem; }
.form-input { display: block; width: 100%; min-width: 0; min-height: 42px; padding: 6px 8px; border: 2px solid #849768; border-radius: 0; background: #fffdf4; color: var(--forest); font: inherit; }
#envelope-form .form-input { margin-bottom: 12px; }
.transfer-accounts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.transfer-accounts label { min-width: 0; color: var(--muted); }
.transfer-accounts select { margin-top: 4px; }
select.form-input {
  appearance: none;
  padding-right: 23px;
  background-image: linear-gradient(currentColor, currentColor), linear-gradient(currentColor, currentColor), linear-gradient(currentColor, currentColor);
  background-repeat: no-repeat;
  background-size: 10px 2px, 6px 2px, 2px 2px;
  background-position: right 7px calc(50% - 2px), right 9px center, right 11px calc(50% + 2px);
}
.transfer-available { margin: 8px 0 10px; color: var(--muted); font-size: .95rem; }
#transfer-form .amount-keypad { margin-top: 10px; }
.categories { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; }
.category {
  min-height: 82px;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 6px;
  padding: 5px;
  background: #ebeed4;
  color: inherit;
  border: 2px solid #c0c7a3;
  text-align: center;
  font-size: 1.06rem;
  font-weight: 650;
}
.category:hover { background: #e1e8be; border-color: #78905b; }
.category .tile { width: 34px; height: 34px; }
.amount-heading { display: flex; justify-content: space-between; align-items: center; gap: 9px; margin-bottom: 9px; }
.amount-heading .field-label { margin: 0; }
.category-chip { display: inline-flex; align-items: center; gap: 8px; background: #e8ebd0; color: inherit; border: 2px solid #a0aa82; padding: 4px 9px 4px 4px; font-size: 1rem; }
.category-chip .tile { width: 26px; height: 26px; flex-basis: 26px; box-shadow: none; }
.category-chip .pixel-glyph { width: 16px; height: 16px; }
.amount-field { display: flex; align-items: center; gap: 8px; border: 2px solid #849768; padding: 8px 11px; background: #fffdf4; }
.amount-field:focus-within { outline: 2px solid #8ca648; outline-offset: 1px; }
.amount-field span { color: #51664b; font-size: 1.6rem; }
.amount-field input { width: 100%; min-width: 0; outline: none; border: 0; background: transparent; color: inherit; font-size: 2.15rem; font-weight: 700; caret-color: transparent; }
.amount-field input::placeholder { color: #78876a; }
.repeat-amount {
  min-height: 44px;
  margin-top: 10px;
  padding: 5px 10px;
  border: 2px solid #a0aa82;
  background: #e8ebd0;
  color: #324f37;
}
.repeat-amount:hover { background: #dce6bb; }
.amount-keypad { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; margin: 13px 0 10px; }
.amount-keypad button {
  display: grid;
  place-items: center;
  min-height: 46px;
  padding: 4px;
  border: 2px solid #a6b48e;
  background: #e7edda;
  color: var(--forest);
  box-shadow: 2px 2px 0 #cbd3ba, inset 0 2px 0 #f4f6e9;
  font-size: 1.45rem;
  line-height: 1;
}
.amount-keypad button[data-key=","], .amount-keypad button[data-key="Backspace"] { background: #edefe2; color: var(--muted); }
.amount-keypad button:hover { background: #dce8cc; }
.amount-keypad button:active { translate: 1px 1px; box-shadow: 1px 1px 0 #cbd3ba; }
.amount-help { margin-bottom: 9px; color: var(--muted); font-size: 1rem; }
.amount-help:empty { margin-bottom: 0; }
.button-dark { --button-shadow: #a7ad87; border-color: #203d2b; background: #315740; color: #fff7dc; width: 100%; box-shadow: 3px 3px 0 var(--button-shadow); }
.button-dark:hover:not(:disabled) { background: #406a4d; }
.button-dark:disabled { border-color: #b3b99d; background: #e2e5ce; color: #59654e; box-shadow: none; }
.toast { position: fixed; z-index: 1; inset: auto auto 20px 50%; transform: translateX(-50%); width: max-content; max-width: calc(100% - 24px); border: 2px solid #a4b672; background: var(--forest); color: #fff9dd; padding: 9px 14px; box-shadow: 3px 3px 0 #172c22; overflow-wrap: anywhere; }
.toast:empty { display: none; }
.toast:not(:empty) { animation: arrive .14s steps(3, end); }
@keyframes arrive { from { opacity: 0; } }

@media (821px <= width <= 1020px) {
  .topbar-end .today { display: none; }
}

@media (max-width: 820px) {
  .container { width: calc(100% - 36px); }
  .topbar-inner { min-height: 61px; }
  .brand { font-size: 26px; }
  .brand-mark { width: 32px; height: 32px; }
  .topbar-end { gap: 7px; }
  .today { font-size: .93rem; }
  .navigation {
    position: fixed;
    z-index: 2;
    inset: auto 0 0;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 4px;
    padding: 5px 8px max(7px, env(safe-area-inset-bottom));
    background: var(--forest);
    border-top: 3px solid #88a05d;
  }
  .navigation a { display: grid; justify-items: center; gap: 3px; padding: 3px; color: #e2ecd1; font-size: .95rem; }
  .navigation a:hover { background: #3a5642; }
  .navigation a[aria-current] { box-shadow: none; }
  .navigation .pixel-glyph { width: 18px; height: 18px; }
  main.container { padding-bottom: 90px; }
  .heading { padding: 22px 0 15px; }
  .payday { gap: 4px; font-size: .9rem; padding-inline: 6px; }
  .payday [data-icon] { display: none; }
  .budget { display: flex; flex-direction: column; }
  .garden-window { order: -1; min-height: 0; height: clamp(124px, 35vw, 200px); }
  .garden { object-position: center 50%; }
  .budget-content { min-height: auto; padding: 17px 16px 20px; }
  .balance { margin-bottom: 11px; }
  .budget-meter { width: 100%; }
  .button-bright { width: 100%; margin-top: 17px; }
  .stats-layout, .envelopes { grid-template-columns: 1fr; gap: 13px; }
  .chart-bars { --plot-height: 116px; }
  .panel { padding: 15px 14px 9px; }
  .envelope { grid-template: auto / auto minmax(0, 1fr) auto; align-items: center; gap: 8px; padding: 13px 11px; }
  .envelope-main .envelope-deposit { grid-column: 1 / -1; width: 100%; }
  .envelope h2 { font-size: 1.15rem; }
  .envelope p { font-size: .98rem; }
  .envelope-money { font-size: 1.4rem; white-space: nowrap; }
  .toast { bottom: calc(74px + env(safe-area-inset-bottom)); }
}

@media (max-width: 520px) {
  .stats-heading { align-items: start; flex-direction: column; gap: 6px; }
  .stats-range { text-align: left; }
  .stats-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .summary-card { padding: 10px 11px; }
  .summary-card:last-child { grid-column: 1 / -1; grid-template-columns: 1fr auto; align-items: center; }
  .summary-card:last-child .summary-meta { grid-column: 1 / -1; }
  .switcher button { padding-inline: 8px; }
  .chart-date { font-size: .8rem; }
  .chart-date-long { display: none; }
  .chart-date-short { display: inline; }
}

@media (max-width: 385px) {
  .categories { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 365px) {
  .container { width: calc(100% - 28px); }
  .topbar-inner { gap: 6px; }
  .topbar-end .today { font-size: .84rem; }
  .weekday { display: none; }
  .navigation a { font-size: .85rem; }
  h1 { font-size: 2rem; }
  .payday { font-size: .82rem; }
  dialog { padding: 16px; }
  .category { gap: 4px; font-size: .94rem; }
  .category .tile { width: 28px; height: 28px; }
  .category .pixel-glyph { width: 18px; height: 18px; }
  .envelope-money { font-size: 1.22rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
