:root {
  --bg: #f7f7f8; --surface: #ffffff; --text: #1b1b1b; --muted: #595959; --border: #d0d0d4;
  --accent: #0f5aa0; --on-accent: #ffffff; --negative: #b3261e; --warning: #8a4b00;
  --warning-bg: #fff4e0; --positive: #1b6e2d;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161618; --surface: #222225; --text: #f0f0f0; --muted: #b3b3b3; --border: #3d3d41;
    --accent: #8ab8f5; --on-accent: #0b1b2d; --negative: #ff8a80; --warning: #ffc069;
    --warning-bg: #3a2e17; --positive: #7fd294;
  }
}
/* 18 px and every size in rem: Chrome's own text size makes all of it larger still */
html { font-size: 112.5%; }
* { box-sizing: border-box; }
[hidden] { display: none !important; } /* a grid or flex rule must not show a hidden part */
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 1rem/1.35 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  display: flex; flex-direction: column; min-height: 100dvh;
}
.bar {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.35rem 1rem; background: var(--surface); border-bottom: 1px solid var(--border);
}
.state { flex: 1; font-size: 0.85rem; color: var(--muted); }
.state.warn { color: var(--warning); }
main {
  flex: 1; display: flex; flex-direction: column; width: 100%; max-width: 560px;
  margin: 0 auto; padding: 0.6rem 1rem;
}
h1 { font-size: 1.4rem; margin: 0.5rem 0 0.75rem; }
h2 { font-size: 1.1rem; margin: 1.1rem 0 0.5rem; }
.muted { color: var(--muted); font-size: 0.875rem; }
.error { color: var(--negative); min-height: 1.2em; }
.done { color: var(--positive); min-height: 1.2em; text-align: center; }
.notice {
  padding: 0.6rem 0.75rem; border-radius: 10px; background: var(--warning-bg);
  color: var(--warning); margin: 0; font-size: 0.875rem;
}
label { display: block; margin: 0.75rem 0; font-size: 0.875rem; color: var(--muted); }
input, select, textarea {
  display: block; width: 100%; margin-top: 0.25rem; padding: 0.65rem; font: inherit;
  font-size: 1rem; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px; min-height: 2.75rem;
}
button {
  font: inherit; min-height: 2.75rem; padding: 0.5rem 0.9rem; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
}
button.primary {
  width: 100%; min-height: 3.1rem; background: var(--accent); color: var(--on-accent);
  border-color: var(--accent); font-weight: 600; font-size: 1.1rem;
}
button:disabled { opacity: 0.6; }
button.ghost { min-height: 2.2rem; padding: 0.2rem 0.7rem; font-size: 0.875rem; }
[aria-pressed="true"] {
  background: var(--accent); color: var(--on-accent); border-color: var(--accent);
}

/* the entry screen fills the height between the top and the tabs, never more */
.entry:not([hidden]) { flex: 1; display: flex; flex-direction: column; gap: 0.45rem; }
.kinds { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.35rem; }
.amount {
  display: flex; align-items: baseline; justify-content: flex-end; gap: 0.4rem;
  padding: 0 0.25rem; border-bottom: 2px solid var(--accent);
  font-size: 2.4rem; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1.25;
}
.amount .empty { color: var(--muted); font-weight: 400; }
.amount .cur { font-size: 1.1rem; font-weight: 400; color: var(--muted); }
.tiles {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-auto-rows: minmax(3rem, auto); gap: 0.35rem;
}
.tiles button, .tile {
  font-size: 0.95rem; line-height: 1.15; padding: 0.25rem 0.35rem; min-height: 3rem;
  overflow-wrap: anywhere; hyphens: auto;
}
/* a native list under a tile or chip: its text shows, the control itself is invisible
   on top and opens the phone's own picker */
.tile, .chip {
  position: relative; display: flex; align-items: center; justify-content: center;
  margin: 0; min-width: 0; border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); color: var(--text); text-align: center;
}
.tile select, .chip select, .chip input {
  position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; min-height: 0;
  padding: 0; opacity: 0; cursor: pointer;
}
.tile:focus-within, .chip:focus-within { outline: 2px solid var(--accent); outline-offset: 1px; }
.pick { color: var(--accent); }
.pick[aria-pressed="true"] { color: var(--on-accent); }
.chips { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 0.35rem; }
.chip { min-height: 2.75rem; padding: 0 0.5rem; font-size: 0.95rem; }
.chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip.to { min-height: 6.35rem; font-size: 1.1rem; }
.keypad {
  flex: 1; display: grid; grid-template-columns: repeat(3, 1fr);
  grid-auto-rows: minmax(2.6rem, 1fr); gap: 0.35rem;
}
.keypad button {
  min-height: 0; padding: 0; font-size: 1.6rem; font-variant-numeric: tabular-nums;
  touch-action: manipulation; user-select: none;
}
/* a short phone, or the status strip shown: the same screen a little tighter */
@media (max-height: 700px) {
  .entry:not([hidden]) { gap: 0.3rem; }
  .amount { font-size: 2rem; }
  .tiles { grid-auto-rows: minmax(2.6rem, auto); }
  .tiles button, .tile { min-height: 2.6rem; }
  .chip { min-height: 2.5rem; }
  .keypad { grid-auto-rows: minmax(2.2rem, 1fr); gap: 0.3rem; }
  button.primary { min-height: 2.8rem; }
}
.toast {
  position: fixed; left: 1rem; right: 1rem; bottom: calc(3.6rem + env(safe-area-inset-bottom));
  max-width: 528px; margin: 0 auto; padding: 0.7rem 1rem; border-radius: 10px;
  background: var(--surface); border: 1px solid currentColor; text-align: center; z-index: 2;
}
.toast:empty { display: none; }
dialog {
  width: calc(100% - 2rem); max-width: 528px; margin: 1rem auto auto; padding: 1rem;
  border: 1px solid var(--border); border-radius: 14px; background: var(--surface);
  color: var(--text);
}
dialog::backdrop { background: rgb(0 0 0 / 45%); }
dialog label:first-child { margin-top: 0; }

.list { list-style: none; padding: 0; margin: 0; }
.list li {
  display: flex; justify-content: space-between; gap: 0.75rem; padding: 0.6rem 0.75rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  margin-bottom: 0.35rem;
}
.list .what { min-width: 0; overflow-wrap: anywhere; }
.list .sum { white-space: nowrap; font-variant-numeric: tabular-nums; }
.neg { color: var(--negative); }
.badge { font-size: 0.8rem; color: var(--muted); }
.badge.warn { color: var(--warning); }
.list .actions { display: flex; gap: 0.35rem; margin-top: 0.35rem; }
.list .actions button { min-height: 2.2rem; padding: 0.2rem 0.6rem; font-size: 0.875rem; }
video { width: 100%; border-radius: 10px; margin-top: 0.75rem; background: #000; }
details { margin-top: 1.1rem; }
.tabs {
  position: sticky; bottom: 0; display: grid; grid-template-columns: repeat(3, 1fr);
  background: var(--surface); border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabs button { border: 0; border-radius: 0; background: none; min-height: 3.1rem; }
.tabs [aria-current="page"] { color: var(--accent); font-weight: 600; }
