:root {
  --bg: #f7f5f2;
  --card: #ffffff;
  --ink: #1d1b19;
  --muted: #6b665f;
  --line: #e6e1da;
  --accent: #c8102e;      /* Husker scarlet */
  --accent-ink: #ffffff;
  --accent-soft: #fbe9ec;
  --good: #1f7a4d;
  --maybe: #a86400;
  --chip: #f0ece6;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141312;
    --card: #1e1c1a;
    --ink: #f2efea;
    --muted: #a39d94;
    --line: #34302c;
    --accent: #ff4d5e;
    --accent-ink: #1a0004;
    --accent-soft: #3a1a1f;
    --good: #5cc28f;
    --maybe: #e2a34a;
    --chip: #2a2724;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}
a { color: inherit; }
button, input { font: inherit; color: inherit; }

.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 750; font-size: 19px; text-decoration: none; letter-spacing: -.01em; }
.logo { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 9px; background: var(--accent); color: var(--accent-ink); font-size: 18px; font-weight: 800; }
.about-link { color: var(--muted); text-decoration: none; font-size: 15px; }

main { max-width: 640px; margin: 0 auto; padding: 4px 16px 40px; outline: none; }
.loading, .empty { color: var(--muted); text-align: center; padding: 32px 0; }

/* Home: two ways in */
.ways { display: grid; gap: 14px; margin-top: 6px; }
.way {
  background: var(--card); border: 1px solid var(--line); border-radius: 18px;
  padding: 18px; box-shadow: var(--shadow);
}
.way h2 { margin: 0 0 4px; font-size: 21px; letter-spacing: -.01em; }
.way p { margin: 0 0 14px; color: var(--muted); font-size: 15px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 18px; border-radius: 12px; border: 0;
  background: var(--accent); color: var(--accent-ink); font-weight: 650; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.btn.secondary { background: var(--chip); color: var(--ink); }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-row .btn { flex: 1 1 auto; }
.search {
  width: 100%; min-height: 50px; padding: 0 14px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--bg); font-size: 17px;
  -webkit-appearance: none; appearance: none;
}
.search:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.privacy { color: var(--muted); font-size: 13px; text-align: center; margin: 18px 0 0; }

/* Sections and lists */
h3.section { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 26px 0 8px; font-weight: 700; }
.list { display: grid; gap: 8px; }
.person {
  display: grid; grid-template-columns: 56px 1fr auto; gap: 12px; align-items: center;
  padding: 10px; border-radius: 14px; background: var(--card); border: 1px solid var(--line);
  text-decoration: none; -webkit-tap-highlight-color: transparent;
}
.person:active { transform: scale(.99); }
.person .who { min-width: 0; }
.person .name { font-weight: 650; }
.person .line {
  color: var(--muted); font-size: 14px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.person .note { font-size: 14px; margin-top: 2px; }
.score { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.chip { font-size: 12.5px; padding: 3px 9px; border-radius: 999px; background: var(--chip); color: var(--ink); }
.chip.nebraska { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.avatar {
  width: 56px; height: 56px; border-radius: 50%; background-color: var(--chip);
  background-repeat: no-repeat; display: grid; place-items: center;
  color: var(--muted); font-weight: 700; font-size: 18px; overflow: hidden;
}
.avatar.big { width: 112px; height: 112px; font-size: 32px; }
.avatar.hero { width: 156px; height: 156px; font-size: 44px; margin: 0 auto; }

/* Filters */
.filters { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 6px; margin: 6px -16px 0; padding-left: 16px; padding-right: 16px; scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.filter { flex: none; min-height: 34px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); font-size: 14px; cursor: pointer; }
.filter[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.toggle { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); margin-top: 4px; }

/* Photo with face boxes */
.photo-wrap { position: relative; border-radius: 16px; overflow: hidden; background: #000; margin: 6px auto 0; width: fit-content; max-width: 100%; }
.photo-wrap canvas { display: block; max-width: 100%; max-height: 38vh; width: auto; height: auto; }
.facebox {
  position: absolute; border: 2px solid rgba(255,255,255,.9); border-radius: 10px;
  box-shadow: 0 0 0 9999px rgba(0,0,0,0); background: transparent; cursor: pointer; padding: 0;
}
.facebox[aria-pressed="true"] { border-color: var(--accent); border-width: 3px; }
.hint { color: var(--muted); font-size: 15px; margin: 10px 0 0; text-align: center; }

/* Best match card */
.best {
  display: grid; grid-template-columns: 112px 1fr; gap: 16px; align-items: center;
  background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 14px;
  text-decoration: none; box-shadow: var(--shadow);
}
.best .name { font-size: 21px; font-weight: 750; letter-spacing: -.01em; }
.badge { display: inline-block; font-size: 12px; font-weight: 700; padding: 3px 8px; border-radius: 999px; margin-bottom: 6px; }
.badge.strong { background: color-mix(in srgb, var(--good) 15%, transparent); color: var(--good); }
.badge.possible { background: color-mix(in srgb, var(--maybe) 15%, transparent); color: var(--maybe); }
.badge.none { background: var(--chip); color: var(--muted); }

/* Person page */
.hero { text-align: center; padding: 10px 0 4px; }
.hero h1 { font-size: 28px; margin: 12px 0 4px; letter-spacing: -.02em; }
.hero .line { color: var(--muted); margin: 0 auto; max-width: 30em; }
.hero .chips { justify-content: center; }
.extract { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin-top: 16px; font-size: 15px; }
.extract a { color: var(--accent); }
.back { background: none; border: 0; color: var(--accent); padding: 8px 0; font-weight: 600; cursor: pointer; }

.about h1 { font-size: 24px; }
.about p, .about li { color: var(--ink); }
.about .muted { color: var(--muted); font-size: 14px; }
.status { font-size: 13px; color: var(--muted); text-align: center; margin-top: 10px; }
.err { color: var(--accent); }

.best { scroll-margin-top: 64px; }
