/* QSC palette: Force Blue #131e29, Wave Gray #cfd2d3.
   Quark Red uses the guide's RGB 170,30,46 (#aa1e2e);
   its printed red HEX value is inconsistent with that RGB and swatch. */
:root {
  --bg: #f5f6f6;
  --surface: #ffffff;
  --border: #cfd2d3;
  --text: #131e29;
  --text-muted: #58636c;
  --accent: #aa1e2e;
  --accent-soft: #f8ecee;
  --bar: #131e29;
  --bar-track: #edf0f1;
  --ci: #aeb8bf;
  --selection: #131e29;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101820;
    --surface: #192632;
    --border: #3e4b56;
    --text: #f2f4f5;
    --text-muted: #b2bcc3;
    --accent: #f18c99;
    --accent-soft: #38262f;
    --bar: #cfd2d3;
    --bar-track: #2a3946;
    --ci: #647684;
    --selection: #cfd2d3;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

main {
  max-width: 880px;
  margin: 0 auto;
  padding: 0 20px 60px;
}

.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.site-header-inner {
  max-width: 880px;
  margin: 0 auto;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.brand-logo-wrap {
  display: inline-flex;
  align-items: center;
  background: #ffffff;
  border-radius: 8px;
  padding: 10px 12px;
  max-width: 100%;
}

.brand-logo-wrap--square {
  padding: 8px;
}

.brand-logo {
  display: block;
  width: 260px;
  max-width: 100%;
  height: auto;
}

.brand-logo--square {
  height: 56px;
  width: 56px;
}

.site-nav {
  display: flex;
  gap: 4px;
}

.site-nav-link {
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--text-muted);
  text-decoration: none;
}

.site-nav-link:hover {
  color: var(--text);
  background: var(--accent-soft);
}

.site-nav-link.active {
  color: white;
  background: #aa1e2e;
}

.page-header {
  max-width: 880px;
  margin: 0 auto;
  padding: 48px 20px 8px;
}

.page-header h1 {
  margin: 0 0 6px;
  font-size: 2rem;
  letter-spacing: -0.02em;
}

.subtitle {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.controls {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 16px;
  margin: 28px 0 28px;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.control-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.segmented {
  display: inline-flex;
  flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 3px;
  gap: 2px;
}

.segmented button {
  border: none;
  background: transparent;
  color: var(--text-muted);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.85rem;
  cursor: pointer;
  white-space: nowrap;
}

.segmented button:hover {
  color: var(--text);
}

.segmented button.active {
  background: #aa1e2e;
  color: white;
}

.dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 200px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 7px 12px;
  border-radius: 8px;
  font-size: 0.85rem;
  cursor: pointer;
}

.dropdown-toggle:hover {
  border-color: var(--accent);
}

.dropdown-toggle[aria-expanded="true"] {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.dropdown-caret {
  color: var(--text-muted);
  font-size: 0.7rem;
}

.dropdown-menu {
  position: absolute;
  z-index: 20;
  top: calc(100% + 4px);
  left: 0;
  min-width: 100%;
  max-height: 280px;
  overflow-y: auto;
  margin: 0;
  padding: 4px;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.1);
  white-space: nowrap;
}

.dropdown-menu[hidden] {
  display: none;
}

.dropdown-option {
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 0.85rem;
  color: var(--text);
  cursor: pointer;
}

.dropdown-option:hover,
.dropdown-option:focus {
  background: var(--accent-soft);
  outline: none;
}

.dropdown-option.selected {
  background: #aa1e2e;
  color: white;
  font-weight: 600;
}

.board-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.status {
  padding: 32px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.board {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.board thead th {
  text-align: left;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.board .col-rank { width: 40px; }
.board .col-metric { width: 150px; }
.board .col-n { width: 70px; text-align: right; }

.board th.sortable {
  cursor: pointer;
  user-select: none;
}

.board th.sortable:hover {
  color: var(--text);
}

.board th.sortable.active {
  color: var(--accent);
  font-weight: 700;
  border-bottom: 2px solid var(--accent);
}

.board th.sortable.active::after {
  content: " \25BE";
}

.board tbody tr.row {
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}

.board tbody tr.row:hover {
  background: var(--accent-soft);
}

.board tbody tr.row:last-child {
  border-bottom: none;
}

.board td {
  padding: 12px 16px;
  vertical-align: middle;
}

.rank-num {
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.model-name {
  font-weight: 600;
}

.metric-value {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.metric-ci {
  display: block;
  font-weight: 400;
  font-size: 0.72rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.metric-value .bar-track {
  margin-top: 6px;
}

.bar-track {
  position: relative;
  height: 6px;
  border-radius: 3px;
  background: var(--bar-track);
  overflow: hidden;
}

.bar-ci {
  position: absolute;
  top: 0;
  bottom: 0;
  background: var(--ci);
}

.bar-fill {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  background: var(--bar);
  border-radius: 4px;
}

.col-n {
  text-align: right;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  font-size: 0.82rem;
}

tr.detail-row td {
  background: var(--bg);
  padding: 4px 16px 18px;
}

.detail-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  margin-top: 8px;
}

.detail-table th {
  text-align: left;
  color: var(--text-muted);
  font-weight: 500;
  padding: 4px 10px;
  border-bottom: 1px solid var(--border);
}

.detail-table td {
  padding: 4px 10px;
  font-variant-numeric: tabular-nums;
}

.detail-loading {
  color: var(--text-muted);
  font-size: 0.82rem;
  padding: 4px 10px;
}

.footnote {
  margin-top: 18px;
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.footnote code {
  background: var(--accent-soft);
  padding: 1px 5px;
  border-radius: 4px;
}

.table-scroll {
  overflow-x: auto;
}

.problem-board {
  width: auto;
  border-collapse: collapse;
  font-size: 0.78rem;
  white-space: nowrap;
}

.problem-board th,
.problem-board td {
  padding: 7px 8px;
  text-align: center;
  border-bottom: 1px solid var(--border);
}

.problem-board thead th {
  position: sticky;
  top: 0;
  background: var(--surface);
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.72rem;
  z-index: 1;
}

.problem-board .col-model,
.problem-board .col-metric {
  text-align: left;
}

.problem-board .model-name {
  font-weight: 600;
}

.problem-board .metric-value {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  text-align: left;
}

.problem-sticky {
  position: sticky;
  left: 0;
  background: var(--surface);
  z-index: 2;
}

.problem-board thead th.problem-sticky {
  z-index: 3;
}

.col-task {
  min-width: 22px;
  width: 22px;
  padding: 7px 2px;
}

.cell-task {
  height: 26px;
}

.cell-empty {
  background: var(--bar-track);
}

.models-board .col-date,
.models-board .col-open {
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.models-board .col-params {
  color: var(--text-muted);
}

/* Problem inspection stays outside the horizontally scrolling matrix. */
.problem-board td.cell-task { padding: 0; }
.problem-cell { display: block; width: 100%; min-width: 22px; height: 29px; border: 0; cursor: pointer; }
.problem-cell[aria-pressed="true"] { box-shadow: inset 0 0 0 3px var(--selection), inset 0 0 0 5px white; }
.problem-cell:focus-visible { outline: 3px solid var(--selection); outline-offset: -3px; }
.problem-detail { margin-top: 24px; padding: 24px; border: 1px solid var(--border); border-radius: 16px; background: var(--surface); box-shadow: 0 3px 12px #131e2910; }
.problem-detail[hidden] { display: none; }
.inspection-header { display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap; margin-bottom: 22px; }
.inspection-header h2 { margin: 0 0 12px; font-size: 1.3rem; }
.inspection-header p, .problem-navigation, .inspection-placeholder { font-size: .84rem; color: var(--text-muted); line-height: 1.6; }
.inspection-header p { margin: 8px 0 0; }
.inspection-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.inspection-chips span { padding: 4px 8px; border-radius: 6px; background: var(--bg); font-size: .72rem; overflow-wrap: anywhere; }
.problem-navigation { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.problem-detail button { font: inherit; cursor: pointer; }
.problem-navigation button { border: 1px solid var(--border); border-radius: 7px; padding: 7px 10px; background: var(--surface); color: var(--text); }
.problem-navigation button:disabled { opacity: .4; cursor: default; }
.problem-detail :focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.inspection-columns { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.inspection-card { min-width: 0; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--bg); }
.inspection-card h3 { margin: 0; padding: 14px; font-size: .88rem; border-bottom: 1px solid var(--border); background: var(--surface); }
.inspection-card h3 small { float: right; color: var(--text-muted); font-size: .65rem; font-weight: 400; }
.inspection-code, .inspection-prompt { margin: 0; padding: 16px; max-height: 480px; overflow: auto; font: .76rem/1.7 ui-monospace, SFMono-Regular, Consolas, monospace; tab-size: 4; }
.inspection-prompt { white-space: pre-wrap; overflow-wrap: anywhere; }
.attempt-tabs { display: flex; overflow-x: auto; padding: 10px; gap: 6px; background: var(--surface); }
.attempt-tabs button { flex-shrink: 0; border: 1px solid var(--border); border-radius: 6px; padding: 7px 9px; font-size: .72rem; }
.attempt-tabs button span { display: block; margin-top: 4px; font-size: .65rem; }
.attempt-tabs [aria-selected="true"] { box-shadow: inset 0 0 0 2px currentColor; font-weight: 600; }
.problem-detail .correct { background: #edf8f0; color: #24643c; }
.problem-detail .incorrect { background: #fff0ef; color: #943e39; }
.problem-detail .unknown { background: var(--bg); color: var(--text-muted); }
.evaluation-result, .attempt-output details { margin: 0; padding: 12px 16px; border-top: 1px solid var(--border); font-size: .76rem; }
.inspection-summary { margin-top: 18px; border-radius: 8px; padding: 14px 16px; font-size: .84rem; line-height: 1.6; }
@media (min-width: 1100px) { .problem-detail { width: min(1240px, calc(100vw - 60px)); margin-left: calc((840px - min(1240px, 100vw - 60px)) / 2); } }
@media (max-width: 760px) { .inspection-columns { grid-template-columns: 1fr; } .problem-detail { padding: 16px; } }
@media (prefers-color-scheme: dark) { .problem-detail .correct { background: #203e2d; color: #b4dfc3; } .problem-detail .incorrect { background: #472b2c; color: #f0bdb9; } }

.models-wrap { overflow-x: auto; }
.model-source-link { color: var(--accent); white-space: nowrap; text-underline-offset: 3px; font-size: .8rem; }
.model-source-link:hover { color: var(--text); }
.model-source-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 2px; }

/* Independent QuantumBenchEval preview collection. */
.qbe-panel { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 24px; }
.qbe-panel h2 { margin-top: 0; font-size: 1.25rem; }
.qbe-panel p { line-height: 1.6; }
.qbe-panel .muted { color: var(--text-muted); font-size: .8rem; }
.qbe-badge { font-size: .75rem; vertical-align: middle; padding: 5px 9px; border-radius: 6px; background: var(--accent-soft); color: var(--accent); }
.qbe-topics a { padding: 7px 16px; text-decoration: none; color: var(--text-muted); border-radius: 6px; }
.qbe-topics a[aria-current] { background: #aa1e2e; color: white; }
.qbe-metrics { display: flex; gap: 48px; flex-wrap: wrap; margin: 24px 0; }
.qbe-metrics span { display: block; color: var(--text-muted); font-size: .85rem; margin-bottom: 6px; }
.qbe-metrics strong { font-size: 2rem; font-variant-numeric: tabular-nums; }
.qbe-notice { border-left: 3px solid var(--accent); padding: 12px 16px; background: var(--accent-soft); }
.qbe-statuses { display: flex; flex-wrap: wrap; gap: 10px; }
.qbe-statuses div { display: flex; gap: 12px; border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px; font-size: .8rem; overflow-wrap: anywhere; }
.qbe-statuses dd { margin: 0; font-weight: 600; }
.qbe-variant { border-top: 1px solid var(--border); margin-top: 24px; padding-top: 12px; }
.qbe-panel summary { cursor: pointer; margin-top: 24px; color: var(--accent); }
.qbe-panel .board { font-size: .8rem; }
@media (max-width: 600px) { .qbe-panel { padding: 16px; } .site-nav { flex-wrap: wrap; } }

/* Explicit display rules must not override conditional controls. */
.control-group[hidden] { display: none; }

.problem-detail .rubric-score { background: hsl(var(--score-hue) 65% 94%); color: hsl(var(--score-hue) 55% 27%); }
@media (prefers-color-scheme: dark) {
  .problem-detail .rubric-score { background: hsl(var(--score-hue) 30% 20%); color: hsl(var(--score-hue) 55% 78%); }
}

/* Shared QSC accent for dataset links and navigation. */
main a { color: var(--accent); text-decoration: none; font-weight: 600; }
main a:hover { text-decoration: underline; }

/* Home and team pages share the Arena palette and navigation. */
.site-nav { flex-wrap: wrap; }
.home-main { padding-top: 52px; }
.eyebrow { color: var(--accent); font-size: .72rem; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; line-height: 1.6; }
.home-hero { padding: 10px 0 44px; border-bottom: 1px solid var(--border); }
.home-hero h1 { max-width: 740px; margin: 18px 0; font-size: clamp(2.2rem, 5.5vw, 3.7rem); line-height: 1.08; letter-spacing: -.04em; }
.hero-copy { max-width: 700px; font-size: 1.1rem; line-height: 1.8; color: var(--text-muted); }
.home-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 28px; }
main .action-primary, main .action-secondary { display: inline-flex; align-items: center; justify-content: center; padding: 12px 18px; border-radius: 8px; font-size: .88rem; text-decoration: none; }
main .action-primary { background: #aa1e2e; color: white; }
main .action-secondary { border: 1px solid var(--border); color: var(--text); background: var(--surface); }
main .action-primary:hover { background: #891825; }
main .action-secondary:hover { border-color: var(--accent); }
a:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
.home-section { margin-top: 44px; }
.home-section h2, .home-callout h2 { font-size: 1.6rem; letter-spacing: -.025em; margin: 8px 0 16px; }
.home-section > p:not(.eyebrow), .home-callout p:not(.eyebrow), .about-intro { color: var(--text-muted); line-height: 1.8; }
.goal-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-top: 24px; }
.info-card { border: 1px solid var(--border); background: var(--surface); border-radius: 12px; padding: 24px; }
.card-number { color: var(--accent); font-size: .78rem; font-weight: 700; }
.info-card h3 { font-size: 1.05rem; line-height: 1.4; margin: 18px 0 10px; }
.info-card p { font-size: .9rem; line-height: 1.7; color: var(--text-muted); margin: 0; }
.home-callout { margin-top: 44px; padding: 28px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); border-top: 3px solid var(--accent); }
.about-intro { margin: 24px 0 32px; max-width: 740px; }
.team-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
.team-card { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: var(--surface); }
.team-photo { aspect-ratio: 4 / 3; background: var(--bar-track); display: grid; place-items: center; border-bottom: 1px solid var(--border); color: var(--text-muted); font-size: .8rem; }
.team-copy { padding: 22px; }
.team-copy h3 { font-size: 1.1rem; margin: 0 0 14px; }
.team-copy p, .profile-links { font-size: .84rem; line-height: 1.7; color: var(--text-muted); }
.profile-links { margin: 20px 0 0; }
.profile-links div { padding: 8px 0; border-top: 1px solid var(--border); }
.profile-links dt { color: var(--text); font-weight: 600; }
.profile-links dd { margin: 0; overflow-wrap: anywhere; }
@media (max-width: 700px) {
  .goal-grid, .team-grid { grid-template-columns: 1fr; }
  .home-main { padding-top: 28px; }
  .home-callout { padding: 22px; }
  .team-photo { aspect-ratio: 16 / 9; }
}

.team-group > h2 { margin: 0 0 22px; font-size: 1.4rem; letter-spacing: -.02em; }
.team-divider { border: 0; border-top: 1px solid var(--border); margin: 40px 0; }
.team-copy .team-role { color: var(--accent); font-weight: 600; margin: -4px 0 16px; }

/* Crop portraits in the page while retaining the original image files. */
.team-photo--portrait { position: relative; overflow: hidden; aspect-ratio: 4 / 5; }
.team-photo--portrait img { display: block; width: 100%; height: 100%; object-fit: contain; object-position: center; }
/* Ethan's wide event photo: keep his head and upper torso in the portrait frame. */
.team-photo--ethan img { position: absolute; width: 302%; max-width: none; height: auto; left: -202%; top: -42%; }

/* Four team members in the requested order; stack naturally on small screens. */
.team-grid--four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.team-grid--four .team-copy { padding: 16px; }
.team-grid--four .team-photo { aspect-ratio: 4 / 5; }
/* Frame Seung-Hwan's head and upper torso, retaining breathing room above his hair. */
.team-photo--seung-hwan img { position: absolute; width: 365%; max-width: none; height: auto; left: -40%; top: -32%; }
@media (min-width: 701px) and (max-width: 850px) {
  .team-grid--four { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 700px) {
  .team-grid--four { grid-template-columns: 1fr; }
}
