/* ==========================================================================
   论文降AI · 智能改写工作台 —— 全局样式
   纯原生 CSS：无外部字体、无 CDN、无构建步骤
   视觉基调：深海军蓝 / 石板灰 + 蓝色强调色
   ========================================================================== */

/* ---------------------------------------------------------------
   1. 设计变量
   --------------------------------------------------------------- */
:root {
  --bg: #070c16;
  --surface: #0f1729;
  --surface-2: #141e33;
  --surface-3: #1a2740;
  --border: #22304b;
  --border-soft: #1a2540;
  --text: #e9effb;
  --text-2: #b7c5dd;
  --muted: #7e8da8;
  --accent: #3b82f6;
  --accent-2: #60a5fa;
  --accent-soft: rgba(59, 130, 246, 0.14);
  --cyan: #22d3ee;
  --success: #22c55e;
  --warn: #f59e0b;
  --danger: #ef4444;
  --radius-lg: 16px;
  --radius: 12px;
  --radius-sm: 9px;
  --sidebar-w: 232px;
  --shadow: 0 14px 34px rgba(3, 8, 20, 0.55);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
          "Hiragino Sans GB", "Microsoft YaHei", "Source Han Sans SC",
          "Noto Sans CJK SC", sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

/* ---------------------------------------------------------------
   2. 基础重置
   --------------------------------------------------------------- */
*,
*::before,
*::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* 顶部柔和光晕，避免纯黑背景过于生硬 */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(1100px 520px at 12% -8%, rgba(59, 130, 246, 0.13), transparent 62%),
    radial-gradient(900px 480px at 96% 4%, rgba(34, 211, 238, 0.07), transparent 58%);
}

h1, h2, h3, p, ul { margin: 0; }
ul { padding: 0; list-style: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }

.hidden { display: none !important; }
.muted { color: var(--muted); }

::selection { background: rgba(59, 130, 246, 0.35); }

/* 滚动条（Webkit） */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: #24314c;
  border-radius: 8px;
  border: 2px solid transparent;
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background: #31415f; background-clip: content-box; }

/* 键盘可达性 */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------------------------------------------------------------
   3. 整体布局
   --------------------------------------------------------------- */
.app {
  position: relative;
  z-index: 1;
  min-height: 100vh;
}

/* --- 侧边栏 --- */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  padding: 20px 14px 16px;
  background: linear-gradient(180deg, #0c1425 0%, #080e1b 100%);
  border-right: 1px solid var(--border-soft);
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 4px 8px 20px;
}

.brand-logo {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  background: linear-gradient(135deg, #3b82f6, #22d3ee);
  color: #04101f;
  font-weight: 800;
  font-size: 14px;
  letter-spacing: 0.5px;
  box-shadow: 0 6px 16px rgba(59, 130, 246, 0.35);
}

.brand-name { font-size: 15px; font-weight: 700; letter-spacing: 0.3px; }
.brand-sub { font-size: 11.5px; color: var(--muted); margin-top: 1px; }

.nav {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1 1 auto;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 11px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-2);
  font-size: 13.5px;
  text-align: left;
  transition: background 0.16s ease, color 0.16s ease, border-color 0.16s ease;
}

.nav-item svg { width: 17px; height: 17px; flex: 0 0 17px; opacity: 0.85; }

.nav-item:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
}

.nav-item.active {
  background: var(--accent-soft);
  border-color: rgba(59, 130, 246, 0.32);
  color: #dbeafe;
  font-weight: 600;
}

.nav-item.active svg { opacity: 1; color: var(--accent-2); }

.side-foot { padding-top: 14px; }

.side-card {
  padding: 11px 12px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.02);
}

.side-card-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 5px;
}

.side-card-row strong {
  color: var(--text-2);
  font-weight: 600;
  font-size: 12px;
  max-width: 110px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mini-track {
  height: 4px;
  border-radius: 999px;
  background: #1b2740;
  overflow: hidden;
  margin-top: 8px;
}

.mini-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--cyan));
  transition: width 0.4s ease;
}

.side-note {
  margin-top: 10px;
  text-align: center;
  font-size: 11px;
  color: #5c6a83;
}

/* --- 主区域 --- */
.main {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 15;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 14px 28px;
  background: rgba(8, 14, 26, 0.82);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-soft);
}

.topbar-left h1 {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.topbar-left p {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.content {
  flex: 1 1 auto;
  padding: 22px 28px 52px;
  max-width: 1640px;
  width: 100%;
}

/* ---------------------------------------------------------------
   4. 通用组件
   --------------------------------------------------------------- */

/* --- 页面切换 --- */
.page { display: none; }
.page.active { display: block; animation: pageIn 0.24s ease both; }

@keyframes pageIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

/* --- 卡片 --- */
.card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  margin-bottom: 16px;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.02) inset;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.card-head h2 {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.3px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-head h2::before {
  content: "";
  width: 3px;
  height: 14px;
  border-radius: 2px;
  background: linear-gradient(180deg, var(--accent), var(--cyan));
}

.card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  flex-wrap: wrap;
}

/* --- 按钮 --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  transition: background 0.16s ease, border-color 0.16s ease,
              color 0.16s ease, transform 0.1s ease;
}

.btn:hover:not(:disabled) {
  background: var(--surface-3);
  border-color: #2c3c5c;
  color: var(--text);
}

.btn:active:not(:disabled) { transform: translateY(1px); }

.btn:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(180deg, #3b82f6, #2f6fe0);
  border-color: #2f6fe0;
  color: #fff;
  font-weight: 600;
  box-shadow: 0 6px 16px rgba(47, 111, 224, 0.28);
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(180deg, #4a8dfa, #3b82f6);
  border-color: #4a8dfa;
  color: #fff;
}

.btn-danger {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.42);
  color: #fca5a5;
}

.btn-danger:hover:not(:disabled) {
  background: rgba(239, 68, 68, 0.2);
  border-color: rgba(239, 68, 68, 0.6);
  color: #fecaca;
}

.btn-sm { padding: 5px 11px; font-size: 12px; }

.btn-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* --- 分段控件 --- */
.segmented {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
}

.seg {
  padding: 6px 14px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  transition: background 0.16s ease, color 0.16s ease;
}

.seg:hover { color: var(--text-2); background: rgba(255, 255, 255, 0.035); }

.seg.active {
  background: var(--accent-soft);
  color: #bfdbfe;
  font-weight: 600;
  box-shadow: inset 0 0 0 1px rgba(59, 130, 246, 0.32);
}

/* --- 字段 / 下拉 --- */
.controls-card { padding: 16px 18px 14px; }

.control-row {
  display: flex;
  align-items: flex-end;
  gap: 18px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.control-row:last-of-type { margin-bottom: 0; }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-grow { flex: 1 1 320px; }

.field-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0.2px;
}

.select {
  width: 100%;
  min-width: 190px;
  padding: 8px 34px 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background-color: var(--surface-2);
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%237e8da8' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
  color: var(--text-2);
  font-size: 13px;
  appearance: none;
  -webkit-appearance: none;
  text-overflow: ellipsis;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.select:hover { border-color: #2c3c5c; }

.select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.select option {
  background: #101a2c;
  color: var(--text);
}

/* --- 提示文字 --- */
.hint {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
}

.counter {
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* --- 状态胶囊 --- */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.pill .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #4b5a76;
  flex: 0 0 6px;
}

.pill.ok { color: #86efac; border-color: rgba(34, 197, 94, 0.3); }
.pill.ok .dot { background: var(--success); box-shadow: 0 0 8px rgba(34, 197, 94, 0.8); }

.pill.bad { color: #fca5a5; border-color: rgba(239, 68, 68, 0.3); }
.pill.bad .dot { background: var(--danger); box-shadow: 0 0 8px rgba(239, 68, 68, 0.8); }

.pill-quota { color: var(--text-2); font-variant-numeric: tabular-nums; }
.pill-mini { padding: 2px 8px; font-size: 11px; }

/* --- 状态芯片（输出面板） --- */
.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 11px;
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.status-chip .chip-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4b5a76;
  flex: 0 0 7px;
}

.status-chip.is-running { color: #bfdbfe; border-color: rgba(59, 130, 246, 0.4); }
.status-chip.is-running .chip-dot {
  background: var(--accent-2);
  animation: pulse 1.1s ease-in-out infinite;
}

.status-chip.is-done { color: #86efac; border-color: rgba(34, 197, 94, 0.34); }
.status-chip.is-done .chip-dot { background: var(--success); }

.status-chip.is-error { color: #fca5a5; border-color: rgba(239, 68, 68, 0.4); }
.status-chip.is-error .chip-dot { background: var(--danger); }

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.35; transform: scale(0.72); }
}

/* --- 进度条 --- */
.progress-line {
  height: 3px;
  margin: 0 0 10px;
  border-radius: 999px;
  background: #16213a;
  overflow: hidden;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.progress-line.active { opacity: 1; }

.progress-line-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--cyan));
  transition: width 0.35s ease;
}

/* ---------------------------------------------------------------
   5. 工作台 / 文档页
   --------------------------------------------------------------- */
.work-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
  align-items: stretch;
}

.work-grid > .card {
  margin-bottom: 0;
  display: flex;
  flex-direction: column;
  /* 让左右两栏尽量填满首屏，同时避免小屏被强行撑高 */
  min-height: clamp(420px, calc(100vh - 372px), 720px);
}

.editor {
  flex: 1 1 auto;
  width: 100%;
  min-height: 320px;
  padding: 13px 15px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #0b1322;
  color: var(--text-2);
  font-size: 14px;
  line-height: 1.85;
  resize: vertical;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.editor::placeholder { color: #56657f; }

.editor:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* 统计条 */
.stats-bar {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  margin-bottom: 10px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  background: var(--border-soft);
  overflow: hidden;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 9px 12px;
  background: var(--surface-2);
}

.stat-label { font-size: 11px; color: var(--muted); letter-spacing: 0.2px; }

.stat-value {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.2px;
}

.stat-value.good { color: #4ade80; }
.stat-value.warn { color: #fbbf24; }
.stat-value.bad  { color: #f87171; }

/* 输出区 */
.output-body {
  flex: 1 1 auto;
  min-height: 300px;
  max-height: 520px;
  overflow-y: auto;
  padding: 14px 16px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  background: #0b1322;
  font-size: 14px;
  line-height: 1.95;
  color: var(--text-2);
  scroll-behavior: smooth;
}

.out-para {
  margin: 0 0 11px;
  animation: fadeUp 0.3s ease both;
  word-break: break-word;
}

.out-para:last-child { margin-bottom: 0; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(5px); }
  to   { opacity: 1; transform: none; }
}

.empty-state {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 120px;
  padding: 20px;
  color: #55647e;
  font-size: 13px;
  text-align: center;
}

/* 打字光标 */
.caret::after {
  content: "▍";
  color: var(--accent-2);
  animation: blink 1s step-end infinite;
  margin-left: 1px;
}

@keyframes blink { 50% { opacity: 0; } }

/* --- 上传区 --- */
.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex: 1 1 auto;
  min-height: 220px;
  padding: 28px 20px;
  border: 1.5px dashed #2a3a58;
  border-radius: var(--radius);
  background: rgba(59, 130, 246, 0.03);
  color: var(--muted);
  text-align: center;
  cursor: pointer;
  transition: border-color 0.18s ease, background 0.18s ease, color 0.18s ease;
}

.dropzone svg { width: 30px; height: 30px; color: #4d6a9c; }

.dropzone:hover,
.dropzone.drag {
  border-color: var(--accent);
  background: rgba(59, 130, 246, 0.09);
  color: var(--text-2);
}

.dropzone.drag { box-shadow: inset 0 0 0 3px var(--accent-soft); }

.dz-title { font-size: 14px; font-weight: 600; color: var(--text-2); }
.dz-sub { font-size: 12px; color: var(--muted); }

.file-info {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  padding: 9px 12px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  flex-wrap: wrap;
}

.file-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------------------------------------------------------------
   6. AI率检测
   --------------------------------------------------------------- */
.detect-result {
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 8px 4px 14px;
  flex-wrap: wrap;
}

.gauge-wrap {
  position: relative;
  width: 160px;
  height: 160px;
  flex: 0 0 160px;
}

.gauge {
  width: 160px;
  height: 160px;
  transform: rotate(-90deg);
}

.gauge-track,
.gauge-fill {
  fill: none;
  stroke-width: 13;
  stroke-linecap: round;
}

.gauge-track { stroke: #17233a; }

.gauge-fill {
  stroke: var(--accent);
  stroke-dasharray: 414.69;
  stroke-dashoffset: 414.69;
  transition: stroke-dashoffset 0.7s cubic-bezier(0.22, 1, 0.36, 1), stroke 0.4s ease;
}

.gauge-fill.low  { stroke: var(--success); }
.gauge-fill.mid  { stroke: var(--warn); }
.gauge-fill.high { stroke: var(--danger); }

.gauge-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}

.gauge-value {
  font-size: 27px;
  font-weight: 800;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.5px;
}

.gauge-unit { font-size: 11px; color: var(--muted); }

.detect-meta { flex: 1 1 200px; display: flex; flex-direction: column; gap: 9px; }

.meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 8px;
  border-bottom: 1px dashed var(--border-soft);
  font-size: 13px;
  color: var(--muted);
}

.meta-row:last-child { border-bottom: none; padding-bottom: 0; }

.meta-row strong { color: var(--text-2); font-weight: 600; }

.risk-badge {
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px !important;
  border: 1px solid transparent;
}

.risk-badge.none { color: var(--muted); }
.risk-badge.low  { color: #86efac; background: rgba(34, 197, 94, 0.12); border-color: rgba(34, 197, 94, 0.35); }
.risk-badge.medium { color: #fcd34d; background: rgba(245, 158, 11, 0.12); border-color: rgba(245, 158, 11, 0.35); }
.risk-badge.high { color: #fca5a5; background: rgba(239, 68, 68, 0.12); border-color: rgba(239, 68, 68, 0.38); }

.risk-box {
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.02);
  padding: 12px 14px;
}

.risk-title {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 8px;
}

.risk-list { display: flex; flex-direction: column; gap: 7px; }

.risk-list li {
  position: relative;
  padding-left: 18px;
  font-size: 12.5px;
  line-height: 1.65;
  color: var(--text-2);
}

.risk-list li::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 8px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
}

.risk-list li.muted { color: var(--muted); }
.risk-list li.muted::before { background: #3d4a63; }

/* ---------------------------------------------------------------
   7. 表格 / 分页
   --------------------------------------------------------------- */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  min-width: 760px;
}

.table th {
  padding: 10px 14px;
  text-align: left;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.4px;
  color: var(--muted);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border-soft);
  white-space: nowrap;
}

.table td {
  padding: 10px 14px;
  border-bottom: 1px solid rgba(34, 48, 75, 0.55);
  color: var(--text-2);
  vertical-align: middle;
}

.table tbody tr:last-child td { border-bottom: none; }

.table-hover tbody tr { transition: background 0.14s ease; }
.table-hover tbody tr:hover { background: rgba(59, 130, 246, 0.07); cursor: pointer; }

.table .th-actions,
.table td.td-actions { text-align: right; white-space: nowrap; }

.table-empty {
  padding: 26px 14px !important;
  text-align: center;
  color: var(--muted);
}

.td-mono { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.td-name {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tag {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 6px;
  font-size: 11.5px;
  background: rgba(59, 130, 246, 0.12);
  color: #93c5fd;
  border: 1px solid rgba(59, 130, 246, 0.24);
}

.tag-lang { background: rgba(34, 211, 238, 0.1); color: #67e8f9; border-color: rgba(34, 211, 238, 0.24); }

.ai-ok { color: #4ade80; font-weight: 600; }
.ai-mid { color: #fbbf24; font-weight: 600; }
.ai-bad { color: #f87171; font-weight: 600; }

.row-btn {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: transparent;
  color: var(--text-2);
  font-size: 12px;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.14s ease, color 0.14s ease, border-color 0.14s ease;
}

.row-btn:hover {
  background: var(--surface-3);
  color: var(--text);
  border-color: #2c3c5c;
  text-decoration: none;
}
.row-btn.danger { color: #f87171; border-color: rgba(239, 68, 68, 0.3); }
.row-btn.danger:hover { background: rgba(239, 68, 68, 0.14); }

.pagination { justify-content: center; gap: 14px; }

.page-info {
  font-size: 12.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  min-width: 110px;
  text-align: center;
}

/* ---------------------------------------------------------------
   8. 数据统计
   --------------------------------------------------------------- */
.stats-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.stats-grid > .card { margin-bottom: 0; }

.chart-list { display: flex; flex-direction: column; gap: 13px; }

.bar-row { display: flex; flex-direction: column; gap: 6px; }

.bar-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  font-size: 12.5px;
}

.bar-name {
  color: var(--text-2);
  font-family: var(--mono);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-count {
  color: var(--text);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  flex: 0 0 auto;
}

.track {
  height: 8px;
  border-radius: 999px;
  background: #16213a;
  overflow: hidden;
}

.track-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--cyan));
  transition: width 0.55s cubic-bezier(0.22, 1, 0.36, 1);
}

.quota-block { padding: 4px 0 14px; }

.quota-nums {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-size: 21px;
  font-weight: 700;
  margin-bottom: 9px;
  font-variant-numeric: tabular-nums;
}

.quota-nums .muted { font-size: 12.5px; font-weight: 400; }

.kv-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  background: var(--border-soft);
  overflow: hidden;
}

.kv-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); margin-top: 14px; }

.kv {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 11px 14px;
  background: var(--surface-2);
}

.kv span { font-size: 11.5px; color: var(--muted); }
.kv strong { font-size: 14px; font-weight: 600; color: var(--text-2); font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------
   9. 关于页
   --------------------------------------------------------------- */
.prose p {
  font-size: 13.5px;
  line-height: 1.9;
  color: var(--text-2);
  margin-bottom: 10px;
}

.prose p:last-child { margin-bottom: 0; }
.prose strong { color: #bfdbfe; font-weight: 600; }

.provider-cards { display: flex; flex-direction: column; gap: 12px; }

.provider-card {
  padding: 12px 14px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.02);
}

.provider-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.provider-name { font-size: 13.5px; font-weight: 600; color: var(--text); }

.provider-card p { font-size: 12.5px; line-height: 1.75; color: var(--muted); }

.tip-list { display: flex; flex-direction: column; gap: 9px; }

.tip-list li {
  position: relative;
  padding-left: 20px;
  font-size: 12.5px;
  line-height: 1.7;
  color: var(--text-2);
}

.tip-list li::before {
  content: "✓";
  position: absolute;
  left: 2px;
  top: 0;
  color: var(--success);
  font-size: 12px;
  font-weight: 700;
}

/* ---------------------------------------------------------------
   10. Toast
   --------------------------------------------------------------- */
.toast-container {
  position: fixed;
  right: 22px;
  /* 顶部对齐：避免遮挡输出面板右下角的「复制结果 / 下载TXT」按钮 */
  top: 84px;
  z-index: 90;
  display: flex;
  flex-direction: column;
  gap: 9px;
  max-width: 380px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-left-width: 3px;
  border-radius: var(--radius-sm);
  background: #121c2f;
  color: var(--text-2);
  font-size: 13px;
  line-height: 1.55;
  box-shadow: var(--shadow);
  animation: toastIn 0.24s ease both;
  pointer-events: auto;
  word-break: break-word;
}

.toast.out { animation: toastOut 0.2s ease both; }

.toast .t-icon {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  margin-top: 1px;
  font-weight: 700;
  font-size: 13px;
  text-align: center;
}

.toast-info    { border-left-color: var(--accent); }
.toast-info .t-icon { color: var(--accent-2); }
.toast-success { border-left-color: var(--success); }
.toast-success .t-icon { color: #4ade80; }
.toast-warn    { border-left-color: var(--warn); }
.toast-warn .t-icon { color: #fbbf24; }
.toast-error   { border-left-color: var(--danger); }
.toast-error .t-icon { color: #f87171; }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(16px) scale(0.98); }
  to   { opacity: 1; transform: none; }
}

@keyframes toastOut {
  to { opacity: 0; transform: translateX(16px) scale(0.98); }
}

/* ---------------------------------------------------------------
   11. 弹窗
   --------------------------------------------------------------- */
.modal-root {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 8, 16, 0.72);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  animation: fadeIn 0.18s ease both;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(1120px, 100%);
  max-height: min(86vh, 900px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
  animation: modalIn 0.22s cubic-bezier(0.22, 1, 0.36, 1) both;
  overflow: hidden;
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(14px) scale(0.985); }
  to   { opacity: 1; transform: none; }
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-soft);
}

.modal-head h3 { font-size: 15px; font-weight: 700; margin-bottom: 3px; }

.icon-btn {
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  transition: background 0.15s ease, color 0.15s ease;
}

.icon-btn:hover { background: var(--surface-3); color: var(--text); }

.modal-body {
  flex: 1 1 auto;
  overflow: auto;
  padding: 16px 20px;
}

.diff-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 14px;
}

.diff-pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  background: #0b1322;
  overflow: hidden;
}

.diff-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-soft);
  background: var(--surface-2);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
}

.diff-text {
  flex: 1 1 auto;
  max-height: 52vh;
  overflow-y: auto;
  padding: 12px 14px;
  font-size: 13px;
  line-height: 1.9;
  color: var(--text-2);
  white-space: pre-wrap;
  word-break: break-word;
}

.modal-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 9px;
  padding: 13px 20px;
  border-top: 1px solid var(--border-soft);
  background: rgba(255, 255, 255, 0.015);
}

/* ---------------------------------------------------------------
   12. 其它
   --------------------------------------------------------------- */
.noscript {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  background: var(--bg);
  color: var(--text-2);
  font-size: 15px;
  padding: 24px;
  text-align: center;
}

/* 按钮内的加载小圆环 */
.spinner {
  width: 13px;
  height: 13px;
  border: 2px solid rgba(255, 255, 255, 0.28);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex: 0 0 13px;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------------
   13. 响应式
   --------------------------------------------------------------- */
@media (max-width: 1280px) {
  .content { padding: 20px 20px 48px; }
  .topbar { padding: 12px 20px; }
}

@media (max-width: 1100px) {
  .work-grid,
  .stats-grid { grid-template-columns: minmax(0, 1fr); }
  .work-grid > .card { min-height: 0; }
  .stats-bar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .diff-grid { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 860px) {
  .sidebar {
    position: static;
    width: 100%;
    height: auto;
    flex-direction: column;
    padding: 12px 12px 8px;
    border-right: none;
    border-bottom: 1px solid var(--border-soft);
  }

  .brand { padding: 2px 6px 12px; }

  .nav {
    flex-direction: row;
    overflow-x: auto;
    gap: 6px;
    padding-bottom: 4px;
  }

  .nav-item {
    width: auto;
    white-space: nowrap;
    padding: 8px 12px;
  }

  .side-foot { display: none; }

  .main { margin-left: 0; }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    position: static;
  }

  .topbar-right { justify-content: flex-start; }

  .content { padding: 16px 14px 40px; }

  .kv-grid,
  .kv-grid-3 { grid-template-columns: minmax(0, 1fr); }

  .modal { max-height: 92vh; }
  .modal-foot { flex-wrap: wrap; }

  .toast-container { top: auto; left: 14px; right: 14px; bottom: 14px; max-width: none; }
}

/* 减少动效偏好 */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
