/* Light only — there is no dark theme. The glass and the blue dot field are
   tuned for a bright background, so a dark variant would need its own tuning
   rather than a palette swap. */
:root {
  color-scheme: light;
  --bg: #f6f8fc;
  --fg: #0f1115;
  --muted: #71767f;
  --line: #e2e6ee;
  --accent: #0f1115;
  --accent-fg: #ffffff;
  --danger: #c2382f;
  --sheet: #ffffff;
  --radius: 16px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font: 400 17px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  overscroll-behavior-y: none;
}

body { display: flex; flex-direction: column; }

.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
}
.screen[hidden] { display: none; }
.center { justify-content: center; align-items: center; padding: 24px; }

svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  min-height: 52px;
}
.topbar-title { font-size: 17px; font-weight: 600; margin: 0; }
.spacer { flex: 1; }
.topbar > :first-child:not(.spacer) ~ .topbar-title { margin-left: 2px; }
#home .topbar { justify-content: flex-end; }

.icon-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--fg);
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  cursor: pointer;
}
.icon-btn:active { background: var(--line); }

.pill {
  margin-right: auto;
  font-size: 13px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 10px;
}

/* ---------- home: amount + note only ---------- */
.entry {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 20px;
  padding: 0 24px 32px;
  max-width: 520px;
  width: 100%;
  margin: 0 auto;
}

/* Column, so the number stays dead-centre no matter how many digits it has. */
.amount-wrap { display: flex; flex-direction: column; align-items: center; gap: 2px; }

.amount {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--fg);
  font-size: clamp(48px, 16vw, 72px);
  font-weight: 600;
  letter-spacing: -0.03em;
  text-align: center;
  width: 100%;
  padding: 0;
  outline: none;
  font-variant-numeric: tabular-nums;
}
.amount::placeholder { color: var(--line); }

/* The currency label doubles as the switcher — one tap, no extra chrome. */
.currency {
  appearance: none;
  margin-top: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font: 600 13px/1 inherit;
  letter-spacing: 0.1em;
  padding: 9px 16px;
  cursor: pointer;
  transition: color .15s, border-color .15s;
}
.currency:active { color: var(--fg); border-color: var(--fg); }

.note {
  appearance: none;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--fg);
  font-size: 18px;
  padding: 12px 2px;
  text-align: center;
  outline: none;
  transition: border-color .15s;
}
.note::placeholder { color: var(--muted); }
.note:focus { border-bottom-color: var(--fg); }

.btn {
  appearance: none;
  border: 0;
  border-radius: var(--radius);
  font-size: 17px;
  font-weight: 600;
  padding: 15px 18px;
  cursor: pointer;
  transition: opacity .15s, transform .06s;
}
.btn:active { transform: scale(.985); }
.btn.primary { background: var(--accent); color: var(--accent-fg); }
.btn.primary:disabled { opacity: .3; }
.btn.big { padding: 17px; font-size: 18px; }

/* ---------- login ---------- */
.login-card { display: flex; flex-direction: column; gap: 14px; width: 100%; max-width: 320px; }
.login-title { font-size: 22px; font-weight: 600; margin: 0 0 8px; text-align: center; }
.field {
  appearance: none;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: transparent;
  color: var(--fg);
  font-size: 17px;
  padding: 15px 16px;
  outline: none;
}
.field:focus { border-color: var(--fg); }
.error { color: var(--danger); font-size: 14px; text-align: center; min-height: 20px; margin: 0; }

/* ---------- menu sheet ---------- */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .38);
  display: flex;
  align-items: flex-end;
  z-index: 20;
  animation: fade .18s ease;
}
.sheet-backdrop[hidden] { display: none; }
.sheet {
  background: var(--sheet);
  width: 100%;
  border-radius: 22px 22px 0 0;
  padding: 8px 8px calc(12px + var(--safe-bottom));
  animation: rise .22s cubic-bezier(.2, .8, .2, 1);
}
@keyframes fade { from { opacity: 0 } }
@keyframes rise { from { transform: translateY(100%) } }

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 8px 12px 16px;
}
.who-name { font-size: 17px; font-weight: 600; }
.who-status { font-size: 13px; color: var(--muted); margin-top: 2px; }

.sheet-item {
  appearance: none;
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  border-top: 1px solid var(--line);
  color: var(--fg);
  font-size: 17px;
  padding: 17px 16px;
  cursor: pointer;
}
.sheet-item:active { background: var(--line); }
.sheet-item.danger { color: var(--danger); }

/* ---------- history ---------- */
.history-list { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding-bottom: 24px; }
.day {
  display: flex;
  justify-content: space-between;
  padding: 18px 16px 6px;
  font-size: 13px;
  color: var(--muted);
  position: sticky;
  top: 0;
  background: var(--bg);
}
.row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
}
.row-main { flex: 1; min-width: 0; }
.row-note { font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-meta { font-size: 12px; color: var(--muted); margin-top: 3px; }
.row-amount { font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; }
.row-cur { font-size: 11px; color: var(--muted); font-weight: 600; letter-spacing: .06em; margin-left: 4px; }
.day-totals { display: flex; gap: 10px; }
.row.unsynced .row-amount::after { content: " •"; color: var(--muted); }
.row-del {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 6px;
  cursor: pointer;
  line-height: 0;
}
.row-del svg { width: 18px; height: 18px; }
.empty { text-align: center; color: var(--muted); padding: 48px 24px; font-size: 15px; }

/* ---------- toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(28px + var(--safe-bottom));
  transform: translate(-50%, 20px);
  background: var(--accent);
  color: var(--accent-fg);
  font-size: 15px;
  padding: 11px 18px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 30;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
