:root {
  color-scheme: light dark;
  --bg: #ffffff;
  --surface: #faf8f6;
  --fg: #14110f;
  --muted: #6b6560;
  --line: #e2ddd8;
  --accent: #ff5500;
  --ok: #1a7f4b;
  --bad: #c0392b;
  --radius: 12px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14110f;
    --surface: #1c1816;
    --fg: #f5f2ef;
    --muted: #9b938c;
    --line: #2e2926;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  /* Room for the iPhone home indicator and the notch. */
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
           calc(env(safe-area-inset-bottom) + 5.5rem) env(safe-area-inset-left);
  -webkit-text-size-adjust: 100%;
}

main { max-width: 34rem; margin-inline: auto; padding: 1.25rem 1rem 2rem; }

header {
  display: flex; align-items: baseline; justify-content: space-between; gap: 1rem;
  margin-bottom: 1.5rem;
}
header h1 { font-size: 1.35rem; margin: 0; letter-spacing: -0.01em; }
header .who { font-size: .8rem; color: var(--muted); }

h2 { font-size: 1.05rem; margin: 0 0 .75rem; }
p.hint { color: var(--muted); font-size: .85rem; margin: .35rem 0 0; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: .75rem;
}
.card.tappable { cursor: pointer; }
.card.tappable:active { transform: scale(.995); }

.row { display: flex; justify-content: space-between; align-items: baseline; gap: .75rem; }
.row .title { font-weight: 600; }
.amount { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.meta { color: var(--muted); font-size: .82rem; margin-top: .2rem; }

label { display: block; font-size: .8rem; color: var(--muted); margin: .8rem 0 .25rem; }
input, select, textarea {
  width: 100%; padding: .65rem .7rem; font: inherit;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg); color: var(--fg);
}
textarea { min-height: 4rem; resize: vertical; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.checkline { display: flex; align-items: center; gap: .5rem; margin-top: .9rem; }
.checkline input { width: auto; }
.checkline label { margin: 0; color: var(--fg); font-size: .9rem; }

button {
  width: 100%; margin-top: 1rem; padding: .75rem 1rem; font: inherit; font-weight: 600;
  border: 0; border-radius: 8px; background: var(--accent); color: #fff; cursor: pointer;
}
button.secondary { background: transparent; color: var(--fg); border: 1px solid var(--line); }
button.link {
  background: none; color: var(--accent); width: auto; margin: 0; padding: 0;
  font-weight: 500; font-size: .85rem;
}
button:disabled { opacity: .5; cursor: not-allowed; }

#status {
  padding: .7rem .9rem; border-radius: 8px; border: 1px solid var(--line);
  font-size: .875rem; margin-bottom: 1rem; white-space: pre-wrap;
}
#status:empty { display: none; }
#status.ok { border-color: var(--ok); color: var(--ok); }
#status.bad { border-color: var(--bad); color: var(--bad); }
#status.busy { border-color: var(--accent); color: var(--accent); }

/* The capture button is the whole point of the app being on a home screen.
   Library sits beside it rather than replacing it: the camera stays one tap. */
.shutter-row {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(env(safe-area-inset-bottom) + 1.25rem);
  width: min(30rem, calc(100vw - 2rem));
  display: flex; gap: .5rem;
}
.shutter-row button {
  margin: 0; padding: .95rem 1rem; font-size: 1.05rem;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .18);
}
.shutter-row #shutter { flex: 1 1 auto; }
.shutter-row #from-library {
  flex: 0 0 auto; width: auto; padding-inline: 1.1rem;
  /* Opaque, or the drop shadow shows through over scrolling content. */
  background: var(--surface);
}
.shutter-row[hidden] { display: none; }

.thumb {
  width: 100%; border-radius: 8px; border: 1px solid var(--line);
  margin-top: .75rem; display: block;
}

.empty { color: var(--muted); font-size: .9rem; padding: 1.5rem 0; text-align: center; }
.back { margin-bottom: .75rem; }
[hidden] { display: none !important; }
