:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --surface: #ffffff;
  --surface-soft: #f9fbfb;
  --line: #d7dee3;
  --text: #182026;
  --muted: #64717a;
  --accent: #1d6f72;
  --accent-2: #8a5a1f;
  --danger: #a33a3a;
  --shadow: 0 12px 32px rgba(24, 32, 38, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

.dashboard {
  width: min(1480px, 100%);
  margin: 0 auto;
  padding: 22px;
}

.masthead,
.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.masthead {
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 30px;
  line-height: 1.15;
}

h2 {
  font-size: 16px;
}

.workbook-link {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px;
  background: var(--surface);
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
}

.header-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.page-tabs {
  display: inline-grid;
  grid-auto-flow: column;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface-soft);
  box-shadow: var(--shadow);
}

.page-tab {
  min-width: 150px;
  border: 0;
  border-right: 1px solid var(--line);
  padding: 9px 12px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.page-tab:last-child {
  border-right: 0;
}

.page-tab.active {
  background: var(--accent);
  color: #fff;
}

.dashboard-page {
  display: none;
}

.dashboard-page.active {
  display: block;
}

.controls,
.summary-grid,
.chart-grid {
  display: grid;
  gap: 12px;
  margin-bottom: 14px;
}

.controls {
  grid-template-columns: minmax(220px, 1.6fr) repeat(3, minmax(150px, 1fr)) auto;
  align-items: end;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.fake-title-mode .controls {
  grid-template-columns: minmax(260px, 2fr) minmax(220px, 1fr);
}

.fake-title-mode .controls > :nth-child(2),
.fake-title-mode .controls > :nth-child(4),
.fake-title-mode .controls > :nth-child(5) {
  display: none;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

input,
select {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 10px;
  background: #fff;
  color: var(--text);
}

.toggle-row {
  min-height: 38px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
}

.toggle-row input {
  min-height: auto;
}

.summary-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.summary-grid article,
.chart-panel,
.table-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.summary-grid article {
  padding: 14px;
}

.summary-grid span {
  display: block;
  font-size: 26px;
  font-weight: 800;
  line-height: 1;
}

.summary-grid p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.chart-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.chart-grid.single {
  grid-template-columns: 1fr;
}

.chart-panel {
  padding: 14px;
}

.chart-tooltip {
  position: fixed;
  z-index: 40;
  display: none;
  max-width: min(280px, calc(100vw - 24px));
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 7px 9px;
  background: rgba(24, 32, 38, 0.96);
  box-shadow: var(--shadow);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.35;
  pointer-events: none;
}

.chart-tooltip.visible {
  display: block;
}

.chart-tools {
  display: grid;
  justify-items: end;
  gap: 8px;
}

.chart-mode {
  display: inline-grid;
  grid-auto-flow: column;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface-soft);
}

.mode-button {
  min-width: 68px;
  border: 0;
  border-right: 1px solid var(--line);
  padding: 7px 10px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
}

.mode-button:last-child {
  border-right: 0;
}

.mode-button.active {
  background: var(--accent);
  color: #fff;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.chart-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.chart-legend span.hidden {
  display: none;
}

.legend-swatch {
  width: 12px;
  height: 12px;
  display: inline-block;
  border-radius: 3px;
}

.legend-swatch.flash {
  background: var(--accent);
}

.legend-swatch.pro {
  background: var(--accent-2);
}

.legend-swatch.qwen {
  background: #7656a8;
}

.legend-swatch.concrete-flash {
  background: #1f7a4d;
}

.legend-swatch.concrete-pro {
  background: #6da34d;
}

.legend-swatch.concrete-qwen {
  background: #1f8f8a;
}

.legend-swatch.abstract-flash {
  background: #7a5bb1;
}

.legend-swatch.abstract-pro {
  background: #b24f7a;
}

.legend-swatch.abstract-qwen {
  background: #d17b31;
}

canvas {
  width: 100%;
  height: 360px;
  display: block;
  margin-top: 10px;
}

.table-panel {
  overflow: hidden;
}

.table-panel .section-head {
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.agreement-panel {
  margin-top: 14px;
}

.agreement-note {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

#visibleCount {
  color: var(--muted);
  font-size: 13px;
}

.concrete-summary article {
  min-height: 92px;
}

.probe-intro {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 28px;
  margin-bottom: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff8ed;
  box-shadow: var(--shadow);
}

.probe-intro > p {
  max-width: 720px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.fake-title-summary p {
  line-height: 1.35;
}

.fake-title-table-wrap {
  max-height: 640px;
}

.model-descriptions {
  margin-bottom: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.model-descriptions h3 {
  margin: 0 0 8px;
  font-size: 14px;
}

.model-descriptions p {
  margin: 7px 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.rationale-grid.three-models {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.concrete-summary strong {
  display: block;
  margin-bottom: 7px;
  font-size: 15px;
}

.concrete-summary span {
  font-size: 22px;
}

.concrete-summary small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}

.table-wrap {
  max-height: 560px;
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th,
td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
}

tr {
  cursor: pointer;
}

tbody tr:hover {
  background: #eef5f5;
}

.delta {
  font-weight: 800;
}

.delta.hot {
  color: var(--danger);
}

.confidence {
  color: var(--muted);
}

.detail-drawer {
  position: fixed;
  z-index: 20;
  top: 0;
  right: 0;
  width: min(520px, 100vw);
  height: 100vh;
  padding: 18px;
  border-left: 1px solid var(--line);
  background: var(--surface);
  box-shadow: -20px 0 40px rgba(24, 32, 38, 0.16);
  overflow-y: auto;
  transform: translateX(105%);
  transition: transform 160ms ease;
}

.detail-drawer.open {
  transform: translateX(0);
}

.detail-drawer.fake-title-detail,
.detail-drawer.three-model-detail {
  width: min(920px, 100vw);
}

.detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.detail-head button {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #fff;
  cursor: pointer;
}

.detail-video {
  width: min(100%, 360px);
  aspect-ratio: 25 / 36;
  display: block;
  margin: 0 auto 14px;
  border-radius: 8px;
  background: #111;
  object-fit: cover;
  object-position: center center;
}

.detail-card {
  border-top: 1px solid var(--line);
  padding: 12px 0;
}

.detail-card h3 {
  margin: 0 0 8px;
  font-size: 14px;
}

.rating-title {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
  cursor: help;
  outline: none;
}

.rating-title:focus-visible {
  border-radius: 4px;
  box-shadow: 0 0 0 3px rgba(29, 111, 114, 0.16);
}

.category-help {
  width: 18px;
  height: 18px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #fff;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
}

.rating-title:hover .category-help,
.rating-title:focus-visible .category-help {
  border-color: var(--accent);
  color: var(--accent);
}

.rating-delta {
  color: var(--muted);
  font-weight: 700;
}

.category-tooltip {
  position: absolute;
  z-index: 30;
  left: 0;
  bottom: calc(100% + 8px);
  width: min(360px, calc(100vw - 56px));
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
  color: #3f4c53;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.4;
  opacity: 0;
  pointer-events: none;
  transition: opacity 120ms ease;
}

.rating-title:hover .category-tooltip,
.rating-title:focus-visible .category-tooltip {
  opacity: 1;
}

.rationale-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.rationale-grid p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

@media (max-width: 980px) {
  .controls,
  .chart-grid,
  .summary-grid {
    grid-template-columns: 1fr 1fr;
  }

  .chart-grid.single {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .dashboard {
    padding: 14px;
  }

  .masthead {
    display: block;
  }

  .probe-intro {
    display: block;
  }

  .probe-intro > p {
    margin-top: 10px;
  }

  .section-head {
    display: block;
  }

  .chart-tools {
    justify-items: start;
    margin-top: 10px;
  }

  .workbook-link {
    display: inline-block;
    margin-top: 10px;
  }

  .header-links {
    justify-content: flex-start;
  }

  .controls,
  .chart-grid,
  .summary-grid,
  .rationale-grid {
    grid-template-columns: 1fr;
  }

  .fake-title-mode .controls {
    grid-template-columns: 1fr;
  }

  .rationale-grid.three-models {
    grid-template-columns: 1fr;
  }
}
