:root {
  --bg: #0f131a;
  --bg-soft: #151b25;
  --card: #1a2230;
  --card-2: #202a3a;
  --line: #2d3a4f;
  --text: #e8edf6;
  --muted: #8b9bb4;
  --accent: #5eead4;
  --accent-2: #38bdf8;
  --warn: #fbbf24;
  --danger: #fb7185;
  --ok: #34d399;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background:
    radial-gradient(1200px 600px at 90% -10%, rgba(56, 189, 248, .08), transparent 60%),
    radial-gradient(900px 500px at -10% 20%, rgba(94, 234, 212, .07), transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

code, pre { font-family: "Cascadia Code", Consolas, "Courier New", monospace; }
code { color: var(--accent); background: rgba(94, 234, 212, .08); padding: 1px 5px; border-radius: 4px; }
a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }
.hidden { display: none !important; }
.spacer { flex: 1; }
.hint { color: var(--muted); font-size: 12px; font-weight: normal; }

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 22px;
  background: rgba(21, 27, 37, .85);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 20;
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 230px; }
.logo { font-size: 26px; filter: drop-shadow(0 0 10px rgba(94,234,212,.35)); }
.brand h1 { font-size: 15px; margin: 0; letter-spacing: .3px; }
.brand p { margin: 1px 0 0; color: var(--muted); font-size: 11px; }
.engine-box {
  display: flex; align-items: center; gap: 10px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; padding: 7px 10px; flex: 1; min-width: 420px;
}
.engine-text { display: flex; flex-direction: column; min-width: 150px; }
.engine-text strong { font-size: 13px; }
.engine-text small { color: var(--muted); font-size: 11px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.ok { background: var(--ok); box-shadow: 0 0 0 4px rgba(52, 211, 153, .14); }
.dot.busy { background: var(--warn); animation: pulse 1.2s infinite; }
.dot.off { background: var(--danger); }
@keyframes pulse { 50% { opacity: .35; } }
.gpu-chip {
  font-size: 11px; color: var(--muted);
  background: var(--bg-soft); border: 1px solid var(--line);
  border-radius: 999px; padding: 6px 10px; white-space: nowrap;
}

/* ---------- 按钮 ---------- */
.btn {
  appearance: none; border: 1px solid var(--line); border-radius: 9px;
  background: var(--card-2); color: var(--text);
  padding: 9px 15px; font-size: 13px; cursor: pointer;
  transition: .15s ease; font-family: inherit;
}
.btn:hover { border-color: #4b6386; background: #263246; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn.sm { padding: 6px 10px; font-size: 12px; border-radius: 8px; }
.btn.primary {
  background: linear-gradient(135deg, #2dd4bf, #22d3ee);
  color: #062029; border: none; font-weight: 600;
  box-shadow: 0 6px 18px rgba(45, 212, 191, .18);
}
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: var(--card-2); }

/* ---------- 标签页 ---------- */
.tabs {
  display: flex; align-items: center; gap: 6px;
  padding: 10px 22px; border-bottom: 1px solid var(--line);
  position: sticky; top: 73px; z-index: 10;
  background: rgba(15, 19, 26, .82); backdrop-filter: blur(8px);
  flex-wrap: wrap;
}
.tab {
  background: transparent; border: none; color: var(--muted);
  padding: 8px 14px; border-radius: 9px; cursor: pointer;
  font-size: 13px; font-family: inherit;
}
.tab:hover { color: var(--text); background: var(--card); }
.tab.active { color: #052e2b; background: var(--accent); font-weight: 600; }

main { padding: 18px 22px 34px; max-width: 1440px; margin: 0 auto; }
.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fade .18s ease; }
@keyframes fade { from { opacity: .4; transform: translateY(3px); } }

/* ---------- 卡片布局 ---------- */
.two-col { display: grid; grid-template-columns: minmax(0, 1.06fr) minmax(0, .94fr); gap: 16px; align-items: start; }
@media (max-width: 1050px) { .two-col { grid-template-columns: 1fr; } }
.card {
  background: linear-gradient(180deg, var(--card), rgba(26, 34, 48, .92));
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow);
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.card-head h2 { font-size: 15px; margin: 0; letter-spacing: .2px; }
.result-card { min-height: 380px; display: flex; flex-direction: column; }

/* ---------- 表单 ---------- */
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.field > span { font-size: 12px; color: #c3cee0; font-weight: 600; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 640px) { .row-2 { grid-template-columns: 1fr; } }
input, select, textarea {
  width: 100%; background: #111823; color: var(--text);
  border: 1px solid #2c3a50; border-radius: 9px;
  padding: 9px 10px; font-size: 13px; font-family: inherit;
  outline: none; transition: border-color .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent-2); box-shadow: 0 0 0 3px rgba(56, 189, 248, .1); }
textarea { resize: vertical; line-height: 1.5; }
select option { background: #111823; }
.advanced { border-top: 1px dashed var(--line); padding-top: 10px; margin-bottom: 12px; }
.advanced summary { cursor: pointer; color: var(--muted); font-size: 12px; user-select: none; }
.advanced summary:hover { color: var(--text); }
.params-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px 12px; margin-top: 10px; }
@media (max-width: 720px) { .params-grid { grid-template-columns: 1fr 1fr; } }
.inline-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 6px; }
.actions { display: flex; align-items: center; gap: 12px; margin-top: 14px; flex-wrap: wrap; }
.check { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; }
.check input { width: auto; }

/* ---------- 状态 / 日志 ---------- */
.badge {
  display: inline-flex; align-items: center;
  border-radius: 999px; padding: 3px 9px; font-size: 11px;
  border: 1px solid var(--line); color: var(--muted); background: var(--bg-soft);
}
.badge.ok { color: #052e2b; background: var(--ok); border-color: transparent; }
.badge.run { color: #3b2a02; background: var(--warn); border-color: transparent; }
.badge.err { color: #3b0713; background: var(--danger); border-color: transparent; }
.badge.gray { color: var(--muted); }
.empty { color: var(--muted); text-align: center; padding: 44px 12px; font-size: 13px; }
.empty-icon { font-size: 34px; margin-bottom: 8px; opacity: .85; }
.progress-line { display: flex; align-items: center; gap: 10px; font-size: 13px; margin-bottom: 6px; }
.progress-meta { color: var(--muted); font-size: 12px; margin-bottom: 12px; }
.spinner {
  width: 15px; height: 15px; border-radius: 50%;
  border: 2px solid rgba(94, 234, 212, .25); border-top-color: var(--accent);
  display: inline-block; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.log-box { margin-top: 10px; border-top: 1px dashed var(--line); padding-top: 8px; }
.log-box summary { cursor: pointer; color: var(--muted); font-size: 12px; }
.log-box pre {
  max-height: 220px; overflow: auto; background: #0b1017;
  border: 1px solid #232f42; border-radius: 8px; padding: 10px;
  color: #a9b8cf; font-size: 11.5px; white-space: pre-wrap; word-break: break-word;
}
.notice {
  margin-top: 14px; padding: 10px 12px; border-radius: 9px;
  border: 1px dashed var(--line); color: var(--muted); font-size: 12px;
}

/* ---------- 画廊 ---------- */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin: 10px 0; }
.gallery figure {
  margin: 0; background: #0b1017; border: 1px solid var(--line);
  border-radius: 10px; overflow: hidden;
}
.gallery img { display: block; width: 100%; aspect-ratio: 1/1; object-fit: cover; cursor: zoom-in; background: #05080c; }
.gallery figcaption { padding: 6px 8px; font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.summary-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(105px, 1fr)); gap: 8px; margin: 12px 0; }
.summary-grid .stat { background: var(--bg-soft); border: 1px solid var(--line); border-radius: 10px; padding: 10px; }
.summary-grid .stat b { display: block; font-size: 18px; color: var(--accent); font-weight: 600; }
.summary-grid .stat span { color: var(--muted); font-size: 11px; }

/* ---------- 拖拽上传 ---------- */
.dropzone {
  border: 1.5px dashed #3b4d68; border-radius: 12px;
  padding: 26px; text-align: center; color: var(--muted);
  cursor: pointer; transition: .15s ease; background: rgba(17, 24, 35, .5);
}
.dropzone:hover, .dropzone.drag { border-color: var(--accent); background: rgba(94, 234, 212, .05); }
.dropzone p { margin: 4px 0; color: var(--text); }
.file-preview { display: flex; align-items: center; gap: 10px; margin-top: 10px; font-size: 12px; color: var(--muted); }
.file-preview img { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }

/* ---------- 历史 ---------- */
.history-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.history-card { background: var(--bg-soft); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.history-card img { width: 100%; height: 150px; object-fit: cover; display: block; background: #05080c; }
.history-body { padding: 9px 10px; }
.history-body h3 { margin: 0 0 4px; font-size: 12px; color: var(--accent); font-weight: 600; }
.history-body p { margin: 0 0 6px; font-size: 11px; color: var(--muted); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.history-meta { display: flex; gap: 8px; color: var(--muted); font-size: 10.5px; flex-wrap: wrap; }
.history-actions { padding: 0 10px 10px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; right: 20px; bottom: 20px; z-index: 100;
  background: #0b1017; color: var(--text); border: 1px solid var(--line);
  border-left: 3px solid var(--accent); border-radius: 10px;
  padding: 11px 14px; font-size: 12.5px; max-width: 420px;
  box-shadow: var(--shadow); animation: toast-in .18s ease;
}
.toast.err { border-left-color: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } }

/* ---------- 页脚 ---------- */
.footer {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 14px 22px; border-top: 1px solid var(--line);
  color: var(--muted); font-size: 11px; flex-wrap: wrap;
}

/* ---------- 调优预设绑定 ---------- */
.auth-box { display: flex; align-items: center; gap: 8px; }
.tuning-panel {
  margin: -2px 0 12px; padding: 10px 12px; border-radius: 10px;
  border: 1px solid rgba(94, 234, 212, .25);
  background: linear-gradient(135deg, rgba(94, 234, 212, .08), rgba(56, 189, 248, .05));
  font-size: 12px; color: var(--muted);
}
.tuning-panel strong { color: var(--text); font-weight: 600; }
.tuning-panel .tuning-line { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.tuning-panel .tuning-line + .tuning-line { margin-top: 4px; }
.tuning-panel .tuning-tag {
  display: inline-flex; align-items: center; gap: 4px;
  border: 1px solid rgba(94, 234, 212, .35); border-radius: 999px;
  padding: 1px 7px; color: var(--accent); font-size: 11px;
}

/* ---------- 参数评测表 ---------- */
.eval-filters {
  display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap;
  margin-bottom: 12px; padding-bottom: 12px; border-bottom: 1px dashed var(--line);
}
.field.compact { margin-bottom: 0; min-width: 150px; }
.eval-summary { margin-inline-start: auto; align-self: center; }
.table-wrapper {
  overflow: auto;
  max-block-size: min(64vh, 620px);
  border: 1px solid var(--line);
  border-radius: 10px;
  container-type: inline-size;
  background: #0b1017;
}
.table-wrapper:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }
.eval-table { width: 100%; border-collapse: separate; border-spacing: 0; min-inline-size: 980px; font-size: 12px; }
.eval-table caption {
  padding: 10px 12px; text-align: start; color: var(--muted);
  font-size: 12px; background: #0f1621; border-bottom: 1px solid var(--line);
}
.eval-table thead { position: sticky; inset-block-start: 0; z-index: 2; }
.eval-table th, .eval-table td { padding: 8px 10px; text-align: start; border-bottom: 1px solid #1d2939; vertical-align: top; }
.eval-table th { background: #182231; color: #c8d5e8; font-weight: 600; white-space: nowrap; }
.eval-table tbody tr:hover { background: rgba(56, 189, 248, .05); }
.eval-table td { color: var(--muted); }
.eval-table td.num { text-align: end; font-variant-numeric: tabular-nums; }
.eval-table .cell-strong { color: var(--text); }
.eval-table .cell-notes { max-width: 260px; white-space: pre-wrap; overflow-wrap: anywhere; }
.eval-table .cell-image img { width: 66px; height: 66px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); cursor: zoom-in; }
.sort-btn {
  appearance: none; border: 0; background: transparent; color: inherit;
  font: inherit; font-weight: 600; cursor: pointer; padding: 2px 4px;
  border-radius: 5px; min-height: 24px;
}
.sort-btn:hover { background: rgba(255, 255, 255, .06); }
.sort-btn:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 1px; }
.eval-table th[aria-sort="ascending"] .sort-btn::after { content: " ↑"; color: var(--accent); }
.eval-table th[aria-sort="descending"] .sort-btn::after { content: " ↓"; color: var(--accent); }
.score-badge { font-weight: 700; color: var(--accent); }
.score-badge.pending { color: var(--warn); font-weight: 600; }
.eval-empty-row { color: var(--muted); text-align: center; padding: 24px; }
@container (width < 760px) {
  .eval-table { min-inline-size: 0; }
  .eval-table thead { display: none; }
  .eval-table, .eval-table tbody, .eval-table tr, .eval-table td { display: block; width: 100%; }
  .eval-table tbody { display: grid; gap: 10px; padding: 10px; }
  .eval-table tr { border: 1px solid var(--line); border-radius: 9px; background: var(--bg-soft); overflow: hidden; }
  .eval-table td { border-bottom: 1px dashed #1d2939; padding: 7px 10px; }
  .eval-table td:last-child { border-bottom: 0; }
  .eval-table td::before {
    content: attr(data-label) "：";
    color: #9fb0c8; font-weight: 600;
  }
  .eval-table .cell-image img { width: 80px; height: 80px; }
}

/* ---------- 评分 / 预览原生 dialog ---------- */
dialog {
  color: var(--text);
  background: #0b1017;
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 0;
}
dialog::backdrop { background: rgba(2, 6, 12, .78); backdrop-filter: blur(3px); }
dialog.lightbox:modal { overscroll-behavior: contain; }
dialog.lightbox::backdrop { overflow: hidden; overscroll-behavior: contain; }
dialog.lightbox {
  width: min(96vw, 1440px);
  height: min(92vh, 920px);
  max-width: none;
  max-height: none;
  overflow: hidden;
}
dialog.lightbox[open] { display: flex; }
.lightbox-shell { display: flex; flex-direction: column; width: 100%; height: 100%; min-height: 0; }
.lightbox-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 14px;
  padding: 12px 14px; border-bottom: 1px solid var(--line); flex-wrap: wrap;
}
.lightbox-title-wrap { min-width: 0; }
.lightbox-title-wrap h1 { margin: 0; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lightbox-title-wrap p { margin: 2px 0 0; color: var(--muted); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: min(70vw, 880px); }
.lightbox-tools { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.icon-btn {
  appearance: none; border: 1px solid var(--line); border-radius: 8px;
  background: var(--card-2); color: var(--text);
  min-width: 34px; min-height: 34px; padding: 4px 8px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 15px; line-height: 1; text-decoration: none;
}
.icon-btn:hover { border-color: #4b6386; background: #263246; }
.icon-btn:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }
.icon-btn:disabled { opacity: .35; cursor: not-allowed; }
.icon-btn.danger { color: var(--danger); }
.lightbox-stage {
  flex: 1; min-height: 0; position: relative; overflow: hidden;
  display: grid; place-items: center; background: #05080c;
  touch-action: none; cursor: grab; user-select: none;
}
.lightbox-stage.dragging { cursor: grabbing; }
.lightbox-stage img {
  max-width: none; max-height: none;
  transform-origin: 50% 50%;
  will-change: transform;
  user-select: none; -webkit-user-drag: none;
}
.lightbox-foot {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 8px 14px; border-top: 1px solid var(--line);
  color: var(--muted); font-size: 11px; flex-wrap: wrap;
}
.lightbox-foot #lightbox-caption { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 75%; }
dialog.eval-dialog { width: min(92vw, 720px); max-height: 92vh; overflow: auto; }
dialog.eval-dialog[open] { display: block; }
.dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 14px 16px 0; }
.dialog-head h1 { margin: 0; font-size: 15px; }
.dialog-head .hint { margin: 3px 0 0; }
.eval-form { padding: 14px 16px 16px; }
.eval-context {
  margin-bottom: 12px; padding: 9px 10px; border-radius: 8px;
  background: var(--bg-soft); border: 1px solid var(--line); font-size: 12px; color: var(--muted);
  overflow-wrap: anywhere;
}
.eval-context strong { color: var(--text); font-weight: 600; }
.eval-context-row { display: flex; gap: 10px; align-items: flex-start; }
.eval-context-thumb { width: 72px; height: 72px; object-fit: cover; border-radius: 7px; border: 1px solid var(--line); flex: none; }
.eval-context-info { min-width: 0; display: grid; gap: 3px; }
.dimensions { margin: 0 0 12px; border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px; }
.dimensions legend { padding: 0 4px; color: var(--muted); font-size: 12px; }
.dimensions-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; }
.error-text { color: var(--danger); }
.password-wrap { display: flex; gap: 6px; }
.password-wrap input { flex: 1; min-width: 0; }

/* ---------- 登录页 ---------- */
.login-body { display: grid; place-items: center; min-height: 100vh; padding: 24px; }
.login-card {
  width: min(440px, 100%); background: linear-gradient(180deg, var(--card), rgba(26, 34, 48, .94));
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 24px;
}
.login-brand { margin-bottom: 14px; }
.login-form { margin-top: 14px; }
.login-submit { width: 100%; margin-top: 4px; }
.login-foot { margin: 16px 0 0; color: var(--muted); font-size: 11px; line-height: 1.55; }

@media (max-width: 760px) {
  .topbar { padding: 10px 12px; }
  .engine-box { min-width: 0; flex-basis: 100%; }
  .tabs { top: 0; position: static; }
  .lightbox-head { align-items: stretch; }
  .lightbox-tools { justify-content: flex-end; }
  .lightbox-title-wrap p { max-width: 90vw; }
  .field.compact { flex: 1 1 140px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
