/* CPRet — ICPC-inspired theme (zero CDN).
   Palette from icpc.global: navy #164173, yellow #FDBC1E, blue #0061CC, ink #0E0F13, paper #F5F6FA. */
:root {
  --navy: #164173;
  --navy-2: #0f2f57;
  --navy-3: #0a2240;
  --yellow: #fdbc1e;
  --yellow-2: #eab308;
  --blue: #0061cc;
  --blue-2: #1d7fe6;
  --red: #d7263d;
  --green: #16a34a;
  --ink: #0e0f13;

  --bg: #f5f6fa;
  --bg-elev: #ffffff;
  --bg-sunk: #eef1f6;
  --border: #e2e7ef;
  --border-strong: #cfd7e3;
  --text: #0f172a;
  --text-2: #475569;
  --text-3: #6b7a90;
  --link: var(--blue);
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow: 0 6px 20px -8px rgba(22, 65, 115, 0.22), 0 1px 3px rgba(15, 23, 42, 0.05);
  --shadow-lg: 0 18px 40px -16px rgba(22, 65, 115, 0.45);
  --ring: 0 0 0 3px rgba(253, 188, 30, 0.45);

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;
  --font: Roboto, "PingFang SC", "Helvetica Neue", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", Arial, sans-serif;
  --serif: "Playfair Display", Georgia, "Times New Roman", "Songti SC", "Noto Serif CJK SC", serif;
  --mono: ui-monospace, SFMono-Regular, "JetBrains Mono", Menlo, Consolas, "Liberation Mono", monospace;

  /* topic-group palette (ICPC balloon colours) */
  --cl-0: #0061cc;
  --cl-1: #f2a900;
  --cl-2: #d7263d;
  --cl-3: #16a34a;
  --cl-4: #7c3aed;
  --cl-5: #0891b2;
  --cl-6: #ea580c;
  --cl-7: #db2777;

  --gold: #f5b400;
  --silver: #a8b3c2;
  --bronze: #c27a3a;

  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e0f13;
    --bg-elev: #171a21;
    --bg-sunk: #12151b;
    --border: #262b36;
    --border-strong: #343b49;
    --text: #e6eaf0;
    --text-2: #a3aec0;
    --text-3: #7d889b;
    --link: #5aa7ff;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.5);
    --shadow: 0 8px 24px -10px rgba(0, 0, 0, 0.7);
    --shadow-lg: 0 18px 40px -16px rgba(0, 0, 0, 0.8);
    --cl-0: #3b8cff;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--link); text-decoration: none; transition: color .2s; }
a:hover { color: var(--navy); text-decoration: underline; text-underline-offset: 3px; }
@media (prefers-color-scheme: dark) { a:hover { color: var(--yellow); } }
button, input, textarea, select { font: inherit; color: inherit; }
[hidden], .is-hidden { display: none !important; }

.bg-decor { display: none; }
.container { width: 100%; max-width: 1180px; margin: 0 auto; padding: 0 20px; }

/* ---------- Top bar (ICPC navy) ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--navy);
  color: #fff;
  box-shadow: 0 2px 0 var(--yellow), 0 6px 18px -8px rgba(0, 0, 0, .45);
}
.topbar-inner { display: flex; align-items: center; gap: 16px; height: 58px; }
.brand { display: flex; flex: 0 1 auto; align-items: center; gap: 10px; color: #fff; font-weight: 500; min-width: 0; }
.topnav { flex: none; }
.brand:hover { color: #fff; text-decoration: none; }
.brand-mark { flex: none; display: inline-flex; align-items: flex-end; gap: 2px; height: 30px; }
.brand-mark .bl { display: block; width: 10px; height: 13px; border-radius: 50% 50% 46% 46%; position: relative; }
.brand-mark .bl::after { content: ""; position: absolute; left: 50%; top: 100%; width: 1px; height: 9px; background: rgba(255, 255, 255, .55); }
.brand-mark .bl:nth-child(1) { background: var(--red); transform: translateY(-4px) rotate(-8deg); }
.brand-mark .bl:nth-child(2) { background: var(--yellow); transform: translateY(-9px); }
.brand-mark .bl:nth-child(3) { background: #3b8cff; transform: translateY(-4px) rotate(8deg); }
.brand-name { font-size: 21px; font-weight: 700; letter-spacing: .2px; }
.brand-name b { color: var(--yellow); font-weight: 700; }
.brand-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 14px; color: rgba(255, 255, 255, .72); padding-left: 12px; border-left: 1px solid rgba(255, 255, 255, .2); }
.topnav { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.nav-link { padding: 6px 12px; border-radius: 6px; color: rgba(255, 255, 255, .85); font-size: 14px; font-weight: 500; white-space: nowrap; transition: background .2s, color .2s; }
.nav-link:hover, .nav-link.active { background: rgba(255, 255, 255, .1); color: #fff; text-decoration: none; }
.nav-link.active { box-shadow: inset 0 -2px 0 var(--yellow); border-radius: 6px 6px 0 0; }
.gh-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 6px;
  color: var(--ink);
  background: var(--yellow);
  font-size: 13.5px;
  font-weight: 600;
  transition: transform .2s, box-shadow .2s, background .2s;
}
.gh-pill:hover { color: var(--ink); background: #ffc93f; text-decoration: none; transform: translateY(-1px); box-shadow: 0 6px 16px -6px rgba(253, 188, 30, .7); }
.gh-stars { display: inline-flex; align-items: center; gap: 3px; padding-left: 8px; margin-left: 2px; border-left: 1px solid rgba(14, 15, 19, .25); font-variant-numeric: tabular-nums; }
.gh-stars:empty { display: none; }
.lang-switch { display: inline-flex; padding: 2px; border-radius: 7px; border: 1px solid rgba(255, 255, 255, .3); }
.lang-switch a { white-space: nowrap; padding: 3px 10px; border-radius: 5px; font-size: 13px; color: rgba(255, 255, 255, .8); transition: background .2s, color .2s; }
.lang-switch a:hover { color: #fff; text-decoration: none; background: rgba(255, 255, 255, .1); }
.lang-switch a.active { background: #fff; color: var(--navy); font-weight: 600; pointer-events: none; }

.mock-banner { text-align: center; font-size: 13px; padding: 6px 12px; color: #713f12; background: #fef3c7; border-bottom: 1px solid #fcd34d; }
@media (prefers-color-scheme: dark) { .mock-banner { color: #fde68a; background: #3a2c07; border-color: #6b4f0a; } }

.main { flex: 1; padding-top: 26px; padding-bottom: 48px; }

/* ---------- Cards ---------- */
.glass { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.card-pad { padding: 20px 22px; }
.section-title { display: flex; align-items: center; gap: 10px; margin: 0 0 2px; font-size: 18px; font-weight: 700; color: var(--text); }
.section-title::before { content: ""; width: 4px; height: 18px; border-radius: 2px; background: var(--yellow); }
.section-sub { margin: 0 0 14px; color: var(--text-3); font-size: 13px; }
.muted { color: var(--text-3); }
.serif { font-family: var(--serif); }

/* ---------- Hero (World-Finals banner style) ---------- */
.hero {
  position: relative;
  overflow: hidden;
  padding: 30px 32px 26px;
  border-radius: 22px;
  border: 0;
  color: #fff;
  background:
    radial-gradient(700px 300px at 100% 0%, rgba(0, 97, 204, .55), transparent 70%),
    radial-gradient(500px 260px at 0% 100%, rgba(253, 188, 30, .12), transparent 70%),
    linear-gradient(rgba(255, 255, 255, .045) 1px, transparent 1px) 0 0 / 28px 28px,
    linear-gradient(90deg, rgba(255, 255, 255, .045) 1px, transparent 1px) 0 0 / 28px 28px,
    linear-gradient(135deg, var(--navy-3) 0%, var(--navy) 60%, #1b4f8a 100%);
  box-shadow: var(--shadow-lg);
  animation: rise .5s ease both;
}
.hero::before {
  content: "";
  position: absolute;
  inset: 10px;
  border: 2px solid var(--yellow);
  border-radius: 16px;
  pointer-events: none;
  opacity: .9;
}
.hero > * { position: relative; }
.hero-kicker { margin: 0 0 4px; font-size: 13px; letter-spacing: .4px; color: rgba(255, 255, 255, .72); font-family: var(--mono); }
.hero-title { margin: 0; font-size: 34px; line-height: 1.2; font-weight: 700; letter-spacing: -.2px; color: #fff; }
.hero-title .hl { color: var(--yellow); }
.grad-text { color: inherit; }
.hero-sub { margin: 8px 0 18px; color: rgba(255, 255, 255, .78); font-size: 15px; }
.hero-balloons { position: absolute; right: 34px; top: 26px; display: flex; gap: 8px; pointer-events: none; }
.hero-balloons span { width: 22px; height: 28px; border-radius: 50% 50% 46% 46%; position: relative; animation: float 4s ease-in-out infinite; box-shadow: inset -4px -5px 0 rgba(0, 0, 0, .12); }
.hero-balloons span::after { content: ""; position: absolute; left: 50%; top: 100%; width: 1px; height: 22px; background: rgba(255, 255, 255, .45); }
.hero-balloons span:nth-child(1) { background: var(--red); animation-delay: -.6s; }
.hero-balloons span:nth-child(2) { background: var(--yellow); transform: translateY(-8px); animation-delay: -1.8s; }
.hero-balloons span:nth-child(3) { background: #3b8cff; animation-delay: -2.9s; }

.notice-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.notice {
  display: inline-block;
  padding: 5px 12px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.45;
  color: rgba(255, 255, 255, .92);
  background: rgba(255, 255, 255, .08);
  border: 1px solid rgba(255, 255, 255, .16);
}
.notice a, .notice .alert-link { color: var(--yellow); font-weight: 600; }
.notice a:hover { color: #ffd766; }

/* ---------- Query box ---------- */
.query-wrap {
  position: relative;
  border-radius: 12px;
  background: var(--bg-elev);
  color: var(--text);
  border: 2px solid transparent;
  transition: border-color .2s, box-shadow .25s;
}
.query-wrap:focus-within { border-color: var(--yellow); box-shadow: 0 0 0 4px rgba(253, 188, 30, .25); }
.query-input { display: block; width: 100%; min-height: 150px; padding: 16px 18px 8px; border: 0; outline: 0; resize: vertical; background: transparent; font-size: 15px; line-height: 1.65; }
.query-input::placeholder { color: var(--text-3); }
.query-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; padding: 8px 10px 10px 12px; border-top: 1px solid var(--border); }
.spacer { flex: 1; }
.example-group { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.example-label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.example-select {
  height: 30px; max-width: 220px; padding: 0 8px; font: inherit; font-size: 13px;
  color: var(--text); background: var(--bg-elev);
  border: 1px solid var(--border-strong); border-radius: 8px; cursor: pointer;
}
.example-select:hover, .example-select:focus { border-color: var(--navy); outline: none; }
.kbd-hint { font-size: 12px; color: var(--text-3); }
kbd { font-family: var(--mono); font-size: 11px; padding: 1px 6px; border-radius: 4px; border: 1px solid var(--border-strong); border-bottom-width: 2px; background: var(--bg-sunk); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 7px 14px; border-radius: 7px; border: 1px solid transparent;
  font-size: 14px; font-weight: 500; cursor: pointer; white-space: nowrap; background: none;
  transition: transform .15s, box-shadow .2s, background .2s, color .2s, border-color .2s, opacity .2s;
}
.btn:hover { text-decoration: none; }
.btn:disabled { opacity: .65; cursor: progress; }
.btn-primary { color: var(--ink); background: var(--yellow); font-weight: 700; box-shadow: 0 4px 0 #c99000; }
.btn-primary:hover:not(:disabled) { color: var(--ink); background: #ffc93f; transform: translateY(-1px); box-shadow: 0 5px 0 #c99000, 0 10px 20px -8px rgba(253, 188, 30, .7); }
.btn-primary:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 #c99000; }
.btn-lg { padding: 10px 26px; font-size: 15px; border-radius: 8px; }
.btn-ghost { color: var(--navy); border-color: var(--border-strong); background: var(--bg-elev); }
.btn-ghost:hover { color: var(--navy); border-color: var(--navy); background: rgba(22, 65, 115, .06); }
@media (prefers-color-scheme: dark) { .btn-ghost, .btn-ghost:hover { color: #cfe0f7; } }
.btn-text { color: var(--text-2); padding: 7px 8px; }
.btn-text:hover { color: var(--blue); }
.btn-sm { padding: 4px 10px; font-size: 13px; }
.link-btn { border: 0; background: none; padding: 2px 6px; font-size: 13px; color: var(--yellow); cursor: pointer; border-radius: 5px; font-weight: 500; }
.link-btn:hover { background: rgba(253, 188, 30, .14); }
.spinner { width: 14px; height: 14px; border-radius: 50%; border: 2px solid rgba(14, 15, 19, .25); border-top-color: var(--ink); animation: spin .8s linear infinite; display: none; }
.is-loading .spinner { display: inline-block; }
.is-loading svg { display: none; }

/* ---------- OJ filter (on hero) ---------- */
.oj-filter { margin-top: 18px; }
.oj-head { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; margin-bottom: 10px; }
.oj-head .label { font-weight: 700; font-size: 14px; color: #fff; }
.hero .muted { color: rgba(255, 255, 255, .6); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { position: relative; cursor: pointer; user-select: none; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px; border-radius: 6px; font-size: 13px; font-weight: 500;
  border: 1px solid rgba(255, 255, 255, .22); background: rgba(255, 255, 255, .04); color: rgba(255, 255, 255, .7);
  transition: all .18s;
}
.chip span::before { content: ""; width: 12px; height: 12px; border-radius: 3px; border: 1.5px solid rgba(255, 255, 255, .5); transition: all .18s; }
.chip:hover span { border-color: rgba(253, 188, 30, .7); color: #fff; }
.chip input:checked + span { color: var(--ink); background: var(--yellow); border-color: var(--yellow); font-weight: 600; }
.chip input:checked + span::before {
  border-color: var(--ink);
  background: var(--ink) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 6.2 5 8.5 9.5 3.5' fill='none' stroke='%23fdbc1e' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 10px no-repeat;
}
.chip input:focus-visible + span { box-shadow: var(--ring); }

/* ---------- Progress (on hero) ---------- */
.progress-card { margin-top: 18px; padding: 12px 16px; border-radius: 10px; background: rgba(0, 0, 0, .22); border: 1px solid rgba(255, 255, 255, .12); animation: fade .3s ease both; }
.progress-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; font-size: 13px; }
.progress-head .label { color: var(--yellow); font-weight: 700; display: inline-flex; align-items: center; gap: 6px; }
.progress-head .label::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.is-running .progress-head .label::before { animation: pulse 1.2s ease-in-out infinite; }
.progress-track { position: relative; height: 8px; border-radius: 999px; overflow: hidden; background: rgba(255, 255, 255, .12); }
.progress-bar { position: absolute; inset: 0; border-radius: inherit; background: linear-gradient(90deg, #3b8cff, var(--yellow)); }
.is-running .progress-bar { background: repeating-linear-gradient(-45deg, var(--yellow) 0 12px, #ffd25e 12px 24px); background-size: 34px 34px; animation: stripes .7s linear infinite; }
.progress-stats { display: flex; flex-wrap: wrap; gap: 6px 22px; margin-top: 9px; font-size: 13px; color: rgba(255, 255, 255, .72); }
.progress-stats b { font-family: var(--mono); font-weight: 600; color: #fff; font-variant-numeric: tabular-nums; }

/* ---------- Insights ---------- */
.insights { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 18px; margin-top: 22px; animation: rise .45s ease both; }
.cluster-list { display: flex; flex-direction: column; gap: 10px; }
.cluster-card {
  position: relative; display: block; width: 100%; text-align: left;
  padding: 12px 14px 12px 18px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--bg-elev); cursor: pointer; overflow: hidden;
  transition: transform .18s, box-shadow .2s, border-color .2s, opacity .2s, background .2s;
  animation: rise .4s ease both;
}
.cluster-card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; background: var(--cc, var(--cl-0)); }
.cluster-card:hover { transform: translateX(3px); box-shadow: var(--shadow); border-color: var(--cc); }
.cluster-card.active { border-color: var(--cc); background: color-mix(in srgb, var(--cc) 7%, var(--bg-elev)); box-shadow: 0 0 0 2px color-mix(in srgb, var(--cc) 35%, transparent), var(--shadow); }
.cluster-list.has-active .cluster-card:not(.active) { opacity: .55; }
.cluster-top { display: flex; align-items: baseline; gap: 10px; }
.cluster-label { flex: 1; min-width: 0; font-weight: 600; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cluster-size { flex: none; font-size: 12px; font-weight: 700; padding: 1px 8px; border-radius: 5px; color: #fff; background: var(--cc); }
.cluster-meta { display: flex; align-items: center; gap: 10px; margin-top: 7px; font-size: 12px; color: var(--text-3); }
.cluster-meter { flex: 1; height: 6px; border-radius: 999px; background: var(--bg-sunk); overflow: hidden; }
.cluster-meter > span { display: block; height: 100%; border-radius: inherit; background: var(--cc); transition: width .5s ease; }
.cluster-meta .num { font-family: var(--mono); font-variant-numeric: tabular-nums; color: var(--text-2); }
.cluster-examples { margin: 6px 0 0; padding: 0; list-style: none; font-size: 12.5px; color: var(--text-2); }
.cluster-examples li { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cluster-examples li::before { content: "› "; color: var(--cc); font-weight: 700; }
.empty-hint { padding: 18px; text-align: center; color: var(--text-3); font-size: 13px; border: 1px dashed var(--border-strong); border-radius: 10px; }

.scatter-wrap { position: relative; }
.scatter-svg { display: block; width: 100%; height: auto; border-radius: 10px; background: var(--bg-sunk); border: 1px solid var(--border); }
.scatter-svg .grid line { stroke: var(--border-strong); stroke-width: 1; stroke-dasharray: 2 4; }
.scatter-svg .pt { cursor: pointer; stroke: var(--bg-elev); stroke-width: 1.5; transition: opacity .2s; }
.scatter-svg .pt:hover, .scatter-svg .pt:focus { stroke: var(--text); stroke-width: 2.2; outline: none; }
.scatter-svg.dim .pt { opacity: .12; }
.scatter-svg.dim .pt.hl { opacity: 1; }
.scatter-svg .q-star { fill: var(--yellow); stroke: var(--navy); stroke-width: 1.4; }
.scatter-svg .q-ring { fill: none; stroke: var(--navy); stroke-opacity: .28; stroke-dasharray: 3 4; }
@media (prefers-color-scheme: dark) { .scatter-svg .q-ring { stroke: var(--yellow); } .scatter-svg .q-star { stroke: #000; } }
.scatter-svg .q-label { font-size: 11px; fill: var(--text); font-weight: 700; }
.scatter-svg .q-star, .scatter-svg .q-ring, .scatter-svg .q-label, .scatter-svg .grid { pointer-events: none; }
.scatter-hint { margin: 8px 2px 0; font-size: 12px; color: var(--text-3); }

.tooltip {
  position: absolute; z-index: 20; pointer-events: none; max-width: 280px;
  padding: 8px 10px; border-radius: 8px; font-size: 12.5px; line-height: 1.45;
  color: #fff; background: var(--navy-3); border: 1px solid rgba(255, 255, 255, .12);
  border-top: 3px solid var(--yellow);
  box-shadow: var(--shadow-lg); opacity: 0; transform: translateY(4px); transition: opacity .15s, transform .15s;
}
.tooltip.show { opacity: 1; transform: translateY(0); }
.tooltip .tt-title { font-weight: 600; }
.tooltip .tt-row { display: flex; align-items: center; gap: 6px; color: rgba(255, 255, 255, .75); }
.tooltip .tt-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.tooltip .num { font-family: var(--mono); font-variant-numeric: tabular-nums; color: var(--yellow); }

/* ---------- Results ---------- */
#search-results { margin-top: 22px; }
.results-toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 18px; padding: 12px 16px; margin-bottom: 12px; border-radius: var(--radius); border-left: 4px solid var(--navy); }
@media (prefers-color-scheme: dark) { .results-toolbar { border-left-color: var(--yellow); } }
.summary { margin: 0; color: var(--text-2); font-size: 14px; }
.summary strong { color: var(--text); font-variant-numeric: tabular-nums; }
.toggles { margin-left: auto; display: flex; flex-wrap: wrap; gap: 8px 18px; }
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13.5px; color: var(--text-2); user-select: none; font-weight: 500; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch-track { position: relative; width: 36px; height: 20px; border-radius: 999px; background: var(--border-strong); transition: background .25s; }
.switch-track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: transform .25s cubic-bezier(.3, 1.4, .6, 1); }
.switch input:checked + .switch-track { background: var(--navy); }
@media (prefers-color-scheme: dark) { .switch input:checked + .switch-track { background: var(--blue); } }
.switch input:checked + .switch-track::after { transform: translateX(16px); background: var(--yellow); }
.switch input:focus-visible + .switch-track { box-shadow: var(--ring); }
.switch:hover { color: var(--text); }

.filter-pill {
  display: inline-flex; align-items: center; gap: 8px; margin: 0 0 12px; padding: 6px 8px 6px 12px;
  border-radius: 8px; font-size: 13px;
  background: color-mix(in srgb, var(--cc, var(--cl-0)) 10%, var(--bg-elev));
  border: 1px solid color-mix(in srgb, var(--cc, var(--cl-0)) 45%, transparent);
  animation: fade .25s ease both;
}
.filter-pill .label-text { font-weight: 700; max-width: 46ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.filter-pill .link-btn { color: var(--blue); }

.result-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.result-card {
  position: relative;
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 14px;
  padding: 13px 18px; border-radius: var(--radius);
  background: var(--bg-elev); border: 1px solid var(--border); box-shadow: var(--shadow-sm);
  transition: transform .18s, box-shadow .2s, border-color .2s;
  animation: rise .35s ease both; animation-delay: calc(var(--i, 0) * 20ms);
}
.result-card::before { content: ""; position: absolute; left: -1px; top: 12px; bottom: 12px; width: 3px; border-radius: 0 3px 3px 0; background: var(--yellow); opacity: 0; transition: opacity .2s; }
.result-card:hover { transform: translateY(-1px); box-shadow: var(--shadow); border-color: var(--border-strong); }
.result-card:hover::before { opacity: 1; }
.rank {
  min-width: 46px; text-align: center; font-family: var(--mono); font-size: 13px; font-weight: 700;
  padding: 5px 8px; border-radius: 7px; color: var(--navy); background: var(--bg-sunk); border: 1px solid var(--border);
}
@media (prefers-color-scheme: dark) { .rank { color: #cfe0f7; } }
.rank.medal-gold { color: #3d2b00; background: linear-gradient(135deg, #ffe08a, var(--gold)); border-color: #e0a400; }
.rank.medal-silver { color: #1f2937; background: linear-gradient(135deg, #f1f4f8, var(--silver)); border-color: #98a4b5; }
.rank.medal-bronze { color: #fff; background: linear-gradient(135deg, #e0a06a, var(--bronze)); border-color: #a9652c; }
.result-title-row { display: flex; align-items: center; gap: 8px; min-width: 0; }
.result-title { font-weight: 600; font-size: 15.5px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result-title:hover { color: var(--blue); }
.cdot { flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--cc, var(--cl-0)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--cc, var(--cl-0)) 20%, transparent); }
.result-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 12px; margin-top: 4px; font-size: 12.5px; color: var(--text-3); }
.oj-tag { display: inline-block; padding: 1px 8px; border-radius: 4px; font-size: 12px; font-weight: 600; color: #fff; background: var(--navy); letter-spacing: .2px; }
@media (prefers-color-scheme: dark) { .oj-tag { background: #24456f; color: #dbe8fa; } }
.meta-link { color: var(--text-2); font-size: 12.5px; }
.meta-link:hover { color: var(--blue); }
.dups summary { cursor: pointer; list-style: none; color: var(--blue); font-weight: 600; }
@media (prefers-color-scheme: dark) { .dups summary { color: var(--yellow); } }
.dups summary::-webkit-details-marker { display: none; }
.dups summary::before { content: "▸"; display: inline-block; margin-right: 4px; transition: transform .2s; }
.dups[open] summary::before { transform: rotate(90deg); }
.dups ul { margin: 6px 0 2px; padding: 8px 10px; list-style: none; border-radius: 8px; background: var(--bg-sunk); border: 1px dashed var(--border-strong); }
.dups li { display: flex; align-items: center; gap: 8px; padding: 2px 0; min-width: 0; }
.dups li a.t { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dups li .num { margin-left: auto; font-family: var(--mono); font-size: 12px; color: var(--text-3); }
.result-meta .dups { flex-basis: 100%; }
.score-col { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; min-width: 76px; }
.score-num { font-family: var(--mono); font-size: 13px; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.score-bar { width: 72px; height: 5px; border-radius: 999px; background: var(--bg-sunk); overflow: hidden; }
.score-bar > span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--blue), var(--yellow)); }
.empty-state { padding: 40px 20px; text-align: center; color: var(--text-3); }

/* ---------- Pagination ---------- */
.pager { margin-top: 24px; }
.pagination { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin: 0; padding: 0; list-style: none; }
.page-link {
  display: inline-flex; align-items: center; justify-content: center; min-width: 38px; height: 38px; padding: 0 12px;
  border-radius: 7px; font-size: 14px; font-weight: 500; font-variant-numeric: tabular-nums;
  color: var(--text-2); background: var(--bg-elev); border: 1px solid var(--border); transition: all .18s;
}
a.page-link:hover { color: var(--navy); border-color: var(--navy); text-decoration: none; }
.page-item.active .page-link { color: #fff; background: var(--navy); border-color: var(--navy); box-shadow: inset 0 -3px 0 var(--yellow); }
.page-item.disabled .page-link { opacity: .45; pointer-events: none; }

/* ---------- Problem page ---------- */
.crumb { display: inline-flex; align-items: center; gap: 6px; margin-bottom: 14px; color: var(--text-2); font-size: 14px; font-weight: 500; }
.crumb:hover { color: var(--blue); }
.problem-head { position: relative; padding: 22px 26px; margin-bottom: 16px; color: #fff; border: 0; background: linear-gradient(135deg, var(--navy-3), var(--navy)); box-shadow: var(--shadow); animation: rise .4s ease both; overflow: hidden; }
.problem-head::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--yellow); }
.problem-title { margin: 0 0 10px; font-size: 26px; line-height: 1.3; font-weight: 700; }
.problem-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.problem-head .oj-tag { background: var(--yellow); color: var(--ink); }
.problem-head .muted { color: rgba(255, 255, 255, .6); font-family: var(--mono); }
.statement { padding: 26px 30px; font-size: 15.5px; line-height: 1.85; max-width: 100%; overflow-wrap: anywhere; animation: rise .45s ease both; }
.statement-inner { max-width: 80ch; margin: 0 auto; }
.problem-foot { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; }

/* ---------- Stats page ---------- */
.page-head { position: relative; margin-bottom: 18px; padding: 22px 26px; border-radius: var(--radius-lg); color: #fff; background: linear-gradient(135deg, var(--navy-3), var(--navy)); box-shadow: var(--shadow); overflow: hidden; }
.page-head::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--yellow); }
.page-head h1 { margin: 0; font-size: 26px; font-weight: 700; }
.page-head p { margin: 4px 0 0; color: rgba(255, 255, 255, .72); }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { padding: 16px 18px; border-top: 3px solid var(--navy); animation: rise .4s ease both; }
.kpi:nth-child(2) { animation-delay: 60ms; border-top-color: var(--blue); }
.kpi:nth-child(3) { animation-delay: 120ms; border-top-color: var(--red); }
.kpi:nth-child(4) { animation-delay: 180ms; border-top-color: var(--green); }
.kpi .k-label { font-size: 13px; color: var(--text-3); font-weight: 500; }
.kpi .k-value { margin-top: 2px; font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.3px; }
.kpi.primary { border-top-color: var(--yellow); }
.kpi.primary .k-value { color: var(--navy); }
@media (prefers-color-scheme: dark) { .kpi.primary .k-value { color: var(--yellow); } }
.chart-card { padding: 18px 20px 14px; margin-bottom: 18px; }
.chart-head { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 16px; margin-bottom: 10px; }
.chart-head .section-title { margin: 0; }
.legend { display: flex; gap: 14px; font-size: 12.5px; color: var(--text-2); }
.legend i { display: inline-block; width: 18px; height: 3px; border-radius: 2px; vertical-align: middle; margin-right: 6px; }
.legend .l-count { background: var(--blue); }
.legend .l-ema { background: repeating-linear-gradient(90deg, var(--yellow-2) 0 4px, transparent 4px 7px); height: 3px; }
.seg { margin-left: auto; display: inline-flex; padding: 3px; border-radius: 8px; background: var(--bg-sunk); border: 1px solid var(--border); }
.seg button { border: 0; background: none; padding: 4px 12px; border-radius: 6px; font-size: 13px; color: var(--text-2); cursor: pointer; transition: all .18s; font-weight: 500; }
.seg button.active { background: var(--navy); color: #fff; box-shadow: inset 0 -2px 0 var(--yellow); }
.chart-box { position: relative; width: 100%; min-height: 320px; }
.chart-box svg { display: block; width: 100%; height: 340px; overflow: visible; }
.chart-box .axis text { font-size: 11px; fill: var(--text-3); font-variant-numeric: tabular-nums; }
.chart-box .gridline { stroke: var(--border); }
.chart-box .area { fill: url(#areaGrad); }
.chart-box .line { fill: none; stroke: var(--blue); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
@media (prefers-color-scheme: dark) { .chart-box .line { stroke: #3b8cff; } }
.chart-box .ema { fill: none; stroke: var(--yellow-2); stroke-width: 2.6; stroke-dasharray: 2 5; stroke-linecap: round; }
.chart-box .draw { animation: draw 1.1s ease-out both; }
.chart-box .cross { stroke: var(--text-3); stroke-dasharray: 3 3; }
.chart-box .hover-dot { fill: var(--bg-elev); stroke-width: 2.5; }
.chart-note { margin: 6px 0 0; font-size: 12px; color: var(--text-3); }
.stats-table-wrap { padding: 0; overflow: hidden; }
.stats-table-wrap summary { cursor: pointer; padding: 15px 20px; font-weight: 700; list-style: none; display: flex; align-items: center; gap: 8px; }
.stats-table-wrap summary::-webkit-details-marker { display: none; }
.stats-table-wrap summary::after { content: "▾"; margin-left: auto; color: var(--text-3); transition: transform .2s; }
.stats-table-wrap[open] summary::after { transform: rotate(180deg); }
.table-scroll { max-height: 360px; overflow-y: auto; border-top: 1px solid var(--border); }
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table th, .data-table td { padding: 9px 20px; text-align: left; }
.data-table td:last-child, .data-table th:last-child { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--mono); }
.data-table thead th { position: sticky; top: 0; background: var(--navy); color: #fff; font-weight: 600; font-size: 12.5px; }
.data-table tbody tr:nth-child(even) { background: var(--bg-sunk); }
.data-table tbody tr:hover { background: rgba(253, 188, 30, .14); }
.data-table .total-row td { font-weight: 700; background: rgba(253, 188, 30, .22); }

/* ---------- Footer ---------- */
.site-footer { margin-top: auto; padding: 20px 0; font-size: 13px; color: rgba(255, 255, 255, .7); background: var(--ink); border-top: 3px solid var(--yellow); }
.site-footer .container { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 6px 14px; }
.site-footer a { color: rgba(255, 255, 255, .8); }
.site-footer a:hover { color: var(--yellow); }
.site-footer .sep { opacity: .4; }

/* ---------- Animations ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes stripes { from { background-position: 0 0; } to { background-position: 34px 0; } }
@keyframes pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .4; transform: scale(.7); } }
@keyframes draw { from { stroke-dashoffset: var(--len, 2000); } to { stroke-dashoffset: 0; } }
@keyframes pop { from { opacity: 0; transform: scale(.3); } to { opacity: 1; transform: scale(1); } }
@keyframes float { 0%, 100% { translate: 0 0; } 50% { translate: 0 -6px; } }
.scatter-svg .pt { animation: pop .35s ease both; transform-box: fill-box; transform-origin: center; }

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

/* ---------- Responsive ---------- */
@media (max-width: 1023px) {
  .insights { grid-template-columns: minmax(0, 1fr); }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .brand-text { display: none; }
}
@media (max-width: 760px) {
  .nav-link .nav-text, .gh-pill .nav-text { display: none; }
  .hero-balloons { display: none; }
}
@media (max-width: 640px) {
  .container { padding: 0 12px; }
  .topbar-inner { gap: 8px; }
  .topnav { gap: 6px; }
  .nav-link { padding: 6px 8px; }
  .hero { padding: 24px 20px 20px; border-radius: 16px; }
  .hero::before { inset: 6px; border-radius: 12px; }
  .hero-title { font-size: 25px; }
  .chips { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 6px; scrollbar-width: thin; }
  .chip span { white-space: nowrap; }
  .query-actions .btn-lg { width: 100%; }
  .kbd-hint { display: none; }
  .result-card { grid-template-columns: minmax(0, 1fr) auto; padding: 12px 14px; }
  .result-card .rank { grid-column: 1 / -1; justify-self: start; min-width: 0; }
  .toggles { margin-left: 0; }
  .statement { padding: 18px; }
  .problem-title { font-size: 21px; }
  .seg { margin-left: 0; }
  .card-pad { padding: 16px; }
}
