/* ============================================================
   OjToken 模型广场 · 布局改版 (20261119 layout)
   参照 api.apiexrouter.top 的紧凑式布局：
   1) 标题左对齐、压缩首屏
   2) 左侧筛选栏 -> 整宽卡片内的横向药丸筛选行
   3) 搜索框并入卡片底部
   仅作用于 /pricing（html[data-ojp] 由 pricing-layout.js 打标）
   ============================================================ */

@media (min-width: 1280px) {
  html[data-ojp] header.mx-auto.max-w-3xl {
    max-width: none;
    margin: 0 0 14px;
    padding-top: 6px;
    text-align: left;
  }

  html[data-ojp] header.mx-auto.max-w-3xl h1 {
    font-size: 32px;
    line-height: 1.2;
    letter-spacing: -0.02em;
  }

  html[data-ojp] header.mx-auto.max-w-3xl > p:nth-of-type(1) {
    margin-top: 6px;
    font-size: 12.5px;
    color: var(--muted-foreground);
  }

  html[data-ojp] header.mx-auto.max-w-3xl > p:nth-of-type(2) {
    margin-top: 2px;
    max-width: none;
    font-size: 12.5px;
    line-height: 1.6;
    color: var(--muted-foreground);
    opacity: 0.75;
  }

  /* 栅格：单列，筛选卡与排序条贴合成一张卡 */
  html[data-ojp] div.grid:has(> aside) {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
  }

  html[data-ojp] aside {
    display: block;
    position: static;
    width: 100%;
    max-height: none;
    overflow: visible;
    padding: 14px 18px 12px;
    border-radius: 14px 14px 0 0;
    border-bottom: 0;
    background: var(--card);
    box-shadow: none;
  }

  /* 主区第一条（排序/视图工具条）被视为同一张卡的下半段 */
  html[data-ojp] main > div:first-child {
    border-radius: 0 0 14px 14px;
    border-top: 1px solid var(--border);
    padding: 8px 18px;
  }

  /* 卡内顶部：模型广场 tab + 重置 */
  html[data-ojp] aside .ojp-tabs {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin: 0;
    padding: 2px 0 10px;
    border-bottom: 1px solid var(--border);
  }

  html[data-ojp] aside .ojp-tab {
    font-size: 14px;
    font-weight: 600;
    color: var(--foreground);
    letter-spacing: -0.01em;
  }

  /* 隐藏原生「筛选」标题区 */
  html[data-ojp] aside > div.mb-2\.5 {
    display: none;
  }

  /* 筛选组容器改为纵向 flex，便于用 order 排布（供应商置顶） */
  html[data-ojp] aside > div.space-y-1 {
    display: flex;
    flex-direction: column;
  }

  /* 每个筛选组：左标签列 + 右侧药丸换行区 */
  html[data-ojp] aside div[data-slot="collapsible"] {
    display: grid;
    grid-template-columns: 84px minmax(0, 1fr);
    gap: 10px;
    align-items: start;
    padding: 6px 0;
    border: 0;
  }

  html[data-ojp] aside [data-slot="collapsible-trigger"] {
    padding: 3px 0 0;
    cursor: default;
    pointer-events: none;
  }

  html[data-ojp] aside [data-slot="collapsible-trigger"] > span {
    font-size: 12px;
    font-weight: 500;
    color: var(--muted-foreground);
    letter-spacing: 0;
  }

  html[data-ojp] aside [data-slot="collapsible-trigger"] svg {
    display: none;
  }

  html[data-ojp] aside [data-slot="collapsible-content"] > div {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 0;
  }

  /* 药丸 */
  html[data-ojp] aside button[aria-pressed] {
    height: auto;
    padding: 3px 10px;
    border-radius: 999px;
    border: 1px solid transparent;
    background: var(--ojp-pill, #f3f4f6);
    color: var(--ojp-pill-fg, #40454d);
    font-size: 12px;
    line-height: 1.55;
    font-weight: 500;
    box-shadow: none;
    transition: background-color 0.14s ease, color 0.14s ease;
  }

  html[data-ojp] aside button[aria-pressed]:hover {
    background: var(--ojp-pill-hover, #e8eaee);
    color: var(--ojp-pill-fg, #1a1d22);
  }

  html[data-ojp] aside button[aria-pressed="true"] {
    background: var(--ojp-pill-active, #17191d);
    color: #ffffff;
  }

  html[data-ojp] aside button[aria-pressed="true"]:hover {
    background: var(--ojp-pill-active, #17191d);
    color: #ffffff;
  }

  /* 分组倍率 / 数量小标签 */
  html[data-ojp] aside .ojp-badge {
    border-radius: 6px;
    padding: 1px 6px;
    margin-left: 2px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.01em;
  }

  html[data-ojp] aside .ojp-badge.ojp-ratio {
    background: var(--ojp-ratio-bg, #e6f8ee);
    color: var(--ojp-ratio-fg, #0a9f64);
  }

  html[data-ojp] aside .ojp-badge.ojp-count {
    background: var(--ojp-count-bg, #eceef1);
    color: var(--ojp-count-fg, #7c828c);
  }

  html[data-ojp] aside button[aria-pressed="true"] .ojp-badge {
    background: rgba(255, 255, 255, 0.16);
    color: #cfe9dc;
  }

  /* 卡片底部搜索行，与筛选行同栅格 */
  html[data-ojp] aside .ojp-searchrow {
    display: grid;
    grid-template-columns: 84px minmax(0, 1fr);
    gap: 10px;
    align-items: center;
    margin-top: 6px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
  }

  html[data-ojp] aside .ojp-searchrow > span {
    font-size: 12px;
    font-weight: 500;
    color: var(--muted-foreground);
  }

  html[data-ojp] aside .ojp-searchcell {
    max-width: 340px;
    margin: 0;
  }

  html[data-ojp] aside .ojp-searchcell > div {
    margin: 0;
    max-width: none;
  }

  html[data-ojp] aside .ojp-searchcell input {
    height: 34px;
    border-radius: 8px;
    font-size: 13px;
    padding-left: 34px;
  }

  /* 排序工具条密度 */
  html[data-ojp] main > div:first-child .flex.flex-wrap {
    row-gap: 6px;
  }

  /* 倍率行：自建药丸，补齐基础排版 */
  html[data-ojp] aside button[data-ojr-pill] {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
    cursor: pointer;
    font-family: inherit;
  }

  html[data-ojp] aside button[data-ojr-pill] .ojp-badge {
    font-variant-numeric: tabular-nums;
  }
}

/* 深色主题下的药丸配色 */
@media (min-width: 1280px) {
  html.dark[data-ojp] aside {
    --ojp-pill: rgba(255, 255, 255, 0.07);
    --ojp-pill-hover: rgba(255, 255, 255, 0.13);
    --ojp-pill-fg: #d5d8dd;
    --ojp-pill-active: #f5f6f8;
    --ojp-ratio-bg: rgba(46, 204, 132, 0.14);
    --ojp-ratio-fg: #5fdc9f;
  }

  html.dark[data-ojp] aside button[aria-pressed="true"] {
    color: #16181c;
  }

  html.dark[data-ojp] aside button[aria-pressed="true"] > span:not(.truncate) {
    background: rgba(0, 0, 0, 0.18);
    color: #10754a;
  }
}

/* 标签改名：属性驱动，避免改写 React 文本节点 */
html[data-ojp] aside [data-slot="collapsible-trigger"] > span[data-ojp-title] {
  position: relative;
  color: transparent !important;
}
html[data-ojp] aside [data-slot="collapsible-trigger"] > span[data-ojp-title]::after {
  content: attr(data-ojp-title);
  position: absolute;
  left: 0;
  top: 0;
  color: var(--muted-foreground);
  white-space: nowrap;
}

/* 动态数量：属性驱动角标 */
html[data-ojp] aside button[aria-pressed][data-ojp-count]::after {
  content: attr(data-ojp-count);
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  background: var(--ojp-count-bg, #eceef1);
  color: var(--ojp-count-fg, #7c828c);
}
html[data-ojp] aside button[aria-pressed="true"][data-ojp-count]::after {
  background: rgba(255, 255, 255, 0.16);
  color: #cfe9dc;
}
html[data-ojp] aside button[aria-pressed][data-ojp-count] > span.ojp-count {
  display: none;
}

