/* ===== Variables ===== */
:root {
  --bg: #f2f5f9;
  --surface: #ffffff;
  --surface-soft: #f7f9fc;
  --text: #111827;
  --muted: #6b7280;
  --muted-strong: #374151;
  --border: #e3e8ef;
  --border-strong: #c9d2dc;
  --accent: #2563eb;
  --accent-soft: rgba(37, 99, 235, 0.1);
  --accent-strong: #1d4ed8;
  --success: #16a34a;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 1px 3px rgba(0, 0, 0, 0.08), 0 8px 24px rgba(0, 0, 0, 0.07);
  --radius: 12px;
  --radius-sm: 8px;
}

/* ===== Reset ===== */
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
h1, h2, h3, p { margin-top: 0; }
ol, ul { margin: 0; padding: 0; list-style: none; }
dl { margin: 0; }

body {
  margin: 0;
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
}

body.is-loading { overflow: hidden; }

/* ===== Page container ===== */
.page {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 36px 0 72px;
  display: grid;
  gap: 32px;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.page.is-pjax-swapping {
  opacity: 0.45;
  transform: translateY(6px);
}

/* ===== Hero shell (index) ===== */
.hero-shell {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(280px, 0.85fr);
  gap: 24px;
  align-items: stretch;
}

.hero-left {
  display: grid;
  gap: 28px;
}

.hero-title-block { display: grid; gap: 12px; }

.hero-id {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.04em;
}

/* ===== Site footer ===== */
.site-footer {
  text-align: center;
  padding: 28px 0 20px;
  display: grid;
  gap: 4px;
}

.site-footer p {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}

.site-footer a {
  color: var(--muted);
  text-decoration: none;
  transition: color 0.14s;
}

.site-footer a:hover { color: var(--accent); }

h1 {
  font-size: clamp(28px, 4vw, 46px);
  line-height: 1.1;
  letter-spacing: -0.01em;
  margin-bottom: 0;
}

.lead {
  font-size: 17px;
  line-height: 1.7;
  color: var(--muted);
  margin-bottom: 0;
  max-width: 52ch;
}

/* ===== Upload form ===== */
.upload-form {
  display: grid;
  gap: 16px;
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
}

.dropzone {
  position: relative;
  display: grid;
  place-items: center;
  gap: 6px;
  min-height: 140px;
  padding: 24px 20px;
  border-radius: var(--radius-sm);
  border: 1.5px dashed var(--border-strong);
  background: var(--surface-soft);
  text-align: center;
  cursor: pointer;
  transition: border-color 0.16s, background 0.16s;
}

.dropzone input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.dropzone:hover {
  border-color: var(--accent);
  background: #f0f5ff;
}

.dropzone-icon {
  font-size: 24px;
  line-height: 1;
}

.dropzone-label {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.dropzone-state {
  font-size: 13px;
  color: var(--muted);
}

.dropzone-file {
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
}

.dropzone.is-ready {
  border-color: var(--success);
  background: #f0fdf4;
}

.dropzone.is-ready .dropzone-label,
.dropzone.is-ready .dropzone-file { color: var(--success); }

/* upload row: model picker + button side by side */
.upload-row {
  display: flex;
  gap: 12px;
  align-items: flex-end;
}

.model-picker {
  display: grid;
  gap: 6px;
  flex: 1;
}

.model-picker label {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted-strong);
}

.select-wrap { position: relative; }

.select-wrap::after {
  content: "▾";
  position: absolute;
  top: 50%;
  right: 12px;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
  font-size: 14px;
}

.model-picker select {
  width: 100%;
  min-height: 44px;
  padding: 0 36px 0 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  appearance: none;
  outline: none;
  cursor: pointer;
}

.model-picker select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.hint {
  font-size: 12px;
  color: var(--muted);
  margin: 0;
}

/* ===== Buttons & links ===== */
button,
.json-link,
.history-link,
.back-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 44px;
  padding: 0 18px;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.14s;
}

button:hover,
.json-link:hover,
.history-link:hover,
.back-button:hover {
  background: var(--accent-strong);
}

.back-button {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--muted-strong);
  padding: 0 14px;
}

.back-button:hover {
  background: var(--surface-soft);
  border-color: var(--muted);
}

.json-link {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--muted-strong);
  font-size: 13px;
  padding: 0 14px;
}

.json-link:hover {
  background: var(--surface-soft);
}

/* ===== Section note ===== */
.section-note {
  font-size: 13px;
  color: var(--muted);
  margin: -8px 0 14px;
}

/* ===== Rank panel (sidebar) ===== */
.rank-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 20px;
  box-shadow: var(--shadow-sm);
}

.rank-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--muted-strong);
}

.rank-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
}

.rank-tab {
  flex: 1;
  height: 34px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: none;
  min-height: unset;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}

.rank-tab:hover,
.rank-tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.rank-view-hidden { display: none; }

.rank-list { display: grid; gap: 6px; }

.rank-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
}

.rank-row:hover { background: var(--surface-soft); }

.rank-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
  background: var(--surface-soft);
  color: var(--muted);
  border: 1px solid var(--border);
}

.rank-num.gold   { background: #fef3c7; color: #92400e; border-color: #fcd34d; }
.rank-num.silver { background: #f1f5f9; color: #475569; border-color: #cbd5e1; }
.rank-num.bronze { background: #fef2ed; color: #9a3412; border-color: #fdba74; }

.rank-name {
  flex: 1;
  font-size: 15px;
  font-weight: 600;
}

.rank-count {
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
}

/* ===== Flash notice ===== */
.notice {
  padding: 14px 18px;
  background: #fffbeb;
  border: 1px solid #fcd34d;
  border-radius: var(--radius);
  color: #92400e;
}

.notice p { margin: 0; font-size: 14px; }

/* ===== Section title ===== */
.section-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 14px;
  color: var(--muted-strong);
}

.empty-hint {
  font-size: 14px;
  color: var(--muted);
  margin: 0;
  padding: 24px 0;
  text-align: center;
}

/* ===== Model cards ===== */
.model-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.model-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color 0.14s, box-shadow 0.14s, transform 0.14s;
}

.model-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.model-card.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.model-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.model-best {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 700;
}

.model-vocab {
  text-align: right;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.35;
  color: var(--muted);
  white-space: nowrap;
}

.model-vocab .model-vocab-family { color: var(--accent-strong); }

.model-card-name {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

.model-card-desc {
  margin: 0;
  flex: 1;
  font-size: 13px;
  line-height: 1.6;
  color: var(--muted);
}

.model-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.model-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 9px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 600;
  background: var(--surface-soft);
  color: var(--muted-strong);
}

.model-chip b {
  font-weight: 700;
}

.model-chip.lv-good { background: #eafaf0; color: #157a3a; }
.model-chip.lv-mid { background: #fff5e6; color: #a8620d; }
.model-chip.lv-heavy { background: #fdecec; color: #b3372f; }

/* ===== History rows ===== */
.history-list {
  display: grid;
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.history-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 18px;
  background: var(--surface);
  font-size: 13px;
  transition: background 0.12s;
}

.history-row:hover { background: #fafbfd; }

.history-id {
  font-family: "Consolas", monospace;
  font-size: 12px;
  color: var(--muted);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-at {
  color: var(--muted);
  white-space: nowrap;
}

.history-type {
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--surface-soft);
  color: var(--muted-strong);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.history-model {
  font-size: 13px;
  font-weight: 500;
  color: var(--muted-strong);
  white-space: nowrap;
}

/* ===== Result page ===== */
.result-head {
  display: grid;
  gap: 10px;
}

.result-head-row {
  display: flex;
  align-items: center;
  gap: 14px;
}

.result-head-row h1 {
  flex: 1;
  font-size: clamp(26px, 4vw, 40px);
  letter-spacing: -0.03em;
  margin: 0;
}

.result-meta {
  font-size: 13px;
  color: var(--muted);
  margin: 0;
}

/* result grid: viewer (left) + panel (right) */
.result-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(280px, 0.9fr);
  gap: 24px;
  align-items: start;
}

.viewer {
  display: grid;
  gap: 16px;
}

.viewer img,
.viewer video {
  display: block;
  width: 100%;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

/* task info below image: simple definition list, no card */
.task-info {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px 20px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.task-info div { display: grid; gap: 3px; }

.task-info dt {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  font-weight: 600;
}

.task-info dd {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted-strong);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ===== Panel (right side card) ===== */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-md);
}

.panel-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.panel-title-row h2 {
  font-size: 16px;
  font-weight: 700;
  margin: 0;
  color: var(--muted-strong);
}

.total-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--text);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}

/* ===== Confidence rows ===== */
.confidence-list {
  display: grid;
  gap: 14px;
  max-height: 720px;
  overflow: auto;
}

.confidence-row { display: grid; gap: 5px; }

.confidence-meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}

.confidence-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.confidence-pct {
  font-size: 13px;
  font-weight: 600;
  color: var(--success);
}

.confidence-count {
  font-size: 12px;
  color: var(--muted);
}

.confidence-track {
  height: 6px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--border);
}

.confidence-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #16a34a 0%, #4ade80 55%, #facc15 100%);
}

/* ===== Raw JSON details ===== */
.raw-details {
  overflow: hidden;
}

.raw-details summary {
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted-strong);
  padding: 4px 0;
  user-select: none;
}

.raw-details summary::-webkit-details-marker { color: var(--muted); }

.json-block {
  margin: 14px 0 0;
  padding: 16px;
  border-radius: var(--radius-sm);
  background: #0f172a;
  color: #94a3b8;
  white-space: pre-wrap;
  word-break: break-word;
  overflow: auto;
  font-size: 12px;
  line-height: 1.65;
}

/* ===== Loading overlay ===== */
.loading-overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(10, 18, 34, 0.4);
  backdrop-filter: blur(8px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.18s ease, visibility 0.18s ease;
  z-index: 9999;
}

.loading-overlay.active {
  opacity: 1;
  visibility: visible;
}

.loading-card {
  width: min(380px, 100%);
  padding: 28px 24px 22px;
  border-radius: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: 0 24px 60px rgba(12, 26, 54, 0.2);
}

.loading-card h2 {
  margin-bottom: 6px;
  font-size: 20px;
}

.loading-card p {
  margin-bottom: 16px;
  color: var(--muted);
  font-size: 14px;
}

.loading-track {
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--border);
}

.loading-bar {
  display: block;
  height: 100%;
  width: 8%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent) 0%, #60a5fa 100%);
  transition: width 0.22s ease;
}

.loading-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
  font-size: 13px;
  color: var(--muted);
}

/* ===== Responsive ===== */
@media (max-width: 1240px) {
  /* fixed auth button would overlap the top-right card — reserve space */
  .page {
    padding-top: 72px;
  }
}

@media (max-width: 960px) {
  .hero-shell,
  .result-grid {
    grid-template-columns: 1fr;
  }

  .page {
    width: calc(100vw - 24px);
    padding-top: 72px;
  }
}

@media (max-width: 680px) {
  .upload-row {
    flex-direction: column;
    align-items: stretch;
  }

  .history-row {
    flex-wrap: wrap;
  }

  .history-id { flex-basis: 100%; }

  .result-head-row {
    flex-wrap: wrap;
  }

  .result-head-row h1 { flex-basis: 100%; order: -1; }

  .task-info {
    grid-template-columns: 1fr 1fr;
  }
}

/* ===== Auth bar (fixed top-right) ===== */
.auth-bar {
  position: fixed;
  top: 16px;
  right: 24px;
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 200;
}

.auth-username {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted-strong);
}

.auth-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  padding: 0 16px;
  border-radius: var(--radius-sm);
  border: 0;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.14s;
}

.auth-btn:hover { background: var(--accent-strong); }

.auth-btn-ghost {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--muted-strong);
}

.auth-btn-ghost:hover { background: var(--surface-soft); }

/* ===== Auth modal overlay ===== */
.auth-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 18, 34, 0.38);
  backdrop-filter: blur(6px);
  display: grid;
  place-items: center;
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.18s, visibility 0.18s;
  z-index: 9000;
}

.auth-overlay.active {
  opacity: 1;
  visibility: visible;
}

.auth-card {
  width: min(360px, 100%);
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(12, 26, 54, 0.18);
}

.auth-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.auth-card-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--muted-strong);
}

.auth-close {
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 16px;
  cursor: pointer;
  border-radius: 6px;
  box-shadow: none;
  min-height: unset;
  flex-shrink: 0;
}

.auth-close:hover { background: var(--surface-soft); color: var(--text); }

.auth-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
}

.auth-tab {
  flex: 1;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: none;
  min-height: unset;
  transition: background 0.12s, color 0.12s;
}

.auth-tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.auth-form { display: grid; gap: 12px; }
.auth-form-hidden { display: none; }

.auth-input {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text);
  background: var(--surface);
  outline: none;
  transition: border-color 0.14s;
}

.auth-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.auth-error {
  margin: 0;
  font-size: 13px;
  color: #dc2626;
  min-height: 18px;
}

.auth-submit {
  height: 44px;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.14s;
  min-height: unset;
}

.auth-submit:hover { background: var(--accent-strong); }

/* ===== History login hint ===== */
.history-login-hint {
  padding: 20px 24px;
  background: #fff5f5;
  border: 1px solid #fca5a5;
  border-radius: var(--radius);
  text-align: center;
}

.history-login-hint p {
  margin: 0;
  font-size: 14px;
  color: #991b1b;
  font-weight: 500;
}

/* ===== Result image ring placeholder ===== */
.img-placeholder {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 4 / 3;
  background: var(--surface-soft);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.ring-svg {
  width: 88px;
  height: 88px;
  transform: rotate(-90deg);
}

.ring-bg {
  fill: none;
  stroke: var(--border);
  stroke-width: 7;
}

.ring-fill {
  fill: none;
  stroke: var(--accent);
  stroke-width: 7;
  stroke-linecap: round;
  stroke-dasharray: 238.76;
  stroke-dashoffset: 238.76;
  transition: stroke-dashoffset 0.12s linear;
}

.ring-pct {
  position: absolute;
  font-size: 15px;
  font-weight: 700;
  color: var(--accent);
}

.result-img {
  display: block;
  width: 100%;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

/* ===== Upload form footer row ===== */
.upload-footer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.upload-footer-row .hint { margin: 0; }

.model-info-btn {
  height: 30px;
  padding: 0 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: none;
  min-height: unset;
  transition: background 0.14s, color 0.14s;
}

.model-info-btn:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
}

/* ===== Model info modal ===== */
.model-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 18, 34, 0.42);
  backdrop-filter: blur(7px);
  display: grid;
  place-items: center;
  padding: 24px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.18s, visibility 0.18s;
  z-index: 8000;
}

.model-overlay.active {
  opacity: 1;
  visibility: visible;
}

.model-modal {
  width: min(900px, 100%);
  max-height: 82vh;
  overflow-y: auto;
  padding: 28px 28px 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: 0 28px 70px rgba(12, 26, 54, 0.22);
}

.model-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.model-modal-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--muted-strong);
}

.model-modal-note {
  font-size: 13px;
  color: var(--muted);
  margin: 0 0 18px;
}

.model-modal-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}

@media (max-width: 600px) {
  .model-modal { padding: 20px 16px 18px; }
  .model-modal-grid { grid-template-columns: 1fr; }
}

/* ===== Account page ===== */
.acct-page {
  max-width: 960px;
}

.acct-header { display: grid; gap: 8px; }

.acct-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

@media (max-width: 720px) {
  .acct-grid { grid-template-columns: 1fr; }
}

.acct-col-left,
.acct-col-right {
  display: grid;
  gap: 16px;
}

.acct-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 22px 20px;
  box-shadow: var(--shadow-sm);
  display: grid;
  gap: 14px;
}

.acct-card-danger {
  border-color: #fca5a5;
  background: #fff5f5;
}

.acct-card-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--muted-strong);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.acct-card-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
}

/* avatar */
.acct-avatar-row {
  display: flex;
  align-items: center;
  gap: 16px;
}

.acct-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--accent-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: 2px solid var(--border);
}

.acct-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.acct-avatar-initial {
  font-size: 24px;
  font-weight: 700;
  color: var(--accent-strong);
  line-height: 1;
}

.acct-avatar-info {
  display: grid;
  gap: 4px;
}

.acct-upload-btn {
  display: inline-flex;
  align-items: center;
  height: 32px;
  padding: 0 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--muted-strong);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.14s, border-color 0.14s;
}

.acct-upload-btn:hover {
  background: var(--surface-soft);
  border-color: var(--accent);
  color: var(--accent);
}

/* fields */
.acct-field-group { display: grid; gap: 6px; }

.acct-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.acct-input {
  width: 100%;
  height: 42px;
  padding: 0 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text);
  background: var(--surface);
  outline: none;
  transition: border-color 0.14s;
}

.acct-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.acct-field-row {
  display: flex;
  gap: 8px;
}

.acct-field-row .acct-input { flex: 1; }

.acct-save-btn {
  height: 42px;
  padding: 0 18px;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: none;
  min-height: unset;
  transition: background 0.14s;
}

.acct-save-btn:hover { background: var(--accent-strong); }

.acct-primary-btn {
  height: 42px;
  width: 100%;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: none;
  min-height: unset;
  transition: background 0.14s;
}

.acct-primary-btn:hover { background: var(--accent-strong); }

.acct-danger-btn {
  height: 40px;
  padding: 0 18px;
  border: 1px solid #fca5a5;
  border-radius: var(--radius-sm);
  background: #fff5f5;
  color: #b91c1c;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: none;
  min-height: unset;
  transition: background 0.14s, border-color 0.14s;
}

.acct-danger-btn:hover {
  background: #fee2e2;
  border-color: #f87171;
}

.acct-msg {
  font-size: 13px;
  margin: 0;
  min-height: 18px;
}

.acct-msg.ok { color: var(--success); }
.acct-msg.err { color: #dc2626; }

.acct-hint {
  font-size: 12px;
  color: var(--muted);
  margin: 0;
}

/* meta row */
.acct-meta-row {
  display: flex;
  gap: 20px;
  padding-top: 4px;
  border-top: 1px solid var(--border);
}

.acct-meta-item {
  display: grid;
  gap: 2px;
}

.acct-meta-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-weight: 600;
}

.acct-meta-val {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted-strong);
}

/* history in account */
.acct-history {
  display: grid;
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  max-height: 420px;
  overflow-y: auto;
}

.acct-history-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  background: var(--surface);
  transition: background 0.12s;
}

.acct-history-row:hover { background: var(--surface-soft); }

.acct-history-main {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.acct-history-id {
  font-family: "Consolas", monospace;
  font-size: 11px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.acct-history-at {
  font-size: 12px;
  color: var(--muted);
}

.acct-history-model {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted-strong);
}

.acct-history-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-shrink: 0;
}

.acct-action-link {
  display: inline-flex;
  align-items: center;
  height: 28px;
  padding: 0 10px;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.14s;
}

.acct-action-link:hover { background: #dbeafe; }

.acct-delete-btn {
  height: 28px;
  padding: 0 10px;
  border: 1px solid #fca5a5;
  border-radius: 6px;
  background: transparent;
  color: #b91c1c;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: none;
  min-height: unset;
  transition: background 0.12s;
}

.acct-delete-btn:hover { background: #fee2e2; }

/* ===== Ranking avatar ===== */
.rank-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 1px solid var(--border);
  background: var(--surface-soft);
}

.rank-avatar-default {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 700;
}

/* ===== v2: dropdown restyle ===== */
.select-wrap::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 14px;
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: translateY(-65%) rotate(45deg);
  pointer-events: none;
}

.model-picker select,
select[data-model-select],
select[data-model-select-b] {
  width: 100%;
  min-height: 44px;
  padding: 0 40px 0 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  appearance: none;
  -webkit-appearance: none;
  outline: none;
  cursor: pointer;
  transition: border-color 0.14s, box-shadow 0.14s;
}

.model-picker select:hover { border-color: var(--accent); }
.model-picker select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.model-picker optgroup { font-weight: 700; color: var(--muted-strong); }

/* ===== v2: compare toggle + second picker ===== */
.compare-toggle-row { margin-top: 4px; }
.compare-toggle {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--muted-strong); cursor: pointer; user-select: none;
}
.compare-toggle input { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }
.compare-picker { margin-top: 8px; }
.compare-picker[hidden] { display: none; }

/* ===== v2: parameter panel ===== */
.param-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 14px;
  background: var(--surface-soft);
}
.param-panel > summary {
  cursor: pointer; font-size: 13px; font-weight: 600;
  color: var(--muted-strong); padding: 8px 0; user-select: none;
}
.param-grid {
  display: grid; grid-template-columns: repeat(2, 1fr);
  gap: 14px 20px; padding: 8px 0 14px;
}
@media (max-width: 560px) { .param-grid { grid-template-columns: 1fr; } }
.param-item { display: grid; gap: 6px; }
.param-item[hidden] { display: none; }
.param-head {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 12px; font-weight: 600; color: var(--muted-strong);
}
.param-head output { font-family: "Consolas", monospace; font-size: 13px; color: var(--accent-strong); }
.param-item input[type="range"] { width: 100%; accent-color: var(--accent); cursor: pointer; }

/* ===== v2: model modal scrollbar fit ===== */
.model-modal-scroll {
  max-height: 66vh; overflow-y: auto;
  margin-right: -12px; padding-right: 12px;
}
.model-modal-scroll::-webkit-scrollbar { width: 8px; }
.model-modal-scroll::-webkit-scrollbar-track { background: transparent; }
.model-modal-scroll::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 999px; }
.model-modal-scroll::-webkit-scrollbar-thumb:hover { background: var(--muted); }
.model-modal { overflow: hidden; }

/* ===== v2: history show more ===== */
.history-more {
  display: inline-block; margin-top: 12px;
  font-size: 13px; font-weight: 600; color: var(--accent); text-decoration: none;
}
.history-more:hover { text-decoration: underline; }

/* ===== v2: result compare grid ===== */
.result-badge {
  display: inline-flex; align-items: center; padding: 4px 12px;
  border-radius: 999px; background: var(--accent-soft);
  color: var(--accent-strong); font-size: 13px; font-weight: 700;
}
.compare-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; align-items: start; }
@media (max-width: 860px) { .compare-grid { grid-template-columns: minmax(0, 1fr); } }
.compare-col {
  min-width: 0;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow-sm);
  display: grid; gap: 10px;
}
.compare-col-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.compare-col-head h2 { font-size: 15px; margin: 0; color: var(--muted-strong); }
.compare-meta { font-size: 12px; color: var(--muted); margin: 0; }
.compare-dl { align-self: start; }
.compare-conf { margin-top: 4px; max-height: 320px; }

/* ===== v2: captcha ===== */
.captcha-block {
  display: grid; gap: 8px; padding: 12px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface-soft);
}
.captcha-q { display: flex; align-items: center; gap: 8px; }
.captcha-label { font-size: 12px; font-weight: 700; color: var(--muted); flex-shrink: 0; }
.captcha-question { flex: 1; font-size: 16px; color: var(--text); }
.captcha-refresh {
  width: 28px; height: 28px; padding: 0;
  border: 1px solid var(--border-strong); border-radius: 6px;
  background: var(--surface); color: var(--muted); cursor: pointer;
  box-shadow: none; min-height: unset; flex-shrink: 0;
}
.captcha-refresh:hover { background: var(--surface-soft); color: var(--accent); }
.captcha-input { height: 40px; }
.captcha-answer { display: grid; gap: 6px; }
.captcha-choice {
  display: flex; align-items: center; gap: 8px; padding: 6px 10px;
  border: 1px solid var(--border); border-radius: 6px; background: var(--surface);
  cursor: pointer; transition: border-color 0.12s, background 0.12s;
}
.captcha-choice:hover { border-color: var(--accent); background: var(--accent-soft); }
.captcha-choice input { accent-color: var(--accent); cursor: pointer; }

/* ===== v2: account tweaks ===== */
.acct-card-full { grid-column: 1 / -1; }
.acct-textarea { height: auto; padding: 10px 14px; resize: vertical; line-height: 1.5; font-family: inherit; }
.acct-weight-list { display: grid; gap: 8px; }
.acct-weight-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 12px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--surface-soft);
}
.acct-weight-name {
  font-family: "Consolas", monospace; font-size: 13px; color: var(--muted-strong);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.raw-details-actions { padding: 10px 0 0; }

/* ===== v2: admin backend ===== */
.admin-page { max-width: 1080px; }
.admin-tabs { display: flex; gap: 6px; margin-bottom: 18px; flex-wrap: wrap; }
.admin-tab {
  height: 38px; padding: 0 16px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: transparent; color: var(--muted);
  font-size: 14px; font-weight: 600; cursor: pointer; box-shadow: none;
  min-height: unset; display: inline-flex; align-items: center; gap: 6px;
}
.admin-tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.admin-view-hidden { display: none; }
.admin-toolbar { margin-bottom: 12px; }
.admin-table-wrap {
  overflow-x: auto; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--surface);
}
.admin-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.admin-table th, .admin-table td {
  padding: 10px 12px; text-align: left;
  border-bottom: 1px solid var(--border); vertical-align: middle;
}
.admin-table th {
  font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--muted); background: var(--surface-soft);
}
.admin-table tr:last-child td { border-bottom: 0; }
.admin-reason { max-width: 280px; color: var(--muted-strong); }
.admin-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.admin-btn {
  height: 30px; padding: 0 10px; border: 1px solid var(--border-strong);
  border-radius: 6px; background: var(--surface); color: var(--muted-strong);
  font-size: 12px; font-weight: 600; cursor: pointer; box-shadow: none; min-height: unset;
}
.admin-btn:hover { background: var(--surface-soft); border-color: var(--accent); color: var(--accent); }
.admin-btn-danger { border-color: #fca5a5; color: #b91c1c; }
.admin-btn-danger:hover { background: #fee2e2; border-color: #f87171; color: #b91c1c; }
.admin-warn {
  margin-top: 14px; padding: 10px 14px; border-radius: var(--radius-sm);
  background: #fffbeb; border: 1px solid #fcd34d; color: #92400e; font-size: 13px;
}
.badge {
  display: inline-flex; align-items: center; padding: 2px 8px;
  border-radius: 999px; font-size: 11px; font-weight: 700;
  background: var(--surface-soft); color: var(--muted); border: 1px solid var(--border);
}
.badge-ok { background: #eafaf0; color: #157a3a; border-color: #bbf7d0; }
.badge-danger { background: #fdecec; color: #b3372f; border-color: #fca5a5; }
.badge-warn { background: #fff5e6; color: #a8620d; border-color: #fcd34d; }
.badge-info { background: var(--accent-soft); color: var(--accent-strong); border-color: #bfdbfe; }
.badge-admin { background: #ede9fe; color: #6d28d9; border-color: #ddd6fe; margin-left: 6px; }

/* ===== v3: control row (params button + compare) ===== */
.control-row {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.param-anchor { position: relative; }

.param-btn {
  height: 38px;
  padding: 0 16px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--muted-strong);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: none;
  min-height: unset;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 0.14s, border-color 0.14s, color 0.14s;
}
.param-btn:hover { background: var(--surface-soft); border-color: var(--accent); color: var(--accent); }
.param-btn[aria-expanded="true"] { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.param-btn-ic { font-size: 14px; line-height: 1; }

/* popover */
.param-popover {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 50;
  width: min(420px, 86vw);
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 18px 44px rgba(12, 26, 54, 0.18);
  opacity: 0;
  transform: translateY(-6px) scale(0.98);
  transform-origin: top left;
  transition: opacity 0.16s ease, transform 0.16s ease;
}
.param-popover.open { opacity: 1; transform: translateY(0) scale(1); }
.param-popover::before {
  content: "";
  position: absolute;
  top: -6px;
  left: 22px;
  width: 12px;
  height: 12px;
  background: var(--surface);
  border-left: 1px solid var(--border);
  border-top: 1px solid var(--border);
  transform: rotate(45deg);
}
.param-popover .param-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 18px;
  padding: 0;
}
@media (max-width: 520px) { .param-popover .param-grid { grid-template-columns: 1fr; } }

/* ===== v3: history "show more" centered pill button ===== */
.history-more {
  display: block;
  width: 100%;
  margin-top: 12px;
  padding: 12px 0;
  text-align: center;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--muted-strong);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.14s, border-color 0.14s, color 0.14s;
}
.history-more:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-strong);
  text-decoration: none;
}

/* ===== v3: account logout row inside profile card ===== */
.acct-logout-row {
  margin-top: 4px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.acct-logout-row .acct-danger-btn { width: 100%; }

/* ===== v3: compare page alignment ===== */
/* 两列等宽：minmax(0,1fr) 防止列内长内容撑开轨道导致左右不等宽 */
.compare-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; }
.compare-col { min-width: 0; align-self: start; }
/* 图片同源同尺寸，等宽列下自然等高，不强套比例、不加黑边 */
.compare-col .result-img {
  width: 100%;
  height: auto;
  display: block;
}
/* 长模型名不撑破等宽列；头部恒为单行（省略号），保证左右图片起始位置永远一致 */
.compare-col-head { min-width: 0; }
.compare-col-head h2 {
  min-width: 0; flex: 1;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.compare-conf {
  /* 恰好 5 行后出现滚动条：每行约 58px */
  max-height: 300px;
  overflow-y: auto;
  scrollbar-gutter: stable;
  padding-right: 12px;
}
.compare-conf::-webkit-scrollbar { width: 8px; }
.compare-conf::-webkit-scrollbar-track { background: transparent; }
.compare-conf::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 999px; }
.compare-conf::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* 单图结果页置信度列表同样留滚动槽间距 */
.confidence-list {
  scrollbar-gutter: stable;
  padding-right: 12px;
}
.confidence-list::-webkit-scrollbar { width: 8px; }
.confidence-list::-webkit-scrollbar-track { background: transparent; }
.confidence-list::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 999px; }
.confidence-list::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* ===== v3: result gate page (404-like) ===== */
.gate-page {
  min-height: 60vh;
  display: grid;
  place-items: center;
}
.gate-card {
  max-width: 460px;
  width: 100%;
  text-align: center;
  padding: 44px 32px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow-md);
  display: grid;
  gap: 14px;
  justify-items: center;
}
.gate-glyph {
  width: 76px;
  height: 76px;
  display: grid;
  place-items: center;
  font-size: 38px;
  border-radius: 50%;
  background: var(--accent-soft);
}
.gate-title { font-size: 22px; margin: 0; color: var(--text); }
.gate-desc { font-size: 14px; color: var(--muted); margin: 0; max-width: 34ch; line-height: 1.7; }
.gate-actions { display: flex; gap: 12px; margin-top: 8px; flex-wrap: wrap; justify-content: center; }
.gate-btn {
  height: 44px;
  padding: 0 22px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  text-decoration: none;
  border: 1px solid transparent;
}
.gate-btn-primary { background: var(--accent); color: #fff; border: 0; }
.gate-btn-primary:hover { background: var(--accent-strong); }
.gate-btn-ghost { background: transparent; border: 1px solid var(--border-strong); color: var(--muted-strong); }
.gate-btn-ghost:hover { background: var(--surface-soft); border-color: var(--accent); color: var(--accent); }
