:root {
  --bg: #f5f6f4;
  --surface: #ffffff;
  --text: #1d2321;
  --muted: #5d6763;
  --border: #dde2df;
  --primary: #2f5d50;
  --primary-text: #ffffff;
  --danger: #a33a2c;
  --success-bg: #e3f1ea;
  --error-bg: #f8e4e1;
  --youth: #3b5c8f;
  --parent: #7a4f8c;
  --radius: 14px;
  --tap: 48px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141816;
    --surface: #1e2421;
    --text: #e8ece9;
    --muted: #9aa5a0;
    --border: #2f3733;
    --primary: #6fb39c;
    --primary-text: #0f1412;
    --danger: #e48a7c;
    --success-bg: #1f3a2e;
    --error-bg: #452420;
    --youth: #8fb0e6;
    --parent: #c9a0dc;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

body.has-nav { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }

a { color: var(--primary); }

h1 { font-size: 1.6rem; margin: 0.5rem 0 0.25rem; }

.muted { color: var(--muted); }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: calc(0.75rem + env(safe-area-inset-top)) 16px 0.75rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.brand { font-weight: 700; text-decoration: none; color: var(--text); }
.who { color: var(--muted); font-size: 0.9rem; }

.page { max-width: 640px; margin: 0 auto; padding: 16px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin: 1rem 0;
}

.card.narrow { max-width: 420px; margin: 2rem auto; }

form label { display: block; font-weight: 600; margin: 1rem 0 0.35rem; }
form label.check { display: flex; align-items: center; gap: 0.5rem; font-weight: 400; }

input[type="text"], input[type="password"] {
  width: 100%;
  min-height: var(--tap);
  padding: 0 12px;
  font-size: 16px; /* avoids iOS zoom on focus */
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
}

input[type="checkbox"] { width: 22px; height: 22px; accent-color: var(--primary); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: var(--tap);
  margin-top: 1.25rem;
  padding: 0 16px;
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
}

.btn-primary { background: var(--primary); color: var(--primary-text); border-color: var(--primary); }
.btn-quiet { color: var(--danger); }

.stack > * { margin-top: 0.75rem; }
.stack form .btn { margin-top: 0; }

.flash { padding: 12px 14px; border-radius: 10px; margin: 0.75rem 0; }
.flash-success { background: var(--success-bg); }
.flash-error { background: var(--error-bg); }
.field-error { color: var(--danger); margin: 0.25rem 0 0; font-size: 0.9rem; }

.list { list-style: none; padding: 0; }
.card.list { padding: 0; }
.list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}
.list li:first-child { border-top: 0; }

.badge {
  font-size: 0.8rem;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 999px;
  border: 1px solid currentColor;
}
.badge-youth { color: var(--youth); }
.badge-parent { color: var(--parent); }

.facts { display: grid; grid-template-columns: auto 1fr; gap: 0.4rem 1rem; margin: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }

.tabbar {
  position: fixed;
  inset: auto 0 0 0;
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}

.tabbar a {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 56px;
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
}

.tabbar a[aria-current="page"] { color: var(--primary); box-shadow: inset 0 3px 0 var(--primary); }
