/* ═══════════════════════════════════════════════════════════════════
   天讯 API · 「综合缓存率」标记 + 详情样式 (tx-cache-rate.css) · 2026-10-19
   只作用于 .tx-cache-rate-* —— 不改任何既有选择器，删掉即完全恢复。
   配色与 tx-degrade.css 同族（青绿=正常 / 琥珀=偏低 / 玫红=明显异常），
   但**不用纯红**：这是对外页面，指标低不等于故障。
   ═══════════════════════════════════════════════════════════════════ */

/* ───────────── 卡片上的徽章 ───────────── */
.tx-cache-rate-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: 8px;
  padding: 1px 8px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 11px;
  line-height: 18px;
  font-weight: 500;
  white-space: nowrap;
  vertical-align: middle;
  cursor: pointer;
  user-select: none;
  transition: filter .15s ease, box-shadow .15s ease;
}
.tx-cache-rate-badge svg { width: 11px; height: 11px; flex: none; }
.tx-cache-rate-badge:hover { filter: brightness(0.97); box-shadow: 0 0 0 3px rgba(16, 185, 129, .12); }
.tx-cache-rate-badge.is-warn:hover { box-shadow: 0 0 0 3px rgba(245, 158, 11, .16); }
.tx-cache-rate-badge.is-bad:hover { box-shadow: 0 0 0 3px rgba(244, 63, 94, .16); }
.tx-cache-rate-badge:focus-visible { outline: 2px solid currentColor; outline-offset: 1px; }

.tx-cache-rate-badge.is-ok {
  color: #0f766e;
  background: rgba(16, 185, 129, 0.10);
  border-color: rgba(16, 185, 129, 0.30);
}
.tx-cache-rate-badge.is-warn {
  color: #b45309;
  background: rgba(245, 158, 11, 0.12);
  border-color: rgba(245, 158, 11, 0.35);
}
.tx-cache-rate-badge.is-bad {
  color: #be123c;
  background: rgba(244, 63, 94, 0.10);
  border-color: rgba(244, 63, 94, 0.32);
}
.tx-cache-rate-more {
  font-size: 10px;
  opacity: .7;
  border-left: 1px solid currentColor;
  padding-left: 5px;
  margin-left: 1px;
}

/* ───────────── 详情弹层 ───────────── */
.tx-cache-rate-modal {
  position: fixed;
  inset: 0;
  z-index: 2147483000;              /* 压过 new-api 的弹层 */
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(15, 23, 42, .45);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}
.tx-cache-rate-panel {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 560px;
  max-height: 84vh;
  overflow: auto;
  border-radius: 14px;
  border: 1px solid rgba(148, 163, 184, .35);
  background: #fff;
  color: #0f172a;
  box-shadow: 0 24px 64px rgba(2, 6, 23, .28);
  font-size: 13px;
  line-height: 1.6;
}
html.dark .tx-cache-rate-panel {
  background: #0f172a;
  color: #e2e8f0;
  border-color: rgba(148, 163, 184, .28);
}

.tx-cache-rate-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px 10px;
}
.tx-cache-rate-title { display: flex; flex-direction: column; gap: 2px; }
.tx-cache-rate-title strong { font-size: 15px; font-weight: 600; }
.tx-cache-rate-model {
  font-size: 12px;
  opacity: .7;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.tx-cache-rate-close {
  flex: none;
  width: 28px; height: 28px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  font-size: 14px;
  cursor: pointer;
  opacity: .65;
}
.tx-cache-rate-close:hover { opacity: 1; background: rgba(148, 163, 184, .16); }

.tx-cache-rate-verdict {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 16px 10px;
  padding: 8px 12px;
  border-radius: 10px;
  font-weight: 600;
}
.tx-cache-rate-verdict svg { width: 14px; height: 14px; flex: none; }
.tx-cache-rate-panel.is-ok .tx-cache-rate-verdict { color: #0f766e; background: rgba(16, 185, 129, .10); }
.tx-cache-rate-panel.is-warn .tx-cache-rate-verdict { color: #b45309; background: rgba(245, 158, 11, .12); }
.tx-cache-rate-panel.is-bad .tx-cache-rate-verdict { color: #be123c; background: rgba(244, 63, 94, .10); }
html.dark .tx-cache-rate-panel.is-ok .tx-cache-rate-verdict { color: #5eead4; }
html.dark .tx-cache-rate-panel.is-warn .tx-cache-rate-verdict { color: #fcd34d; }
html.dark .tx-cache-rate-panel.is-bad .tx-cache-rate-verdict { color: #fda4af; }
.tx-cache-rate-big { font-size: 15px; }
.tx-cache-rate-at { margin-left: auto; font-weight: 400; font-size: 12px; opacity: .75; }

.tx-cache-rate-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px 18px;
  padding: 0 16px 12px;
}
.tx-cache-rate-kv { display: flex; gap: 8px; min-width: 0; }
.tx-cache-rate-k { flex: none; width: 76px; opacity: .62; font-size: 12px; }
.tx-cache-rate-v { min-width: 0; word-break: break-word; font-size: 12px; }

.tx-cache-rate-note {
  margin: 0 16px 14px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(148, 163, 184, .10);
  font-size: 12px;
  line-height: 1.7;
}
.tx-cache-rate-note p { margin: 0 0 6px; }
.tx-cache-rate-note p:last-child { margin-bottom: 0; }
.tx-cache-rate-src { opacity: .65; font-size: 11px; }

/* 窄屏：徽章换行到模型名下方；弹层贴边 */
@media (max-width: 640px) {
  .tx-cache-rate-badge { margin-left: 0; margin-top: 4px; }
  .tx-cache-rate-modal { padding: 10px; }
  .tx-cache-rate-panel { max-height: 90vh; }
  .tx-cache-rate-grid { grid-template-columns: 1fr; }
  .tx-cache-rate-k { width: 72px; }
}
