/* ==========================================================================
   usage-chatgpt.css · v6（2026-10-18 重写，合并前 5 轮补丁）
   --------------------------------------------------------------------------
   结构由 app.js 的 renderUsage 产出（.uc-* / .qu-*），本文件只负责长相。

   ⚠️ patchUsage 每 ~800ms 会把这些节点整体重写一遍，样式只能挂在固定类名上：
        [data-win] / .qu-num / .qu-bar > .fill / .qu-reset-time /
        #u-plan-name / #u-plan-status-text / #u-plan-date / #u-plan-cta /
        .qu-plan-status
      它们身上的其它类名随时会被覆盖掉，不要依赖。

   ⚠️ 本文件是重写版：不再用 !important 互相压。规则顺序即优先级，
      分组 = 令牌 → 画布/骨架 → 组件 → 自适应 → 动效 → 兜底。

   版式：宽屏三档限额并排（3 / 2 / 1 列自适应），容器最宽 1280px。
   动效：进场交错淡入上浮、进度条描画、Tab 药丸滑动、按钮/卡片微交互。
   ========================================================================== */

/* ──────────────────────────────────────────────────────────────────────────
   1. 令牌
   ────────────────────────────────────────────────────────────────────────── */
body:not(.adm-mode) #content-inner.has-usage {
  --uc-page:       #ffffff;
  --uc-card:       #f7f7f7;
  --uc-line:       rgba(0, 0, 0, .075);
  --uc-fg:         #0d0d0d;
  --uc-fg-2:       #6b6b6b;
  --uc-pill:       #efefef;
  --uc-btn:        #0d0d0d;
  --uc-btn-hover:  #2b2b2b;
  --uc-btn-fg:     #ffffff;
  --uc-btn-ring:   rgba(0, 0, 0, .08);
  --uc-btn-shadow: 0 1px 2px rgba(0, 0, 0, .16);
  --uc-bar-fill:   #0d0d0d;
  --uc-bar-track:  rgba(0, 0, 0, .09);
  --uc-dot:        #1a8917;
  --uc-crit:       #d93025;
  --uc-focus:      #0b5fd0;
  --uc-ease:       cubic-bezier(.22, 1, .36, 1);     /* 出场：快起慢收 */
  --uc-ease-press: cubic-bezier(.2, .9, .25, 1);      /* 交互：跟手 */

  max-width: none;
  width: 100%;
  background-color: var(--uc-page);
  background-image: none;
}

[data-theme="dark"] body:not(.adm-mode) #content-inner.has-usage {
  --uc-page:       #181818;
  --uc-card:       #232323;
  --uc-line:       rgba(255, 255, 255, .075);
  --uc-fg:         #f4f4f4;
  --uc-fg-2:       #a0a0a0;
  --uc-pill:       #2c2c2c;
  --uc-btn:        #313131;
  --uc-btn-hover:  #3d3d3d;
  --uc-btn-fg:     #f4f4f4;
  --uc-btn-ring:   rgba(255, 255, 255, .07);
  --uc-btn-shadow: 0 1px 2px rgba(0, 0, 0, .5);
  --uc-bar-fill:   #ffffff;
  --uc-bar-track:  rgba(255, 255, 255, .1);
  --uc-dot:        #4cd97b;
  --uc-crit:       #f06058;
  --uc-focus:      #6fa8ff;
  color-scheme: dark;
  /* 极淡的顶部聚光：让整块画布有「光源」，不是死平的一个色块 */
  background-image: radial-gradient(1100px 380px at 50% -140px,
                    rgba(255, 255, 255, .028), transparent 72%);
}

/* 没显式 data-theme 时跟随系统 */
@media (prefers-color-scheme: dark) {
  html:not([data-theme]) body:not(.adm-mode) #content-inner.has-usage {
    --uc-page:       #181818;
    --uc-card:       #232323;
    --uc-line:       rgba(255, 255, 255, .075);
    --uc-fg:         #f4f4f4;
    --uc-fg-2:       #a0a0a0;
    --uc-pill:       #2c2c2c;
    --uc-btn:        #313131;
    --uc-btn-hover:  #3d3d3d;
    --uc-btn-fg:     #f4f4f4;
    --uc-btn-ring:   rgba(255, 255, 255, .07);
    --uc-btn-shadow: 0 1px 2px rgba(0, 0, 0, .5);
    --uc-bar-fill:   #ffffff;
    --uc-bar-track:  rgba(255, 255, 255, .1);
    --uc-dot:        #4cd97b;
    --uc-crit:       #f06058;
    --uc-focus:      #6fa8ff;
    color-scheme: dark;
    background-image: radial-gradient(1100px 380px at 50% -140px,
                      rgba(255, 255, 255, .028), transparent 72%);
  }
}

/* ──────────────────────────────────────────────────────────────────────────
   2. 骨架
   ────────────────────────────────────────────────────────────────────────── */
body:not(.adm-mode) #content-inner.has-usage .uc-page {
  --uc-font: "GS Sans", "Google Sans", "Product Sans", Roboto,
             "Noto Sans SC", "PingFang SC", "HarmonyOS Sans SC",
             "Microsoft YaHei", system-ui, sans-serif;

  margin: 0 auto;
  padding: clamp(40px, 4vw, 64px) 32px 96px;
  color: var(--uc-fg);
  font-family: var(--uc-font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
#content-inner.has-usage .uc-page *,
#content-inner.has-usage .uc-page *::before,
#content-inner.has-usage .uc-page *::after { box-sizing: border-box; }

/* 内容列：宽度按容器自适应（container query，不是 viewport），
   控制台侧栏宽度会变，用 viewport 断点在半宽窗口里会算错。 */
.uc-page .uc-wrap {
  container-type: inline-size;
  width: 100%;
  max-width: min(1440px, 100%);
  margin: 0 auto;
}

/* ── 标题 ───────────────────────────────────────────────────────────────── */
.uc-page .uc-h1 {
  margin: 0 0 24px;
  font-size: 28px;
  line-height: 36px;
  font-weight: 700;
  letter-spacing: -.02em;
  color: var(--uc-fg);
}

/* ── Tab：药丸由 .uc-tabs::before 单独一层画，切换时滑动 ─────────────────── */
.uc-page .uc-tabs {
  position: relative;
  display: inline-flex;
  gap: 2px;
  margin: 0 0 30px;
  padding: 0;
}
.uc-page .uc-tabs::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: calc((100% - 2px) / 2);
  border-radius: 999px;
  background: var(--uc-pill);
  z-index: 0;
  transform: translate3d(0, 0, 0);
  transition: transform .34s var(--uc-ease), background-color .24s ease;
}
.uc-page .uc-tabs:has(.uc-tab:nth-child(2).is-active)::before {
  transform: translate3d(calc(100% + 2px), 0, 0);
}

.uc-page .uc-tab {
  position: relative;
  z-index: 1;
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--uc-fg-2);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
  padding: 9px 14px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  transition: color .18s ease, transform .18s var(--uc-ease-press);
}
.uc-page .uc-tab:hover { color: var(--uc-fg); }
.uc-page .uc-tab:active { transform: scale(.96); }
.uc-page .uc-tab.is-active { color: var(--uc-fg); }

/* 老浏览器（无 :has）：退回「谁激活谁自己上底色」，不会出现没高亮 */
@supports not (selector(:has(*))) {
  .uc-page .uc-tabs::before { display: none; }
  .uc-page .uc-tab.is-active { background: var(--uc-pill); }
}

/* ── 分区 ───────────────────────────────────────────────────────────────── */
.uc-page .uc-sec + .uc-sec { margin-top: 40px; }
.uc-page .uc-h2 {
  margin: 0 0 4px;
  font-size: 16px;
  line-height: 24px;
  font-weight: 600;
  letter-spacing: -.005em;
  color: var(--uc-fg);
}
.uc-page .uc-desc {
  margin: 4px 0 16px;
  color: var(--uc-fg-2);
  font-size: 13.5px;
  line-height: 20px;
}

/* ── 卡片 ───────────────────────────────────────────────────────────────── */
.uc-page .uc-card {
  background: var(--uc-card);
  border: 1px solid var(--uc-line);
  border-radius: 22px;
  transition: background-color .24s ease, border-color .24s ease,
              box-shadow .24s ease;
}
@supports (corner-shape: squircle) {
  .uc-page .uc-card { corner-shape: squircle; }  /* 连续曲率圆角 */
}
/* 浅色：极轻的投影；深色：一像素内高光 + 轻投影 */
.uc-page .uc-card { box-shadow: 0 1px 2px rgba(0, 0, 0, .04); }
[data-theme="dark"] .uc-page .uc-card {
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .035), 0 1px 2px rgba(0, 0, 0, .22);
}
@media (prefers-color-scheme: dark) {
  html:not([data-theme]) .uc-page .uc-card {
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .035), 0 1px 2px rgba(0, 0, 0, .22);
  }
}
/* 小标题后面直接跟卡片（没有说明行）时的间距 */
.uc-page .uc-h2 + .uc-card { margin-top: 16px; }

/* ── 左文右按钮的横向卡片 ───────────────────────────────────────────────── */
.uc-page .uc-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 68px;
  padding: 0 20px;
}
.uc-page .uc-row-main { min-width: 0; }
.uc-page .uc-row-title {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 14px;
  line-height: 20px;
  font-weight: 600;
  color: var(--uc-fg);
}
.uc-page .uc-row-sub {
  font-size: 13px;
  line-height: 18px;
  color: var(--uc-fg-2);
}
.uc-page .tnum { font-variant-numeric: tabular-nums; }

/* 套餐状态：patchUsage 会把 className 整体重写成 qu-plan-status is-ok|is-exp */
.uc-page .qu-plan-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12.5px;
  line-height: 18px;
  font-weight: 500;
  color: var(--uc-fg-2);
  white-space: nowrap;
}
.uc-page .qu-plan-status .dot {
  width: 6px; height: 6px; border-radius: 50%; flex: none;
  background: var(--uc-dot);
  transition: background-color .25s ease;
}
.uc-page .qu-plan-status.is-exp { color: var(--uc-crit); }
.uc-page .qu-plan-status.is-exp .dot { background: var(--uc-crit); }

/* ── 按钮 ───────────────────────────────────────────────────────────────── */
.uc-page .uc-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  border: 0;
  background: var(--uc-btn);
  color: var(--uc-btn-fg);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
  height: 30px;
  padding: 0 12px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 0 0 1px var(--uc-btn-ring), var(--uc-btn-shadow);
  transition: background-color .16s linear, transform .2s var(--uc-ease-press),
              box-shadow .2s ease;
}
.uc-page .uc-btn:hover {
  background: var(--uc-btn-hover);
  transform: translateY(-1px);
  box-shadow: 0 0 0 1px var(--uc-btn-ring), 0 3px 8px rgba(0, 0, 0, .22);
}
.uc-page .uc-btn:active {
  transform: scale(.965);
  transition-duration: .08s;
}
.uc-page .uc-btn[disabled] { opacity: .55; pointer-events: none; }

/* ── 限额卡（宽屏三张并排）─────────────────────────────────────────────── */
.uc-page .uc-limit {
  display: flex;
  flex-direction: column;
  min-height: 112px;
  padding: 18px 20px 20px;
}
.uc-page .uc-limit + .uc-limit { margin-top: 12px; }
.uc-page .uc-limit-title {
  font-size: 13.5px;
  line-height: 20px;
  font-weight: 600;
  letter-spacing: -.003em;
  color: var(--uc-fg);
}
.uc-page .uc-limit-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  /* NumberFlow 宿主按自身字体度量会占 21px 高；这里钉住行高，
     数字仍按 13px 完整显示，只是不参与行高计算。 */
  height: 22px;
  margin-top: 8px;
  color: var(--uc-fg-2);
  font-size: 12.5px;
  line-height: 22px;
}
.uc-page .uc-limit-cd {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.uc-page .uc-limit-rem { flex: none; white-space: nowrap; }
.uc-page .uc-limit-rem .uc-pct { color: var(--uc-fg-2); }

/* patchUsage 会把 .qu-num 的 className 整体重写成 qu-num tnum is-XX —— 只认类名 */
.uc-page .uc-limit .qu-num {
  display: inline-block;
  font-size: 13.5px;
  line-height: 22px;
  font-weight: 600;
  color: var(--uc-fg);
  font-variant-numeric: tabular-nums;
  vertical-align: baseline;
}
.uc-page .uc-limit .qu-num.is-warn,
.uc-page .uc-limit .qu-num.is-risk { color: var(--uc-fg); }
.uc-page .uc-limit .qu-num.is-crit { color: var(--uc-crit); }

/* 进度条：4px、两端全圆、贴卡片底部（margin-top:auto 让三张卡的条对齐） */
.uc-page .uc-limit .qu-bar {
  position: relative;
  height: 4px;
  margin-top: auto;
  padding-top: 0;
  border-radius: 999px;
  background: var(--uc-bar-track);
  overflow: hidden;
  transition: background-color .24s ease;
}
.uc-page .uc-limit .qu-bar .fill {
  position: absolute;
  inset: 0;
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--uc-bar-fill);
  transform-origin: left center;
  transform: scaleX(var(--ratio, 0));
  transition: transform .7s var(--uc-ease), background-color .25s ease;
}

/* 悬停：只提亮描边 + 底色提一档，不位移（卡片点不了，位移会骗人） */
@media (hover: hover) and (pointer: fine) {
  .uc-page .uc-limit:hover {
    border-color: rgba(0, 0, 0, .12);
    background: #f1f1f1;
  }
  [data-theme="dark"] .uc-page .uc-limit:hover {
    border-color: rgba(255, 255, 255, .16);
    background: #282828;
  }
  @media (prefers-color-scheme: dark) {
    html:not([data-theme]) .uc-page .uc-limit:hover {
      border-color: rgba(255, 255, 255, .16);
      background: #282828;
    }
  }
}

/* ── 重置卡余量 ─────────────────────────────────────────────────────────── */
.uc-page .uc-reset-count { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--uc-fg); }

/* ── 按钥匙（usageKeysHtml 产出的 qu-* 结构）────────────────────────────── */
.uc-page .qu-keys {
  margin-top: 40px;
  padding: 18px 20px 8px;
  background: var(--uc-card);
  border: 1px solid var(--uc-line);
  border-radius: 22px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .04);
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  transition: background-color .24s ease, border-color .24s ease;
}
@supports (corner-shape: squircle) {
  .uc-page .qu-keys { corner-shape: squircle; }
}
[data-theme="dark"] .uc-page .qu-keys {
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .035), 0 1px 2px rgba(0, 0, 0, .22);
}
.uc-page .qu-keys-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}
.uc-page .qu-keys-title { font-size: 14px; line-height: 20px; font-weight: 600; color: var(--uc-fg); }
.uc-page .qu-keys-sub { font-size: 12.5px; line-height: 18px; color: var(--uc-fg-2); }
.uc-page .qu-key-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid var(--uc-line);
}
.uc-page .qu-key-row:last-child { border-bottom: 0; }
.uc-page .qu-key-main { flex: 1; min-width: 0; }
.uc-page .qu-key-name { font-size: 13.5px; line-height: 18px; font-weight: 600; color: var(--uc-fg); }
.uc-page .qu-key-sub { font-size: 12.5px; line-height: 18px; color: var(--uc-fg-2); margin-top: 1px; }
.uc-page .qu-key-bar {
  flex: none;
  width: 140px;
  height: 4px;
  border-radius: 999px;
  background: var(--uc-bar-track);
  position: relative;
  overflow: hidden;
}
.uc-page .qu-key-bar i {
  position: absolute;
  inset: 0;
  display: block;
  border-radius: inherit;
  background: var(--uc-bar-fill);
  transform-origin: left center;
  transform: scaleX(var(--r, 0));
  transition: transform .7s var(--uc-ease);
}
.uc-page .qu-key-pct {
  flex: none;
  min-width: 52px;
  text-align: right;
  font-size: 13px;
  line-height: 18px;
  font-weight: 600;
  color: var(--uc-fg);
  font-variant-numeric: tabular-nums;
}
.uc-page .qu-key-sign { margin-left: 1px; font-size: 11px; font-weight: 400; color: var(--uc-fg-2); }
.uc-page .qu-key-empty { padding: 10px 0; font-size: 13px; line-height: 18px; color: var(--uc-fg-2); }

/* ──────────────────────────────────────────────────────────────────────────
   3. 自适应（容器查询，不是 viewport —— 控制台侧栏会吃掉 300+px）

   ⚠️ 三档限额永远是 3 张：绝不做「两列」（会剩一张孤儿卡悬在第二行左边，
      就是之前被截图指出的「汇集在一起」）。

   < 600px  容器        → 单列（手机/窄侧栏）
   600–899px           → 三列紧凑版（内边距 16px）
   ≥ 900px             → 三列舒展版
   ────────────────────────────────────────────────────────────────────────── */
.uc-page .uc-sec:has(> .uc-limit) {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  column-gap: 14px;
  row-gap: 0;
  align-items: stretch;
}
.uc-page .uc-sec:has(> .uc-limit) > .uc-h2,
.uc-page .uc-sec:has(> .uc-limit) > .uc-desc { grid-column: 1 / -1; }
.uc-page .uc-sec:has(> .uc-limit) > .uc-limit + .uc-limit { margin-top: 12px; }

@container (min-width: 600px) {
  .uc-page .uc-sec:has(> .uc-limit) { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .uc-page .uc-sec:has(> .uc-limit) > .uc-limit + .uc-limit { margin-top: 0; }
  /* 紧凑版：卡片只有 ~200px，「倒计时」和「剩余 N%」挤一行会被省略号截断，
     所以固定拆成两行（三张卡一致，不会有的折有的不折）。 */
  .uc-page .uc-limit { min-height: 120px; padding: 15px 16px 17px; }
  .uc-page .uc-limit-meta { flex-wrap: wrap; height: auto; gap: 0 8px; }
  .uc-page .uc-limit-rem { flex: 1 0 100%; text-align: right; }
}
@container (min-width: 900px) {
  .uc-page .uc-limit { min-height: 110px; padding: 18px 20px 20px; }
  .uc-page .uc-limit-meta { flex-wrap: nowrap; height: 22px; gap: 12px; }
  .uc-page .uc-limit-rem { flex: none; text-align: left; }
}

@media (max-width: 640px) {
  body:not(.adm-mode) #content-inner.has-usage .uc-page { padding: 40px 18px 72px; }
  .uc-page .uc-h1 { font-size: 24px; line-height: 32px; margin-bottom: 20px; }
  .uc-page .uc-tabs { margin-bottom: 24px; }
  .uc-page .uc-sec + .uc-sec { margin-top: 32px; }
  .uc-page .uc-row { padding: 0 16px; gap: 12px; min-height: 64px; }
  .uc-page .uc-limit { min-height: 0; padding: 16px 16px 18px; }
  .uc-page .qu-keys { margin-top: 32px; padding: 16px 16px 6px; }
  .uc-page .qu-key-bar { display: none; }
  .uc-page .uc-btn { height: 28px; font-size: 12.5px; }
}

/* ──────────────────────────────────────────────────────────────────────────
   4. 动效
   ────────────────────────────────────────────────────────────────────────── */
@keyframes uc-rise { /* 淡入 + 上浮 10px */
  from { opacity: 0; transform: translate3d(0, 10px, 0); }
  to   { opacity: 1; transform: none; }
}
@keyframes uc-draw { /* 进度条从 0 描到真实比例 */
  from { transform: scaleX(0); }
  to   { transform: scaleX(var(--ratio, 0)); }
}

/* 进场：renderUsage 双 rAF 后给 #usage-details 挂 .qu-on，只播一次。
   fill-mode 用 backwards（不是 both）：延迟期间就位为「未出现」，
   播完交还给元素自身样式，后续 patchUsage 的 transition 不被动画压住。 */
body:not(.adm-mode) #usage-details .uc-head,
body:not(.adm-mode) #usage-details .uc-sec,
body:not(.adm-mode) #usage-details.qu-on .qu-keys.qu-reveal { animation: uc-rise .56s var(--uc-ease) backwards; }
body:not(.adm-mode) #usage-details .uc-head { animation-delay: 0ms; }
body:not(.adm-mode) #usage-details .uc-sec:nth-of-type(1) { animation-delay: 40ms; }
body:not(.adm-mode) #usage-details .uc-sec:nth-of-type(2) { animation-delay: 100ms; }
body:not(.adm-mode) #usage-details .uc-sec:nth-of-type(3) { animation-delay: 160ms; }
body:not(.adm-mode) #usage-details.qu-on .qu-keys.qu-reveal { animation-delay: 210ms; }

/* 进度条描画：跟着限额区出现，三张各差 70ms */
body:not(.adm-mode) #usage-details.qu-on .uc-limit .qu-bar .fill {
  animation: uc-draw .92s var(--uc-ease) .26s backwards;
}
body:not(.adm-mode) #usage-details.qu-on .uc-limit:nth-of-type(2) .qu-bar .fill { animation-delay: .33s; }
body:not(.adm-mode) #usage-details.qu-on .uc-limit:nth-of-type(3) .qu-bar .fill { animation-delay: .40s; }

/* 焦点可见 */
.uc-page :where(.uc-tab, .uc-btn):focus-visible {
  outline: 2px solid var(--uc-focus);
  outline-offset: 2px;
}

/* 减少动态 */
@media (prefers-reduced-motion: reduce) {
  body:not(.adm-mode) #usage-details .uc-head,
  body:not(.adm-mode) #usage-details .uc-sec,
  body:not(.adm-mode) #usage-details.qu-on .qu-keys.qu-reveal,
  body:not(.adm-mode) #usage-details.qu-on .uc-limit .qu-bar .fill { animation: none; }
  .uc-page .uc-limit .qu-bar .fill,
  .uc-page .qu-key-bar i,
  .uc-page .uc-tabs::before,
  .uc-page .uc-btn,
  .uc-page .uc-tab { transition: none; }
}

/* ──────────────────────────────────────────────────────────────────────────
   5. 兜底：新用量页已自带「使用重置卡」卡片，user-extras.js 注入的旧长条
      在用量页里隐藏（真实动作由新卡片按钮转发点击，见 app.js 的
      __ucResetBridge），避免同页出现两种圆角的重复块。
   ────────────────────────────────────────────────────────────────────────── */
body:not(.adm-mode) #content-inner.has-usage #uxe-reset-wrap {
  display: none !important;
}
