/* ==========================================================================
   热点内容工厂 · 设计系统 v0.4
   侧栏导航 + 内容区高对比（Linear / Vercel / Stripe 的 2026 打法）
   单一强调色只用于「状态」与「主操作」，其余一律中性灰
   ========================================================================== */

:root {
  /* 面 */
  --bg:        #ffffff;
  --bg-app:    #ffffff;
  --bg-side:   #fafaf9;
  --bg-sub:    #f7f7f6;
  --surface:   #f2f2f0;
  --surface-2: #e9e9e7;

  /* 线 */
  --line:      #eaeae8;
  --line-2:    #e0e0de;
  --line-3:    #cfcfcc;

  /* 字 */
  --ink:       #17181a;
  --ink-2:     #56585e;
  --ink-3:     #8a8c93;
  --ink-4:     #b2b4ba;

  /* 强调（仅状态 + 主操作） */
  --brand:      #0e7a5f;
  --brand-ink:  #0a5e49;
  --brand-soft: #e9f5f1;
  --brand-line: #cde7de;
  --brand-glow: rgba(14, 122, 95, .15);

  --amber:      #9c5a12;
  --amber-soft: #fdf6ea;
  --amber-line: #f0ddc1;

  --red:        #b02a1f;
  --red-soft:   #fdf3f1;
  --red-line:   #f1d2cc;

  --blue:       #1e4a8a;
  --blue-soft:  #eef3fb;
  --blue-line:  #d5e1f4;

  /* 形 */
  --r-xs: 6px;
  --r-sm: 8px;
  --r:    10px;
  --r-lg: 14px;
  --r-xl: 18px;

  --sh-1: 0 1px 2px rgba(17,18,20,.04);
  --sh-2: 0 1px 2px rgba(17,18,20,.05), 0 8px 18px -10px rgba(17,18,20,.14);
  --sh-3: 0 24px 56px -18px rgba(17,18,20,.22), 0 3px 10px rgba(17,18,20,.05);
  --sh-pop: 0 10px 30px -8px rgba(17,18,20,.2), 0 2px 6px rgba(17,18,20,.06);

  --ease:     cubic-bezier(.22,.68,.32,1);
  --ease-out: cubic-bezier(.16,1,.3,1);

  --side-w: 268px;
}

* { box-sizing: border-box; }

/* 任何带了 display 的元素都会盖掉 hidden 的默认 display:none —— 统一钉死 */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg-app);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro SC", "PingFang SC",
               "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -.011em; }

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }

::selection { background: var(--brand-glow); }

:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--brand-glow); border-radius: var(--r-xs); }

/* 滚动条 */
* { scrollbar-width: thin; scrollbar-color: var(--line-3) transparent; }
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: var(--line-3); border-radius: 99px;
  border: 3px solid transparent; background-clip: content-box;
}
*::-webkit-scrollbar-thumb:hover { background: var(--ink-4); background-clip: content-box; }

/* ==========================================================================
   骨架布局
   ========================================================================== */

.app {
  display: grid;
  grid-template-columns: var(--side-w) minmax(0, 1fr);
  min-height: 100vh;
}

/* --------------------------------------------------------------------------
   侧边栏 —— 刻意比内容区对比度低（导航不该抢戏）
   -------------------------------------------------------------------------- */

.sidebar {
  position: sticky; top: 0; height: 100vh; z-index: 20;
  display: flex; flex-direction: column;
  background: var(--bg-side);
  border-right: 1px solid var(--line);
}

.side-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 15px 14px 14px 16px;
  flex: 0 0 auto;
}
.mark {
  width: 32px; height: 32px; border-radius: 9px; flex: 0 0 auto;
  display: grid; place-items: center;
  background: var(--bg); border: 1px solid var(--brand-line);
  box-shadow: 0 1px 0 #fff inset, var(--sh-1);
}
.mark svg { width: 18px; height: 18px; stroke: var(--brand); fill: none; }
.brand-text { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.brand-text strong { font-size: 13.5px; font-weight: 600; letter-spacing: -.01em; }
.brand-text span { font-size: 11px; color: var(--ink-4); letter-spacing: .01em; }
.sidebar .side-close { display: none; margin-left: auto; }

/* 主操作 */
.side-run { padding: 4px 14px 16px; flex: 0 0 auto; }
.run-btn {
  width: 100%; height: 40px; border-radius: var(--r);
  display: flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--brand); color: #fff;
  font-size: 13.5px; font-weight: 500;
  box-shadow: 0 1px 2px rgba(14,122,95,.3), 0 6px 16px -8px rgba(14,122,95,.6);
  transition: background .16s var(--ease), transform .12s var(--ease), box-shadow .16s var(--ease);
}
.run-btn:hover:not(:disabled) { background: var(--brand-ink); }
.run-btn:active:not(:disabled) { transform: scale(.98); box-shadow: 0 1px 2px rgba(14,122,95,.34); }
.run-btn:disabled { opacity: .6; cursor: not-allowed; }
.run-ico { display: grid; place-items: center; }
.run-ico svg { width: 15px; height: 15px; stroke: currentColor; fill: none; }
.run-btn kbd {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10px; padding: 2px 5px; border-radius: 4px;
  background: rgba(255,255,255,.17); color: rgba(255,255,255,.86);
}
@media (hover: none) { .run-btn kbd { display: none; } }

.run-note {
  margin: 8px 2px 0; font-size: 11.5px; color: var(--ink-4);
  text-align: center; line-height: 1.45;
}

/* 滚动配置区 */
.side-scroll { flex: 1 1 auto; overflow-y: auto; padding: 2px 14px 20px; overscroll-behavior: contain; }

.side-block { margin-bottom: 22px; }
.block-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; margin-bottom: 9px; padding: 0 2px;
}
.block-head h3 {
  font-size: 10.5px; font-weight: 600; letter-spacing: .075em;
  text-transform: uppercase; color: var(--ink-4);
}
.link-btn {
  font-size: 11.5px; color: var(--brand); padding: 1px 3px; border-radius: 4px;
  transition: background .14s var(--ease);
}
.link-btn:hover { background: var(--brand-soft); }

/* 梯队 */
.tiers { display: flex; flex-direction: column; gap: 7px; }

.tier {
  border: 1px solid var(--line); border-radius: var(--r);
  background: var(--bg); overflow: hidden;
  transition: border-color .16s var(--ease), box-shadow .16s var(--ease);
}
.tier.open { box-shadow: var(--sh-1); }

.tier-head {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 9px 10px; text-align: left;
  transition: background .14s var(--ease);
}
.tier-head:hover { background: var(--bg-sub); }
.tier-chev {
  width: 13px; height: 13px; flex: 0 0 auto; stroke: var(--ink-4); fill: none;
  transition: transform .2s var(--ease);
}
.tier.open .tier-chev { transform: rotate(90deg); }

.tier-meta { flex: 1; min-width: 0; }
.tier-name { display: block; font-size: 12.5px; font-weight: 500; line-height: 1.35; }
.tier-desc {
  display: block; font-size: 10.5px; color: var(--ink-4); line-height: 1.4;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tier-count {
  flex: 0 0 auto; font-size: 10.5px; font-variant-numeric: tabular-nums;
  padding: 1.5px 6px; border-radius: 5px;
  background: var(--surface); color: var(--ink-3);
}
.tier-count.partial { background: var(--brand-soft); color: var(--brand); }

/* 组内复选 */
.tier-body { border-top: 1px solid var(--line); padding: 5px; display: none; }
.tier.open .tier-body { display: block; animation: rise .22s var(--ease-out) both; }

.sub-opt {
  display: flex; align-items: center; gap: 8px;
  padding: 5.5px 7px; border-radius: var(--r-xs); cursor: pointer;
  transition: background .13s var(--ease);
}
.sub-opt:hover { background: var(--bg-sub); }
.sub-opt input { position: absolute; opacity: 0; pointer-events: none; }
.sub-box {
  width: 15px; height: 15px; flex: 0 0 auto; border-radius: 4.5px;
  border: 1.5px solid var(--line-3); background: var(--bg);
  display: grid; place-items: center;
  transition: background .14s var(--ease), border-color .14s var(--ease);
}
.sub-box svg {
  width: 10px; height: 10px; stroke: #fff; fill: none; stroke-width: 2.8;
  stroke-dasharray: 16; stroke-dashoffset: 16;
  transition: stroke-dashoffset .2s var(--ease) .03s;
}
.sub-opt input:checked + .sub-box { background: var(--brand); border-color: var(--brand); }
.sub-opt input:checked + .sub-box svg { stroke-dashoffset: 0; }
.sub-opt input:focus-visible + .sub-box { box-shadow: 0 0 0 3px var(--brand-glow); }
.sub-name {
  font-size: 12px; color: var(--ink-2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sub-opt input:checked ~ .sub-name { color: var(--ink); }

/* 分数线 */
.thr-val {
  font-size: 15px; font-weight: 600; color: var(--brand); line-height: 1;
  font-variant-numeric: tabular-nums; letter-spacing: -.02em;
  transition: color .2s var(--ease);
}
input[type=range] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 20px; background: none; outline: none; display: block;
}
input[type=range]::-webkit-slider-runnable-track {
  height: 4px; border-radius: 99px;
  background: linear-gradient(to right, var(--brand) var(--fill, 70%), var(--surface-2) var(--fill, 70%));
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 15px; height: 15px; margin-top: -5.5px;
  border-radius: 50%; background: #fff; border: 2px solid var(--brand);
  box-shadow: 0 1px 3px rgba(17,18,20,.2);
  transition: transform .14s var(--ease), box-shadow .14s var(--ease);
}
input[type=range]:hover::-webkit-slider-thumb { transform: scale(1.12); }
input[type=range]:active::-webkit-slider-thumb { transform: scale(1.2); box-shadow: 0 0 0 6px var(--brand-glow); }
input[type=range]::-moz-range-track { height: 4px; border-radius: 99px; background: var(--surface-2); }
input[type=range]::-moz-range-progress { height: 4px; border-radius: 99px; background: var(--brand); }
input[type=range]::-moz-range-thumb {
  width: 13px; height: 13px; border-radius: 50%; background: #fff;
  border: 2px solid var(--brand);
}
input[type=range]:focus-visible { box-shadow: none; }
input[type=range]:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 5px var(--brand-glow); }

.thr-scale {
  display: flex; justify-content: space-between;
  font-size: 10px; color: var(--ink-4); margin-top: -3px;
  font-variant-numeric: tabular-nums; padding: 0 1px;
}
.thr-hint {
  margin: 8px 2px 0; font-size: 11.5px; color: var(--ink-3);
  min-height: 17px; line-height: 1.5;
}

/* 内容库统计 */
.stat-rows { display: flex; flex-direction: column; gap: 1px; }
.stat-row {
  display: flex; align-items: baseline; justify-content: space-between;
  padding: 6px 2px; font-size: 12.5px;
}
.stat-row + .stat-row { border-top: 1px dashed var(--line); }
.stat-row span:first-child { color: var(--ink-3); }
.stat-row span:last-child {
  font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -.01em;
}

/* 侧栏底部 */
.side-foot {
  flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between;
  gap: 8px; padding: 11px 14px; border-top: 1px solid var(--line);
}
.health {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 11.5px; color: var(--ink-3); min-width: 0;
}
.health #healthText { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pulse {
  position: relative; width: 6px; height: 6px; border-radius: 50%;
  background: var(--ink-4); flex: 0 0 auto;
  transition: background .2s var(--ease);
}
.health.ok .pulse { background: var(--brand); }
.health.ok .pulse::after {
  content: ''; position: absolute; inset: -3.5px; border-radius: 50%;
  border: 1.5px solid var(--brand); opacity: 0;
  animation: ping 2.6s var(--ease-out) infinite;
}
.health.bad { color: var(--red); }
.health.bad .pulse { background: var(--red); }
.health.busy { color: var(--amber); }
.health.busy .pulse { background: var(--amber); animation: blink 1s steps(2) infinite; }

.ghost-btn {
  font-size: 11.5px; color: var(--ink-3); padding: 4px 8px; border-radius: var(--r-xs);
  transition: background .14s var(--ease), color .14s var(--ease);
}
.ghost-btn:hover { background: var(--surface); color: var(--ink-2); }

/* 令牌气泡 */
.token-pop {
  position: absolute; left: 12px; right: 12px; bottom: 56px; z-index: 5;
  background: var(--bg); border: 1px solid var(--line-2); border-radius: var(--r-lg);
  box-shadow: var(--sh-pop); padding: 13px 14px;
  animation: pop-in .2s var(--ease-out) both;
}
.token-pop label { display: block; font-size: 11.5px; color: var(--ink-3); margin-bottom: 7px; }
.token-row { display: flex; gap: 6px; }
.token-row input {
  flex: 1; min-width: 0; height: 32px; padding: 0 10px;
  border: 1px solid var(--line-2); border-radius: var(--r-sm);
  background: var(--bg-sub); font-size: 12.5px; letter-spacing: .02em; outline: none;
  transition: border-color .16s var(--ease), box-shadow .16s var(--ease), background .16s var(--ease);
}
.token-row input:focus { border-color: var(--brand); background: var(--bg); box-shadow: 0 0 0 3px var(--brand-glow); }
.token-hint { margin: 8px 0 0; font-size: 11px; color: var(--ink-4); line-height: 1.5; }

/* ==========================================================================
   授权门 —— 未授权时挡住整个工作台
   左侧那枚小气泡适合「已登录取换令牌」，首屏未授权不该让用户去找它：
   直接给一张居中卡片，一句话 + 一个输入框 + 一个按钮。
   ========================================================================== */

.gate {
  position: fixed; inset: 0; z-index: 70;
  display: grid; place-items: center; padding: 24px;
  background: rgba(17, 18, 20, .4);
  -webkit-backdrop-filter: blur(7px) saturate(120%);
  backdrop-filter: blur(7px) saturate(120%);
  animation: gate-in .2s var(--ease-out) both;
}
.gate.out { animation: gate-out .18s var(--ease) both; }

.gate-card {
  width: 100%; max-width: 372px; margin: 0;
  background: var(--bg); border: 1px solid var(--line-2); border-radius: var(--r-xl);
  box-shadow: var(--sh-3); padding: 30px 28px 22px;
  text-align: center;
  animation: gate-card-in .32s var(--ease-out) both;
}
.gate.out .gate-card { animation: none; }

.gate-mark {
  display: grid; place-items: center; width: 46px; height: 46px; margin: 0 auto 16px;
  border-radius: 14px; background: var(--brand-soft); border: 1px solid var(--brand-line);
  color: var(--brand);
}
.gate-mark svg { width: 23px; height: 23px; stroke: currentColor; }

.gate-card h2 { margin: 0 0 7px; font-size: 17px; font-weight: 650; letter-spacing: -.01em; color: var(--ink); }
.gate-sub { margin: 0 0 20px; font-size: 12.5px; line-height: 1.62; color: var(--ink-3); }

.gate-field { position: relative; }
.gate-field input {
  width: 100%; height: 42px; padding: 0 42px 0 13px;
  border: 1px solid var(--line-2); border-radius: var(--r);
  background: var(--bg-sub); color: var(--ink);
  font-size: 13px; letter-spacing: .01em; outline: none;
  transition: border-color .16s var(--ease), box-shadow .16s var(--ease), background .16s var(--ease);
}
.gate-field input::placeholder { color: var(--ink-4); letter-spacing: 0; }
.gate-field input:focus { border-color: var(--brand); background: var(--bg); box-shadow: 0 0 0 3px var(--brand-glow); }
.gate-card.shake { animation: gate-shake .38s var(--ease) both; }

.gate-eye {
  position: absolute; right: 5px; top: 50%; transform: translateY(-50%);
  width: 32px; height: 32px; color: var(--ink-4);
}
.gate-eye svg { width: 16px; height: 16px; }
.gate-eye:hover { color: var(--ink-2); }
.gate-eye[aria-pressed="true"] { color: var(--brand); }

.gate-err {
  margin: 10px 0 0; font-size: 12px; color: var(--red); text-align: left;
  display: flex; align-items: flex-start; gap: 6px; line-height: 1.5;
}
.gate-err::before { content: ''; flex: 0 0 auto; width: 5px; height: 5px; margin-top: 6px; border-radius: 50%; background: currentColor; }

.gate-go { width: 100%; height: 42px; margin-top: 16px; font-size: 13.5px; }
.gate-go[disabled] { opacity: .6; cursor: default; }

.gate-note { margin: 14px 0 0; font-size: 11px; line-height: 1.55; color: var(--ink-4); }

@keyframes gate-in  { from { opacity: 0; } to { opacity: 1; } }
@keyframes gate-out { from { opacity: 1; } to { opacity: 0; } }
@keyframes gate-card-in { from { opacity: 0; transform: translateY(10px) scale(.985); } to { opacity: 1; transform: none; } }
@keyframes gate-shake {
  0%, 100% { transform: translateX(0); }
  18% { transform: translateX(-7px); }
  38% { transform: translateX(6px); }
  58% { transform: translateX(-4px); }
  78% { transform: translateX(3px); }
}

/* ==========================================================================
   主区
   ========================================================================== */

.main { display: flex; flex-direction: column; min-width: 0; background: var(--bg-app); }

.main-head {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 0 26px; height: 58px; flex: 0 0 auto;
  background: rgba(255,255,255,.86);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--line);
}
.head-titles { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.head-titles h1 { font-size: 15px; letter-spacing: -.015em; }
.count { font-size: 12.5px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.head-titles .menu-btn { display: none; }

.head-tools { display: flex; align-items: center; gap: 8px; }

.tabs { display: inline-flex; padding: 2.5px; border-radius: var(--r-sm); background: var(--surface); gap: 1px; }
.tab {
  border-radius: 6px; padding: 5px 11px; font-size: 12.5px; color: var(--ink-2);
  white-space: nowrap; display: inline-flex; align-items: center; gap: 5px;
  transition: background .15s var(--ease), color .15s var(--ease), box-shadow .15s var(--ease);
}
.tab:hover { color: var(--ink); }
.tab.on { background: var(--bg); color: var(--ink); box-shadow: var(--sh-1); font-weight: 500; }
.tab .tc { font-size: 10.5px; color: var(--ink-4); font-variant-numeric: tabular-nums; }
.tab.on .tc { color: var(--brand); }

.select-wrap { position: relative; display: inline-flex; align-items: center; }
.select-wrap select {
  -webkit-appearance: none; appearance: none;
  padding: 6.5px 28px 6.5px 11px; border-radius: var(--r-sm);
  border: 1px solid var(--line-2); background: var(--bg);
  font-size: 12.5px; color: var(--ink-2); cursor: pointer;
  transition: border-color .15s var(--ease), background .15s var(--ease);
}
.select-wrap select:hover { border-color: var(--line-3); background: var(--bg-sub); }
.select-wrap select:focus-visible { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-glow); }
.select-wrap svg {
  position: absolute; right: 8px; width: 13px; height: 13px;
  stroke: var(--ink-3); fill: none; pointer-events: none;
}

/* ---------- 指标条 ---------- */

.metric { padding: 20px 26px 4px; animation: rise .4s var(--ease-out) both; }
.metric-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 11px; }
.metric-head h2 { font-size: 12.5px; color: var(--ink-2); font-weight: 500; }
.muted { font-size: 11.5px; color: var(--ink-4); font-variant-numeric: tabular-nums; }

.metric-row { display: grid; gap: 9px; grid-template-columns: repeat(5, minmax(0, 1fr)); }

.metric-card {
  padding: 12px 13px 11px; border-radius: var(--r-lg);
  background: var(--bg); border: 1px solid var(--line);
  animation: rise .42s var(--ease-out) both;
  animation-delay: calc(var(--i, 0) * 45ms);
}
.metric-k {
  font-size: 11px; color: var(--ink-4); line-height: 1.3;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.metric-v {
  font-size: 23px; font-weight: 600; line-height: 1.2; margin-top: 3px;
  letter-spacing: -.035em; font-variant-numeric: tabular-nums;
}
.metric-bar { height: 3px; border-radius: 99px; background: var(--surface-2); margin-top: 10px; overflow: hidden; }
.metric-bar i {
  display: block; height: 100%; border-radius: 99px; background: var(--ink-4);
  animation: bar-grow .8s var(--ease-out) both;
  animation-delay: calc(var(--i, 0) * 45ms + 80ms);
}
.metric-card.kept { background: var(--brand-soft); border-color: var(--brand-line); }
.metric-card.kept .metric-v { color: var(--brand); }
.metric-card.kept .metric-k { color: var(--brand-ink); }
.metric-card.kept .metric-bar i { background: var(--brand); }
.metric-card.drop .metric-v { color: var(--ink-3); }
.metric-card.drop .metric-bar i { background: var(--line-3); }
.metric-card.text .metric-v { color: var(--blue); }
.metric-card.text .metric-bar i { background: var(--blue); }

.metric-note {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  margin-top: 12px; font-size: 11.5px; color: var(--ink-4);
}
.metric-note .pill {
  padding: 2.5px 8px; border-radius: 6px;
  background: var(--red-soft); color: var(--red); border: 1px solid var(--red-line);
  font-size: 11px;
}

/* ---------- 选题列表 ---------- */

.pool { padding: 12px 26px 90px; }
.list { display: flex; flex-direction: column; gap: 7px; }

.card-item {
  display: flex; align-items: center; gap: 14px;
  padding: 13px 15px;
  border: 1px solid var(--line); border-radius: var(--r-lg);
  background: var(--bg); cursor: pointer;
  transition: border-color .16s var(--ease), box-shadow .2s var(--ease),
              transform .16s var(--ease);
  animation: rise .38s var(--ease-out) both;
  animation-delay: calc(var(--i, 0) * 26ms);
}
.card-item:hover { border-color: var(--brand-line); transform: translateY(-1px); box-shadow: var(--sh-2); }
.card-item:active { transform: translateY(0); }
.card-item:focus-visible { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-glow); }
.card-item.busy { opacity: .6; pointer-events: none; }

/* 分数环 */
.ring { position: relative; width: 42px; height: 42px; flex: 0 0 auto; }
.ring svg { width: 42px; height: 42px; transform: rotate(-90deg); display: block; }
.ring circle { fill: none; stroke-width: 3.2; stroke-linecap: round; }
.ring .bg { stroke: var(--surface-2); }
.ring .fg {
  stroke: var(--ink-4);
  stroke-dasharray: 113.1;
  animation: ring-draw .8s var(--ease-out) both;
  animation-delay: calc(var(--i, 0) * 26ms + 50ms);
}
.ring.high .fg { stroke: var(--brand); }
.ring.mid  .fg { stroke: var(--blue); }
.ring span {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 13px; font-weight: 600; letter-spacing: -.04em;
  font-variant-numeric: tabular-nums;
}
.ring.high span { color: var(--brand); }
.ring.mid  span { color: var(--blue); }
.ring span.sm { font-size: 11.5px; }

.card-item .main { flex: 1; min-width: 0; }
.card-item .title {
  font-size: 14px; line-height: 1.5; font-weight: 500;
  margin-bottom: 6px; word-break: break-word;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card-item .meta {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  font-size: 11.5px; color: var(--ink-3);
}
.tag {
  padding: 2px 7px; border-radius: 5px; font-size: 11px; font-weight: 500;
  background: var(--surface); color: var(--ink-2); white-space: nowrap;
}
.tag.reddit { background: var(--blue-soft); color: var(--blue); }

.badge {
  padding: 2px 7px; border-radius: 5px; font-size: 10.5px; font-weight: 500;
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.badge.full { background: var(--brand-soft); color: var(--brand-ink); }
.badge.prev { background: var(--amber-soft); color: var(--amber); }

.reason {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px; border-radius: 5px;
  background: var(--surface); color: var(--ink-2); font-size: 11px;
  max-width: 100%;
}
.reason::before {
  content: ''; width: 4px; height: 4px; border-radius: 50%;
  background: var(--brand); flex: 0 0 auto; opacity: .5;
}
.reason span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.mini-link {
  font-size: 11.5px; color: var(--blue); text-decoration: none;
  border-bottom: 1px solid var(--blue-line); padding-bottom: .5px;
  transition: border-color .15s var(--ease);
}
.mini-link:hover { border-bottom-color: var(--blue); }

.card-item .go {
  flex: 0 0 auto;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 13px; border-radius: 9px;
  border: 1px solid var(--brand-line); background: var(--brand-soft); color: var(--brand-ink);
  font-size: 12.5px; font-weight: 500; white-space: nowrap;
  transition: background .15s var(--ease), color .15s var(--ease),
              border-color .15s var(--ease), transform .12s var(--ease), box-shadow .15s var(--ease);
}
.card-item .go svg { width: 13px; height: 13px; stroke: currentColor; fill: none; }
.card-item .go:hover { background: var(--brand); border-color: var(--brand); color: #fff; box-shadow: 0 4px 12px -4px rgba(14,122,95,.55); }
.card-item .go:active { transform: scale(.96); }
.card-item .go:disabled { opacity: .5; cursor: not-allowed; }
.card-item .go.done { background: var(--bg); border-color: var(--line-2); color: var(--ink-3); }
.card-item .go.done:hover { background: var(--brand-soft); border-color: var(--brand-line); color: var(--brand-ink); box-shadow: none; }

/* 空态 */
.empty {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 66px 20px; text-align: center;
  border: 1px dashed var(--line-2); border-radius: var(--r-xl);
  background: linear-gradient(180deg, var(--bg), var(--bg-sub));
}
.empty svg { width: 54px; height: 54px; stroke: var(--line-3); fill: none; margin-bottom: 6px; }
.empty-t { font-size: 13.5px; font-weight: 500; color: var(--ink-2); }
.empty-d { font-size: 12.5px; color: var(--ink-4); max-width: 330px; line-height: 1.65; }

/* 骨架 */
.sk {
  padding: 13px 15px; border: 1px solid var(--line); border-radius: var(--r-lg);
  display: flex; gap: 14px; align-items: center; background: var(--bg);
}
.sk-i {
  background: linear-gradient(90deg, var(--surface) 25%, var(--surface-2) 37%, var(--surface) 63%);
  background-size: 400% 100%; border-radius: 5px;
  animation: shimmer 1.5s ease-in-out infinite;
}
.sk .c { width: 42px; height: 42px; border-radius: 50%; flex: 0 0 auto; }
.sk .l { flex: 1; display: flex; flex-direction: column; gap: 8px; }
.sk .l .a { height: 12px; width: 58%; }
.sk .l .b { height: 9px; width: 34%; }

/* ==========================================================================
   抽屉
   ========================================================================== */

.drawer {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: min(680px, 95vw);
  background: var(--bg);
  border-left: 1px solid var(--line);
  box-shadow: var(--sh-3);
  z-index: 50; display: flex; flex-direction: column;
  transform: translateX(101%);
  transition: transform .36s var(--ease-out);
  will-change: transform;
}
.drawer.open { transform: translateX(0); }

.drawer-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 14px;
  padding: 15px 18px 14px 24px; border-bottom: 1px solid var(--line); flex: 0 0 auto;
  background: rgba(255,255,255,.88);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
}
.drawer-head-text { min-width: 0; }
.drawer-kicker {
  display: block; font-size: 10.5px; font-weight: 600; letter-spacing: .075em;
  text-transform: uppercase; color: var(--brand); margin-bottom: 3px;
}
.drawer-head h2 {
  font-size: 15px; line-height: 1.42; font-weight: 600;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.icon-btn {
  padding: 6px; border-radius: 8px; flex: 0 0 auto;
  display: grid; place-items: center;
  transition: background .15s var(--ease), transform .12s var(--ease);
}
.icon-btn:hover { background: var(--surface); }
.icon-btn:active { transform: scale(.94); }
.icon-btn svg { width: 16px; height: 16px; stroke: var(--ink-2); fill: none; }

.drawer-body { flex: 1; overflow-y: auto; padding: 22px 24px 34px; overscroll-behavior: contain; }
.drawer-foot {
  display: flex; gap: 8px; flex-wrap: wrap; flex: 0 0 auto;
  padding: 13px 24px; border-top: 1px solid var(--line);
  background: rgba(255,255,255,.92);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  animation: rise .3s var(--ease-out) both;
}

.overlay {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(20,22,26,.24);
  -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
  opacity: 0; transition: opacity .3s var(--ease);
}
.overlay.on { opacity: 1; }

/* ---------- 通用按钮 ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 0 16px; height: 38px; border-radius: var(--r);
  border: 1px solid var(--line-2); background: var(--bg); color: var(--ink);
  font-size: 13px; font-weight: 500; white-space: nowrap;
  transition: background .15s var(--ease), border-color .15s var(--ease),
              box-shadow .15s var(--ease), transform .12s var(--ease), color .15s var(--ease);
}
.btn svg { width: 15px; height: 15px; stroke: currentColor; fill: none; }
.btn:hover:not(:disabled) { background: var(--surface); border-color: var(--line-3); }
.btn:active:not(:disabled) { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary {
  background: var(--brand); border-color: var(--brand); color: #fff;
  box-shadow: 0 1px 2px rgba(14,122,95,.28), 0 6px 16px -8px rgba(14,122,95,.6);
}
.btn.primary:hover:not(:disabled) { background: var(--brand-ink); border-color: var(--brand-ink); }
.btn.tiny { height: 32px; padding: 0 12px; font-size: 12.5px; }
.btn.copied { background: var(--brand-soft) !important; border-color: var(--brand-line) !important; color: var(--brand-ink) !important; }
.btn.primary.copied { background: var(--brand-ink) !important; border-color: var(--brand-ink) !important; color: #fff !important; }

/* ---------- 抽屉内容 ---------- */

.sec {
  font-size: 10.5px; font-weight: 600; letter-spacing: .075em; text-transform: uppercase;
  color: var(--ink-4); margin: 24px 0 10px;
  display: flex; align-items: center; gap: 8px;
}
.sec::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.sec:first-child { margin-top: 0; }
.sec .sec-hint { font-size: 10.5px; letter-spacing: 0; text-transform: none; color: var(--ink-4); font-weight: 400; }

.raw-box {
  border: 1px solid var(--line); border-radius: var(--r);
  background: var(--bg-sub); padding: 14px 16px;
  font-size: 13.5px; line-height: 1.8; color: var(--ink-2);
  white-space: pre-wrap; word-break: break-word;
  max-height: 46vh; overflow-y: auto;
}
.raw-box.short { color: var(--ink-3); }

.opt {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 11px 13px; margin-bottom: 7px;
  border: 1px solid var(--line); border-radius: var(--r);
  cursor: pointer; position: relative; overflow: hidden;
  transition: border-color .15s var(--ease), background .15s var(--ease), transform .12s var(--ease);
}
.opt:hover { border-color: var(--brand-line); background: var(--brand-soft); }
.opt:active { transform: scale(.995); }
.opt .no {
  flex: 0 0 auto; width: 18px; height: 18px; border-radius: 5px; margin-top: 1px;
  display: grid; place-items: center; font-size: 10.5px; font-weight: 600;
  background: var(--surface-2); color: var(--ink-3);
}
.opt:hover .no { background: var(--brand); color: #fff; }
.opt .tx { font-size: 13.5px; line-height: 1.5; }
.opt .cp {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%) translateX(5px);
  font-size: 11px; color: var(--brand); opacity: 0;
  transition: opacity .17s var(--ease), transform .17s var(--ease);
}
.opt:hover .cp { opacity: 1; transform: translateY(-50%); }

.body-box {
  border: 1px solid var(--line); border-radius: var(--r);
  padding: 18px 20px; background: var(--bg);
  font-size: 14.5px; line-height: 1.92; white-space: pre-wrap; word-break: break-word;
}
.cover-box {
  border: 1px solid var(--line); border-radius: var(--r);
  padding: 12px 15px; background: var(--bg-sub);
  font-size: 13px; line-height: 1.7; color: var(--ink-2);
}

/* 配图 */
.img-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.img-cell {
  /* 4:3 —— 真实手机照的比例。正方形一眼就是"生成图" */
  position: relative; aspect-ratio: 4 / 3; border-radius: var(--r);
  overflow: hidden; border: 1px solid var(--line); background: var(--surface);
}
.img-cell img { width: 100%; height: 100%; object-fit: cover; display: block; }
.img-skel { width: 100%; height: 100%; }
.img-shot {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 20px 9px 8px;
  background: linear-gradient(to top, rgba(12,13,15,.7), transparent);
  color: #fff; font-size: 10.5px; line-height: 1.4;
  opacity: 0; transition: opacity .2s var(--ease);
}
.img-cell:hover .img-shot { opacity: 1; }
.img-cell .img-hover {
  position: absolute; inset: 0; opacity: 0; pointer-events: none;
  background: rgba(12,13,15,.34); transition: opacity .18s var(--ease);
  display: grid; place-items: center;
}
.img-cell:hover .img-hover { opacity: 1; pointer-events: auto; }
.img-acts { display: flex; gap: 6px; }
.img-hover .btn { height: 30px; padding: 0 11px; font-size: 12px;
  background: rgba(255,255,255,.94); border-color: transparent; color: var(--ink); }
.img-hover .btn:hover { background: #fff; }
.img-hover .btn.copied { background: var(--brand); color: #fff; }

/* 适配判断 */
.score-box { border: 1px solid var(--line); border-radius: var(--r); background: var(--bg-sub); padding: 12px 14px; }
.score-reason { display: flex; align-items: flex-start; gap: 8px; font-size: 13px; line-height: 1.6; }
.score-reason svg { width: 14px; height: 14px; stroke: var(--brand); fill: none; flex: 0 0 auto; margin-top: 2px; }
.dims { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.dim {
  display: inline-flex; align-items: baseline; gap: 5px;
  padding: 3px 9px; border-radius: 6px;
  background: var(--bg); border: 1px solid var(--line);
}
.dim-k { font-size: 11px; color: var(--ink-3); }
.dim-v { font-size: 12px; font-weight: 600; color: var(--ink-2); font-variant-numeric: tabular-nums; }

/* 提示 */
.note {
  display: flex; gap: 10px; align-items: flex-start;
  border: 1px solid var(--amber-line); border-radius: var(--r);
  padding: 12px 14px; background: var(--amber-soft);
  font-size: 12.5px; line-height: 1.65; color: var(--ink-2);
}
.note svg { width: 14px; height: 14px; stroke: var(--amber); fill: none; flex: 0 0 auto; margin-top: 2px; }
.note b { color: var(--amber); font-weight: 600; }

.alert { border: 1px solid var(--red-line); border-radius: var(--r); padding: 13px 15px; background: var(--red-soft); }
.alert-h { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--red); margin-bottom: 7px; }
.alert-h svg { width: 14px; height: 14px; stroke: var(--red); fill: none; }
.alert-row { font-size: 12.5px; color: var(--ink-2); line-height: 1.9; }
.alert-row code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px;
  background: #fff; border: 1px solid var(--red-line); border-radius: 5px;
  padding: 1px 6px; color: var(--red);
}

.src-card { border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; background: var(--bg-sub); }
.src-card-h { display: flex; align-items: center; gap: 8px; margin-bottom: 7px; }
.src-card-t { font-size: 12.5px; line-height: 1.5; color: var(--ink-2); word-break: break-word; }
.facts { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 3px; }
.fact {
  font-size: 11px; padding: 2px 7px; border-radius: 5px;
  background: var(--bg); border: 1px solid var(--line); color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}
.fact.warn { background: var(--amber-soft); border-color: var(--amber-line); color: var(--amber); }
.src-card .mini-link { display: inline-block; margin-top: 9px; }

.cmts { border: 1px solid var(--line); border-radius: var(--r); background: var(--bg-sub); overflow: hidden; max-height: 320px; overflow-y: auto; }
.cmt { display: flex; gap: 10px; align-items: flex-start; padding: 10px 14px; }
.cmt + .cmt { border-top: 1px solid var(--line); }
.cmt-n {
  flex: 0 0 auto; min-width: 28px; padding-top: 1px;
  font-size: 10.5px; font-weight: 600; color: var(--ink-4);
  font-variant-numeric: tabular-nums;
}
.cmt-t { font-size: 12.5px; line-height: 1.7; color: var(--ink-2); word-break: break-word; }

.usage { font-size: 11px; color: var(--ink-4); margin-top: 14px; font-variant-numeric: tabular-nums; text-align: right; }

/* 缓存提示条 */
.cache-tip {
  display: flex; align-items: center; gap: 8px;
  border: 1px solid var(--brand-line); border-radius: var(--r);
  background: var(--brand-soft); color: var(--brand-ink);
  padding: 10px 13px; font-size: 12.5px; line-height: 1.5;
  animation: rise .3s var(--ease-out) both;
}
.cache-tip svg { width: 14px; height: 14px; stroke: var(--brand); fill: none; flex: 0 0 auto; }

.loading { display: flex; flex-direction: column; align-items: center; gap: 13px; padding: 56px 20px; }
.loading .spin {
  width: 24px; height: 24px; border-radius: 50%;
  border: 2.5px solid var(--surface-2); border-top-color: var(--brand);
  animation: spin .8s linear infinite;
}
.loading .lt { font-size: 13px; color: var(--ink-2); }
.loading .ls { font-size: 11.5px; color: var(--ink-4); text-align: center; line-height: 1.6; max-width: 320px; }

/* ==========================================================================
   Toast
   ========================================================================== */

.toasts {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  z-index: 80; display: flex; flex-direction: column-reverse; gap: 7px;
  align-items: center; pointer-events: none; width: max-content; max-width: 90vw;
}
.toast {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 15px 9px 12px; border-radius: var(--r);
  background: #1b1d21; color: #fff; font-size: 12.5px;
  box-shadow: 0 12px 32px -8px rgba(16,18,21,.45), 0 2px 8px rgba(16,18,21,.2);
  animation: toast-in .3s var(--ease-out) both;
  overflow: hidden; position: relative;
  pointer-events: auto; cursor: pointer; max-width: 100%;
}
.toast.out { animation: toast-out .22s var(--ease) both; }
.toast svg { width: 14px; height: 14px; stroke: currentColor; fill: none; flex: 0 0 auto; }
.toast.ok svg { stroke: #4ade80; }
.toast.err { background: #8a1f16; }
.toast.err svg { stroke: #fca5a5; }
.toast::after {
  content: ''; position: absolute; left: 0; bottom: 0; height: 2px; width: 100%;
  background: currentColor; opacity: .28; transform-origin: left;
  animation: drain linear forwards; animation-duration: var(--dur, 2600ms);
}
.toast.err::after { opacity: .45; }

.spinner {
  display: inline-block; width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.32); border-top-color: #fff;
  animation: spin .7s linear infinite; vertical-align: -2px;
}
.btn .spinner { border-color: var(--line-3); border-top-color: var(--brand); }

/* ==========================================================================
   动效
   ========================================================================== */

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes pop-in { from { opacity: 0; transform: scale(.96) translateY(-3px); } to { opacity: 1; transform: none; } }
@keyframes ring-draw { from { stroke-dashoffset: 113.1; } }
@keyframes bar-grow { from { width: 0; } }
@keyframes ping { 0% { opacity: .55; transform: scale(.7); } 70%, 100% { opacity: 0; transform: scale(1.8); } }
@keyframes blink { 50% { opacity: .35; } }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(7px) scale(.98); } }
@keyframes drain { from { transform: scaleX(1); } to { transform: scaleX(0); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important; animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
  .drawer { transition-duration: .12s !important; }
}

/* ==========================================================================
   响应式
   ========================================================================== */

@media (max-width: 1100px) {
  :root { --side-w: 244px; }
  .main-head, .metric, .pool { padding-left: 20px; padding-right: 20px; }
}

@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; width: min(300px, 86vw); z-index: 60;
    transform: translateX(-101%);
    transition: transform .3s var(--ease-out);
    box-shadow: var(--sh-3);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar .side-close, .head-titles .menu-btn { display: grid; }
  .head-titles .menu-btn { margin-right: -4px; }
  .metric-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .img-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
  .main-head {
    height: auto; padding: 11px 14px; gap: 9px;
    flex-wrap: wrap; align-items: center;
  }
  .head-titles { flex: 1 1 auto; min-width: 0; }
  .head-tools { flex: 1 1 100%; min-width: 0; justify-content: space-between; gap: 8px; }
  .tabs { flex: 1 1 0; min-width: 0; overflow-x: auto; }
  .select-wrap { flex: 0 0 auto; }
  .select-wrap select { padding: 6px 26px 6px 10px; font-size: 12px; }
  .metric, .pool { padding-left: 14px; padding-right: 14px; }
  .head-titles h1 { font-size: 14.5px; }
  .pool { padding-bottom: 70px; }
  .card-item { padding: 12px 13px; gap: 11px; }
  .ring, .ring svg { width: 38px; height: 38px; }
  .card-item .go { padding: 7px 10px; }
  .card-item .go span { display: none; }
  .drawer-body { padding: 18px 16px 30px; }
  .drawer-head { padding: 13px 13px 12px 16px; }
  .drawer-foot { padding: 12px 16px; }
  .drawer-foot .btn { flex: 1 1 100%; }
  .img-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
