:root,
body[data-theme="light"] {
  color-scheme: light;
  --canvas: #f4f6f8;
  --surface: #ffffff;
  --surface-muted: #f7f8f9;
  --ink: #17212b;
  --ink-soft: #43505d;
  --muted: #73808c;
  --line: #dfe5ea;
  --line-strong: #c9d2da;
  --accent: #0e766f;
  --accent-soft: #dff2ef;
  --shadow: 0 1px 2px rgb(23 33 43 / 5%), 0 12px 30px rgb(23 33 43 / 6%);
  --radius: 8px;
  --shell: 1280px;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --canvas: #10161d;
    --surface: #151d26;
    --surface-muted: #19232d;
    --ink: #ecf1f5;
    --ink-soft: #c3ced7;
    --muted: #91a0ad;
    --line: #2b3945;
    --line-strong: #3b4c5b;
    --accent: #5ec7bd;
    --accent-soft: #173b39;
    --shadow: 0 1px 2px rgb(0 0 0 / 22%), 0 14px 32px rgb(0 0 0 / 18%);
  }
}

body[data-theme="dark"] {
  color-scheme: dark;
  --canvas: #10161d;
  --surface: #151d26;
  --surface-muted: #19232d;
  --ink: #ecf1f5;
  --ink-soft: #c3ced7;
  --muted: #91a0ad;
  --line: #2b3945;
  --line-strong: #3b4c5b;
  --accent: #5ec7bd;
  --accent-soft: #173b39;
  --shadow: 0 1px 2px rgb(0 0 0 / 22%), 0 14px 32px rgb(0 0 0 / 18%);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select {
  font: inherit;
}

button,
select {
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

.shell {
  width: min(calc(100% - 40px), var(--shell));
  margin-inline: auto;
}

.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;
}

.skip-link {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 100;
  padding: 9px 12px;
  border-radius: 6px;
  background: var(--ink);
  color: var(--surface);
  transform: translateY(-160%);
  transition: transform 160ms ease;
}

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

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--canvas) 92%, transparent);
  backdrop-filter: blur(16px);
}

.header-content {
  display: flex;
  min-height: 66px;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand {
  display: inline-flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  font-weight: 720;
}

.brand-mark {
  display: grid;
  width: 31px;
  height: 31px;
  flex: 0 0 auto;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: var(--surface);
  color: var(--accent);
  font-weight: 780;
}

.brand-mark img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 18px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 620;
}

.header-nav a {
  transition: color 150ms ease;
}

.header-nav a:hover {
  color: var(--ink);
}

.page-heading {
  padding: 48px 0 30px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.12em;
}

.heading-row {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
}

h1 {
  margin: 0;
  font-size: clamp(30px, 4vw, 44px);
  line-height: 1.08;
  letter-spacing: 0;
}

.page-description {
  max-width: 740px;
  margin: 12px 0 0;
  color: var(--ink-soft);
  line-height: 1.7;
  white-space: pre-line;
}

.user-state {
  margin: 0;
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 13px;
  text-align: right;
}

.filter-region {
  padding: 20px 0;
  border-bottom: 1px solid var(--line);
}

.filter-bar {
  display: grid;
  grid-template-columns: minmax(210px, 1.55fr) repeat(3, minmax(130px, 0.7fr)) auto;
  gap: 10px;
  align-items: end;
}

.search-field,
.select-field {
  display: grid;
  min-width: 0;
  gap: 5px;
}

.select-field span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 680;
}

.search-field input,
.select-field select {
  width: 100%;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  outline: none;
  background: var(--surface);
  color: var(--ink);
  padding: 0 11px;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.search-field input:focus,
.select-field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent);
}

.reset-button {
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: transparent;
  color: var(--ink-soft);
  padding: 0 12px;
  font-size: 13px;
  font-weight: 650;
}

.reset-button:hover {
  border-color: var(--line-strong);
  color: var(--ink);
}

.catalog-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 13px;
  color: var(--muted);
  font-size: 12px;
}

#price-mode-note {
  margin-left: 8px;
}

.catalog-region {
  padding: 32px 0 56px;
}

.catalog-content {
  display: grid;
  gap: 40px;
}

.group-section {
  display: grid;
  gap: 15px;
}

.group-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 20px;
}

.group-heading-main {
  min-width: 0;
}

.group-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
}

.group-title {
  margin: 0;
  font-size: 19px;
  line-height: 1.3;
  letter-spacing: 0;
}

.group-description {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
  white-space: pre-line;
}

.group-note {
  margin: 8px 0 0;
  color: #a46018;
  font-size: 12px;
}

.rate-chip,
.plain-chip,
.platform-chip,
.billing-chip,
.tier-label {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  border-radius: 5px;
  padding: 3px 7px;
  font-size: 11px;
  font-weight: 680;
  line-height: 1;
}

.rate-chip {
  border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--line));
  background: var(--accent-soft);
  color: var(--accent);
}

.rate-chip.is-custom s {
  margin-right: 4px;
  opacity: 0.55;
}

.plain-chip {
  border: 1px solid var(--line);
  background: var(--surface-muted);
  color: var(--muted);
}

.model-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.model-card {
  position: relative;
  display: flex;
  min-width: 0;
  flex-direction: column;
  min-height: 278px;
  border: 1px solid var(--line);
  border-top: 3px solid var(--platform);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.model-card[data-platform="anthropic"] {
  --platform: #d97706;
  --platform-soft: #fff3dc;
}

.model-card[data-platform="openai"] {
  --platform: #16856b;
  --platform-soft: #def5ec;
}

.model-card[data-platform="gemini"] {
  --platform: #2d73c8;
  --platform-soft: #e1efff;
}

.model-card[data-platform="antigravity"] {
  --platform: #8658c7;
  --platform-soft: #eee6fb;
}

.model-card[data-platform="grok"] {
  --platform: #616d78;
  --platform-soft: #e9ecef;
}

.model-card[data-platform="composite"] {
  --platform: #117f99;
  --platform-soft: #def3f7;
}

@media (prefers-color-scheme: dark) {
  .model-card[data-platform="anthropic"] { --platform-soft: #3b2a12; }
  .model-card[data-platform="openai"] { --platform-soft: #133b31; }
  .model-card[data-platform="gemini"] { --platform-soft: #173354; }
  .model-card[data-platform="antigravity"] { --platform-soft: #33254b; }
  .model-card[data-platform="grok"] { --platform-soft: #27323c; }
  .model-card[data-platform="composite"] { --platform-soft: #173842; }
}

.card-head {
  padding: 16px 16px 0;
}

.card-tags {
  display: flex;
  min-width: 0;
  flex-wrap: wrap;
  gap: 6px;
}

.platform-chip {
  background: var(--platform-soft);
  color: var(--platform);
}

.billing-chip {
  background: var(--surface-muted);
  color: var(--muted);
}

.model-name {
  margin: 12px 0 0;
  overflow-wrap: anywhere;
  font-size: 17px;
  font-weight: 730;
  letter-spacing: 0;
  line-height: 1.28;
}

.card-group {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.card-price {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.price-label {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 660;
}

.price-value {
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: 0;
}

.price-unit {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 11px;
}

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

.token-price-grid > div {
  min-width: 0;
}

.tier-list {
  display: grid;
  gap: 6px;
}

.tier-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: baseline;
  gap: 8px;
  padding-top: 7px;
  border-top: 1px solid var(--line);
}

.tier-row:first-child {
  border-top: 0;
  padding-top: 0;
}

.tier-label {
  flex: 0 0 auto;
  background: var(--surface-muted);
  color: var(--muted);
}

.tier-values {
  min-width: 0;
  overflow: hidden;
  color: var(--ink-soft);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  line-height: 1.55;
  text-align: right;
  overflow-wrap: anywhere;
  white-space: normal;
}

.card-footer {
  display: flex;
  min-height: 57px;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  margin-top: auto;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  background: var(--surface-muted);
}

.official-price {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.official-price span:first-child {
  color: var(--muted);
  font-size: 10px;
  font-weight: 650;
}

.official-price span:last-child {
  overflow: hidden;
  color: var(--ink-soft);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-rate {
  flex: 0 0 auto;
  color: var(--platform);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  font-weight: 750;
}

.loading-state,
.empty-state,
.error-state {
  display: grid;
  min-height: 260px;
  place-content: center;
  justify-items: center;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--muted);
  text-align: center;
}

.catalog-skeleton {
  display: grid;
  gap: 15px;
}

.skeleton-group-heading {
  display: grid;
  gap: 8px;
  max-width: 280px;
}

.skeleton {
  display: block;
  border-radius: 5px;
  background: linear-gradient(
    90deg,
    var(--surface-muted) 20%,
    color-mix(in srgb, var(--surface-muted) 54%, var(--surface)) 42%,
    var(--surface-muted) 64%
  );
  background-size: 200% 100%;
  animation: skeleton-shimmer 1250ms ease-in-out infinite;
}

.skeleton-chip {
  width: 68px;
  height: 24px;
}

.skeleton-chip.short {
  width: 44px;
}

.skeleton-title {
  width: 176px;
  height: 22px;
}

.skeleton-meta {
  width: 122px;
  height: 14px;
}

.model-card-skeleton {
  pointer-events: none;
}

.model-card-skeleton .card-head {
  display: grid;
  gap: 12px;
}

.model-card-skeleton .card-tags {
  min-height: 24px;
}

.skeleton-model-name {
  width: min(100%, 216px);
  height: 20px;
}

.skeleton-group-name {
  width: 94px;
  height: 14px;
}

.skeleton-label {
  width: 92px;
  height: 13px;
}

.skeleton-price {
  width: 82px;
  height: 22px;
}

.skeleton-footer {
  width: 136px;
  height: 12px;
}

.skeleton-rate {
  width: 34px;
  height: 16px;
}

.loading-state {
  grid-auto-flow: column;
  gap: 10px;
}

.loading-dot {
  width: 16px;
  height: 16px;
  border: 2px solid color-mix(in srgb, var(--accent) 25%, transparent);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 800ms linear infinite;
}

.empty-title,
.error-title {
  margin: 0;
  color: var(--ink);
  font-size: 17px;
  font-weight: 720;
}

.empty-copy,
.error-copy {
  max-width: 480px;
  margin: 6px 20px 0;
  font-size: 13px;
}

.error-state {
  border-color: color-mix(in srgb, #c2410c 35%, var(--line));
}

.error-action {
  margin-top: 14px;
  border-bottom: 1px solid currentColor;
  color: var(--accent);
  font-size: 13px;
  font-weight: 680;
}

.site-footer {
  border-top: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
}

/* AppLayout 的自定义菜单 iframe 会传入 ui_mode=embedded。 */
html.is-embedded .site-header,
body.is-embedded .site-header,
html.is-embedded .site-footer,
body.is-embedded .site-footer {
  display: none;
}

html.is-embedded .page-heading,
body.is-embedded .page-heading {
  padding: 20px 0 14px;
  border-bottom: 0;
  background: transparent;
}

html.is-embedded .page-heading .eyebrow,
body.is-embedded .page-heading .eyebrow,
html.is-embedded .page-heading h1,
body.is-embedded .page-heading h1,
html.is-embedded .user-state,
body.is-embedded .user-state {
  display: none;
}

html.is-embedded .page-description,
body.is-embedded .page-description {
  max-width: none;
  margin: 0;
}

html.is-embedded .filter-region,
body.is-embedded .filter-region {
  padding: 0 0 18px;
}

html.is-embedded .catalog-region,
body.is-embedded .catalog-region {
  padding-top: 24px;
}

html.is-embedded .catalog-content,
body.is-embedded .catalog-content {
  gap: 32px;
}

html.is-embedded body.is-loading main {
  display: none;
}

body.is-loading .reset-button {
  display: none;
}

.footer-content {
  display: flex;
  min-height: 64px;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes skeleton-shimmer {
  to { background-position: -200% 0; }
}

@media (max-width: 1040px) {
  .filter-bar {
    grid-template-columns: minmax(220px, 1fr) repeat(2, minmax(140px, 0.7fr));
  }

  .reset-button {
    justify-self: start;
  }

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

@media (max-width: 650px) {
  .shell {
    width: min(calc(100% - 28px), var(--shell));
  }

  .header-content {
    min-height: 58px;
  }

  .header-nav {
    gap: 12px;
  }

  .page-heading {
    padding: 34px 0 25px;
  }

  .heading-row,
  .group-heading,
  .footer-content {
    align-items: start;
    flex-direction: column;
  }

  .user-state {
    text-align: left;
  }

  .filter-bar {
    grid-template-columns: 1fr 1fr;
  }

  .search-field {
    grid-column: span 2;
  }

  .reset-button {
    grid-column: span 2;
    width: 100%;
  }

  #price-mode-note {
    width: 100%;
    margin-left: 0;
  }

  .catalog-region {
    padding-top: 26px;
  }

  .catalog-content {
    gap: 32px;
  }

  .model-grid {
    grid-template-columns: 1fr;
  }

  .model-card {
    min-height: 0;
  }

  .footer-content {
    justify-content: center;
    min-height: 74px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
