@font-face {
  font-family: PixelUI;
  src: url("assets/unifont-pixel-v2.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: PixelDisplay;
  src: url("assets/pixel.ttf") format("truetype");
  font-weight: 400;
  font-display: swap;
}
* {
  box-sizing: border-box;
}
html {
  color-scheme: dark;
  --bg: #102235;
  --panel: #193b4c;
  --raised: #244c5c;
  --ink: #edffe9;
  --muted: #b6d1d2;
  --line: #477787;
  --accent: #88f0cc;
  --expense: #ffc19e;
  --income: #a6ddff;
  --danger: #ffc9bd;
  --frame: url("assets/frame.svg");
  --frame-active: url("assets/frame-active.svg");
  --font: PixelUI, monospace;
  scrollbar-color: #538b94 #0b1e30;
}
body {
  margin: 0;
  position: relative;
  isolation: isolate;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 var(--font);
  font-weight: 400;
  font-synthesis: none;
  -webkit-font-smoothing: none;
  text-rendering: geometricPrecision;
}
button,
input,
select,
textarea,
a {
  font-family: var(--font);
  font-weight: 400;
  font-synthesis: none;
  -webkit-tap-highlight-color: transparent;
}
button,
input,
select,
textarea {
  font-size: 16px;
  line-height: 1.5;
}
button,
select {
  touch-action: manipulation;
}
button {
  color: inherit;
  cursor: pointer;
}
button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}
a {
  color: inherit;
  text-decoration: none;
}
h1,
h2,
h3,
p {
  margin: 0;
}
h1,
h2,
h3,
strong,
b {
  font-weight: 400;
}
h1 {
  font-size: 32px;
  line-height: 1.4;
  letter-spacing: 0;
}
h2 {
  font-size: 16px;
  line-height: 1.5;
}
h3 {
  font-size: 16px;
}
small,
.muted {
  color: var(--muted);
}
small {
  font-size: 16px;
}
.number {
  font-family: var(--font);
  font-variant-numeric: tabular-nums;
}
.pixel {
  font-family: PixelDisplay, var(--font);
}
.icon {
  width: 24px;
  height: 24px;
  display: inline-block;
  flex-shrink: 0;
  vertical-align: middle;
  fill: currentColor;
  shape-rendering: crispEdges;
}
::selection {
  background: var(--accent);
  color: #102a32;
}
input,
textarea {
  caret-color: var(--accent);
}
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-thumb {
  background: #528a92;
  border: 2px solid #0b1e30;
}
::-webkit-scrollbar-track {
  background: #0b1e30;
}
button,
a,
input,
textarea,
select {
  outline-offset: 4px;
}
button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 2px dashed #efffd6;
  outline-offset: 3px;
}
.skip {
  position: fixed;
  top: -100px;
  left: 16px;
  z-index: 300;
  background: var(--accent);
  padding: 12px;
  color: #102a32;
}
.skip:focus {
  top: 16px;
}
/* Every frame is a native nine-slice pixel border; no diagonal clips or radii. */
.panel,
dialog,
.ui-popover {
  background: var(--panel);
  background-clip: padding-box;
  border: 8px solid transparent;
  border-image: var(--frame) 8 stretch;
  position: relative;
  filter: drop-shadow(4px 4px 0 #061522);
}
.panel-head,
.dialog-head {
  padding: 14px 16px;
  border-bottom: 2px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: #214757;
}
.panel-head h2,
.dialog-head h2 {
  display: flex;
  align-items: center;
  gap: 8px;
}
.panel-head .icon {
  color: var(--accent);
  width: 16px;
  height: 16px;
}
.panel-body {
  padding: 20px 16px;
}
.side-stack {
  display: grid;
  gap: 24px;
}
.panel-note {
  padding: 0 16px 16px;
  color: var(--muted);
  font-size: 16px;
}
.rail {
  position: fixed;
  width: 240px;
  inset: 0 auto 0 0;
  background: #112b3c;
  border-right: 4px solid #061522;
  box-shadow: inset -2px 0 #477787;
  padding: 32px 16px 24px;
  display: flex;
  flex-direction: column;
  z-index: 20;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 8px;
}
.brand > .icon {
  height: 32px;
  width: 32px;
  color: var(--accent);
}
.brand-word {
  font:
    16px/1.75 PixelDisplay,
    var(--font);
  color: var(--accent);
}
.brand-word span {
  display: block;
  font:
    8px/2 PixelDisplay,
    var(--font);
  letter-spacing: 4px;
  color: var(--ink);
}
.rail-title {
  margin: 32px 12px 12px;
  color: var(--muted);
  font-size: 16px;
}
.nav {
  display: grid;
  gap: 12px;
}
.nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 12px;
  min-height: 64px;
  border: 4px solid transparent;
  background-clip: padding-box;
  color: var(--muted);
}
.nav a:hover {
  background: var(--raised);
  border-image: var(--frame) 8 stretch;
  color: var(--ink);
}
.nav a.active {
  background: #245b5e;
  border-image: var(--frame-active) 8 stretch;
  color: var(--accent);
}
.nav a.active:after {
  content: "";
  width: 8px;
  height: 8px;
  background: var(--accent);
  box-shadow:
    4px 0 var(--accent),
    4px 4px var(--accent);
  margin-left: auto;
}
.nav .en {
  font:
    8px/2 PixelDisplay,
    var(--font);
  display: block;
  color: var(--muted);
  margin-top: 4px;
  letter-spacing: 0;
}
.rail-bottom {
  margin-top: auto;
  padding-top: 24px;
}
.rail-sprite {
  display: block;
  width: 144px;
  height: 144px;
  object-fit: contain;
  image-rendering: pixelated;
  margin: 8px auto 16px;
}
.rail-bottom p {
  font-size: 16px;
  color: var(--muted);
  margin: 12px 8px 0;
}
.local-indicator {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 16px;
  color: var(--muted);
}
.local-indicator:before {
  content: "";
  width: 8px;
  height: 8px;
  background: var(--accent);
  box-shadow: 0 2px #337e78;
  flex-shrink: 0;
}
.rail-bottom .local-indicator {
  padding: 0 8px;
}
.app-main {
  margin-left: 240px;
  max-width: 1700px;
  padding: 28px 36px 48px;
  min-height: 100vh;
}
.topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 2px solid var(--line);
  padding-bottom: 16px;
  margin-bottom: 28px;
  font-size: 16px;
  color: var(--muted);
}
.path {
  display: flex;
  gap: 12px;
  align-items: center;
}
.path .icon {
  width: 16px;
  height: 16px;
  color: var(--accent);
}
.top-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  margin-bottom: 24px;
}
.header > div:first-child {
  min-width: 0;
}
.header p {
  color: var(--muted);
  margin-top: 8px;
}
.date-chip {
  display: flex;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-size: 16px;
  flex-shrink: 0;
}
.date-chip .icon {
  width: 16px;
  height: 16px;
}
.entry-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(300px, 1fr);
  gap: 24px;
  align-items: start;
}
.entry-bottom {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 24px;
  color: var(--muted);
  font-size: 16px;
}
.entry-bottom .pixel {
  font-size: 8px;
  line-height: 3;
}
/* Buttons have mechanical travel, framed hover, and independent selected markers. */
.primary,
.secondary,
.danger,
.icon-button,
.add-template,
.tabs button,
.category,
.ui-trigger,
.ui-option,
.ui-calendar-day {
  border: 4px solid transparent;
  border-image: var(--frame) 8 stretch;
  background-clip: padding-box;
  border-radius: 0;
  min-height: 44px;
  line-height: 1.5;
  position: relative;
}
.primary,
.secondary,
.danger {
  padding: 8px 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 400;
}
.primary {
  background: #88e5bf;
  border-image: url("assets/frame-button.svg") 8 stretch;
  color: #0b2934;
  box-shadow: 0 4px #061522;
}
.primary:hover {
  background: #b2ffd3;
  border-image: var(--frame-active) 8 stretch;
}
.secondary {
  background: #1b4051;
  color: var(--accent);
  box-shadow: 0 4px #061522;
}
.secondary:hover {
  background: #2a5d62;
  border-image: var(--frame-active) 8 stretch;
}
.danger {
  color: var(--danger);
  background: #4a3648;
  border-image: url("assets/frame-danger.svg") 8 stretch;
  box-shadow: 0 4px #061522;
}
.danger:hover {
  background: #704952;
}
.primary:active,
.secondary:active,
.danger:active,
.icon-button:active,
.add-template:active {
  transform: translateY(2px);
  box-shadow: 0 2px #061522;
}
.wide {
  width: 100%;
  margin-top: 24px;
}
.text-button {
  padding: 0 4px;
  min-height: 32px;
  border: 0;
  background: none;
  color: var(--accent);
  font-size: 16px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.text-button .icon {
  width: 16px;
  height: 16px;
}
.text-button:hover {
  background: #28575c;
  color: #f0ffe5;
  text-decoration: underline;
  text-underline-offset: 5px;
  text-decoration-style: dashed;
}
.icon-button {
  padding: 8px;
  background: #173546;
  min-width: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.icon-button .icon {
  width: 16px;
  height: 16px;
}
.icon-button:hover {
  background: #2b5b60;
  border-image: var(--frame-active) 8 stretch;
  color: var(--accent);
}
.tabs {
  display: flex;
  gap: 4px;
  background: #0a2031;
  padding: 6px;
  border: 2px solid #477787;
  box-shadow: inset 2px 2px #061522;
}
.tabs button {
  flex: 1;
  padding: 6px 12px;
  background: #1c3949;
  color: var(--muted);
  border-image: none;
}
.tabs button:hover {
  color: var(--ink);
  background: #2b505b;
}
.tabs button.selected {
  color: #0c2a32;
  background: #8debc7;
  border-image: var(--frame-active) 8 stretch;
}
.tabs button.selected:after {
  content: "";
  height: 4px;
  position: absolute;
  bottom: 0;
  left: 8px;
  right: 8px;
  background: #3a9288;
}
.tabs button[data-type="income"].selected {
  background: var(--income);
}
.category-head {
  margin: 24px 0 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.category-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}
.category-more {
  color: var(--accent);
}
.category-more .icon {
  color: currentColor;
}
.entry-note {
  margin-top: 20px;
}
.entry-note summary {
  display: flex;
  align-items: center;
  min-height: 44px;
  gap: 8px;
  color: var(--muted);
  cursor: pointer;
  list-style: none;
}
.entry-note summary::-webkit-details-marker {
  display: none;
}
.entry-note summary:before {
  content: "+";
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  color: var(--accent);
  background: var(--bg);
}
.entry-note[open] summary:before {
  content: "−";
}
.entry-note .field {
  margin-top: 8px;
}
.draft-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 12px;
  margin-top: 12px;
  color: var(--muted);
}
.category {
  background: #102a3d;
  padding: 12px 2px 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  font-size: 16px;
  min-height: 80px;
}
.category .icon {
  width: 24px;
  height: 24px;
  color: var(--cat);
}
.category:hover {
  background: #28505c;
  border-image: var(--frame-active) 8 stretch;
}
.category.selected {
  background: #2c5b5e;
  color: var(--accent);
  border-image: var(--frame-active) 8 stretch;
  box-shadow: 0 4px #061522;
}
.category.selected:after {
  content: "";
  position: absolute;
  top: 4px;
  right: 4px;
  width: 4px;
  height: 4px;
  background: #eaffc7;
  box-shadow:
    -4px 4px #eaffc7,
    -8px 0 #eaffc7;
}
.form-row {
  display: flex;
  gap: 16px;
  align-items: end;
}
.form-row > * {
  flex: 1;
  min-width: 0;
}
.field {
  margin-top: 20px;
  display: block;
}
.field > span,
.field > label {
  display: block;
  color: var(--muted);
  font-size: 16px;
  margin-bottom: 8px;
}
.field input,
.field textarea,
.search,
.category-edit input,
.ui-time-value {
  width: 100%;
  background: #0c2436;
  background-clip: padding-box;
  border: 4px solid transparent;
  border-image: var(--frame) 8 stretch;
  box-shadow: inset 2px 2px #061522;
  color: var(--ink);
  padding: 8px 12px;
  min-height: 48px;
  border-radius: 0;
  font-family: var(--font);
}
.field textarea {
  min-height: 80px;
  resize: vertical;
}
.field input:hover,
.field textarea:hover,
.search:hover,
.category-edit input:hover {
  border-image: var(--frame-active) 8 stretch;
}
.field input:focus,
.field textarea:focus,
.search:focus,
.category-edit input:focus {
  border-image: var(--frame-active) 8 stretch;
  background: #153747;
}
.field input::placeholder,
.field textarea::placeholder,
.search::placeholder {
  color: #a6c0c6;
  opacity: 1;
}
.amount-field {
  padding: 16px 16px 12px;
  margin-top: 24px;
  background: #112a3a;
  border: 2px solid var(--line);
  box-shadow: inset 2px 2px #061522;
}
.amount-label {
  display: flex;
  justify-content: space-between;
  font-size: 16px;
  color: var(--muted);
}
.amount-input {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
}
.amount-input .currency {
  color: var(--expense);
  font: 16px/1.5 var(--font);
}
.amount-input input {
  width: 100%;
  min-width: 0;
  font: 48px/1.3 var(--font);
  font-variant-numeric: tabular-nums;
  background: none;
  border: 0;
  color: var(--expense);
  padding: 0;
  border-radius: 0;
  box-shadow: none;
}
.amount-input.income input,
.amount-input.income .currency {
  color: var(--income);
}
.amount-input input::placeholder {
  color: #87a2b2;
  opacity: 1;
}
.form-footer {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  font-size: 16px;
  color: var(--muted);
}
.form-footer .icon {
  width: 16px;
  height: 16px;
}
.field select {
  width: 100%;
  background: #0c2436;
  color: var(--ink);
  border: 4px solid var(--line);
  border-radius: 0;
  padding: 8px 12px;
  min-height: 48px;
}
.native-control {
  display: none !important;
}
.ui-control {
  display: block;
  min-width: 0;
}
.ui-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 12px;
  text-align: left;
  background: #0c2436;
  color: var(--ink);
  font: 16px/1.5 var(--font);
  min-height: 48px;
  box-shadow: inset 2px 2px #061522;
}
.ui-trigger span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ui-trigger .icon {
  width: 16px;
  height: 16px;
  color: var(--accent);
}
.ui-trigger:hover,
.ui-trigger[aria-expanded="true"] {
  border-image: var(--frame-active) 8 stretch;
  background: #204855;
}
.ui-popover {
  position: fixed;
  z-index: 200;
  max-height: min(420px, 70dvh);
  overflow: auto;
  min-width: 180px;
  padding: 8px;
  isolation: isolate;
  filter: drop-shadow(4px 4px 0 #061522);
}
.ui-options {
  display: grid;
  gap: 4px;
  max-height: 300px;
  overflow: auto;
}
.ui-option {
  text-align: left;
  padding: 6px 12px;
  min-height: 40px;
  background: #173748;
  border-image: none;
  color: var(--ink);
  width: 100%;
}
.ui-option:hover,
.ui-option:focus-visible {
  background: #306068;
  border-image: var(--frame-active) 8 stretch;
  outline-offset: -4px;
}
.ui-option[aria-selected="true"] {
  color: #102c33;
  background: #8bdfc2;
  border-image: var(--frame-active) 8 stretch;
}
.ui-option[aria-selected="true"]:before {
  content: "";
  width: 4px;
  height: 4px;
  background: #143d43;
  box-shadow:
    4px 4px #143d43,
    8px 0 #143d43;
  display: inline-block;
  margin-right: 16px;
}
.ui-picker-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  gap: 8px;
}
.ui-week,
.ui-date-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
}
.ui-week {
  text-align: center;
  color: var(--muted);
  font-size: 16px;
  margin: 4px 0 8px;
}
.ui-date-grid {
  min-width: 252px;
}
.ui-calendar-day {
  padding: 4px 0;
  min-height: 36px;
  min-width: 0;
  font-size: 16px;
  background: #16384a;
  border-image: none;
}
.ui-calendar-day:hover {
  background: #37696c;
}
.ui-calendar-day.selected {
  background: var(--accent);
  color: #102c33;
  border-image: var(--frame-active) 8 stretch;
}
.ui-calendar-day.outside {
  color: #91b0ba;
}
.ui-date-manual {
  margin-top: 12px;
  display: flex;
  gap: 8px;
}
.ui-date-manual input {
  min-width: 0;
  flex: 1 1 0;
  width: 0;
  background: #0c2436;
  color: var(--ink);
  border: 2px solid var(--line);
  padding: 8px;
  font: 16px/1.5 var(--font);
}
.ui-date-manual .secondary {
  flex: 0 0 auto;
  white-space: nowrap;
  padding: 4px 8px;
}
.ui-time-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 12px 0;
}
.ui-time-value {
  width: 72px;
  text-align: center;
  font: 32px/1.5 var(--font);
  padding: 4px;
}
.ui-picker-error {
  color: var(--danger);
  font-size: 16px;
  padding: 8px 0;
}
.ui-picker-error:empty {
  display: none;
}
.stat-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  padding: 20px 16px;
  gap: 12px;
  border-bottom: 2px solid var(--line);
}
.stat-strip span {
  display: block;
  color: var(--muted);
  font-size: 16px;
  margin-bottom: 8px;
}
.stat-strip strong {
  font: 16px/1.5 var(--font);
  overflow-wrap: anywhere;
}
.expense {
  color: var(--expense);
}
.income {
  color: var(--income);
}
.balance {
  color: var(--accent);
}
.template-list {
  padding: 0 16px;
}
.template {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 0;
  border-bottom: 2px solid var(--line);
}
.template:last-child {
  border: 0;
}
.cat-tile {
  width: 40px;
  height: 40px;
  background: #112b3c;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 4px solid transparent;
  border-image: var(--frame) 8 stretch;
  color: var(--cat);
  flex-shrink: 0;
}
.cat-tile .icon {
  width: 24px;
  height: 24px;
}
.template-info {
  flex: 1;
  min-width: 0;
}
.template-info strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 16px;
}
.template-info small {
  font-size: 16px;
  display: block;
}
.add-template {
  background: #235451;
  color: var(--accent);
  padding: 6px 8px;
  font: 16px/1.5 var(--font);
  white-space: nowrap;
  min-height: 40px;
  box-shadow: 0 4px #061522;
}
.add-template:hover {
  border-image: var(--frame-active) 8 stretch;
  background: #396e65;
}
.empty {
  padding: 28px 20px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  color: var(--muted);
}
.empty > .icon {
  width: 48px;
  height: 48px;
  color: #8fcbc1;
}
.empty strong {
  font-size: 16px;
  color: var(--ink);
}
.empty p {
  max-width: 29ch;
  font-size: 16px;
}
.empty .secondary {
  font-size: 16px;
  margin-top: 4px;
}
.records {
  padding: 0 16px;
}
.record {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 16px 0;
  border: 0;
  border-bottom: 2px solid var(--line);
  width: 100%;
  text-align: left;
  background: none;
  color: var(--ink);
}
.record:last-child {
  border: 0;
}
.record:hover {
  background: #285664;
  box-shadow:
    8px 0 #285664,
    -8px 0 #285664;
}
.record-body {
  flex: 1;
  min-width: 0;
}
.record-body strong {
  font-size: 16px;
  display: block;
  overflow-wrap: anywhere;
}
.record-body small {
  margin-top: 4px;
  font-size: 16px;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}
.record-amount {
  font-size: 16px;
  white-space: nowrap;
}
.record > .icon {
  width: 16px;
  height: 16px;
  color: var(--muted);
}
.period-control {
  display: flex;
  align-items: center;
  gap: 12px;
}
.period-control strong {
  min-width: 144px;
  text-align: center;
  font-size: 16px;
}
.calendar-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(300px, 1fr);
  gap: 24px;
  align-items: start;
}
.calendar-panel {
  container: ledger-calendar / inline-size;
}
.calendar {
  padding: 16px 12px 20px;
}
.week,
.days {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
}
.week {
  text-align: center;
  color: var(--muted);
  font-size: 16px;
  padding: 0 0 12px;
}
.days {
  background: #0c2233;
  padding: 4px;
  border: 2px solid var(--line);
}
.day {
  position: relative;
  background: #183a4b;
  color: var(--ink);
  border: 4px solid transparent;
  min-height: 88px;
  padding: 8px 2px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 0;
}
.day:hover {
  border-image: var(--frame) 8 stretch;
  background: #2c5663;
}
.day.selected {
  border-image: var(--frame-active) 8 stretch;
  background: #31696b;
}
.day.outside {
  color: #94adb9;
  background: #112c3e;
}
.day.today:after {
  content: "";
  position: absolute;
  top: 4px;
  right: 4px;
  width: 4px;
  height: 4px;
  background: var(--accent);
  box-shadow: -4px 0 var(--accent);
}
.day b {
  font: 16px/1.5 var(--font);
}
.day span {
  font: 16px/1.25 var(--font);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}
.day.today b {
  color: var(--accent);
}
.calendar-legend {
  display: flex;
  gap: 16px;
  justify-content: center;
  margin-top: 16px;
  font-size: 16px;
  color: var(--muted);
}
.dot {
  width: 8px;
  height: 8px;
  display: inline-block;
  background: var(--cat, var(--accent));
  margin-right: 8px;
  vertical-align: middle;
}
.search-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 16px 16px 0;
}
.search-wrap .search {
  min-width: 0;
  flex: 1;
}
.search-wrap .icon-button {
  flex-shrink: 0;
}
[hidden] {
  display: none !important;
}
.day-total {
  padding: 16px;
  border-bottom: 2px solid var(--line);
  display: flex;
  justify-content: space-between;
  font-size: 16px;
  gap: 8px;
}
.report-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  padding: 24px;
  margin-bottom: 24px;
  gap: 16px;
}
.report-summary > div + div {
  border-left: 2px solid var(--line);
  padding-left: 16px;
}
.report-summary small {
  display: block;
  margin-bottom: 12px;
}
.report-summary strong {
  font: 32px/1.3 var(--font);
  overflow-wrap: anywhere;
}
.report-layout {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(0, 1.4fr);
  gap: 24px;
}
.donut-wrap {
  padding: 32px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}
.donut {
  width: 256px;
  max-width: 100%;
  aspect-ratio: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  isolation: isolate;
}
.pixel-donut {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  shape-rendering: crispEdges;
  image-rendering: pixelated;
}
.donut-center {
  z-index: 1;
  text-align: center;
  max-width: 60%;
}
.donut-center strong {
  display: block;
  font: 32px/1.5 var(--font);
  overflow-wrap: anywhere;
}
.donut-center small {
  font-size: 16px;
}
.chart-legend {
  display: flex;
  gap: 12px 16px;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 320px;
  font-size: 16px;
  color: var(--muted);
}
.breakdown {
  padding: 0 16px;
}
.breakdown-row {
  display: grid;
  grid-template-columns: 24px minmax(60px, 1fr) auto 16px;
  gap: 12px;
  align-items: center;
  width: 100%;
  padding: 20px 0;
  border: 0;
  border-bottom: 2px solid var(--line);
  background: none;
  color: var(--ink);
  text-align: left;
}
.breakdown-row:hover {
  background: #285664;
}
.breakdown-row:last-child {
  border: 0;
}
.breakdown-row > .icon {
  color: var(--cat);
  width: 24px;
  height: 24px;
}
.breakdown-row > .icon:last-child {
  width: 16px;
  height: 16px;
  color: var(--muted);
}
.bar-track {
  display: block;
  height: 8px;
  background: #102a3a;
  margin-top: 8px;
  max-width: 240px;
}
.bar-track span {
  display: block;
  height: 100%;
  background: repeating-linear-gradient(
    to right,
    var(--cat) 0 6px,
    transparent 6px 8px
  );
}
.breakdown-row .value {
  text-align: right;
  font: 16px/1.5 var(--font);
}
.breakdown-row .value small {
  display: block;
  font: 16px/1.5 var(--font);
}
.report-range {
  font-size: 16px;
  color: var(--muted);
  margin-bottom: 20px;
}
.settings-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(300px, 1fr);
  gap: 24px;
  align-items: start;
}
.settings-jumps {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 0 0 24px;
}
.settings-layout section[id] {
  scroll-margin-top: 20px;
}
.setting-group-title {
  color: var(--accent);
  font-size: 16px;
  margin: 24px 0 4px;
  padding-top: 12px;
  border-top: 2px solid var(--line);
}
.setting-group-title:first-child {
  margin-top: 16px;
  padding-top: 0;
  border-top: 0;
}
.category-group + .category-group {
  margin-top: 28px;
}
.setting {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 16px 0;
  border-bottom: 2px solid var(--line);
}
.setting:last-child {
  border: 0;
}
.setting > div {
  min-width: 0;
}
.setting strong {
  font-size: 16px;
  display: block;
}
.setting small {
  font-size: 16px;
  display: block;
  margin-top: 4px;
}
.setting .ui-control {
  width: 160px;
  flex-shrink: 0;
}
.setting .ui-trigger {
  padding: 8px;
  font-size: 16px;
  min-height: 44px;
}
.setting select,
.setting input[type="time"] {
  background: #0c2436;
  border: 4px solid var(--line);
  padding: 8px;
  color: var(--ink);
  max-width: 160px;
  min-height: 44px;
}
.toggle {
  appearance: none;
  -webkit-appearance: none;
  width: 48px;
  height: 28px;
  flex-shrink: 0;
  border: 4px solid transparent;
  border-image: var(--frame) 8 stretch;
  background: #0b2435;
  background-clip: padding-box;
  border-radius: 0;
  position: relative;
  cursor: pointer;
  box-shadow: inset 2px 2px #061522;
}
.toggle:after {
  content: "";
  position: absolute;
  left: 2px;
  top: 2px;
  width: 12px;
  height: 16px;
  background: #a0b8c3;
  box-shadow: 2px 2px #4b707f;
}
.toggle:checked {
  background: #37786d;
  border-image: var(--frame-active) 8 stretch;
}
.toggle:checked:after {
  background: #c6ffcc;
  left: auto;
  right: 2px;
  box-shadow: 2px 2px #165249;
}
.setting-section {
  padding: 0 16px 8px;
}
.settings-layout .side-stack .panel-body {
  padding-top: 8px;
}
.button-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 20px;
}
.category-edit {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 2px solid var(--line);
}
.category-edit > .icon {
  width: 24px;
  height: 24px;
  color: var(--cat);
}
.category-edit input {
  min-width: 0;
  padding: 6px 8px;
  min-height: 44px;
}
.category-edit small {
  flex-shrink: 0;
}
.category-edit .icon-button {
  min-width: 40px;
  min-height: 40px;
  padding: 4px;
}
.recurring-row {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 16px 0;
  border-bottom: 2px solid var(--line);
}
.recurring-row > div {
  flex: 1;
  min-width: 0;
}
.recurring-row strong {
  font-size: 16px;
  display: block;
}
.recurring-row small {
  font-size: 16px;
}
.notice {
  padding: 12px 16px;
  font-size: 16px;
  border: 4px solid transparent;
  border-image: var(--frame) 8 stretch;
  color: var(--muted);
  margin-top: 16px;
  background: #193747;
}
.error {
  color: var(--danger);
  font-size: 16px;
  margin-top: 12px;
}
.error:empty {
  display: none;
}
.demo-banner {
  background: #295754;
  padding: 12px 16px;
  border: 4px solid transparent;
  border-image: var(--frame-active) 8 stretch;
  color: var(--accent);
  margin-bottom: 24px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 16px;
}
#toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  visibility: hidden;
  pointer-events: none;
  padding: 12px 20px;
  background: var(--accent);
  color: #0e2d36;
  border: 4px solid transparent;
  border-image: var(--frame-active) 8 stretch;
  box-shadow: 4px 4px #061522;
  z-index: 250;
  font-size: 16px;
  max-width: min(600px, 90vw);
  font-family: var(--font);
}
#toast.show {
  visibility: visible;
}
dialog {
  overscroll-behavior: contain;
  position: fixed;
  inset: 0;
  margin: auto;
  overflow: auto;
  padding: 0;
  color: var(--ink);
  width: 540px;
  max-width: calc(100vw - 32px);
  max-height: 88dvh;
  filter: none;
  box-shadow: 8px 8px #061522;
}
dialog .dialog-head {
  position: sticky;
  top: 0;
  z-index: 6;
  background: var(--panel);
}
dialog::backdrop {
  background: #071624d9;
}
dialog .dialog-body {
  padding: 20px 16px;
}
dialog .dialog-body > p {
  color: var(--muted);
  font-size: 16px;
}
dialog .field:first-child {
  margin-top: 0;
}
.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 24px;
}
dialog .records {
  padding: 0;
}
.lock-screen {
  position: fixed;
  inset: 0;
  background: var(--bg) url("assets/pixel-stars.svg");
  z-index: 180;
  display: grid;
  place-items: center;
  padding: 20px;
}
.lock-box {
  width: 392px;
  max-width: 100%;
  padding: 24px;
}
.lock-box > .icon {
  width: 48px;
  height: 48px;
  color: var(--accent);
  margin-bottom: 24px;
}
.lock-box h1 {
  font-size: 32px;
}
.boot {
  padding: 48px;
}
.mobile-brand {
  display: none;
}
.hidden {
  display: none !important;
}
@media (min-width: 1550px) {
  .app-main {
    padding: 32px 52px;
  }
  .entry-layout {
    grid-template-columns: minmax(0, 1.2fr) minmax(360px, 1fr);
  }
}
@media (max-width: 1200px) {
  .rail {
    width: 208px;
    padding: 28px 12px;
  }
  .brand {
    gap: 8px;
  }
  .brand-word {
    font-size: 16px;
  }
  .app-main {
    margin-left: 208px;
    padding: 24px;
  }
  .entry-layout {
    gap: 20px;
    grid-template-columns: minmax(0, 1.15fr) minmax(280px, 1fr);
  }
  .category-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
  .calendar-layout {
    grid-template-columns: 1fr;
  }
  .settings-layout {
    grid-template-columns: minmax(0, 1.15fr) minmax(280px, 1fr);
    gap: 20px;
  }
  .setting .ui-control {
    width: 144px;
  }
  .report-summary strong {
    font-size: 32px;
  }
  #toast {
    left: 50%;
  }
}
@media (max-width: 980px) {
  .entry-layout,
  .settings-layout,
  .report-layout {
    grid-template-columns: 1fr;
  }
  .category-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
  .entry-layout > .side-stack {
    grid-template-columns: 1fr 1fr;
    gap: 20px;
  }
  .entry-layout > .side-stack > .panel:first-child {
    grid-column: 1/-1;
  }
  .template {
    flex-wrap: wrap;
  }
  .add-template {
    margin-left: auto;
  }
  .report-summary strong {
    font-size: 32px;
  }
  .report-summary {
    padding: 20px 16px;
  }
  .header {
    align-items: start;
    flex-wrap: wrap;
  }
  .header .date-chip {
    margin-left: auto;
  }
  .setting .ui-control {
    width: 176px;
  }
}
@media (max-width: 700px) {
  .rail {
    position: fixed;
    inset: auto 0 0;
    width: 100%;
    padding: 4px 0 env(safe-area-inset-bottom);
    border: 0;
    border-top: 4px solid #061522;
    box-shadow: inset 0 2px #659d9f;
    background: #153647;
    display: block;
  }
  .rail > .brand,
  .rail-title,
  .rail-bottom {
    display: none;
  }
  .nav {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 4px;
    padding: 0 4px;
  }
  .nav a {
    min-height: 68px;
    padding: 8px 2px 6px;
    flex-direction: column;
    gap: 4px;
    text-align: center;
    font-size: 16px;
    border: 4px solid transparent;
  }
  .nav a .icon {
    width: 24px;
    height: 24px;
  }
  .nav a .en {
    display: none;
  }
  .nav a.active {
    background: #295a5f;
    border-image: var(--frame-active) 8 stretch;
  }
  .nav a.active:after {
    display: none;
  }
  .app-main {
    margin: 0;
    padding: 20px 16px 112px;
  }
  .mobile-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--accent);
    font:
      8px/2 PixelDisplay,
      var(--font);
  }
  .mobile-brand .icon {
    width: 24px;
    height: 24px;
  }
  .topline {
    padding-bottom: 12px;
    margin-bottom: 24px;
  }
  .topline .path {
    display: none;
  }
  .top-actions {
    gap: 8px;
  }
  .top-actions .local-label {
    display: none;
  }
  .local-indicator {
    font-size: 16px;
  }
  .header {
    gap: 12px;
    margin-bottom: 24px;
    align-items: start;
  }
  h1 {
    font-size: 32px;
  }
  .header p {
    font-size: 16px;
    margin-top: 8px;
  }
  .header .date-chip {
    font-size: 16px;
    margin-left: 0;
    width: 100%;
  }
  .date-chip .icon {
    width: 16px;
    height: 16px;
  }
  .header.report-header .period-control {
    margin-left: auto;
  }
  .entry-layout,
  .side-stack,
  .entry-layout > .side-stack,
  .settings-layout,
  .report-layout {
    gap: 20px;
    grid-template-columns: 1fr;
  }
  .entry-layout > .side-stack > .panel:first-child {
    grid-column: auto;
  }
  .panel-head,
  .dialog-head {
    padding: 12px;
    gap: 8px;
  }
  .panel-body {
    padding: 16px 12px;
  }
  .category-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 8px 4px;
  }
  .category {
    padding: 8px 0;
    min-height: 76px;
    font-size: 16px;
    gap: 8px;
  }
  .category .icon {
    width: 24px;
    height: 24px;
  }
  .form-row {
    gap: 12px;
    flex-wrap: wrap;
  }
  .form-row > .field {
    flex-basis: 100%;
  }
  .field {
    margin-top: 20px;
  }
  .amount-input input {
    font-size: 48px;
  }
  .amount-field {
    padding: 8px 12px 4px;
  }
  .category-head {
    flex-wrap: wrap;
  }
  .stat-strip {
    padding: 16px 12px;
    gap: 8px;
  }
  .stat-strip span {
    font-size: 16px;
    min-height: 24px;
  }
  .stat-strip strong {
    font-size: 16px;
  }
  .entry-bottom {
    flex-direction: column;
    gap: 12px;
  }
  .entry-bottom .pixel {
    font-size: 8px;
    line-height: 2;
  }
  .records,
  .template-list {
    padding: 0 12px;
  }
  .template {
    flex-wrap: nowrap;
    gap: 8px;
  }
  .template-info small {
    font-size: 16px;
  }
  .add-template {
    padding: 6px;
    min-height: 40px;
    font-size: 16px;
  }
  .calendar {
    padding: 16px 0;
  }
  .week,
  .days {
    gap: 0;
  }
  .days {
    padding: 0;
  }
  .day {
    min-height: 58px;
    border-width: 2px;
    padding: 3px 0;
    gap: 0;
  }
  .day b {
    font-size: 16px;
  }
  .day span {
    font-size: 16px;
    line-height: 1.25;
    max-width: 100%;
    text-overflow: clip;
    letter-spacing: -1px;
  }
  .day.today:after {
    top: 2px;
    right: 2px;
    width: 2px;
    height: 2px;
    box-shadow: -2px 0 var(--accent);
  }
  .period-control {
    gap: 8px;
  }
  .period-control strong {
    min-width: 128px;
    font-size: 16px;
  }
  .period-control .icon-button {
    min-width: 36px;
    min-height: 40px;
    padding: 4px;
  }
  .calendar-layout .panel-head {
    flex-wrap: wrap;
  }
  .report-summary {
    padding: 10px 12px;
    gap: 8px;
  }
  .report-summary small {
    font-size: 16px;
    margin-bottom: 4px;
  }
  .report-summary strong {
    font-size: 16px;
  }
  .report-summary > div + div {
    padding-left: 8px;
  }
  .report-range {
    font-size: 16px;
  }
  .donut {
    width: 256px;
  }
  .donut-wrap {
    padding: 24px 8px;
  }
  .donut-center strong {
    font-size: 32px;
  }
  .breakdown {
    padding: 0 12px;
  }
  .breakdown-row {
    gap: 8px;
  }
  .setting-section {
    padding: 0 12px 8px;
  }
  .setting {
    gap: 12px;
    align-items: center;
  }
  .setting strong,
  .setting small {
    font-size: 16px;
  }
  .setting small {
    max-width: 20ch;
  }
  .setting .ui-control {
    width: 100%;
    max-width: none;
  }
  .setting:has(.ui-control) {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
  }
  .setting small {
    max-width: none;
  }
  .settings-jumps {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }
  .settings-jumps a:first-child {
    grid-column: 1 / -1;
  }
  .settings-jumps .secondary {
    padding: 8px;
  }
  .category-grid:not(.expanded) {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
  .category-grid:not(.expanded) .category-more {
    grid-column: 1 / -1;
    flex-direction: row;
    min-height: 44px;
    padding: 8px;
    justify-content: center;
  }
  .setting .ui-trigger {
    padding: 6px 8px;
    gap: 8px;
  }
  .setting .secondary {
    padding: 8px;
    font-size: 16px;
    flex-shrink: 0;
  }
  .category-edit {
    gap: 8px;
  }
  .category-edit input {
    padding: 6px;
  }
  .category-edit > .icon {
    width: 16px;
    height: 16px;
  }
  .category-edit .icon-button {
    min-width: 36px;
  }
  .recurring-row {
    gap: 8px;
  }
  .recurring-row .icon-button {
    min-width: 36px;
    padding: 4px;
  }
  .recurring-row .toggle {
    width: 44px;
  }
  .button-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }
  .button-row [data-action="import"] {
    grid-column: 1 / -1;
    grid-row: 1;
  }
  .button-row .secondary {
    flex: 1;
    padding: 8px;
  }
  .panel-note {
    padding: 0 12px 16px;
  }
  .empty {
    padding: 24px 12px;
  }
  .demo-banner {
    padding: 8px 12px;
    gap: 8px;
    align-items: center;
  }
  .demo-banner .text-button {
    flex-shrink: 0;
  }
  .lock-box {
    padding: 20px 16px;
  }
  #toast {
    left: 50%;
    bottom: 96px;
    width: max-content;
    max-width: calc(100vw - 32px);
    font-size: 16px;
    padding: 12px 16px;
  }
  .ui-popover {
    max-width: calc(100vw - 16px);
  }
  .ui-date-grid {
    min-width: 238px;
  }
  .ui-calendar-day {
    min-height: 36px;
  }
  .category-grid .category:nth-child(n) {
    min-width: 0;
  }
}
@media (max-width: 360px) {
  .app-main {
    padding-left: 12px;
    padding-right: 12px;
  }
  .category-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
  .setting .ui-control {
    width: 100%;
    max-width: none;
  }
  .calendar-legend {
    gap: 8px;
  }
  .calendar-legend .dot {
    margin-right: 4px;
  }
  .stat-strip {
    padding-left: 8px;
    padding-right: 8px;
  }
  .record {
    gap: 8px;
  }
  .cat-tile {
    width: 36px;
    height: 36px;
  }
  .record > .icon {
    width: 8px;
  }
  .report-summary {
    padding: 16px 8px;
  }
  .report-summary > div + div {
    padding-left: 4px;
  }
  .report-summary small {
    font-size: 16px;
  }
  .setting .secondary {
    max-width: 50%;
    overflow-wrap: anywhere;
  }
  .period-control strong {
    min-width: 120px;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *:before,
  *:after {
    transition: none !important;
    animation: none !important;
    scroll-behavior: auto !important;
  }
}
.calendar-compact,
.calendar-amount-note {
  display: none;
}
@container ledger-calendar (max-width: 1040px) {
  .day .calendar-full {
    display: none;
  }
  .day .calendar-compact {
    display: block;
    letter-spacing: 0;
    white-space: nowrap;
    font-size: 16px;
    line-height: 1.25;
    overflow: visible;
  }
  .calendar-amount-note {
    display: block;
    font-size: 16px;
    color: var(--muted);
    margin-top: 12px;
    text-align: center;
    padding: 0 8px;
  }
}
@media (max-width: 700px) {
  .day .calendar-full {
    display: none;
  }
  .day .calendar-compact {
    display: block;
    letter-spacing: 0;
    white-space: nowrap;
    font-size: 16px;
    line-height: 1.25;
    overflow: visible;
  }
  .calendar-amount-note {
    display: block;
    font-size: 16px;
    color: var(--muted);
    margin-top: 12px;
    text-align: center;
    padding: 0 8px;
  }
  .day > span {
    overflow: visible;
  }
  .header h1 {
    font-size: 32px;
  }
  .donut-center strong,
  .lock-box h1 {
    font-size: 32px;
  }
}
.record-body small,
.template-info small,
.setting small,
.recurring-row strong,
.recurring-row small,
.notice,
.panel-note {
  overflow-wrap: anywhere;
}
.ui-date-grid .icon {
  width: 16px;
  height: 16px;
}

/* Compact navigation and task-focused secondary settings pages. */
.brand {
  justify-content: center;
  padding: 0;
}
.app-mark {
  display: block;
  width: 60px;
  height: 60px;
  object-fit: contain;
  image-rendering: pixelated;
}
.rail .nav {
  margin-top: 32px;
}
.nav a {
  position: relative;
  justify-content: center;
  padding: 8px;
  min-height: 52px;
  gap: 0;
}
.nav a.active:after {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 4px;
  height: 4px;
  margin: 0;
  box-shadow: 0 4px var(--accent);
}
.nav a:before {
  content: attr(data-tooltip);
  position: absolute;
  z-index: 30;
  left: calc(100% + 16px);
  top: 50%;
  transform: translateY(-50%);
  background: var(--panel);
  color: var(--ink);
  border: 4px solid transparent;
  border-image: var(--frame) 8 stretch;
  padding: 6px 12px;
  white-space: nowrap;
  visibility: hidden;
  pointer-events: none;
}
.nav a:hover:before,
.nav a:focus-visible:before {
  visibility: visible;
}
.rail-lock {
  margin-top: auto;
}
.entry-clear {
  display: flex;
  justify-content: flex-end;
  margin-top: 12px;
}
.period-short {
  display: none;
}
.report-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 20px;
  margin-bottom: 24px;
}
.report-toolbar > .tabs {
  width: 250px;
}
.settings-home,
.settings-subpage {
  max-width: 820px;
  margin: 0 auto;
}
.settings-back {
  margin-bottom: 20px;
}
.settings-menu {
  padding: 4px 16px;
}
.settings-link {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px 8px;
  min-height: 76px;
  border-bottom: 2px solid var(--line);
}
.settings-link:last-child {
  border-bottom: 0;
}
.settings-link > .icon:first-child {
  color: var(--accent);
}
.settings-link > span {
  flex: 1;
}
.settings-link > .icon:last-child {
  width: 16px;
  height: 16px;
  color: var(--muted);
}
.settings-link:hover {
  background: var(--raised);
}
.category-icon {
  color: var(--cat);
  flex-shrink: 0;
}
.icon-choice-grid,
.category-options {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}
.icon-choice .icon {
  color: var(--accent);
}
.icon-choice span,
.category-options span {
  overflow-wrap: anywhere;
}
.template-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.template-manager-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  padding-bottom: 12px;
  color: var(--muted);
}
.managed-template {
  flex-wrap: wrap;
}
.managed-template .template-info {
  min-width: 120px;
}
.managed-template .template-controls {
  margin-left: auto;
}
@media (min-width: 701px) {
  .rail {
    width: 88px;
    padding: 20px 12px;
  }
  .app-main {
    margin-left: 88px;
  }
}
@media (max-width: 700px) {
  .rail .nav {
    margin-top: 0;
  }
  .nav a {
    min-height: 60px;
  }
  .nav a:before {
    left: 50%;
    top: auto;
    bottom: calc(100% + 8px);
    transform: translateX(-50%);
  }
  .rail-lock {
    position: fixed;
    right: 16px;
    top: 8px;
    z-index: 40;
  }
  .report-toolbar {
    flex-wrap: nowrap;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 20px;
  }
  .report-toolbar > .tabs {
    width: auto;
    padding: 4px;
    gap: 2px;
  }
  .report-toolbar .tabs button {
    padding: 6px 4px;
    white-space: nowrap;
  }
  .report-toolbar .period-control,
  .calendar-panel .period-control {
    gap: 4px;
  }
  .report-toolbar .period-control strong,
  .calendar-panel .period-control strong {
    min-width: 64px;
  }
  .report-toolbar .period-full,
  .calendar-panel .period-full {
    display: none;
  }
  .report-toolbar .period-short,
  .calendar-panel .period-short {
    display: inline;
  }
  .calendar-panel .panel-head > .secondary {
    padding: 8px;
  }
  .settings-menu {
    padding: 4px 12px;
  }
  .category-options {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
  .managed-template .template-controls {
    justify-content: flex-end;
    width: 100%;
  }
}

/* A persistent pixel frame follows navigation, including the mobile bottom bar. */
.nav {
  position: relative;
  isolation: isolate;
}
.nav-indicator {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
  border: 4px solid transparent;
  border-image: var(--frame-active) 8 stretch;
  background: #245b5e;
  background-clip: padding-box;
  visibility: hidden;
}
.nav-indicator.positioned {
  visibility: visible;
  transition: transform 240ms cubic-bezier(0.22, 1, 0.36, 1);
}
.nav-indicator:after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 4px;
  height: 4px;
  background: var(--accent);
  box-shadow: 0 4px var(--accent);
}
.nav a {
  z-index: 1;
}
.nav a.active,
.nav a.active:hover {
  background: transparent;
  border-image: none;
}
.nav a.active:after {
  display: none;
}
#page-content {
  position: relative;
}
.page-view {
  position: relative;
  z-index: 1;
  display: flow-root;
}
.page-transitioning {
  overflow: clip;
  isolation: isolate;
}
.page-transitioning > .page-view {
  min-height: var(--transition-height);
  overflow: clip;
  background: var(--bg);
}
.outgoing-view {
  position: absolute;
  left: 0;
  pointer-events: none;
}
@media (max-width: 700px) {
  .nav-indicator:after {
    display: none;
  }
}
@media (prefers-reduced-motion: reduce) {
  .nav-indicator.positioned {
    transition: none;
  }
}

/* Default is the original star tile; snow is an explicitly selected skin. */
html {
  --scene-image: url("assets/pixel-stars.svg");
  --scene-size: auto;
  --scene-repeat: repeat;
  --scene-position: left top;
}
html[data-skin="snow"] {
  --scene-image: url("assets/snow-night-desktop-v1.webp");
  --scene-size: cover;
  --scene-repeat: no-repeat;
  --scene-position: center bottom;
}
body::before,
.page-transitioning > .page-view::before {
  content: "";
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  background: var(--bg) var(--scene-image) var(--scene-position) / var(--scene-size) var(--scene-repeat);
  image-rendering: pixelated;
  pointer-events: none;
  z-index: -1;
}
body::before {
  position: fixed;
  top: 0;
  left: 0;
}
/* Align each opaque sliding surface with the stationary scene at rest. */
.page-transitioning > .page-view::before {
  position: absolute;
  left: var(--scene-x);
  top: var(--scene-y);
}
@media (max-width: 700px) and (orientation: portrait) {
  html[data-skin="snow"] {
    --scene-image: url("assets/snow-night-mobile-v1.webp");
  }
}

.skin-intro {
  margin-bottom: 20px;
}
.skin-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}
.skin-choice {
  min-width: 0;
  padding: 12px;
  border: 4px solid transparent;
  border-image: var(--frame) 8 stretch;
  border-radius: 0;
  background: var(--panel);
  background-clip: padding-box;
  text-align: left;
  box-shadow: 4px 4px 0 #061522;
}
.skin-choice:hover {
  background-color: var(--raised);
}
.skin-choice[aria-pressed="true"] {
  border-image: var(--frame-active) 8 stretch;
  background-color: #245b5e;
}
.skin-preview {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  image-rendering: pixelated;
}
.skin-preview-default {
  background: var(--bg) url("assets/pixel-stars.svg");
}
.skin-preview-snow {
  background: var(--bg) url("assets/snow-night-desktop-v1.webp") center bottom / cover no-repeat;
}
.skin-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
}
.skin-info strong,
.skin-info small {
  display: block;
}
.skin-info small {
  color: var(--muted);
  margin-top: 4px;
}
.skin-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--accent);
  white-space: nowrap;
}
.skin-status .icon {
  width: 16px;
  height: 16px;
}
@media (max-width: 700px) {
  .skin-options {
    grid-template-columns: 1fr;
    gap: 16px;
  }
}

/* List hover fills the inset up to the containing panel frame. */
.records, .breakdown, .settings-menu { --row-gutter: 16px; }
.record:hover, .breakdown-row:hover {
  box-shadow: var(--row-gutter) 0 #285664, calc(-1 * var(--row-gutter)) 0 #285664;
}
.settings-link:hover {
  box-shadow: var(--row-gutter) 0 var(--raised), calc(-1 * var(--row-gutter)) 0 var(--raised);
}
@media (max-width: 700px) {
  .records, .breakdown, .settings-menu { --row-gutter: 12px; }
}
dialog .records { --row-gutter: 16px; }

/* Canvas stays between the generated scenery and the translucent UI. */
.scene-weather {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  pointer-events: none;
  image-rendering: pixelated;
}
.scene-weather[hidden] { display: none; }

/* Account access stays at the foot of the desktop rail; phones use Settings. */
.rail-bottom { margin-top: auto; display: flex; flex-direction: column; align-items: center; gap: 16px; }
.rail-bottom .rail-lock { margin-top: 0; }
.rail-account { width: 56px; height: 56px; padding: 6px; }
.pixel-avatar { --avatar-face: #ffe0ae; display: inline-flex; width: 40px; height: 40px; color: #143546; background: #88e5bf; flex-shrink: 0; }
.pixel-avatar svg { width: 100%; height: 100%; image-rendering: pixelated; }
.pixel-avatar { position: relative; overflow: hidden; }
.custom-avatar-image { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; image-rendering: auto; }
.avatar-preview { margin-block: 16px; }
.avatar-preview .pixel-avatar { width: 80px; height: 80px; }
.avatar-1 { background: #a6ddff; color: #254973; --avatar-face: #f9e9c8; }
.avatar-2 { background: #edbfdb; color: #633f65; --avatar-face: #ffe0c9; }
.avatar-3 { background: #ffc89c; color: #745039; --avatar-face: #fff0d2; }
.avatar-4 { background: #c7c4ff; color: #454379; --avatar-face: #efd7bb; }
.avatar-5 { background: #d4e5a6; color: #3b5641; --avatar-face: #ffe5d1; }
.account-identity { display: flex; align-items: center; gap: 16px; margin: 4px 0 24px; }
.account-identity strong { display: block; overflow-wrap: anywhere; }
.account-identity small { display: block; color: var(--muted); margin-top: 4px; }
.account-actions { display: flex; flex-wrap: wrap; gap: 12px; }
.account-help { margin: 24px 0; max-width: 68ch; }
.account-action { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 48px; padding: 12px 8px; color: var(--ink); text-align: left; background: transparent; border: none; box-shadow: none; text-decoration: none; }
.account-action:hover { background: var(--raised); color: var(--accent); }
.account-action:active { transform: none; }
.account-action .icon { width: 20px; height: 20px; }
.account-actions .account-action + .account-action { border-top: 2px solid var(--line); }
.account-menu-links { margin-top: 16px; padding-top: 12px; border-top: 2px solid var(--line); }
.account-form { margin-top: 24px; }
.account-form .field { margin-bottom: 20px; }
.account-form small { color: var(--muted); }
.avatar-options { display: flex; flex-wrap: wrap; gap: 12px; padding: 0; border: none; margin: 24px 0; }
.avatar-options legend { margin-bottom: 12px; }
.avatar-options label { display: flex; align-items: center; gap: 4px; cursor: pointer; }
.avatar-options input { accent-color: var(--accent); width: 16px; height: 16px; }
.avatar-options label:has(input:checked) .pixel-avatar { outline: 2px dashed var(--focus); outline-offset: 3px; }
@media (min-width: 701px) {
  dialog.account-popover { margin: 0; inset: auto auto 20px 104px; width: 336px; max-height: calc(100dvh - 48px); }
}
@media (max-width: 700px) { .rail-bottom { display: none; } }

/* The quick account menu leaves the ledger interactive; protected actions stay modal. */
dialog.account-popover { position: fixed; z-index: 260; }
.avatar-options label { min-height: 44px; padding-block: 2px; }

/* Touch labels have a finite lifetime; keyboard/mouse hints stay available. */
@media (max-width: 700px), (hover: none), (pointer: coarse) {
  .nav a:hover:before, .nav a:focus-visible:before { visibility: hidden; }
  .nav a.touch-hint:before { visibility: visible; }
}
@media (max-width: 700px) {
  #entry-form { padding-top: 12px; }
  .amount-input { margin-top: 4px; }
}

@media (max-width: 700px) {
  .day { min-height: 44px; padding-block: 2px; }
  .day b, .day span, .day .calendar-compact { line-height: 1; }
}
