:root {
  --ink: #17201f;
  --ink-soft: #243330;
  --muted: #637170;
  --line: #d6ded9;
  --paper: #f3f6f2;
  --paper-cool: #e8eef0;
  --surface: #fffefa;
  --surface-strong: #ffffff;
  --charcoal: #0f1715;
  --teal: #087b69;
  --teal-pale: #dcefe8;
  --blue: #315d8c;
  --coral: #c44e45;
  --gold: #b77a22;
  --signal-green: #07894a;
  --signal-red: #d7332f;
  color: var(--ink);
  background: var(--paper);
  font-family: 'Noto Sans SC', sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--paper); }
body {
  min-width: 0;
  margin: 0;
  background:
    linear-gradient(180deg, rgba(232, 238, 240, .82) 0, rgba(243, 246, 242, 0) 360px),
    repeating-linear-gradient(90deg, rgba(23, 32, 31, .035) 0 1px, transparent 1px 72px),
    var(--paper);
}
button, a { font: inherit; }
button { cursor: pointer; }
button:focus-visible, a:focus-visible { outline: 3px solid rgba(49, 93, 140, .34); outline-offset: 3px; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid rgba(23, 32, 31, .12);
  background: rgba(255, 254, 250, .88);
  backdrop-filter: blur(18px);
}
.topbar-inner {
  width: min(1480px, 100%);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin: 0 auto;
  padding: 14px clamp(18px, 4vw, 56px);
}
.brand {
  display: inline-flex;
  align-items: center;
  color: var(--ink);
  font: 500 17px 'DM Mono', monospace;
  text-decoration: none;
}
.brand span { color: var(--teal); }
.topbar-tag {
  color: var(--muted);
  font: 500 11px 'DM Mono', monospace;
  white-space: nowrap;
}

.market-content {
  width: min(1480px, 100%);
  margin: 0 auto;
  padding: 38px clamp(18px, 4vw, 56px) 72px;
}
.market-head {
  position: relative;
  display: grid;
  grid-template-columns: minmax(190px, 1fr) minmax(340px, auto) minmax(160px, 1fr);
  align-items: end;
  gap: 28px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 8px;
  padding: 30px clamp(22px, 4vw, 38px);
  color: #f4fbf7;
  background:
    linear-gradient(135deg, #0f1715 0%, #17352e 56%, #10242a 100%);
  box-shadow: 0 18px 42px rgba(16, 33, 30, .18);
}
.market-head::after {
  content: '';
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(90deg, rgba(255, 255, 255, .075) 0 1px, transparent 1px 56px),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, .05) 0 1px, transparent 1px 56px);
  opacity: .42;
  pointer-events: none;
}
.market-title-block, .model-recommendation, .result-note { position: relative; z-index: 1; }
.eyebrow {
  margin: 0 0 10px;
  color: #84d9c3;
  font: 500 11px 'DM Mono', monospace;
}
h1, h2, p { margin-top: 0; }
h1 {
  margin-bottom: 0;
  font: 700 38px/1.12 'Noto Serif SC', serif;
  letter-spacing: 0;
}
.model-recommendation {
  min-width: 0;
  align-self: center;
  border-right: 1px solid rgba(132, 217, 195, .22);
  border-left: 1px solid rgba(132, 217, 195, .22);
  padding: 4px 30px 5px;
  text-align: center;
}
.model-recommendation-copy {
  margin: 0 0 5px;
  color: #a7c9bf;
  font: 500 11px/1.35 'DM Mono', monospace;
}
.model-recommendation-name {
  display: block;
  overflow-wrap: anywhere;
  color: #ffe3a0;
  font: 500 18px/1.28 'DM Mono', monospace;
}
.model-recommendation-metrics {
  margin: 6px 0 0;
  color: #d3e8e0;
  font: 400 11px/1.45 'DM Mono', monospace;
}
.model-recommendation-copy, .model-recommendation-name, .model-recommendation-metrics {
  overflow-wrap: anywhere;
}
.result-note {
  min-width: 148px;
  justify-self: end;
  display: grid;
  gap: 3px;
  margin: 0;
  border: 1px solid rgba(132, 217, 195, .38);
  border-radius: 8px;
  padding: 11px 14px;
  color: #dff7ee;
  background: rgba(7, 27, 23, .56);
  text-align: left;
  white-space: nowrap;
}
.result-note strong {
  color: #f2fff9;
  font: 500 13px 'DM Mono', monospace;
}
.result-note span {
  color: #9fc8bc;
  font: 400 10px 'DM Mono', monospace;
}

.model-benchmark[hidden] { display: none; }
.model-benchmark {
  margin-top: 18px;
  overflow: hidden;
  border: 1px solid rgba(23, 32, 31, .14);
  border-radius: 8px;
  padding: 20px;
  color: #dce8e4;
  background: #101918;
  box-shadow: 0 16px 36px rgba(16, 25, 24, .14);
}
.model-benchmark-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 16px;
}
.benchmark-eyebrow {
  margin: 0 0 4px;
  color: #82b4a7;
  font: 500 10px 'DM Mono', monospace;
}
.model-benchmark h2 {
  margin: 0;
  color: #f5faf8;
  font: 600 18px/1.3 'Noto Serif SC', serif;
  letter-spacing: 0;
}
.benchmark-date {
  margin: 0;
  color: #8eaaa2;
  font: 500 11px 'DM Mono', monospace;
}
.model-groups { display: grid; gap: 10px; }
.model-family-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(148px, 1fr));
  gap: 10px;
}
.model-card {
  --model-accent: #d9e4e1;
  position: relative;
  min-width: 0;
  min-height: 104px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(62px, .64fr);
  grid-template-rows: auto 1fr auto;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--model-accent), transparent 62%);
  border-top: 4px solid var(--model-accent);
  border-radius: 8px;
  background: color-mix(in srgb, var(--model-accent), #101918 91%);
}
.model-card.family-sol { --model-accent: #f1b91c; }
.model-card.family-terra { --model-accent: #438cf4; }
.model-card.family-luna { --model-accent: #d5e1ed; }
.model-card.family-legacy { --model-accent: #24cddd; }
.model-card-name {
  min-width: 0;
  overflow: hidden;
  padding: 10px 12px 0;
  color: color-mix(in srgb, var(--model-accent), white 28%);
  font: 600 12px 'DM Mono', monospace;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.model-card-score {
  grid-row: 2 / 4;
  align-self: center;
  padding: 2px 12px 11px;
  color: var(--model-accent);
  font: 500 31px/1 'DM Mono', monospace;
}
.model-card-cost, .model-card-duration {
  display: grid;
  place-items: center;
  border-left: 1px solid color-mix(in srgb, var(--model-accent), transparent 68%);
  color: var(--model-accent);
  font: 500 11px 'DM Mono', monospace;
  white-space: nowrap;
}
.model-card-cost {
  grid-column: 2;
  grid-row: 1 / 3;
  align-self: stretch;
  border-bottom: 1px solid color-mix(in srgb, var(--model-accent), transparent 68%);
  padding: 8px 6px;
}
.model-card-duration {
  grid-column: 2;
  grid-row: 3;
  padding: 8px 6px;
}
.model-card-badge {
  position: absolute;
  right: 6px;
  top: 6px;
  border-radius: 3px;
  padding: 2px 5px;
  color: #0d1715;
  background: var(--model-accent);
  font-size: 9px;
  font-weight: 700;
}
.model-card.is-recommended .model-card-cost { padding-right: 43px; }
.model-card.is-recommended { box-shadow: 0 0 0 2px color-mix(in srgb, var(--model-accent), transparent 34%); }
.model-card.is-below-threshold { opacity: .58; }

.market-controls {
  display: flex;
  justify-content: flex-end;
  padding: 18px 0;
}
.segmented {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid rgba(23, 32, 31, .13);
  border-radius: 8px;
  background: rgba(255, 254, 250, .84);
  box-shadow: 0 8px 26px rgba(23, 32, 31, .06);
}
.filter-button {
  min-width: 98px;
  border: 0;
  border-radius: 6px;
  padding: 8px 14px;
  color: var(--muted);
  background: transparent;
  font-size: 12px;
}
.filter-button:hover { color: var(--ink); background: rgba(8, 123, 105, .08); }
.filter-button.is-active {
  color: var(--surface-strong);
  background: var(--ink);
}

.market-table {
  overflow: hidden;
  border: 1px solid rgba(23, 32, 31, .12);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 18px 46px rgba(23, 32, 31, .09);
}
.table-head, .site-row {
  display: grid;
  grid-template-columns: minmax(210px, 1.18fr) minmax(128px, .62fr) minmax(130px, .62fr) minmax(360px, 2.05fr) minmax(112px, .55fr);
}
.table-head {
  min-height: 48px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  background: linear-gradient(180deg, #f9fbf8, #edf3ef);
  font-size: 11px;
}
.table-head span {
  padding: 0 18px;
  border-right: 1px solid var(--line);
}
.table-head span:last-child { border-right: 0; }
.site-row {
  position: relative;
  min-height: 92px;
  animation: entrance .4s ease both;
  animation-delay: var(--delay);
  background: var(--surface);
}
.site-row:not(:last-child) { border-bottom: 1px solid var(--line); }
.site-row::before {
  content: '';
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--site-accent);
  opacity: .72;
  transition: opacity .18s ease, width .18s ease;
}
.site-row:hover {
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--site-accent), white 90%), transparent 42%),
    var(--surface-strong);
}
.site-row:hover::before { width: 6px; opacity: 1; }
.table-cell {
  min-width: 0;
  display: flex;
  align-items: center;
  padding: 16px 18px;
  border-right: 1px solid var(--line);
  color: var(--ink);
  font-size: 13px;
}
.table-cell:last-child { border-right: 0; }
.site-identity {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 13px;
}
.site-logo {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--site-accent), white 56%);
  border-radius: 8px;
  color: color-mix(in srgb, var(--site-accent), black 8%);
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--site-accent), white 86%), #fffefa);
  font: 500 15px 'DM Mono', monospace;
}
.site-logo img { width: 100%; height: 100%; object-fit: cover; }
.site-copy {
  min-width: 0;
  display: grid;
  gap: 4px;
}
.site-copy strong {
  overflow: hidden;
  font: 700 18px/1.15 'Noto Serif SC', serif;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.site-host {
  overflow: hidden;
  color: var(--muted);
  font: 500 11px 'DM Mono', monospace;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pool-value {
  min-width: 74px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid rgba(23, 32, 31, .12);
  border-radius: 999px;
  padding: 7px 10px;
  background: #f4f8f5;
}
.pool-value strong {
  color: var(--ink);
  font: 500 13px 'DM Mono', monospace;
}
.pool-value span { color: var(--muted); font-size: 11px; }
.pool-value.pool-pro {
  border-color: rgba(8, 123, 105, .2);
  background: #edf7f2;
}
.pool-value.pool-pro strong { color: var(--teal); }
.pool-value.pool-plus {
  border-color: rgba(49, 93, 140, .2);
  background: #eef3f9;
}
.pool-value.pool-plus strong { color: var(--blue); }
.multiplier-cell {
  color: var(--blue);
  font: 700 16px 'DM Mono', monospace;
}
.stability-value {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
}
.stability-metric {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  white-space: nowrap;
}
.stability-label { color: var(--muted); font-size: 11px; }
.stability-score, .latency-value { font: 700 12px 'DM Mono', monospace; }
.stability-score::before, .latency-value::before {
  content: '';
  width: 7px;
  height: 7px;
  display: inline-block;
  margin-right: 6px;
  border-radius: 50%;
  background: currentColor;
}
.stability-score.stability-healthy { color: var(--signal-green); }
.stability-score.stability-degraded { color: var(--gold); }
.stability-score.stability-unhealthy { color: var(--signal-red); }
.stability-score.stability-unknown { color: var(--muted); }
.latency-value { color: var(--ink-soft); }
.history-summary {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}
.history-label {
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}
.availability-chart {
  width: 188px;
  flex: 0 1 188px;
  min-width: 150px;
  height: 18px;
  display: grid;
  grid-template-columns: repeat(30, minmax(2px, 1fr));
  align-items: end;
  gap: 2px;
}
.availability-bar {
  min-width: 0;
  height: 10px;
  border-radius: 2px;
  background: #aeb8b5;
}
.availability-bar.stability-healthy { height: 18px; background: var(--signal-green); }
.availability-bar.stability-degraded { height: 12px; background: var(--gold); }
.availability-bar.stability-unhealthy { height: 6px; background: var(--signal-red); }
.availability-bar.stability-unknown { height: 10px; background: #aeb8b5; }
.access-link {
  min-width: 70px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid color-mix(in srgb, var(--site-accent), black 8%);
  border-radius: 7px;
  padding: 8px 12px;
  color: #fff;
  background: color-mix(in srgb, var(--site-accent), #17201f 20%);
  font-size: 12px;
  text-decoration: none;
  white-space: nowrap;
  transition: transform .16s ease, box-shadow .16s ease;
}
.access-link:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 18px color-mix(in srgb, var(--site-accent), transparent 74%);
}
.missing-value { color: #879291; font-size: 12px; }
.empty-state {
  margin: 0;
  padding: 44px;
  color: var(--muted);
  text-align: center;
}
.empty-state.is-error { color: var(--coral); }
.loading-state {
  margin: 0;
  padding: 44px;
  color: var(--muted);
  font: 500 12px 'DM Mono', monospace;
  text-align: center;
}
.site-disclaimer {
  margin-top: 28px;
  border: 1px solid rgba(23, 32, 31, .11);
  border-radius: 8px;
  padding: 16px 18px;
  color: var(--muted);
  background: rgba(255, 254, 250, .72);
  font-size: 12px;
  line-height: 1.75;
}
.site-disclaimer p { margin: 0; }
.site-disclaimer p + p { margin-top: 4px; }
.site-disclaimer strong { color: var(--ink); font-weight: 700; }
.source-attribution {
  color: var(--teal);
  text-decoration-color: rgba(8, 123, 105, .42);
  text-underline-offset: 3px;
}
.source-attribution:hover { color: var(--blue); }

body.modal-open { overflow: hidden; }
.exit-warning[hidden] { display: none; }
.exit-warning {
  position: fixed;
  z-index: 30;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
}
.exit-warning-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(8, 13, 12, .74);
}
.exit-dialog {
  position: relative;
  width: min(760px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
  border: 1px solid #314f45;
  border-radius: 8px;
  padding: 28px;
  color: #d9e5e0;
  background:
    linear-gradient(180deg, rgba(24, 45, 39, .72), rgba(12, 21, 19, .94)),
    #0c1513;
  box-shadow: 0 24px 72px rgba(0, 0, 0, .45);
}
.exit-dialog-header {
  display: flex;
  align-items: flex-start;
  gap: 16px;
}
.risk-symbol {
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border: 1px solid #4d836d;
  border-radius: 8px;
  color: #8fe0bd;
  background: #142b22;
  font: 700 25px/1 'DM Mono', monospace;
}
.risk-eyebrow {
  margin: 1px 0 7px;
  color: #8fe0bd;
  font-size: 13px;
}
.exit-dialog h2 {
  margin: 0;
  color: #ecf3f0;
  font: 600 25px/1.25 'Noto Serif SC', serif;
  letter-spacing: 0;
}
.exit-close {
  width: 34px;
  height: 34px;
  margin-left: auto;
  border: 0;
  padding: 0;
  color: #aab8b4;
  background: transparent;
  font: 400 28px/1 sans-serif;
}
.exit-close:hover { color: #eff8f4; }
.exit-copy {
  margin: 26px 0 22px;
  color: #c7d2ce;
  font-size: 16px;
  line-height: 1.9;
}
.exit-copy strong { color: #8fe0bd; }
.exit-copy b { color: #eff8f4; font-weight: 700; }
.exit-destination {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  margin: 0;
  background: #2f4a41;
}
.exit-destination > div {
  min-width: 0;
  padding: 16px 18px;
  background: #13211e;
}
.exit-destination dt {
  margin-bottom: 6px;
  color: #91a69f;
  font-size: 11px;
}
.exit-destination dd {
  overflow: hidden;
  margin: 0;
  color: #edf6f2;
  font: 500 14px 'DM Mono', monospace;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.exit-preference {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin: 20px 0 0;
  color: #c6d3cf;
  font-size: 14px;
  cursor: pointer;
}
.exit-preference input {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: #8fe0bd;
}
.exit-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 22px;
}
.exit-button {
  min-height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
  padding: 0 20px;
  font-size: 15px;
  text-decoration: none;
}
.exit-button-secondary {
  border: 1px solid #46635b;
  color: #d5e0dc;
  background: transparent;
}
.exit-button-secondary:hover { border-color: #76988d; color: #fff; }
.exit-button-primary {
  border: 1px solid #4a9c70;
  color: #f3fff8;
  background: #1d5e3d;
}
.exit-button-primary:hover { background: #277a4e; }
.exit-hint {
  margin: 16px 0 0;
  color: #879a94;
  font-size: 12px;
  line-height: 1.6;
  text-align: center;
}

@keyframes entrance {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 1050px) {
  .market-content { padding-top: 28px; }
  .market-head {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
    gap: 20px 28px;
  }
  .model-recommendation {
    width: 100%;
    grid-column: 1 / -1;
    grid-row: 2;
    border-top: 1px solid rgba(132, 217, 195, .22);
    border-right: 0;
    border-left: 0;
    padding: 18px 0 0;
    text-align: left;
  }
  .table-head { display: none; }
  .market-table {
    overflow: visible;
    border: 0;
    background: transparent;
    box-shadow: none;
  }
  .market-rows {
    display: grid;
    gap: 12px;
  }
  .site-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    min-height: 0;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: 0 12px 30px rgba(23, 32, 31, .07);
  }
  .site-row:not(:last-child) { border-bottom: 1px solid var(--line); }
  .site-row::before { opacity: 1; }
  .table-cell {
    min-height: 76px;
    align-items: start;
    flex-direction: column;
    gap: 8px;
    padding: 14px 16px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .table-cell:nth-child(2) { border-right: 1px solid var(--line); }
  .table-cell:last-child { border-bottom: 0; }
  .table-cell::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 10px;
  }
  .site-cell, .stability-cell, .access-cell { grid-column: 1 / -1; }
  .site-cell, .stability-cell { border-right: 0 !important; }
  .site-copy strong { font-size: 18px; }
  .history-summary {
    flex: 1 1 100%;
    flex-wrap: wrap;
    margin-left: 0;
  }
  .availability-chart { flex: 0 1 190px; }
  .access-link { width: 100%; }
  .exit-dialog { padding: 24px; }
}

@media (max-width: 560px) {
  .topbar-inner { padding: 12px 16px; }
  .topbar-tag { font-size: 9px; }
  .market-content { padding: 24px 14px 44px; }
  .market-head {
    grid-template-columns: minmax(0, 1fr);
    padding: 23px 16px;
  }
  h1 { font-size: 30px; }
  .model-recommendation { grid-column: 1; grid-row: 2; }
  .model-recommendation-name { font-size: 16px; }
  .model-recommendation-metrics { font-size: 10px; }
  .result-note { width: 100%; grid-column: 1; grid-row: 3; }
  .market-controls { justify-content: stretch; }
  .segmented { width: 100%; }
  .filter-button {
    flex: 1;
    min-width: 0;
    padding-inline: 8px;
  }
  .result-note {
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
  }
  .model-benchmark { padding: 16px 12px; }
  .model-family-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .model-card { min-height: 98px; }
  .model-card-score { font-size: 27px; }
  .model-card-name { padding-inline: 9px; font-size: 10px; }
  .model-card-cost, .model-card-duration { font-size: 9px; }
  .result-note span { text-align: right; }
  .table-cell { min-height: 68px; padding: 12px 14px; }
  .table-cell:nth-child(2) { border-right: 1px solid var(--line); }
  .site-cell { min-height: 76px; }
  .stability-cell { min-height: 88px; }
  .access-cell { min-height: 62px; }
  .history-summary {
    display: grid;
    width: 100%;
    gap: 6px;
  }
  .history-label { white-space: normal; }
  .availability-chart {
    width: 100%;
    min-width: 0;
  }
  .site-disclaimer { padding: 15px 16px; }
  .exit-warning { padding: 12px; }
  .exit-dialog {
    max-height: calc(100vh - 24px);
    padding: 20px;
  }
  .exit-dialog-header { gap: 12px; }
  .risk-symbol {
    width: 40px;
    height: 40px;
    font-size: 21px;
  }
  .exit-dialog h2 { font-size: 22px; }
  .exit-copy {
    margin: 20px 0;
    font-size: 15px;
    line-height: 1.8;
  }
  .exit-destination { grid-template-columns: 1fr; }
  .exit-actions { flex-direction: column-reverse; }
  .exit-button { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .site-row { animation: none; }
  .access-link { transition: none; }
}
