:root {
  color-scheme: light;
  --paper: #edf0e8;
  --card: #f8faf5;
  --card-hover: #ffffff;
  --ink: #252b2c;
  --ink-muted: #626b66;
  --ink-faint: #8f968f;
  --rule: #d4dbc9;
  --rule-strong: #bac5b1;
  --accent: #176f73;
  --accent-soft: #dff1ef;
  --accent-deep: #0b4f52;
  --excellent: #1f7a4c;
  --excellent-soft: #dff1e7;
  --strong: #2b7284;
  --possible: #936a15;
  --warn: #b9501c;
  --warn-soft: #ffe8dc;
  --star: #c69214;
  --star-soft: #fff1c6;
  --shadow: 0 10px 24px rgb(45 55 41 / 11%);
  --shadow-lift: 0 16px 34px rgb(34 45 37 / 15%);
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --serif: Georgia, "Times New Roman", serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --ease: cubic-bezier(.2, .7, .2, 1);
  --ease-bounce: cubic-bezier(.34, 1.56, .64, 1);
  font-family: var(--sans);
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --paper: #151a19;
    --card: #1d2321;
    --card-hover: #242b29;
    --ink: #edf1eb;
    --ink-muted: #b6bdb5;
    --ink-faint: #858e86;
    --rule: #333d36;
    --rule-strong: #4a564d;
    --accent: #34a7ab;
    --accent-soft: #1c3d3e;
    /* In light mode --accent-deep is a near-black teal used as *text* on the
       pale --accent-soft pills; on a dark ground that would be invisible, so in
       dark mode it must become a light teal. Fixes tag / active-segment /
       active-country / home-brief text contrast in one place. */
    --accent-deep: #7fded7;
    --shadow: 0 12px 28px rgb(0 0 0 / 28%);
    --shadow-lift: 0 18px 40px rgb(0 0 0 / 36%);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: clip;
  background:
    linear-gradient(90deg, rgb(0 0 0 / 3%) 1px, transparent 1px) 0 0 / 54px 54px,
    var(--paper);
  color: var(--ink);
}

button, input, textarea, select { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

.app-shell {
  max-width: 1180px;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 18px calc(104px + env(safe-area-inset-bottom));
  min-width: 0;
}

.topbar {
  padding: 4px 0 14px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: .09em;
  font-size: 10.5px;
  font-weight: 850;
}

h1, h2, h3 {
  margin: 0;
  font-family: var(--serif);
  letter-spacing: 0;
}

h1 { font-size: clamp(26px, 4vw, 40px); line-height: 1.02; }
h2 { font-size: clamp(24px, 6vw, 38px); line-height: 1.05; }
h3 { font-size: 18px; line-height: 1.3; }

.dek {
  max-width: 650px;
  margin: 7px 0 0;
  color: var(--ink-muted);
  line-height: 1.45;
  font-size: 14px;
}

.ghost-btn, .primary-btn, .danger-btn, .chip, .reset-link {
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  background: var(--card);
  color: var(--ink);
  padding: 9px 13px;
  cursor: pointer;
  transition: transform .16s var(--ease), border-color .16s, background .16s, color .16s;
}

.primary-btn {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  font-weight: 800;
}

.danger-btn {
  width: 100%;
  margin-top: 10px;
  border-color: color-mix(in srgb, var(--warn) 50%, var(--rule-strong));
  background: transparent;
  color: var(--warn);
  font-weight: 800;
}

.ghost-btn:disabled, .primary-btn:disabled, .danger-btn:disabled {
  cursor: progress;
  opacity: .7;
}

.ghost-btn:hover, .primary-btn:hover, .danger-btn:hover, .chip:hover, .reset-link:hover {
  transform: translateY(-1px);
  border-color: var(--accent);
}

.danger-btn:hover {
  border-color: var(--warn);
  background: color-mix(in srgb, var(--warn-soft) 45%, transparent);
}

/* ---------- Tab panels ---------- */
.tab-panel {
  min-width: 0;
  opacity: 0;
  transform: translateY(6px);
  animation: panelIn .3s var(--ease) forwards;
}
@keyframes panelIn { to { opacity: 1; transform: translateY(0); } }
.tab-panel[hidden] { display: none; }

/* ---------- Home ---------- */
.home-brief {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 12px;
  padding: 16px 18px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.home-brief p:last-child { margin: 4px 0 0; color: var(--ink); font-size: 14.5px; line-height: 1.5; }
.home-brief strong { color: var(--accent-deep); }

/* ---------- Account ---------- */
.account-card {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 12px;
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}
.account-identity { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.account-identity .avatar-dot { width: 46px; height: 46px; font-size: 18px; }
.account-identity strong { display: block; font-size: 17px; }
.account-identity p { margin: 2px 0 0; color: var(--ink-muted); font-size: 13px; }
.account-actions { display: flex; flex-wrap: wrap; gap: 9px; }

.operation-progress {
  margin-top: 14px;
  padding: 12px;
  border: 1px solid var(--rule);
  border-radius: 12px;
  background: color-mix(in srgb, var(--rule) 24%, transparent);
}

.operation-progress-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
  margin-bottom: 8px;
  font-size: 12.5px;
  font-weight: 800;
  color: var(--ink);
}

.operation-progress-head strong {
  color: var(--accent-deep);
  font-variant-numeric: tabular-nums;
}

.operation-progress p {
  margin: 8px 0 0;
  color: var(--ink-muted);
  font-size: 12px;
  line-height: 1.4;
}

.settings-card {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 12px;
  padding: 16px 20px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}
.settings-card summary {
  cursor: pointer;
  font-weight: 800;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
}
.settings-card summary::-webkit-details-marker { display: none; }
.settings-card summary .chev { display: inline-block; transition: transform .18s var(--ease); }
.settings-card[open] summary .chev { transform: rotate(90deg); }
.settings-form { margin-top: 16px; }

.score-sync-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 16px;
}

.score-sync-card h2 {
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.2;
}

.score-sync-copy {
  margin: 5px 0 0;
  color: var(--ink-muted);
  font-size: 13px;
  line-height: 1.45;
}

.score-sync-stats {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.score-sync-stats span {
  display: inline-grid;
  min-width: 86px;
  gap: 2px;
  padding: 9px 10px;
  border: 1px solid var(--rule);
  border-radius: 10px;
  background: color-mix(in srgb, var(--rule) 28%, transparent);
  color: var(--ink-muted);
  font-size: 11.5px;
  font-weight: 750;
  text-align: center;
}

.score-sync-stats strong {
  color: var(--accent-deep);
  font-size: 18px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.score-agent-progress {
  grid-column: 1 / -1;
  margin-top: 0;
}

.compact-agent-list {
  margin-top: 10px;
  gap: 7px;
}

.compact-agent-list .agent-row {
  grid-template-columns: 62px 1fr 54px;
  gap: 8px;
}

.compact-agent-list .agent-label,
.compact-agent-list .agent-count {
  font-size: 10.5px;
}

.compact-agent-list .agent-track {
  height: 6px;
}

/* ---------- Bottom nav: floating glass pill ----------
   A detached, centered pill that content scrolls under: translucent glass
   (backdrop blur + saturation), a hairline edge, a soft drop shadow, and a top
   inner-highlight for the "lit glass" sheen. The active tab carries its own
   accent-tinted inner pill. */
.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: max(16px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 15;
  display: flex;
  gap: 4px;
  width: max-content;
  max-width: calc(100% - 26px);
  padding: 7px 8px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--card) 60%, transparent);
  backdrop-filter: blur(22px) saturate(1.9);
  -webkit-backdrop-filter: blur(22px) saturate(1.9);
  border: 1px solid color-mix(in srgb, var(--rule-strong) 65%, transparent);
  box-shadow:
    0 10px 34px rgb(28 38 30 / 20%),
    inset 0 1px 0 rgb(255 255 255 / 22%);
}
.nav-thumb {
  position: absolute;
  top: 7px;
  bottom: 7px;
  left: 0;
  width: 0;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent-soft) 88%, transparent);
  box-shadow:
    0 8px 18px rgb(23 111 115 / 16%),
    inset 0 1px 0 rgb(255 255 255 / 16%);
  opacity: 0;
  pointer-events: none;
  z-index: 0;
  transition:
    transform .36s var(--ease-bounce),
    width .36s var(--ease-bounce),
    opacity .18s ease;
}
.nav-tab {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  background: none;
  border: none;
  border-radius: 999px;
  padding: 8px 17px;
  color: var(--ink-faint);
  font-size: 11px;
  font-weight: 650;
  cursor: pointer;
  transition: color .18s, background .18s, transform .14s var(--ease);
}
.nav-tab svg { width: 21px; height: 21px; }
.nav-tab:active { transform: scale(.9); }
.nav-tab.active {
  color: var(--accent);
}

@media (max-width: 400px) {
  .nav-tab { padding: 8px 13px; }
}

/* Filter toolbar: a cohesive floating glass panel rather than raw controls
   sitting on the page. Sticks a hair below the top edge so it reads as a
   detached card while scrolling. */
.filters {
  position: sticky;
  top: max(10px, env(safe-area-inset-top));
  z-index: 5;
  padding: 12px 14px;
  margin-bottom: 16px;
  background: color-mix(in srgb, var(--card) 80%, transparent);
  backdrop-filter: blur(18px) saturate(1.6);
  -webkit-backdrop-filter: blur(18px) saturate(1.6);
  border: 1px solid var(--rule);
  border-radius: 16px;
  box-shadow: var(--shadow);
  transition: box-shadow .2s;
}

.filters.is-stuck {
  box-shadow: var(--shadow-lift);
  border-color: var(--rule-strong);
}

/* ----- Filter bar: search, then (desktop) dropdown triggers, then sort -----
   One row holds everything on wide screens. On mobile the dropdown triggers
   and their vertical dividers disappear (hidden in the media query below) and
   a single filter icon button takes their place, opening the combined panel
   underneath instead. */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 8px;
}

.fbar-sep {
  width: 1px;
  height: 22px;
  background: var(--rule-strong);
  flex: none;
}

.search-wrap {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
}

.search-wrap .search-icon {
  position: absolute;
  left: 15px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-faint);
  pointer-events: none;
  display: grid;
  place-items: center;
}
.search-wrap .search-icon svg {
  width: 21px;
  height: 21px;
  display: block;
}

.search-wrap input {
  height: 46px;
  border-radius: 999px;
  padding-left: 46px;
  padding-right: 38px;
  font-size: 15px;
}

.search-clear {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 26px;
  height: 26px;
  border: none;
  border-radius: 999px;
  background: color-mix(in srgb, var(--rule) 60%, transparent);
  color: var(--ink-muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
}
.search-clear:hover { background: var(--rule-strong); color: var(--ink); }

.sort-wrap { flex: 0 0 auto; }
#sortSelect {
  height: 44px;
  border-radius: 999px;
  width: 104px;
  min-width: 104px;
  padding-inline: 14px 30px;
  font-weight: 600;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-muted) 50%),
                    linear-gradient(135deg, var(--ink-muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 19px, calc(100% - 13px) 19px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  -webkit-appearance: none;
  appearance: none;
}

/* ----- Desktop dropdowns: Fit, Funding, Country -----
   Text triggers for Fit/Funding sit directly on the bar; the Country trigger
   is icon-only so it gets its own subtle pill so it still reads as tappable.
   Opens on hover (mouse-capable pointers only, see JS) or click, closes on
   outside-click/Escape/mouseleave. Hidden entirely on mobile. */
.fdrop { position: relative; flex: none; }

.fdrop-trigger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 38px;
  padding: 0 12px;
  border: none;
  background: none;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink-muted);
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, color .15s;
}
.fdrop-trigger strong { color: var(--ink); font-weight: 800; }
.fdrop-trigger:hover, .fdrop.open .fdrop-trigger {
  background: color-mix(in srgb, var(--rule) 60%, transparent);
  color: var(--ink);
}
.fdrop.open .fdrop-trigger strong { color: var(--accent-deep); }

.fdrop-chev {
  width: 14px;
  height: 14px;
  color: var(--ink-faint);
  transition: transform .22s var(--ease);
}
.fdrop.open .fdrop-chev { transform: rotate(180deg); color: var(--accent); }

.fdrop-trigger-icon {
  height: 38px;
  width: 46px;
  justify-content: center;
  padding: 0;
  background: var(--card);
  border: 1px solid var(--rule);
  box-shadow: var(--shadow);
  font-size: 17px;
}
.fdrop-trigger-icon:hover, .fdrop.open .fdrop-trigger-icon {
  border-color: var(--accent);
  background: var(--card-hover);
}

/* Panel: fade + rise, matching the app's other gate/dropdown transitions. */
.fdrop-panel {
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  min-width: max-content;
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 16px;
  box-shadow: var(--shadow-lift);
  padding: 8px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px);
  pointer-events: none;
  transition: opacity .18s var(--ease), transform .18s var(--ease), visibility .18s;
  z-index: 12;
}
/* Invisible bridge over the trigger-to-panel gap so the pointer can travel
   between them without a mouseleave prematurely closing the dropdown. */
.fdrop-panel::before {
  content: "";
  position: absolute;
  top: -10px;
  left: 0;
  right: 0;
  height: 10px;
}
.fdrop.open .fdrop-panel {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  pointer-events: auto;
}

.fdrop-panel-country {
  padding: 12px;
  max-width: 300px;
}
.fdrop-panel-country .country-row { max-width: 276px; }

/* ----- Mobile combined panel (Fit + Funding + Clear all + Country) -----
   Desktop hides this entirely (its content is covered by the dropdowns
   above); the mobile media query reveals it behind the filter icon button. */
.filter-advanced { display: none; }

.filter-refine {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 14px;
}

.filter-group {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 7px;
  min-width: 0;
}

.filter-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .09em;
  font-weight: 850;
  color: var(--ink-faint);
  white-space: nowrap;
}

/* A short fixed tick rather than a line stretched to fill leftover grid
   width — reads as a consistent label accent regardless of how wide the
   surrounding row happens to be. */
.filter-label::after {
  content: "";
  width: 13px;
  height: 1px;
  flex: none;
  background: color-mix(in srgb, var(--rule-strong) 62%, transparent);
}

.reset-link { margin-left: auto; }

.segmented {
  position: relative;
  display: inline-flex;
  background: color-mix(in srgb, var(--rule) 55%, transparent);
  border-radius: 999px;
  padding: 3px;
}

/* Sliding highlight pill; JS sets width + translateX to the active button and
   these transitions animate the move (e.g. 5+ → 7+). */
.seg-thumb {
  position: absolute;
  top: 3px;
  bottom: 3px;
  left: 0;
  width: 0;
  border-radius: 999px;
  background: var(--card);
  box-shadow: 0 1px 3px rgb(30 40 32 / 18%);
  opacity: 0;
  z-index: 0;
  pointer-events: none;
  transition: transform .32s var(--ease-bounce), width .32s var(--ease-bounce), opacity .2s ease;
}

.segmented button {
  flex: 0 0 auto;
  position: relative;
  z-index: 1;
  border: none;
  background: none;
  border-radius: 999px;
  padding: 7px 16px;
  font-size: 13px;
  font-weight: 650;
  color: var(--ink-muted);
  cursor: pointer;
  white-space: nowrap;
  transition: color .18s;
}
.segmented button:hover { color: var(--ink); }
.segmented button.active {
  color: var(--accent-deep);
  font-weight: 800;
}

/* Mobile-only "Clear all", centered under the Fit/Funding groups (the
   desktop #resetBtn instead sits at the trailing edge of the bar itself). */
.reset-link-mobile {
  display: block;
  text-align: center;
  margin: 2px auto 0;
}

/* Mobile-only circular filter icon button (opens .filter-advanced below).
   Hidden on desktop, where the dropdown triggers cover the same controls. */
.filter-icon-btn {
  display: none;
  position: relative;
  flex: none;
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--rule-strong);
  background: var(--card);
  border-radius: 999px;
  color: var(--ink);
  cursor: pointer;
}
.filter-icon-btn svg { width: 19px; height: 19px; }
.filter-icon-btn .fx-dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--accent);
  border: 1.5px solid var(--card);
  opacity: 0;
  transition: opacity .2s;
}
.filters.filtered .filter-icon-btn .fx-dot { opacity: 1; }

/* ----- Country row: flag pills -----
   A hairline divider + extra top space separates this from the Fit/Funding
   toolbar above, so the bar reads as two intentional groups (status filters,
   then geography) instead of one loose stack of controls. */
.filter-countries {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  margin-top: 2px;
  padding-top: 14px;
  border-top: 1px solid var(--rule);
}

/* Wraps into a soft multi-row grid rather than scrolling — every pill is
   visible at once, no hidden overflow to hint at. */
.country-row {
  display: flex;
  flex-wrap: wrap;
  gap: 9px 10px;
  min-width: 0;
}

@keyframes pillIn {
  from { opacity: 0; transform: translateY(7px) scale(.92); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* A softer, slightly springy rise for the mobile filter panel itself —
   distinct from the shared `detailsIn` (used by "More details" on cards) so
   each can be tuned independently. */
@keyframes filterPanelIn {
  from { opacity: 0; transform: translateY(-10px) scale(.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.country-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--rule-strong);
  background: var(--card);
  border-radius: 999px;
  padding: 6px 14px 6px 11px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-muted);
  cursor: pointer;
  white-space: nowrap;
  opacity: 0;
  animation: pillIn .42s var(--ease-bounce) both;
  animation-delay: calc(var(--i, 0) * 28ms);
  transition: background .22s var(--ease), border-color .22s var(--ease),
              color .22s var(--ease), transform .3s var(--ease-bounce),
              box-shadow .22s var(--ease);
}
.country-pill .flag { font-size: 15px; line-height: 1; }
.country-pill:hover { transform: translateY(-1px); border-color: var(--accent); }
.country-pill.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-deep);
  font-weight: 750;
}

input, textarea, select {
  width: 100%;
  border: 1px solid var(--rule-strong);
  background: var(--card);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--ink);
  outline: none;
}

.search-wrap input { padding-left: 34px; }
textarea { resize: vertical; line-height: 1.45; }
input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.reset-link {
  background: transparent;
  border: none;
  color: var(--accent);
  text-decoration: underline;
  padding-inline: 7px;
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
}
.reset-link:hover { color: var(--accent-deep); }

.progress-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 16px;
  align-items: center;
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 10px;
  padding: 14px 16px;
  margin: 0 0 14px;
  box-shadow: var(--shadow);
}

.progress-panel[hidden] { display: none; }
.progress-panel p { margin: 4px 0 0; color: var(--ink-muted); }
.progress-bar {
  height: 8px;
  background: color-mix(in srgb, var(--rule) 70%, transparent);
  border-radius: 999px;
  overflow: hidden;
}
.progress-bar span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent);
  border-radius: inherit;
  transition: width .35s var(--ease);
}

.status-line {
  color: var(--ink-muted);
  margin: 8px 0 14px;
}

.error-text {
  color: var(--warn);
  font-weight: 750;
}

.cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  width: 100%;
  min-width: 0;
}

.card-skeleton {
  min-height: 300px;
  border: 1px solid var(--rule);
  border-radius: 14px;
  background: var(--card);
  box-shadow: var(--shadow);
  padding: 18px;
  display: grid;
  gap: 13px;
  align-content: start;
  overflow: hidden;
}

.card-skeleton span,
.card-skeleton strong,
.card-skeleton p,
.card-skeleton em {
  display: block;
  height: 14px;
  border-radius: 999px;
  background:
    linear-gradient(90deg, transparent, color-mix(in srgb, var(--card-hover) 80%, transparent), transparent),
    color-mix(in srgb, var(--rule) 62%, transparent);
  background-size: 180% 100%;
  animation: shimmer 1.1s linear infinite;
}

.card-skeleton span { width: 32%; height: 28px; }
.card-skeleton strong { width: 86%; height: 25px; border-radius: 8px; }
.card-skeleton p:nth-of-type(1) { width: 68%; }
.card-skeleton p:nth-of-type(2) { width: 54%; }
.card-skeleton em { width: 45%; margin-top: 18px; }

@keyframes shimmer {
  from { background-position: 180% 0; }
  to { background-position: -180% 0; }
}

.card {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 16px 18px 14px;
  min-height: 360px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  opacity: 0;
  transform: translateY(10px);
  animation: cardIn .42s var(--ease) forwards;
  animation-delay: calc(var(--i, 0) * 24ms);
  transition: transform .18s var(--ease), background .18s, box-shadow .18s;
  overflow: hidden;
}

@keyframes cardIn { to { opacity: 1; transform: translateY(0); } }

.card:hover {
  background: var(--card-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-lift);
}

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.quality {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--excellent);
  text-transform: uppercase;
  letter-spacing: .07em;
  font-size: 11px;
  font-weight: 850;
}

.quality-label { line-height: 1; }

.quality strong {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  background: var(--excellent);
  color: #fff;
  font-size: 14px;
  letter-spacing: 0;
}

.quality.strong { color: var(--strong); }
.quality.strong strong { background: var(--strong); }
.quality.possible { color: var(--possible); }
.quality.possible strong { background: var(--possible); }
.quality.weak { color: var(--ink-faint); }
.quality.weak strong { background: var(--ink-faint); }
.quality.pending { color: var(--ink-faint); }
.quality.pending strong {
  background: transparent;
  border: 1px dashed var(--rule-strong);
  color: var(--ink-faint);
}

.star {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 999px;
  color: var(--ink-faint);
  font-size: 19px;
  line-height: 1;
  cursor: pointer;
  transition: background .18s, border-color .18s, color .18s, transform .25s var(--ease-bounce);
}

.star:hover {
  background: var(--star-soft);
  border-color: var(--star);
  color: var(--star);
  transform: scale(1.15);
}
.star.saved { color: var(--star); animation: pop .3s var(--ease-bounce); }
@keyframes pop { 40% { transform: scale(1.35); } }

.card-title {
  /* Clamp to 3 lines so a listing whose "title" field actually holds a whole
     paragraph (a real data-quality case in some sources) can't blow the card
     height out and destabilise the grid row. Full title is still in the link
     title attribute + the source page. */
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
  text-wrap: pretty;
}
.card-title a {
  color: var(--ink);
  text-decoration: none;
  overflow-wrap: anywhere;
}
.card-title a:hover {
  color: var(--accent);
  text-decoration: underline;
}

.card-meta {
  margin: 0;
  color: var(--ink-muted);
  font-size: 13px;
  line-height: 1.4;
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0 5px;
  min-width: 0;
  overflow-wrap: anywhere;
}
.card-meta .flag { font-size: 15px; line-height: 1; }
.card-meta .card-uni {
  min-width: 0;
  font-weight: 650;
  color: var(--ink);
  overflow-wrap: anywhere;
}
.card-meta .dot { color: var(--ink-faint); }

.sources, .tags, .status-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  min-width: 0;
}

.status-row { gap: 7px; }

.source-pill, .pill {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  border-radius: 7px;
  background: #dfe8d9;
  color: #42513f;
  padding: 4px 8px;
  font-size: 11.5px;
  text-decoration: none;
  white-space: nowrap;
  min-width: 0;
  overflow-wrap: anywhere;
}

.source-pill {
  font-family: var(--mono);
  font-size: 11px;
  background: color-mix(in srgb, var(--rule) 45%, transparent);
  color: var(--ink-muted);
  transition: background .15s, color .15s, transform .15s;
}

.source-pill:hover {
  background: var(--accent);
  color: #fff;
  transform: translateY(-1px);
}

.card-foot {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.also-on {
  color: var(--ink-faint);
  font-size: 11.5px;
  font-weight: 600;
}

.pub-note {
  color: var(--ink-faint);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
}

.card-brief {
  display: grid;
  gap: 3px;
  margin: 0;
  color: var(--ink-muted);
  line-height: 1.45;
  font-size: 13px;
  min-width: 0;
  overflow-wrap: anywhere;
}

.tag {
  background: var(--accent-soft);
  color: var(--accent-deep);
}

.funded {
  background: var(--excellent-soft);
  color: var(--excellent);
  font-weight: 750;
}

.funded-unclear {
  background: #fff4cf;
  color: var(--possible);
}

.funded-self_funded {
  background: #f2dddd;
  color: #8d3434;
}

.deadline {
  background: var(--warn-soft);
  color: var(--warn);
  font-weight: 750;
}

.pill.muted {
  background: color-mix(in srgb, var(--rule) 58%, transparent);
  color: var(--ink-muted);
  text-decoration: none;
}

.deadline.passed {
  color: var(--ink-faint);
  background: color-mix(in srgb, var(--rule) 60%, transparent);
  text-decoration: line-through;
}

.details {
  border-top: 1px solid var(--rule);
  padding-top: 10px;
}

.details summary {
  cursor: pointer;
  color: var(--accent);
  font-weight: 850;
  list-style: none;
  font-size: 13.5px;
  display: inline-flex;
  align-items: center;
  transition: color .18s, transform .25s var(--ease-bounce);
  transform-origin: left center;
}
.details summary:hover { color: var(--accent-deep); }
.details summary:active { transform: scale(.95); }

.details summary::-webkit-details-marker { display: none; }
.details summary .chev {
  display: inline-block;
  font-size: 16px;
  transition: transform .3s var(--ease-bounce);
  margin-right: 5px;
}
.details[open] summary .chev { transform: rotate(90deg); }

.details-body {
  margin-top: 10px;
  color: var(--ink-muted);
  animation: detailsIn .34s var(--ease) both;
}

.details-body h4 {
  margin: 12px 0 4px;
  color: var(--ink);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .07em;
}

.details-body p {
  margin: 0 0 7px;
  line-height: 1.45;
}

@keyframes detailsIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

.empty-state {
  grid-column: 1 / -1;
  background: var(--card);
  border: 1px dashed var(--rule-strong);
  border-radius: 12px;
  padding: 28px;
  color: var(--ink-muted);
  text-align: center;
}

/* ---------- Explore pager ---------- */
.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin: 22px 0 6px;
}

.pager-btn {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--rule-strong);
  background: var(--card);
  border-radius: 999px;
  color: var(--ink);
  cursor: pointer;
  transition: background .18s, border-color .18s, color .18s, transform .25s var(--ease-bounce);
}
.pager-btn svg { width: 18px; height: 18px; }
.pager-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.pager-btn:active:not(:disabled) { transform: scale(.88); }
.pager-btn:disabled {
  opacity: .38;
  cursor: default;
}

.pager-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
  min-width: 92px;
  text-align: center;
}

.footnote {
  margin: 26px auto 0;
  max-width: 820px;
  color: var(--ink-muted);
  font-size: 12.5px;
  line-height: 1.5;
  text-align: center;
}

.gate {
  position: fixed;
  inset: 0;
  z-index: 20;
  /* Flex + `margin:auto` on the panel centers when it fits but lets a tall
     panel (e.g. the CV/preferences form on a phone) scroll to the very top
     and bottom — plain grid/place-items:center would clip an overflowing
     panel and trap the submit button off-screen. */
  display: flex;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: max(20px, env(safe-area-inset-top)) 16px calc(24px + env(safe-area-inset-bottom));
  background: var(--paper);
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  opacity: 0;
  visibility: hidden;
  transition: opacity .28s var(--ease), visibility .28s var(--ease);
}

.gate[hidden] { display: none; }
.gate.show { opacity: 1; visibility: visible; }

.gate-panel {
  width: min(560px, 100%);
  margin: auto;
  background: var(--card);
  border: 1px solid var(--rule);
  box-shadow: var(--shadow-lift);
  border-radius: 16px;
  padding: 26px;
  transform: translateY(16px) scale(.97);
  opacity: 0;
  transition: transform .32s var(--ease), opacity .32s var(--ease);
}

.gate.show .gate-panel { transform: translateY(0) scale(1); opacity: 1; }

.gate-panel p { color: var(--ink-muted); line-height: 1.5; }
.google-host { margin-top: 18px; min-height: 44px; }
.onboarding { display: grid; gap: 14px; }
.onboarding label { display: grid; gap: 7px; font-weight: 780; }
.fine-print { font-size: 13px; margin: 0; }

/* ---------- Live scoring gate ---------- */
.scoring-panel { width: min(620px, 100%); }
.scoring-sub { margin: 6px 0 20px; }

.overall-progress { margin-bottom: 20px; }
.overall-progress p {
  margin: 8px 0 0;
  color: var(--ink-muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.agent-list { display: flex; flex-direction: column; gap: 10px; }
.agent-row {
  display: grid;
  grid-template-columns: 74px 1fr 70px;
  align-items: center;
  gap: 12px;
  opacity: 0;
  transform: translateY(6px);
  animation: agentIn .35s var(--ease) forwards;
  animation-delay: calc(var(--i, 0) * 60ms);
}

@keyframes agentIn { to { opacity: 1; transform: translateY(0); } }

.agent-label {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-muted);
  white-space: nowrap;
}

.agent-row.agent-done .agent-label { color: var(--excellent); }

.agent-track {
  height: 7px;
  background: color-mix(in srgb, var(--rule) 70%, transparent);
  border-radius: 999px;
  overflow: hidden;
}

.agent-fill {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent);
  border-radius: inherit;
  transition: width .4s var(--ease);
}

.agent-row.agent-done .agent-fill { background: var(--excellent); }

.agent-count {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--ink-faint);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.scoring-done-note {
  margin-top: 18px;
  color: var(--excellent);
  font-weight: 750;
  text-align: center;
  opacity: 0;
  animation: doneIn .4s var(--ease) forwards;
}

.scoring-done-note.scoring-error { color: var(--warn); }

@keyframes doneIn { to { opacity: 1; } }


.toast {
  position: fixed;
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: #163937;
  color: white;
  border-radius: 999px;
  padding: 12px 16px;
  box-shadow: var(--shadow-lift);
  z-index: 30;
}

/* ---------- Tap feedback ----------
   Springy press-in on every tappable control so touch users get a physical
   sense that a tap registered. Placed after the element rules so it wins the
   transform transition; disabled by the reduced-motion block below. */
.primary-btn, .ghost-btn, .danger-btn, .country-pill,
.source-pill, .reset-link, .segmented button, .nav-tab, .star,
.fdrop-trigger, .filter-icon-btn {
  transition-property: transform, background, border-color, color, box-shadow;
  transition-duration: .26s, .18s, .18s, .18s, .18s;
  transition-timing-function: var(--ease-bounce), ease, ease, ease, ease;
}
.primary-btn:active, .ghost-btn:active, .danger-btn:active,
.country-pill:active, .source-pill:active, .reset-link:active,
.segmented button:active, .star:active,
.fdrop-trigger:active, .filter-icon-btn:active {
  transform: scale(.9);
}
.nav-tab:active { transform: scale(.84); }

@media (max-width: 980px) {
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 680px) {
  .app-shell { padding-inline: 13px; }
  .topbar { padding: 2px 0 12px; }
  .dek { font-size: 13.5px; }
  /* Non-sticky on phones: a pinned tall panel covered the whole screen. It now
     scrolls away, and the desktop dropdown triggers are replaced by a single
     filter icon button that reveals the combined panel below. */
  .filters {
    position: static;
    padding: 11px;
  }
  .search-wrap { flex: 1 1 auto; }
  .sort-wrap { flex: 0 0 auto; }
  #sortSelect { width: 92px; min-width: 92px; padding-left: 12px; }

  /* Desktop-only chrome disappears on mobile... */
  .fbar-sep, .fdrop, #resetBtn { display: none; }
  /* ...replaced by the icon button, which opens .filter-advanced. */
  .filter-icon-btn { display: flex; }

  .filters.expanded .filter-advanced {
    display: block;
    margin-top: 12px;
    animation: filterPanelIn .38s var(--ease-bounce) both;
  }

  /* Segmented controls stay intrinsic-width on desktop dropdowns but need to
     be full-width, equal-button on this touch-driven combined panel. */
  .segmented { width: 100%; }
  .segmented button { flex: 1 1 0; text-align: center; }
  .account-actions { flex-direction: column; }
  .account-actions button { width: 100%; }
  .score-sync-card {
    grid-template-columns: 1fr;
    align-items: stretch;
  }
  .score-sync-stats { justify-content: stretch; }
  .score-sync-stats span { flex: 1 1 0; }
  .score-sync-card button { width: 100%; }
  .cards { grid-template-columns: 1fr; gap: 13px; }
  .card {
    min-height: auto;
    padding: 15px 16px 13px;
    border-radius: 13px;
  }
  .card-title { font-size: 17px; }
  .source-pill, .pill {
    white-space: normal;
    line-height: 1.25;
  }
  .status-row .pill {
    max-width: 100%;
  }
  .home-brief { padding: 14px 16px; }
  .gate-panel { padding: 20px; border-radius: 14px; }
  .gate-panel h2 { font-size: 24px; }
  .onboarding { gap: 12px; }
  .onboarding textarea { min-height: 108px; }
  .agent-row { grid-template-columns: 58px 1fr 52px; gap: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
  .card { opacity: 1; transform: none; }
}
