:root {
  --bg: #0f1117;
  --panel: #161a24;
  --panel-2: #1e2333;
  --border: rgba(255,255,255,0.06);
  --text: #e6e9f2;
  --muted: #8089a3;
  --accent: #6dd2ff;
  --accent-2: #b06bff;
  --danger: #ff5b6e;
  --ok: #2ecc71;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 16px 28px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 50;
}
.brand {
  font-size: 22px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  color: transparent;
}
.brand-sub { color: var(--muted); font-weight: 400; font-size: 14px; margin-left: 6px; }
.status-pills { display: flex; gap: 8px; }
.pill {
  font-size: 12px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--muted);
  border: 1px solid var(--border);
}
.pill.running { color: var(--accent); border-color: var(--accent); }
.pill.done    { color: var(--ok);     border-color: var(--ok); }
.pill.failed  { color: var(--danger); border-color: var(--danger); }
.actions { margin-left: auto; display: flex; gap: 10px; }

.btn {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  transition: 0.15s;
}
.btn:hover { background: #252a3d; }
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent;
  color: #0c0e16;
  font-weight: 600;
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; }
.btn-danger { color: var(--danger); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.main {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 20px;
  padding: 24px 28px;
}
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.section-head h2 { font-size: 16px; margin: 0; font-weight: 600; }

.items {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}
.item-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.item-head { display: flex; align-items: center; gap: 12px; }
.item-emoji { font-size: 32px; }
.item-meta { flex: 1; }
.item-name { font-size: 16px; font-weight: 600; }
.item-tid { font-size: 12px; color: var(--muted); font-family: ui-monospace, monospace; }
.item-kind { font-size: 11px; padding: 2px 8px; border-radius: 6px; background: var(--panel-2); color: var(--accent); }

.item-section { font-size: 12px; }
.item-section-title { color: var(--muted); margin-bottom: 6px; display: flex; justify-content: space-between; }
.file-list { display: flex; flex-direction: column; gap: 4px; }
.file-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--panel-2);
  padding: 6px 10px;
  border-radius: 6px;
}
.file-row .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: ui-monospace, monospace; font-size: 11px; }
.file-row .size { color: var(--muted); font-size: 10px; }
.file-row .x { color: var(--danger); cursor: pointer; font-size: 14px; opacity: 0.6; }
.file-row .x:hover { opacity: 1; }

.upload-trigger {
  border: 1px dashed var(--border);
  padding: 8px;
  text-align: center;
  border-radius: 6px;
  color: var(--muted);
  font-size: 11px;
  cursor: pointer;
  margin-top: 4px;
}
.upload-trigger:hover { color: var(--accent); border-color: var(--accent); }

.item-actions { display: flex; justify-content: flex-end; gap: 8px; }

.log-section { display: flex; flex-direction: column; }
#log {
  background: #0a0c12;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  font-family: ui-monospace, monospace;
  font-size: 11px;
  color: #b9c0d4;
  height: calc(100vh - 220px);
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

.modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
}
.modal.hidden { display: none; }
.modal-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
  width: 460px;
  max-width: 90vw;
  max-height: 90vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.modal-card-wide { width: 620px; }
.modal-section-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-top: 4px;
  margin-bottom: -4px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}
.modal-section-title:first-of-type { border-top: none; padding-top: 0; }
.modal-card textarea {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  resize: vertical;
}
.clue-preview {
  margin-top: 6px;
  padding: 8px;
  border-radius: 6px;
  background: var(--panel-2);
  font-size: 11px;
  color: var(--muted);
}
.clue-preview.hidden { display: none; }

/* ---- 标注弹窗（全屏模式） ---- */
.modal-fullscreen { padding: 0; }
.modal-card-fullscreen {
  width: 100vw !important;
  height: 100vh !important;
  max-width: 100vw !important;
  max-height: 100vh !important;
  border-radius: 0 !important;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.annotate-head { display: flex; align-items: center; justify-content: space-between; }
.annotate-head h3 { margin: 0; }
.annotate-actions { display: flex; gap: 8px; }
.annotate-hint {
  font-size: 12px; color: var(--muted);
  background: rgba(109, 210, 255, 0.06);
  border-left: 2px solid var(--accent);
  padding: 8px 12px; border-radius: 6px;
}
.annotate-body {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 14px;
  flex: 1;
  min-height: 0;        /* 让 grid 子项可以 overflow */
}
.annotate-list {
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding-right: 6px;
  align-content: start;
  max-width: 100%;
}
.thumb {
  position: relative;
  width: 100%;
  height: 110px;
  background: var(--panel-2);
  border: 2px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  overflow: hidden;
}
.thumb.active { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(109, 210, 255, 0.3); }
.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.thumb-badge {
  position: absolute; top: 4px; right: 4px;
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--ok); color: #0c0e16;
  font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.thumb.unannotated .thumb-badge { background: var(--danger); }
.thumb.unannotated .thumb-badge::after { content: '!'; }
.thumb.unannotated::after {
  content: ''; position: absolute; inset: 0;
  background: rgba(255, 91, 110, 0.15);
}

.annotate-canvas-wrap {
  display: flex; flex-direction: column;
  background: var(--panel-2);
  border-radius: 8px;
  padding: 12px;
  gap: 10px;
}
.annotate-empty {
  flex: 1;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 14px;
}
.annotate-canvas {
  background: #000;
  border-radius: 6px;
  cursor: crosshair;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  align-self: center;
  display: block;
}
.annotate-canvas-wrap { min-height: 0; overflow: hidden; }
.annotate-canvas.hidden, .annotate-controls.hidden { display: none; }
.annotate-controls {
  display: flex; align-items: center; gap: 8px;
}
.annotate-meta { flex: 1; font-size: 12px; color: var(--muted); }
.modal-card h3 { margin: 0; }
.modal-card label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--muted); }
.modal-card input, .modal-card select {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 13px;
}
.modal-card .row { display: flex; gap: 12px; }
.flex-1 { flex: 1; }
.w-100 { width: 100px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }
.kind-config.hidden { display: none; }

/* ---- 环境反例图片 ---- */
.env-section {
  grid-column: span 2;
  padding: 20px 0 0;
  border-top: 1px solid var(--border);
}
.env-hint {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 14px;
  line-height: 1.6;
}
.env-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.env-thumb {
  position: relative;
  width: 96px;
  height: 96px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--panel-2);
}
.env-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.env-del {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(0,0,0,0.65);
  color: #fff;
  border: none;
  font-size: 11px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  line-height: 1;
}
.env-del:hover { background: rgba(255,91,110,0.8); }

@media (max-width: 1100px) {
  .main { grid-template-columns: 1fr; }
  #log { height: 300px; }
  .env-section { grid-column: span 1; }
}
