:root {
  /* Light theme (default) — soft off-white page, white surfaces on top */
  --bg: #eef1f5;
  --bg-soft: #ffffff;
  --bg-row: #f5f7fa;
  --line: #e1e6ec;
  --text: #1b2330;
  --muted: #5c6773;
  --accent: #b8770a;       /* key gold, darkened for contrast on white */
  --accent-2: #0a6f93;     /* link */
  --no: #d92d20;           /* no passkeys */
  --yes: #1a7f37;          /* has passkeys */
  --header-bg: rgba(245, 247, 250, 0.8);
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 4px 12px rgba(16, 24, 40, .06);
  --shadow-lg: 0 6px 24px rgba(16, 24, 40, .10);

  /* Non-color tokens */
  --radius: 12px;
  --wrap: 880px;
  font-synthesis: none;
  color-scheme: light;
}

/* Dark theme values, applied either when the OS prefers dark (and the user hasn't
   forced light) or when the user explicitly toggles dark. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1117;
    --bg-soft: #161b22;
    --bg-row: #11161d;
    --line: #232b36;
    --text: #e6edf3;
    --muted: #8b97a6;
    --accent: #ffd23f;
    --accent-2: #6ee7ff;
    --no: #ff6b6b;
    --yes: #3fb950;
    --header-bg: rgba(13, 17, 23, 0.8);
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 18px rgba(0, 0, 0, .35);
    --shadow-lg: 0 10px 34px rgba(0, 0, 0, .45);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0d1117;
  --bg-soft: #161b22;
  --bg-row: #11161d;
  --line: #232b36;
  --text: #e6edf3;
  --muted: #8b97a6;
  --accent: #ffd23f;
  --accent-2: #6ee7ff;
  --no: #ff6b6b;
  --yes: #3fb950;
  --header-bg: rgba(13, 17, 23, 0.8);
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 18px rgba(0, 0, 0, .35);
  --shadow-lg: 0 10px 34px rgba(0, 0, 0, .45);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
/* offset in-page anchors so the sticky header doesn't cover them */
#list, #countries { scroll-margin-top: 76px; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background-color: var(--bg);
  background-image: radial-gradient(1100px 420px at 50% -260px, color-mix(in srgb, var(--accent) 18%, transparent), transparent 70%);
  background-repeat: no-repeat;
  background-attachment: fixed;
  color: var(--text);
  font: 16px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }

.wrap { width: 100%; max-width: var(--wrap); margin: 0 auto; padding: 0 20px; }

/* Sponsor pill — sits under the hero, centered */
.promo-row { text-align: center; margin: 18px 0 0; }
.hero-promo {
  display: inline-flex; align-items: center; gap: 10px;
  margin: 0; padding: 9px 15px;
  background: var(--bg-soft); border: 1px solid var(--line); border-radius: 999px;
  box-shadow: var(--shadow);
  font-size: .92rem; color: var(--text); text-decoration: none;
  transition: border-color .15s, box-shadow .15s;
}
.hero-promo:hover { text-decoration: none; border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); box-shadow: var(--shadow-lg); }
.hero-promo .promo-logo { width: 22px; height: 22px; flex-shrink: 0; }
.hero-promo strong { color: var(--accent); font-weight: 700; }
.hero-promo .promo-arrow { color: var(--muted); transition: transform .15s; }
.hero-promo:hover .promo-arrow { transform: translateX(3px); }

/* Header */
.site-header {
  position: sticky; top: 0; z-index: 10;
  background: var(--header-bg);
  backdrop-filter: saturate(140%) blur(8px);
  border-bottom: 1px solid var(--line);
}
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 60px; flex-wrap: wrap; }
.brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; font-size: 1.15rem; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-key { font-size: 1.3rem; }
.brand-text b { color: var(--accent); }
.brand .tld { color: var(--muted); font-weight: 400; }
.site-nav { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; font-size: .95rem; }
.site-nav a { color: var(--muted); }
.site-nav a:hover { color: var(--text); text-decoration: none; }

.theme-toggle {
  background: none; border: 1px solid var(--line); color: var(--text);
  width: 34px; height: 34px; border-radius: 999px; cursor: pointer;
  font-size: 1rem; line-height: 1; display: inline-flex; align-items: center; justify-content: center;
  padding: 0; transition: border-color .15s, background .15s;
}
.theme-toggle:hover { border-color: var(--accent-2); background: var(--bg-soft); }
.theme-toggle:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }

/* Hero */
.hero { padding: 44px 0 8px; }
.hero h1 { font-size: clamp(1.8rem, 5vw, 2.8rem); line-height: 1.15; margin: 0 0 12px; letter-spacing: -0.02em; }
.hero h1 .hl { color: var(--accent); }
.hero p.lede { color: var(--muted); font-size: 1.1rem; margin: 0; }

/* Stat banner */
.stat {
  margin: 28px 0;
  padding: 22px 24px 22px 26px;
  background: color-mix(in srgb, var(--no) 4%, var(--bg-soft));
  border: 1px solid var(--line);
  border-left: 4px solid var(--no);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.stat .big { font-size: clamp(2rem, 7vw, 3rem); font-weight: 800; color: var(--no); line-height: 1; }
.stat .big span { color: var(--text); }
.stat .sub { color: var(--muted); margin-top: 6px; }

/* Controls */
.controls { display: flex; gap: 12px; align-items: center; margin: 18px 0; flex-wrap: wrap; }
.controls input[type="search"] {
  flex: 1 1 220px; min-width: 0;
  background: var(--bg-soft); border: 1px solid var(--line); color: var(--text);
  padding: 10px 14px; border-radius: 999px; font-size: 1rem;
}
.controls input[type="search"]:focus { outline: 2px solid var(--accent-2); border-color: transparent; }
.controls .filter-toggle { display: inline-flex; gap: 6px; align-items: center; color: var(--muted); font-size: .95rem; cursor: pointer; user-select: none; }

/* Table */
.table-card {
  margin: 8px 0 40px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.ranktable { width: 100%; border-collapse: collapse; margin: 0; }
.ranktable thead th { background: var(--bg-row); text-align: left; font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 11px 16px; border-bottom: 1px solid var(--line); }
.ranktable td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.ranktable tbody tr:last-child td { border-bottom: none; }
.ranktable tbody tr:hover td { background: var(--bg-row); }
.ranktable .rank { color: var(--muted); font-variant-numeric: tabular-nums; width: 3.5em; }
.ranktable .site { font-weight: 600; }
.ranktable .site a { color: var(--text); }
.ranktable .flag { margin-right: 8px; }
.col-status { width: 1%; white-space: nowrap; text-align: right; }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: .82rem; font-weight: 600; padding: 4px 10px; border-radius: 999px; border: 1px solid transparent; white-space: nowrap; }
.badge.no { color: var(--no); background: color-mix(in srgb, var(--no) 12%, transparent); border-color: color-mix(in srgb, var(--no) 32%, transparent); }
.badge.yes { color: var(--yes); background: color-mix(in srgb, var(--yes) 12%, transparent); border-color: color-mix(in srgb, var(--yes) 35%, transparent); }
.badge .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.fix-link { display: block; font-size: .78rem; margin-top: 4px; color: var(--muted); }
.fix-link a { color: var(--muted); text-decoration: underline; }
.tag-pl { font-size: .72rem; color: var(--muted); margin-left: 6px; }

/* Country grid */
.section-head { margin: 40px 0 8px; }
.section-head h2 { font-size: 1.5rem; margin: 0 0 4px; }
.section-head p { color: var(--muted); margin: 0; }
.country-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; margin: 16px 0 48px; }
.country-grid a {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; background: var(--bg-soft); border: 1px solid var(--line);
  border-radius: 10px; color: var(--text); box-shadow: var(--shadow);
  transition: border-color .15s, transform .15s, box-shadow .15s;
}
.country-grid a:hover { border-color: var(--accent-2); box-shadow: var(--shadow-lg); transform: translateY(-2px); text-decoration: none; }
.country-grid .cflag { width: 22px; height: 16px; flex-shrink: 0; border-radius: 2px; object-fit: cover; box-shadow: 0 0 0 1px rgba(0, 0, 0, .12); }
.flag-lg { width: 30px; height: 22px; border-radius: 3px; vertical-align: -4px; margin-right: 6px; object-fit: cover; box-shadow: 0 0 0 1px rgba(0, 0, 0, .12); }
/* country page heading: flag + title vertically centered */
.country-h1 { display: flex; align-items: center; gap: 10px; }
.country-h1 .flag-lg { flex: 0 0 auto; margin-right: 0; vertical-align: baseline; }
.country-grid .cname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.country-grid .ccount { color: var(--no); font-weight: 700; font-variant-numeric: tabular-nums; }

/* Prose (about) */
.prose { max-width: 68ch; padding-bottom: 48px; }
.prose h1 { font-size: 2rem; }
.prose h2 { margin-top: 2em; }
.prose code { background: var(--bg-soft); padding: 2px 6px; border-radius: 6px; font-size: .9em; }
.prose .callout { border: 1px solid var(--line); border-left: 3px solid var(--accent); background: var(--bg-soft); padding: 14px 18px; border-radius: 0 10px 10px 0; color: var(--text); box-shadow: var(--shadow); }

.muted { color: var(--muted); }
.back { display: inline-block; margin: 28px 0 8px; color: var(--muted); }

/* Footer */
.site-footer { border-top: 1px solid var(--line); margin-top: 24px; padding: 28px 0 48px; color: var(--muted); font-size: .9rem; }
.site-footer a { color: var(--muted); text-decoration: underline; }
.site-footer p { margin: 6px 0; }

.site-footer .sponsor {
  display: inline-flex; align-items: center; gap: 9px; flex-wrap: wrap;
  margin: 0 0 16px; padding: 8px 14px;
  background: var(--bg-soft); border: 1px solid var(--line); border-radius: 999px;
  font-size: .85rem; color: var(--text); text-decoration: none;
  transition: border-color .15s;
}
.site-footer .sponsor:hover { text-decoration: none; border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.site-footer .sponsor strong { color: var(--accent); font-weight: 700; }
.site-footer .sponsor .promo-logo { width: 20px; height: 20px; flex-shrink: 0; }

.hidden { display: none !important; }

@media (max-width: 560px) {
  .ranktable .rank { width: 2.5em; }
  .ranktable td, .ranktable th { padding: 10px 8px; }
  .col-status .badge { padding: 4px 8px; }
}
