/* ============ CSS 变量 / 主题 ============ */
:root {
  --bg: #0b0f1a;
  --bg-soft: #0f1626;
  --surface: #131b2e;
  --surface-2: #1a2440;
  --border: #243056;
  --text: #e7ecf7;
  --text-dim: #9aa6c2;
  --muted: #6f7a96;
  --primary: #6c8cff;
  --primary-2: #8a6cff;
  --accent: #00e0c6;
  --success: #2bd47b;
  --warning: #ffb547;
  --danger: #ff5a6e;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --radius: 14px;
  --radius-sm: 10px;
  --transition: 220ms cubic-bezier(.2,.7,.2,1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: radial-gradient(1200px 800px at 10% -10%, #1a244a 0%, transparent 60%),
              radial-gradient(1000px 700px at 100% 0%, #2a1d4a 0%, transparent 60%),
              var(--bg);
  min-height: 100vh;
  overflow-x: hidden;
}

/* 背景装饰 */
.bg-decor {
  position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden;
}
.blob {
  position: absolute; border-radius: 50%; filter: blur(80px); opacity: 0.4;
  animation: float 18s ease-in-out infinite;
}
.blob-1 { width: 360px; height: 360px; left: -80px; top: 20%; background: #6c8cff; }
.blob-2 { width: 320px; height: 320px; right: -100px; top: 10%; background: #8a6cff; animation-delay: -6s;}
.blob-3 { width: 280px; height: 280px; left: 30%; bottom: -120px; background: #00e0c6; opacity: 0.25; animation-delay: -12s; }
@keyframes float {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50%      { transform: translate(40px, -30px) scale(1.08); }
}

/* ============ Header ============ */
.app-header {
  position: relative; z-index: 1;
  display: flex; align-items: center; justify-content: space-between;
  padding: 22px 28px; gap: 16px;
  backdrop-filter: blur(8px);
  background: linear-gradient(180deg, rgba(15,22,38,.6), rgba(15,22,38,0));
  border-bottom: 1px solid rgba(255,255,255,.04);
}
.brand { display: flex; align-items: center; gap: 14px; }
.logo {
  font-size: 32px; line-height: 1;
  display: inline-grid; place-items: center;
  width: 48px; height: 48px; border-radius: 14px;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  box-shadow: 0 8px 20px rgba(108,140,255,.35);
}
.brand h1 { font-size: 18px; margin: 0; letter-spacing: .3px; }
.subtitle { margin: 4px 0 0; color: var(--text-dim); font-size: 12.5px; }
.header-actions { display: flex; align-items: center; gap: 10px; }
.pill {
  font-size: 12px; color: var(--text-dim);
  padding: 6px 10px; border: 1px solid var(--border);
  border-radius: 999px; background: rgba(255,255,255,.02);
}
.pill strong { color: var(--text); font-weight: 600; margin-left: 4px; }

/* ============ Layout ============ */
.layout {
  position: relative; z-index: 1;
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 18px;
  padding: 18px 28px 60px;
  max-width: 1400px;
  margin: 0 auto;
}
@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; }
}

.panel { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

.card {
  background: linear-gradient(180deg, var(--surface), var(--bg-soft));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}
.card-title {
  display: flex; align-items: center; gap: 10px;
  font-size: 14px; font-weight: 600; margin: 0 0 14px;
  color: var(--text);
}
.num {
  display: inline-grid; place-items: center;
  width: 22px; height: 22px; border-radius: 7px;
  font-size: 12px; font-weight: 700;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: white;
}

/* ============ Form ============ */
.form-row { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.form-row:last-child { margin-bottom: 0; }
.form-row label { font-size: 12.5px; color: var(--text-dim); font-weight: 500; }
.hint { color: var(--muted); font-size: 11.5px; line-height: 1.5; }
.hint code {
  background: rgba(255,255,255,.06);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 11px;
  word-break: break-all;
  user-select: text;
}
#configPath {
  display: inline-block;
  max-width: 100%;
  color: var(--accent);
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
}

/* Key 状态徽章 */
.key-badge {
  display: inline-block;
  font-size: 10.5px; font-weight: 600;
  padding: 2px 8px; border-radius: 999px;
  background: var(--surface-2); color: var(--muted);
  border: 1px solid var(--border);
  margin-left: 6px; vertical-align: middle;
  transition: all var(--transition);
}
.key-badge.on {
  background: rgba(43,212,123,.12);
  color: var(--success);
  border-color: rgba(43,212,123,.4);
}
.key-badge.env {
  background: rgba(139,92,246,.14);
  color: #c4b5fd;
  border-color: rgba(139,92,246,.45);
}

/* 上次自动保存时间戳 */
.last-saved {
  font-size: 11.5px;
  color: var(--muted);
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 6px;
  background: rgba(255,255,255,.03);
  border: 1px solid var(--border);
  white-space: nowrap;
}

/* 头部内联提示(灰色小字) */
.hint-inline {
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 400;
  white-space: nowrap;
}

/* 余额结果 pill */
.balance-pill {
  font-size: 12px;
  font-weight: 500;
  padding: 5px 10px;
  border-radius: 999px;
  white-space: nowrap;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
}
.balance-pill.ok {
  background: rgba(43,212,123,.12);
  color: var(--success);
  border-color: rgba(43,212,123,.4);
}
.balance-pill.err {
  background: rgba(255,107,107,.12);
  color: #ff8a8a;
  border-color: rgba(255,107,107,.4);
}
.saved-flash {
  display: inline-block;
  font-size: 10.5px; font-weight: 600;
  margin-left: 6px;
  padding: 2px 8px; border-radius: 999px;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: white;
  opacity: 0; transform: translateY(-2px) scale(.9);
  pointer-events: none;
}
.saved-flash.show { animation: flashPop 1.4s ease; }
@keyframes flashPop {
  0%   { opacity: 0; transform: translateY(-2px) scale(.9); }
  15%  { opacity: 1; transform: translateY(0) scale(1); }
  70%  { opacity: 1; transform: translateY(0) scale(1); }
  100% { opacity: 0; transform: translateY(-2px) scale(.9); }
}

/* 版本更新横幅(检测到服务端新版本时弹) */
#updateBanner {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 9999;
  display: flex; align-items: center; gap: 12px;
  background: linear-gradient(135deg, #6c8cff, #8b5cf6);
  color: white;
  padding: 12px 18px;
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(108, 140, 255, .4);
  font-size: 13.5px; font-weight: 500;
  animation: bannerSlide 0.3s ease;
}
@keyframes bannerSlide {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}
#updateBanner .banner-btn {
  background: white;
  color: #6c8cff;
  border: none;
  padding: 6px 14px;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  font-size: 13px;
}
#updateBanner .banner-btn:hover { background: #f0f4ff; }
#updateBanner .banner-close {
  background: transparent;
  color: white;
  border: none;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
  opacity: 0.7;
}
#updateBanner .banner-close:hover { opacity: 1; }

input[type="text"], input[type="password"], textarea, select {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font: inherit; font-size: 13.5px;
}
input[disabled], textarea[disabled], textarea[readonly] {
  background: rgba(255,255,255,.02);
  color: var(--text-dim);
  cursor: not-allowed;
  opacity: .8;
}
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
textarea { font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; font-size: 12.5px; line-height: 1.55; resize: vertical; }
input:focus, textarea:focus, select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(108,140,255,.18);
}

.input-with-icon { position: relative; }
.input-with-icon input { padding-right: 40px; }
.icon-btn {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  background: transparent; border: 0; color: var(--text-dim);
  cursor: pointer; padding: 6px; border-radius: 6px; transition: background var(--transition);
}
.icon-btn:hover { background: rgba(255,255,255,.06); color: var(--text); }

.row { display: flex; align-items: center; gap: 10px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }

input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 6px; background: var(--surface-2);
  border-radius: 999px; outline: none; border: 1px solid var(--border); padding: 0;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 18px; height: 18px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  cursor: pointer; box-shadow: 0 0 0 3px rgba(108,140,255,.25);
  transition: transform var(--transition);
}
input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.1); }
input[type="range"]::-moz-range-thumb {
  width: 18px; height: 18px; border-radius: 50%; border: 0;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  cursor: pointer; box-shadow: 0 0 0 3px rgba(108,140,255,.25);
}
.badge {
  min-width: 36px; text-align: center;
  background: var(--surface-2); border: 1px solid var(--border);
  padding: 4px 8px; border-radius: 8px; font-size: 12.5px; font-weight: 600;
}

/* ============ Buttons ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 14px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text);
  font: inherit; font-size: 13px; font-weight: 500;
  cursor: pointer; transition: transform var(--transition), background var(--transition), border-color var(--transition);
}
.btn:hover:not(:disabled) { transform: translateY(-1px); border-color: rgba(255,255,255,.18); }
.btn:active:not(:disabled) { transform: translateY(0); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  border-color: transparent; color: white; font-weight: 600;
  box-shadow: 0 6px 18px rgba(108,140,255,.35);
}
.btn-primary:hover:not(:disabled) { box-shadow: 0 10px 24px rgba(108,140,255,.45); }
.btn-ghost { background: transparent; }
.btn-sm { padding: 6px 10px; font-size: 12px; border-radius: 8px; }
.btn-link {
  background: transparent; border: 0; color: var(--primary); cursor: pointer;
  font: inherit; font-size: 13px; padding: 0; text-decoration: underline; text-underline-offset: 3px;
}
.btn-link:hover { color: var(--accent); }

/* ============ Tabs ============ */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin: -4px -4px 16px; padding: 0 4px; }
.tab {
  background: transparent; border: 0; color: var(--text-dim);
  padding: 10px 14px; font: inherit; font-size: 13.5px; font-weight: 500;
  cursor: pointer; position: relative; border-radius: 8px 8px 0 0;
  transition: color var(--transition);
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); }
.tab.active::after {
  content: ''; position: absolute; left: 8px; right: 8px; bottom: -1px;
  height: 2px; border-radius: 2px;
  background: linear-gradient(90deg, var(--primary), var(--primary-2));
}
.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fadeIn .25s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px);} to { opacity: 1; transform: none;} }

/* ============ 来源提示 ============ */
.source-hint {
  margin-bottom: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 12.5px; line-height: 1.6;
  border: 1px solid var(--border);
  background: var(--surface-2);
}
.source-hint code {
  background: rgba(255,255,255,.08); padding: 1px 6px; border-radius: 4px; font-size: 11.5px;
}
.source-hint.ok {
  border-color: rgba(43,212,123,.4);
  background: rgba(43,212,123,.08);
  color: var(--success);
}
.source-hint.warn {
  border-color: rgba(255,181,71,.45);
  background: rgba(255,181,71,.08);
  color: var(--warning);
}
.source-hint b { color: var(--text); font-weight: 600; }
.dropzone {
  position: relative;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  padding: 32px;
  min-height: 220px;
  display: grid; place-items: center;
  text-align: center; cursor: pointer;
  transition: border-color var(--transition), background var(--transition), transform var(--transition);
  overflow: hidden;
}
.dropzone:hover { border-color: rgba(108,140,255,.5); }
.dropzone .dz-row { margin-top: 12px; }
.dropzone .dz-row .btn { padding: 12px 22px; font-size: 14px; }
.dropzone.drag-over {
  border-color: var(--primary);
  background: rgba(108,140,255,.08);
  transform: scale(1.005);
}
.dz-icon { font-size: 40px; margin-bottom: 8px; }
.dz-text { color: var(--text); font-size: 14px; }
.dz-sub  { color: var(--muted); font-size: 12px; margin-top: 6px; }
.preview {
  max-width: 100%; max-height: 360px; border-radius: var(--radius-sm);
  box-shadow: 0 6px 16px rgba(0,0,0,.4);
}
.preview.hidden, .hidden { display: none !important; }

.actions { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }

/* ============ Result ============ */
.result {
  margin-top: 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 16px;
  background: var(--surface-2);
  animation: fadeIn .3s ease;
}
.result-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.verdict {
  font-weight: 700; font-size: 14px; padding: 4px 10px; border-radius: 999px;
}
.verdict.low    { background: rgba(43,212,123,.15); color: var(--success); border: 1px solid rgba(43,212,123,.4); }
.verdict.high   { background: rgba(255,90,110,.15); color: var(--danger);  border: 1px solid rgba(255,90,110,.4); }
.verdict.error  { background: rgba(255,181,71,.15); color: var(--warning); border: 1px solid rgba(255,181,71,.4); }
.verdict.review { background: rgba(255,181,71,.15); color: var(--warning); border: 1px solid rgba(255,181,71,.4); }
.reasons { color: var(--text-dim); font-size: 13px; line-height: 1.6; white-space: pre-wrap; }
.raw { margin-top: 10px; color: var(--muted); font-size: 12px; white-space: pre-wrap; word-break: break-word; }

/* ============ Batch ============ */
.batch-toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin: 14px 0 10px; flex-wrap: wrap;
}
.batch-stats { color: var(--text-dim); font-size: 13px; }
.progress-wrap { margin-bottom: 12px; }
.progress { width: 100%; height: 8px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; overflow: hidden; }
.progress-bar {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  transition: width var(--transition);
}
.progress-text { font-size: 12px; color: var(--text-dim); margin-top: 6px; text-align: right; }

.file-list {
  list-style: none; padding: 0; margin: 0;
  display: grid; gap: 8px; max-height: 460px; overflow: auto;
  padding-right: 4px;
}
.file-item {
  display: grid; grid-template-columns: 48px 1fr auto; gap: 12px; align-items: center;
  padding: 8px; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: transform var(--transition), border-color var(--transition);
  animation: slideIn .3s ease;
}
@keyframes slideIn { from { opacity: 0; transform: translateY(6px);} to { opacity: 1; transform: none; } }
.file-item:hover { border-color: rgba(255,255,255,.16); }
.file-item.processing { border-color: var(--primary); }
.file-item.low  { border-color: rgba(43,212,123,.4); }
.file-item.high { border-color: rgba(255,90,110,.45); }
.file-item.error{ border-color: rgba(255,181,71,.4); }
.thumb { width: 48px; height: 48px; border-radius: 8px; object-fit: cover; background: #000; }
.file-meta { min-width: 0; }
.file-name { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-sub  { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.file-status {
  font-size: 11.5px; padding: 4px 8px; border-radius: 999px; font-weight: 600;
  background: var(--surface); border: 1px solid var(--border);
  white-space: nowrap;
}
.file-status.pending  { color: var(--text-dim); }
.file-status.running  { color: var(--primary); border-color: rgba(108,140,255,.4); }
.file-status.low      { color: var(--success); border-color: rgba(43,212,123,.4); background: rgba(43,212,123,.08); }
.file-status.high     { color: var(--danger);  border-color: rgba(255,90,110,.4); background: rgba(255,90,110,.08); }
.file-status.error    { color: var(--warning); border-color: rgba(255,181,71,.4); }
.file-detail { grid-column: 1 / -1; padding: 6px 4px 0; color: var(--text-dim); font-size: 12.5px; line-height: 1.55; border-top: 1px dashed var(--border); margin-top: 4px;}

/* ============ Log ============ */
.log-card { padding-bottom: 8px; }
.log {
  margin: 0; max-height: 220px; overflow: auto;
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 12px; line-height: 1.55; color: var(--text-dim);
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px;
  white-space: pre-wrap; word-break: break-word;
}
.log .ok   { color: var(--success); }
.log .err  { color: var(--danger); }
.log .warn { color: var(--warning); }
.log .info { color: var(--primary); }

/* ============ Toast ============ */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 16px; font-size: 13px;
  box-shadow: var(--shadow);
  z-index: 50;
  animation: toastIn .3s ease;
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 8px);} to { opacity: 1; transform: translate(-50%, 0);} }

/* ============ Modal ============ */
.modal-mask {
  position: fixed; inset: 0; background: rgba(0,0,0,.55);
  display: none; align-items: center; justify-content: center;
  z-index: 100; backdrop-filter: blur(4px);
}
.modal-mask.show { display: flex; animation: fadeIn .2s ease; }
.modal-box {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 20px; min-width: 320px; max-width: 480px;
  box-shadow: var(--shadow);
}
.modal-text { color: var(--text); font-size: 14px; line-height: 1.6; white-space: pre-wrap; margin-bottom: 16px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; }

/* 版本信息(在左侧系统信息卡片里) — 字体跟随卡片默认无衬线,与批量参数一致 */
.version-info {
  background: rgba(108,140,255,.06);
  border: 1px solid rgba(108,140,255,.15);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-family: inherit;
  line-height: 1.6;
}
.version-info .vi-row { display: block; }
.version-info .vi-ver  { color: #6c8cff; font-weight: 700; font-size: 14px; }
.version-info .vi-sub  { color: var(--text-dim); font-size: 12px; }
.version-info .vi-build { color: var(--muted); font-size: 11.5px; margin-top: 2px; }
