/* 模型广场（M3 · 详情优先）：左窄列表 + 右应用商店式详情页 */

.market-layout {
  display: grid;
  min-height: 100vh;
  margin-left: var(--rail-width);
  padding: calc(var(--header-height) + 18px) 22px 32px;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.market-list {
  position: sticky;
  top: calc(var(--header-height) + 18px);
  display: grid;
  max-height: calc(100vh - var(--header-height) - 50px);
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  gap: 12px;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
}

.market-search input {
  width: 100%;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: var(--field-bg);
  font-size: 13px;
}

.market-search input:focus {
  border-color: var(--accent);
  outline: 2px solid var(--accent-soft);
}

.market-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.market-filters button {
  min-height: 28px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface);
  font-size: 11px;
  font-weight: 600;
}

.market-filters button:hover,
.market-filters button.active {
  border-color: var(--accent);
  color: white;
  background: var(--accent);
}

.market-groups {
  display: grid;
  min-height: 0;
  align-content: start;
  overflow: auto;
  gap: 14px;
  padding-right: 2px;
}

.market-group > h2 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 0 6px;
  padding: 0 4px;
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
}

.market-group > h2 small {
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
}

/* 一行 = 图标 + 两行文字：第一行名称（可带 Hot / New），第二行 厂商 · 能力 ‖ 价格 · 可用点 */
.market-item {
  position: relative;
  display: grid;
  width: 100%;
  align-items: center;
  padding: 7px 8px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 10px;
  text-align: left;
}

.market-item:hover {
  background: var(--surface-hover);
}

.market-item[aria-current="true"] {
  border-color: var(--accent-line);
  background: var(--accent-soft);
}

.market-item[aria-current="true"]::before {
  position: absolute;
  top: 9px;
  bottom: 9px;
  left: -8px;
  width: 3px;
  border-radius: 3px;
  background: var(--accent);
  content: "";
}

/* 缩略块：厂商真实图标居中，底色按模型 id 淡淡区分 */
.market-thumb {
  display: grid;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: hsl(var(--model-hue, 220) 45% 96%);
  place-items: center;
}

.market-thumb img {
  width: 62%;
  height: 62%;
  object-fit: contain;
}

.market-thumb[data-vendor="openai"] img,
.market-thumb[data-vendor="wavespeed-ai"] img {
  border-radius: 22%;
}

.market-thumb[data-external="true"] {
  border-style: dashed;
  background: var(--surface-sunken);
}

.market-item-text {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.market-item-text strong {
  overflow: hidden;
  font-size: 12.5px;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Hot / New 角标（与创作台下拉同色）：跟在名字后面 */
.market-item-text strong em {
  margin-left: 5px;
  padding: 1px 5px;
  border-radius: 999px;
  color: var(--accent-text);
  background: rgba(76, 99, 210, 0.14);
  font-size: 9px;
  font-style: normal;
  font-weight: 800;
  vertical-align: 1px;
}

.market-item-text strong em[data-tone="new"] {
  color: #6d28d9;
  background: rgba(124, 58, 237, 0.14);
}

.market-item-text strong em[data-tone="hot"] {
  color: #c2410c;
  background: rgba(234, 88, 12, 0.14);
}

.market-item-meta {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.market-item-text small {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.market-item-side {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 5px;
  color: var(--muted-strong);
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
}

.market-item-side i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--line-strong);
}

.market-item-side i[data-state="available"] {
  background: var(--success);
}

.market-toggle {
  width: 100%;
  min-height: 34px;
  padding: 0 10px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  color: var(--muted);
  background: transparent;
  font-size: 11px;
}

.market-toggle:hover {
  color: var(--text);
  background: var(--surface-hover);
}

.market-source {
  margin: 0;
  padding: 0 4px;
  color: var(--muted);
  font-size: 10px;
}

/* 详情页 */

.market-detail {
  display: grid;
  min-width: 0;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  gap: 20px;
}

.detail-hero {
  display: grid;
  align-items: center;
  grid-template-columns: 112px minmax(0, 1fr) auto;
  gap: 20px;
}

.detail-hero .market-thumb {
  width: 112px;
  height: 112px;
  border-radius: 14px;
}

.detail-hero .market-thumb img {
  width: 58%;
  height: 58%;
}

.detail-title {
  display: grid;
  min-width: 0;
  gap: 8px;
}

.detail-title h1 {
  margin: 0;
  font-size: 26px;
  letter-spacing: -0.02em;
}

.detail-vendor {
  color: var(--muted);
  font-size: 12px;
}

.detail-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.detail-tags span {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted-strong);
  font-size: 11px;
  font-weight: 600;
}

.detail-tags span[data-state="available"] {
  border-color: var(--success);
  color: var(--success);
  background: var(--success-soft);
}

.detail-tags span[data-state="pending"] {
  color: var(--muted);
  background: var(--surface-sunken);
}

.detail-actions {
  display: grid;
  gap: 8px;
  justify-items: stretch;
}

.detail-actions a,
.detail-actions button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 18px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  color: var(--text);
  background: var(--surface);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.detail-actions .primary {
  border-color: var(--accent);
  color: white;
  background: var(--accent);
}

.detail-actions .primary:hover {
  background: var(--accent-hover);
}

.detail-actions .primary[aria-disabled="true"] {
  opacity: 0.5;
  pointer-events: none;
}
