:root {
  --bg: #f5f5f7;
  --panel: #ffffff;
  --surface-soft: #f0f2f6;
  --surface-hover: #eaf0f8;
  --text: #1d1d1f;
  --text-secondary: #606068;
  --line: #dedee4;
  --accent: #0068d1;
  --accent-soft: #e7f2ff;
  --success: #177a38;
  --success-soft: #e9f8ee;
  --warning: #8a5700;
  --warning-soft: #fff5df;
  --danger: #a33131;
  --shadow: 0 18px 52px rgba(34, 45, 65, 0.15);
  --compare-height: 0px;
  --family-m1: #16866f;
  --family-m2: #0068d1;
  --family-m3: #a86610;
  --family-m4: #c1493a;
  --family-m5: #6555d5;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  scroll-behavior: smooth;
}

body {
  min-height: 100dvh;
  margin: 0;
  display: grid;
  grid-template-columns: 212px minmax(0, 1fr);
  color: var(--text);
  background:
    radial-gradient(circle at 70% -10%, rgba(87, 126, 201, 0.08), transparent 32rem),
    var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Hiragino Sans GB", sans-serif;
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

a {
  color: var(--accent);
}

.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 100;
  padding: 10px 14px;
  border-radius: 8px;
  color: #fff;
  background: var(--text);
  transform: translateY(-160%);
  transition: transform 160ms ease;
}

.skip-link:focus {
  transform: translateY(0);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100dvh;
  overflow-y: auto;
  padding: 22px 16px 28px;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(18px);
}

.brand-block {
  margin-bottom: 18px;
}

.brand-kicker,
.board-kicker {
  margin: 0 0 5px;
  color: var(--accent);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.brand-block h1 {
  margin: 0;
  font-size: 17px;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.sub {
  margin: 5px 0 0;
  color: var(--text-secondary);
  font-size: 11px;
  line-height: 1.5;
}

.search-shell {
  position: relative;
  margin-bottom: 16px;
}

.search-shell svg {
  position: absolute;
  top: 50%;
  left: 10px;
  width: 16px;
  height: 16px;
  fill: none;
  stroke: var(--text-secondary);
  stroke-width: 1.6;
  stroke-linecap: round;
  transform: translateY(-50%);
  pointer-events: none;
}

.search {
  width: 100%;
  min-height: 38px;
  padding: 8px 10px 8px 33px;
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
  color: var(--text);
  background: var(--bg);
  transition: border-color 180ms ease, box-shadow 180ms ease, background 180ms ease;
}

.search::placeholder {
  color: #777780;
}

.search:focus {
  border-color: var(--accent);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(0, 104, 209, 0.12);
}

.filter-groups,
.filter-section,
.option-list {
  display: grid;
}

.filter-groups {
  gap: 18px;
}

.filter-section {
  gap: 7px;
}

.group-label {
  margin: 0;
  color: var(--text-secondary);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.option-list {
  gap: 3px;
}

.option-button {
  width: 100%;
  min-height: 36px;
  padding: 7px 10px;
  border: 0;
  border-radius: 8px;
  text-align: left;
  background: transparent;
  cursor: pointer;
  transition: background 160ms ease, color 160ms ease, transform 120ms ease;
}

.option-button:hover {
  background: var(--surface-hover);
}

.option-button:active {
  transform: scale(0.98);
}

.option-button[aria-pressed="true"] {
  color: #fff;
  background: var(--accent);
  font-weight: 650;
}

.family-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.dot,
.legend-swatch {
  flex: 0 0 auto;
  background: var(--family);
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.option-button[aria-pressed="true"] .dot {
  background: #fff;
}

.family-M1 {
  --family: var(--family-m1);
}

.family-M2 {
  --family: var(--family-m2);
}

.family-M3 {
  --family: var(--family-m3);
}

.family-M4 {
  --family: var(--family-m4);
}

.family-M5 {
  --family: var(--family-m5);
}

.tier-base {
  --tier-strength: 46%;
}

.tier-pro {
  --tier-strength: 64%;
}

.tier-max {
  --tier-strength: 82%;
}

.tier-ultra {
  --tier-strength: 100%;
}

main {
  min-width: 0;
  padding: 22px 24px calc(48px + var(--compare-height) + env(safe-area-inset-bottom));
  transition: padding-bottom 180ms ease;
}

.board {
  width: min(100%, 1240px);
  margin: 0 auto;
  padding: 18px 20px 20px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 2px 10px rgba(39, 52, 72, 0.05);
}

.boardtop {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 8px;
}

.boardtop h2 {
  margin: 0;
  font-size: 15px;
  line-height: 1.35;
  letter-spacing: -0.01em;
  text-wrap: balance;
}

.seg {
  display: flex;
  flex: 0 0 auto;
  margin-left: auto;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
}

.seg button {
  min-height: 34px;
  padding: 6px 13px;
  border: 0;
  background: transparent;
  cursor: pointer;
  transition: background 160ms ease, color 160ms ease;
}

.seg button[aria-pressed="true"] {
  color: #fff;
  background: var(--text);
}

.legend {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 13px;
  min-height: 26px;
  margin: 4px 0 3px;
  color: var(--text-secondary);
  font-size: 11px;
}

.legend-item,
.legend-tiers {
  display: inline-flex;
  align-items: center;
}

.legend-item {
  gap: 5px;
}

.legend-swatch {
  width: 10px;
  height: 10px;
  border-radius: 3px;
}

.legend-tiers {
  gap: 7px;
  margin-left: auto;
}

.tone-swatch {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  background: color-mix(in srgb, #3c3c46 var(--tone), transparent);
}

.board-help {
  margin: 0 0 8px;
  color: var(--text-secondary);
  font-size: 11px;
}

.status-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 180px;
  color: var(--text-secondary);
}

.status-panel[hidden] {
  display: none;
}

.status-panel.is-error {
  flex-direction: column;
  padding: 24px;
  text-align: center;
  color: var(--danger);
}

.status-panel.is-error .status-pulse {
  display: none;
}

.status-panel small {
  max-width: 44ch;
  color: var(--text-secondary);
  line-height: 1.6;
}

.status-pulse {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 0 rgba(0, 104, 209, 0.25);
  animation: pulse 1.5s ease-out infinite;
}

@keyframes pulse {
  to {
    box-shadow: 0 0 0 9px rgba(0, 104, 209, 0);
  }
}

.ranking-list {
  display: grid;
  gap: 2px;
}

.group-heading {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  margin: 10px 0 2px;
  padding: 6px 10px;
  border-radius: 8px;
  color: var(--family);
  background: color-mix(in srgb, var(--family) 9%, white);
  font-size: 12px;
  font-weight: 700;
}

.group-count {
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 500;
}

.rank-row {
  display: grid;
  grid-template-columns: 36px 30px minmax(210px, 280px) minmax(96px, 1fr) 78px 50px;
  gap: 10px;
  align-items: center;
  width: 100%;
  min-height: 42px;
  padding: 4px 6px;
  border: 0;
  border-radius: 8px;
  text-align: left;
  background: transparent;
  cursor: pointer;
  transition: background 160ms ease, transform 120ms ease;
}

.rank-row:hover {
  background: var(--surface-hover);
}

.rank-row:active {
  transform: scale(0.995);
}

.rank-row[aria-pressed="true"] {
  background: var(--accent-soft);
}

.checkmark {
  display: grid;
  place-items: center;
  width: 19px;
  height: 19px;
  justify-self: center;
  border: 1.5px solid #b5b5bd;
  border-radius: 5px;
  color: transparent;
  font-size: 12px;
  font-weight: 800;
  transition: border-color 160ms ease, background 160ms ease, color 160ms ease;
}

.rank-row[aria-pressed="true"] .checkmark {
  border-color: var(--accent);
  color: #fff;
  background: var(--accent);
}

.rank-number {
  color: var(--text-secondary);
  font-size: 11px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.chip-label {
  display: grid;
  grid-template-columns: 4px minmax(0, 1fr);
  gap: 9px;
  align-items: center;
  min-width: 0;
}

.family-bar {
  width: 4px;
  height: 22px;
  border-radius: 3px;
  background: color-mix(in srgb, var(--family) var(--tier-strength), transparent);
}

.chip-copy {
  display: flex;
  align-items: baseline;
  min-width: 0;
  white-space: nowrap;
}

.chip-name {
  flex: 0 0 auto;
  font-weight: 680;
}

.tier-badge,
.sample-badge {
  display: inline-flex;
  align-items: center;
  min-height: 19px;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 5px;
  font-size: 9px;
  font-weight: 750;
  line-height: 1;
}

.tier-badge {
  color: color-mix(in srgb, var(--family) 78%, #141419);
  background: color-mix(in srgb, var(--family) 18%, white);
}

.sample-badge {
  color: var(--warning);
  background: var(--warning-soft);
}

.config-label {
  min-width: 0;
  margin-left: 7px;
  overflow: hidden;
  color: var(--text-secondary);
  font-size: 11px;
  text-overflow: ellipsis;
}

.score-track,
.compare-bar {
  overflow: hidden;
  background: #e9ebef;
}

.score-track {
  height: 14px;
  border-radius: 5px;
}

.score-track > span {
  display: block;
  width: var(--bar-width);
  height: 100%;
  border-radius: inherit;
  background: color-mix(in srgb, var(--family) var(--tier-strength), transparent);
  transition: width 280ms ease;
}

.score-value,
.score-diff,
.compare-value {
  font-variant-numeric: tabular-nums;
}

.score-value {
  font-size: 12px;
  font-weight: 700;
  text-align: right;
}

.score-diff {
  color: var(--text-secondary);
  font-size: 10px;
  text-align: right;
}

.empty-state {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 48px 16px 56px;
  color: var(--text-secondary);
  text-align: center;
}

.empty-state p {
  margin: 0;
}

.clear-search {
  min-height: 38px;
  padding: 7px 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
}

.data-footer {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  color: var(--text-secondary);
  font-size: 11px;
  line-height: 1.65;
}

.data-footer > p {
  margin: 0;
}

.source-details {
  margin-top: 7px;
}

.source-details summary {
  width: fit-content;
  color: var(--accent);
  font-weight: 650;
  cursor: pointer;
}

.source-details-content,
#source-details-content {
  display: grid;
  gap: 8px;
  max-width: 74ch;
  margin-top: 9px;
  padding: 10px 12px;
  border-radius: 9px;
  background: var(--surface-soft);
}

#source-details-content p {
  margin: 0;
}

#source-details-content a {
  text-underline-offset: 2px;
}

.compare-drawer {
  position: fixed;
  left: 50%;
  bottom: calc(14px + env(safe-area-inset-bottom));
  z-index: 50;
  display: grid;
  gap: 9px;
  width: min(780px, calc(100% - 28px));
  max-height: calc(100dvh - 28px - env(safe-area-inset-bottom));
  padding: 14px 16px 15px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.97);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translate(-50%, calc(100% + 40px));
  visibility: hidden;
  transition: transform 220ms ease, opacity 180ms ease, visibility 180ms ease;
}

.compare-drawer.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
  visibility: visible;
}

.compare-head,
.compare-names,
.compare-actions {
  display: flex;
  align-items: center;
}

.compare-head {
  gap: 10px;
}

.compare-names {
  flex: 1 1 auto;
  flex-wrap: wrap;
  gap: 5px 8px;
  min-width: 0;
}

.compare-name {
  font-size: 13px;
  font-weight: 750;
}

.compare-name.is-a {
  color: var(--accent);
}

.compare-name.is-b {
  color: #8a3fb0;
}

.versus {
  color: var(--text-secondary);
  font-size: 10px;
}

.compare-actions {
  flex: 0 0 auto;
  gap: 4px;
  margin-left: auto;
}

.share-button,
.icon-button {
  min-height: 40px;
  border: 0;
  border-radius: 9px;
  cursor: pointer;
  transition: background 160ms ease, transform 120ms ease;
}

.share-button:active,
.icon-button:active {
  transform: scale(0.96);
}

.share-button {
  flex: 0 0 auto;
  padding: 0 12px;
  color: var(--accent);
  background: var(--accent-soft);
  font-weight: 650;
  white-space: nowrap;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 40px;
  padding: 0;
  color: var(--text-secondary);
  background: transparent;
}

.icon-button:hover {
  background: var(--surface-soft);
}

.icon-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
}

.verdict {
  margin: 0;
  padding: 8px 10px;
  border-radius: 9px;
  color: var(--success);
  background: var(--success-soft);
  font-size: 12px;
  font-weight: 680;
  line-height: 1.5;
}

.verdict.is-neutral {
  color: var(--text-secondary);
  background: var(--surface-soft);
}

.compare-row {
  display: grid;
  grid-template-columns: 128px 1fr 58px 1fr 128px;
  gap: 8px;
  align-items: center;
  min-height: 30px;
  font-size: 12px;
}

.compare-value {
  white-space: nowrap;
}

.compare-value.is-left {
  text-align: right;
}

.compare-value.is-winner {
  font-weight: 750;
}

.delta-badge {
  display: inline-block;
  margin: 0 5px;
  padding: 2px 6px;
  border-radius: 7px;
  color: #fff;
  background: var(--success);
  font-size: 9px;
  font-weight: 750;
  vertical-align: 1px;
}

.metric-name {
  color: var(--text-secondary);
  font-size: 10px;
  text-align: center;
}

.compare-bar {
  position: relative;
  height: 12px;
  border-radius: 4px;
}

.compare-bar > span {
  position: absolute;
  top: 0;
  width: var(--compare-width);
  height: 100%;
  border-radius: inherit;
  background: #cfd2d8;
}

.compare-bar.is-left > span {
  right: 0;
}

.compare-bar.is-right > span {
  left: 0;
}

.compare-bar > span.is-winner {
  background: var(--success);
}

.compare-source {
  margin: 0;
  color: var(--text-secondary);
  font-size: 10px;
  line-height: 1.5;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  z-index: 80;
  padding: 9px 13px;
  border-radius: 9px;
  color: #fff;
  background: rgba(29, 29, 31, 0.92);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

button:focus-visible,
input:focus-visible,
summary:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(0, 104, 209, 0.35);
  outline-offset: 2px;
}

@media (max-width: 940px) {
  body {
    grid-template-columns: 190px minmax(0, 1fr);
  }

  main {
    padding-inline: 16px;
  }

  .rank-row {
    grid-template-columns: 34px 28px minmax(170px, 230px) minmax(70px, 1fr) 74px;
  }

  .score-diff {
    display: none;
  }

  .legend-tiers {
    width: 100%;
    margin-left: 0;
  }
}

@media (max-width: 760px) {
  body {
    display: block;
    background: var(--bg);
  }

  .sidebar {
    position: static;
    width: 100%;
    max-width: 100%;
    height: auto;
    padding: 14px 12px 12px;
    overflow: hidden;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    backdrop-filter: none;
  }

  .brand-block {
    margin-bottom: 12px;
  }

  .brand-kicker {
    display: none;
  }

  .brand-block h1 {
    font-size: 16px;
  }

  .sub {
    margin-top: 4px;
    font-size: 11px;
  }

  .search-shell {
    margin-bottom: 10px;
  }

  .search {
    min-height: 44px;
    font-size: 16px;
  }

  .filter-groups {
    gap: 8px;
  }

  .filter-section {
    display: block;
    width: 100%;
    min-width: 0;
  }

  .group-label {
    display: none;
  }

  .option-list {
    display: flex;
    width: 100%;
    min-width: 0;
    gap: 4px;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .option-list::-webkit-scrollbar {
    display: none;
  }

  .option-button {
    flex: 0 0 auto;
    width: auto;
    min-height: 44px;
    padding: 8px 12px;
    white-space: nowrap;
  }

  main {
    padding: 14px 10px calc(32px + var(--compare-height) + env(safe-area-inset-bottom));
  }

  .board {
    padding: 14px 12px 16px;
    border-radius: 14px;
  }

  .boardtop {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
  }

  .boardtop h2 {
    font-size: 14px;
  }

  .seg {
    width: 100%;
    margin-left: 0;
  }

  .seg button {
    flex: 1 1 50%;
    min-height: 44px;
    padding-inline: 8px;
  }

  .legend {
    gap: 7px 10px;
    margin-top: 8px;
  }

  .legend-tiers {
    gap: 6px;
  }

  .board-help {
    margin: 6px 0 8px;
  }

  .group-heading {
    margin-top: 12px;
  }

  .rank-row {
    grid-template-columns: 40px 25px minmax(0, 1fr) auto;
    grid-template-rows: auto auto;
    column-gap: 7px;
    row-gap: 6px;
    min-height: 66px;
    padding: 8px 4px;
  }

  .checkmark {
    grid-column: 1;
    grid-row: 1 / 3;
    width: 22px;
    height: 22px;
  }

  .rank-number {
    grid-column: 2;
    grid-row: 1;
  }

  .chip-label {
    grid-column: 3;
    grid-row: 1;
    grid-template-columns: 4px minmax(0, 1fr);
    gap: 7px;
  }

  .family-bar {
    height: 30px;
  }

  .chip-copy {
    display: grid;
    grid-template-columns: auto auto minmax(0, 1fr);
    align-items: center;
  }

  .config-label {
    grid-column: 1 / -1;
    display: block;
    margin: 3px 0 0;
    overflow: visible;
    font-size: 10px;
    line-height: 1.3;
    text-overflow: clip;
    white-space: normal;
  }

  .score-value {
    grid-column: 4;
    grid-row: 1;
    padding-left: 4px;
    font-size: 13px;
  }

  .score-track {
    grid-column: 2 / 5;
    grid-row: 2;
    width: 100%;
    height: 10px;
  }

  .score-diff {
    display: none;
  }

  .data-footer {
    font-size: 11px;
  }

  .compare-drawer {
    bottom: calc(8px + env(safe-area-inset-bottom));
    width: calc(100% - 16px);
    max-height: calc(100dvh - 16px - env(safe-area-inset-bottom));
    padding: 12px 12px 14px;
    border-radius: 18px;
  }

  .share-button,
  .icon-button {
    min-height: 44px;
  }

  .icon-button {
    width: 44px;
  }

  .compare-row {
    grid-template-columns: 92px 1fr 44px 1fr 92px;
    gap: 4px;
    min-height: 30px;
    font-size: 11px;
  }

  .delta-badge {
    margin-inline: 3px;
    padding-inline: 4px;
  }
}

@media (max-width: 380px) {
  .board {
    padding-inline: 10px;
  }

  .legend-tiers {
    display: none;
  }

  .compare-row {
    grid-template-columns: 84px 1fr 40px 1fr 84px;
  }

  .compare-value {
    font-size: 10px;
  }
}

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