:root {
  color-scheme: light dark;
  --bg: light-dark(#f7f5f1, #100f0d);
  --card: light-dark(#fffdf9, #1a1916);
  --ink: light-dark(#17160f, #f1eee7);
  --muted: light-dark(#7c766a, #9b958a);
  --line: light-dark(#e5e0d6, #2c2a25);
  --accent: light-dark(#3f6f52, #8fc0a1);
  --accent-ink: light-dark(#fffdf9, #10201a);
  --danger: light-dark(#a3402f, #e08b7c);
  --radius: 14px;
}

/* Manual override. 'system' matches neither rule, so the OS decides. */
:root[data-theme='light'] { color-scheme: light; }
:root[data-theme='dark'] { color-scheme: dark; }

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.serif { font-family: 'Instrument Serif', Georgia, serif; font-weight: 400; }
.screen { padding: 24px; }

/* Author display rules (.badge is a grid, .screen a block) outrank the browser's
   own [hidden] rule, so hidden elements stay on screen. Enforce it once, globally,
   or every new display: rule quietly reintroduces a stuck badge. */
[hidden] { display: none !important; }

.center {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  text-align: center;
}

/* --- the one screen that matters --- */
.name {
  margin: 0;
  font-size: clamp(3.5rem, 15vw, 9rem);
  line-height: 0.95;
  letter-spacing: -0.02em;
}

.kicker {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.corner { position: fixed; top: 18px; right: 18px; }

/* --- cards, forms --- */
.card {
  width: min(560px, 100%);
  margin: 0 auto 18px;
  padding: 22px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  text-align: left;
}

.card h3 { margin: 0 0 14px; font-size: 0.78rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.title { margin: 0 0 4px; font-size: 2.4rem; }

label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 500;
}

input {
  width: 100%;
  padding: 11px 12px;
  font: inherit;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
}

input:focus-visible, button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

#auth-form input { margin-bottom: 14px; }
#auth-form .muted { margin: 0 0 20px; }

.row { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.field { flex: 0 0 auto; }
.grow { flex: 1 1 110px; }
.grow2 { flex: 2 1 160px; }

.btn {
  padding: 11px 18px;
  font: inherit;
  font-weight: 500;
  border-radius: 10px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: opacity .15s ease;
}

.btn:hover { opacity: .85; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
#auth-form .btn { width: 100%; margin-top: 4px; }
.btn.ghost { background: none; color: var(--muted); border-color: var(--line); }
.btn.small { padding: 7px 12px; font-size: .85rem; }

.icon-btn {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  color: var(--muted);
  background: none;
  border: 1px solid var(--line);
  border-radius: 50%;
  cursor: pointer;
}

.icon-btn:hover { color: var(--ink); }

/* --- details --- */
.bar {
  display: flex;
  align-items: center;
  gap: 14px;
  width: min(560px, 100%);
  margin: 0 auto 20px;
}

.bar h2 { flex: 1; margin: 0; font-size: 1.6rem; }

.standings, .history { list-style: none; margin: 0; padding: 0; }

.standings li { margin-bottom: 14px; }

.standings .line { display: flex; justify-content: space-between; margin-bottom: 6px; }
.standings .who { font-weight: 500; }
.standings .next { margin-left: 8px; font-size: .7rem; letter-spacing: .1em; text-transform: uppercase; color: var(--accent); }
.standings .amount { font-variant-numeric: tabular-nums; color: var(--muted); }

.track { height: 6px; background: var(--line); border-radius: 99px; overflow: hidden; }
.track > span { display: block; height: 100%; background: var(--accent); border-radius: 99px; }

.history li {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

.history li:first-child { border-top: none; }
.history li.dim .who, .history li.dim .amount { opacity: .55; }
.history .who { font-weight: 500; }
.history .note { flex: 1; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history .amount { font-variant-numeric: tabular-nums; }
.history time { color: var(--muted); font-size: .8rem; }

.chip {
  padding: 2px 8px;
  border: 1px solid var(--line);
  border-radius: 99px;
  color: var(--muted);
  font-size: .7rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  white-space: nowrap;
}

.chip.bad { color: var(--danger); border-color: currentColor; }

#approvals li { flex-wrap: wrap; gap: 8px; }
#approvals .btn { padding: 5px 12px; font-size: .8rem; }

.badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 19px;
  height: 19px;
  padding: 0 5px;
  display: grid;
  place-items: center;
  background: var(--danger);
  color: var(--bg);
  border-radius: 99px;
  font-size: .7rem;
  font-weight: 600;
}

.link-danger {
  background: none;
  border: none;
  padding: 0 0 0 4px;
  color: var(--danger);
  font: inherit;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}

.muted { color: var(--muted); }
.small { font-size: .8rem; }
.error { min-height: 1.2em; margin: 8px 0 0; color: var(--danger); font-size: .85rem; }
.empty { color: var(--muted); padding: 6px 0; }
