/* ============================================================
   GroundingPI Studio — 设计系统
   全部本地资源，无任何外链字体 / 图标。
   ============================================================ */

:root {
  color-scheme: light;

  /* 车间工作台：暖灰纸面，一个松绿作主操作色，没有渐变 */
  --brand: #1f6b45;
  --brand-strong: #184f34;
  --brand-soft: #e6f0ea;
  --accent: #8d5a32;
  --accent-soft: #f4ebe3;

  --bg: #e7e4dc;
  --bg-grad-1: transparent;
  --bg-grad-2: transparent;
  --surface: #f7f6f2;
  --surface-2: #f3f1eb;
  --surface-3: #ece9e1;
  --border: #d4cfc4;
  --border-strong: #b7b1a4;
  --text: #2c2924;
  --text-2: #5c564c;
  --text-3: #857e72;

  --ok: #1f7a4d;
  --ok-soft: #e5f3eb;
  --warn: #9a6230;
  --warn-soft: #f8efe4;
  --err: #a33b32;
  --err-soft: #f8e8e6;
  --info: #3d5c73;

  --shadow-xs: none;
  --shadow-sm: 0 1px 0 rgba(44, 41, 36, 0.04);
  --shadow-md: 0 10px 28px rgba(44, 41, 36, 0.08);
  --shadow-lg: 0 18px 48px rgba(44, 41, 36, 0.16);
  --r-sm: 4px;
  --r-md: 6px;
  --r-lg: 8px;
  --r-xl: 10px;

  --sidebar-w: 372px;
  --gap: 18px;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Source Han Sans SC",
    "Noto Sans CJK SC", "WenQuanYi Micro Hei", Roboto, Arial, sans-serif;
  --mono: "SFMono-Regular", "JetBrains Mono", Menlo, Consolas,
    "Liberation Mono", "Courier New", monospace;
}

:root[data-theme="dark"] {
  color-scheme: dark;

  --brand: #5dbe86;
  --brand-strong: #2f7d54;
  --brand-soft: rgba(93, 190, 134, 0.16);
  --accent: #d2a27a;
  --accent-soft: rgba(210, 162, 122, 0.14);

  --bg: #1c1b19;
  --bg-grad-1: transparent;
  --bg-grad-2: transparent;
  --surface: #262420;
  --surface-2: #2c2a26;
  --surface-3: #34312c;
  --border: #3d3a34;
  --border-strong: #524e46;
  --text: #f3f0e8;
  --text-2: #d2cbc0;
  --text-3: #b3ab9e;

  /* 这几个是字色。底色另用 --fill-*，避免浅字压在浅底上。 */
  --ok: #9dccb0;
  --ok-soft: rgba(157, 204, 176, 0.16);
  --warn: #e8c294;
  --warn-soft: rgba(232, 194, 148, 0.16);
  --err: #f0b2ab;
  --err-soft: rgba(240, 178, 171, 0.16);
  --fill-brand: #1f6b45;
  --fill-brand-strong: #184f34;
  --fill-ok: #1c6240;
  --fill-warn: #7a4e22;
  --fill-err: #8c3d36;
  --info: #a9c0ce;

  --shadow-xs: none;
  --shadow-sm: none;
  --shadow-md: 0 12px 32px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 20px 48px rgba(0, 0, 0, 0.5);
}

* { box-sizing: border-box; }

html { height: 100%; overflow: hidden; }
body { height: 100%; }

body {
  margin: 0;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.icon-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

.ic {
  width: 18px;
  height: 18px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: 0; }
p { margin: 0; }
button { font-family: inherit; font-size: inherit; cursor: pointer; }
.hidden { display: none !important; }

/* ------------------------------------------------------------ 顶栏 */
.topbar {
  position: relative;
  flex: none;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 22px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 13px; min-width: 0; }

.brand-mark {
  display: grid;
  place-items: center;
  width: 36px; height: 36px;
  border-radius: 6px;
  color: #f7f6f2;
  background: var(--fill-brand, var(--brand));
}
.brand-mark .ic { width: 21px; height: 21px; stroke-width: 1.9; }

.brand-text h1 { font-size: 17px; line-height: 1.25; }
.brand-text p { font-size: 12px; color: var(--text-3); letter-spacing: 0.01em; }

.topbar-right { display: flex; align-items: center; gap: 10px; }

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px 7px 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  color: var(--text-2);
  font-size: 12.5px;
  font-weight: 550;
  box-shadow: var(--shadow-xs);
  transition: all 0.18s var(--ease);
  max-width: 46vw;
}
.status-pill:hover { border-color: var(--border-strong); color: var(--text); }

.status-pill .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--text-3);
  box-shadow: var(--shadow-sm);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--text-3) 18%, transparent);
  transition: all 0.2s var(--ease);
  flex: none;
}
.status-pill.online { border-color: color-mix(in srgb, var(--ok) 40%, var(--border)); }
.status-pill.online .dot {
  background: var(--ok);
}
.status-pill.offline { border-color: color-mix(in srgb, var(--err) 38%, var(--border)); color: var(--err); }
.status-pill.offline .dot {
  background: var(--err);
  box-shadow: var(--shadow-sm);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--err) 20%, transparent);
}
.status-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 左侧视频区的 ffmpeg 状态：和顶栏模型状态同样的灯，但更小、独占一行靠左 */
.status-pill.ffmpeg-pill {
  align-self: flex-start;
  max-width: 100%;
  padding: 6px 12px 6px 10px;
  font-size: 12px;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 36px; height: 36px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  box-shadow: var(--shadow-xs);
  transition: all 0.16s var(--ease);
}
.icon-btn:hover { color: var(--text); border-color: var(--border-strong); background: var(--surface-3); }
.icon-btn:active { transform: scale(0.96); }
.icon-btn.danger:hover { color: var(--err); border-color: color-mix(in srgb, var(--err) 40%, var(--border)); background: var(--err-soft); }

/* ------------------------------------------------------------ 布局 */
.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  gap: var(--gap);
  padding: var(--gap) 26px var(--gap);
  align-items: stretch;
  flex: 1 1 auto;
  min-height: 0;
  max-width: 1760px;
  margin: 0 auto;
  width: 100%;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  position: static;
  min-height: 0;
  overflow-y: auto;
  scrollbar-gutter: stable;
  overscroll-behavior: contain;
  padding-right: 4px;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
/* 关键：禁止卡片被 flex 压缩，超高时让左栏滚动而不是压扁内容 */
.sidebar > * { flex: 0 0 auto; }
.sidebar::-webkit-scrollbar { width: 7px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 999px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.card-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px 18px 12px;
  border-bottom: 1px solid transparent;
}
.card-icon {
  display: grid;
  place-items: center;
  width: 32px; height: 32px;
  border-radius: 9px;
  background: var(--brand-soft);
  color: var(--brand);
  flex: none;
}
.card-icon .ic { width: 17px; height: 17px; }
.card-head h2 { font-size: 14px; line-height: 1.35; }
.card-head p { font-size: 11.5px; color: var(--text-3); margin-top: 1px; }

.card-body { padding: 4px 18px 18px; display: flex; flex-direction: column; gap: 13px; }

/* ------------------------------------------------------------ 表单 */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label,
.field-head > label { font-size: 12px; font-weight: 600; color: var(--text-2); letter-spacing: 0.01em; }
.field-head {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.field-head > label { margin: 0; }
.field-head .btn { margin-left: auto; }
.hint { font-weight: 400; color: var(--text-3); }
.help-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  margin: 0;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--text-3);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  flex: none;
}
.help-btn .ic {
  width: 16px;
  height: 16px;
  pointer-events: none;
}
.help-btn:hover,
.help-btn:focus-visible,
.help-btn[aria-expanded="true"] {
  color: var(--text);
  border-color: var(--text-3);
  background: var(--surface-3);
  outline: none;
}
.help-pop {
  position: fixed;
  z-index: 180;
  width: max-content;
  max-width: 260px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-md);
  color: var(--text-2);
  font-size: 12px;
  line-height: 1.55;
}

.input {
  width: 100%;
  padding: 9px 12px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  transition: all 0.16s var(--ease);
  outline: none;
}
.input::placeholder,
.tag-input input::placeholder {
  color: var(--text-3);
  opacity: 1;
}
.input:hover { border-color: var(--border-strong); }
.input:focus {
  border-color: var(--brand);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 16%, transparent);
}
select.input {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%),
    linear-gradient(135deg, var(--text-3) 50%, transparent 50%);
  background-position: calc(100% - 17px) 50%, calc(100% - 12px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 32px;
  cursor: pointer;
}
textarea.input { resize: vertical; min-height: 44px; line-height: 1.5; }

.row { display: flex; gap: 8px; }
.row .input { flex: 1; min-width: 0; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 14px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  transition: all 0.16s var(--ease);
  box-shadow: var(--shadow-xs);
}
.btn .ic { width: 16px; height: 16px; }
.btn:hover { border-color: var(--border-strong); background: var(--surface-3); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn[aria-busy="true"] .ic,
.icon-btn[aria-busy="true"] .ic {
  animation: spin 0.9s linear infinite;
  transform-box: fill-box;
  transform-origin: center;
}

.btn-primary {
  background: var(--fill-brand, var(--brand));
  border-color: var(--fill-brand-strong, var(--brand-strong));
  color: #f7f6f2;
}
.btn-primary:hover {
  background: var(--fill-brand-strong, var(--brand-strong));
  border-color: var(--fill-brand-strong, var(--brand-strong));
  color: #f7f6f2;
}
.btn-ghost { background: var(--surface-2); }
.btn-ghost.danger { color: var(--err); }
.btn-ghost.danger:hover { background: var(--err-soft); border-color: color-mix(in srgb, var(--err) 36%, var(--border)); }
.btn.wide { width: 100%; }

.run-row { display: flex; gap: 8px; flex-wrap: wrap; }
.run-row .btn { flex: 1 1 auto; }
.run-row .btn-primary { flex: 2 1 140px; }

.tip {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--text-3);
}
.tip .ic { width: 14px; height: 14px; }

/* ------------------------------------------------------------ 模式选择 */
.mode-grid { display: grid; grid-template-columns: 1fr; gap: 8px; }

.mode-card {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--surface-2);
  text-align: left;
  color: var(--text);
  transition: all 0.16s var(--ease);
}
.mode-card:hover { border-color: var(--border-strong); background: var(--surface); }
.mode-card.active {
  border-color: var(--brand);
  background: var(--brand-soft);
  box-shadow: var(--shadow-sm);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--brand) 45%, transparent);
}
.mode-card .mode-ic {
  display: grid; place-items: center;
  width: 30px; height: 30px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-2);
  flex: none;
}
.mode-card.active .mode-ic { background: var(--surface); border-color: color-mix(in srgb, var(--brand) 40%, var(--border)); color: var(--brand); }
.mode-card .mode-body { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.mode-card .mode-name { font-size: 13px; font-weight: 620; line-height: 1.35; }
.mode-card .mode-desc { font-size: 11.5px; color: var(--text-3); line-height: 1.4; }

/* ------------------------------------------------------------ 标签输入 */
.tag-input {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  min-height: 40px;
  padding: 6px 8px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  transition: all 0.16s var(--ease);
}
.tag-input:focus-within {
  border-color: var(--brand);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 16%, transparent);
}
.tag-input input,
.tag-input textarea {
  flex: 1;
  min-width: 90px;
  border: 0;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  outline: none;
  padding: 3px 2px;
  resize: none;
  overflow: hidden;
  line-height: 1.4;
  min-height: 22px;
  max-height: 22px;
  box-sizing: border-box;
}
.tag-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  flex: none;
  background: var(--tag-color, var(--brand));
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 6px 3px 8px;
  border-radius: 4px;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 12px;
  font-weight: 620;
  border: 1px solid var(--border-strong);
  border: 1px solid color-mix(in srgb, var(--brand) 26%, transparent);
}
:root[data-theme="dark"] .tag { color: #d5e6da; }
:root[data-theme="dark"] .brand-mark { color: #f7f6f2; }
.tag button {
  display: grid; place-items: center;
  width: 15px; height: 15px;
  border: 0; padding: 0;
  border-radius: 50%;
  background: transparent;
  color: inherit;
  opacity: 0.65;
}
.tag button:hover { opacity: 1; background: color-mix(in srgb, var(--brand) 22%, transparent); }
.tag button .ic { width: 10px; height: 10px; stroke-width: 2.4; }
.tag-key {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 4px;
  background: color-mix(in srgb, var(--brand) 16%, transparent);
  color: var(--brand);
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
:root[data-theme="dark"] .tag-key { color: #d5e6da; }

.tag-suggest { display: flex; flex-wrap: wrap; gap: 5px; }
.tag-suggest button {
  padding: 3px 9px;
  border-radius: 4px;
  border: 1px dashed var(--border-strong);
  background: transparent;
  color: var(--text-3);
  font-size: 11.5px;
  transition: all 0.15s var(--ease);
}
.tag-suggest button:hover { color: var(--brand); border-color: var(--brand); background: var(--brand-soft); }

/* ------------------------------------------------------------ 提示词预览 */
.prompt-preview {
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--surface-3);
  padding: 9px 11px;
}
.prompt-head {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12px; font-weight: 600;
  color: var(--text-3);
  margin-bottom: 4px;
}
.prompt-cn {
  font-size: 12px;
  line-height: 1.55;
  color: var(--text);
  word-break: break-word;
}
.prompt-raw {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px dashed var(--border);
}
.prompt-raw-label {
  display: block;
  font-size: 11px;
  color: var(--text-3);
  margin-bottom: 2px;
}
.prompt-preview code {
  display: block;
  font-family: var(--mono);
  font-size: 10.5px;
  line-height: 1.5;
  color: var(--text-3);
  word-break: break-word;
  max-height: 92px;
  overflow-y: auto;
}

/* ------------------------------------------------------------ 上传区 */
.dropzone {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 24px 16px;
  border-radius: var(--r-md);
  border: 1.5px dashed var(--border-strong);
  background: var(--surface-2);
  text-align: center;
  cursor: pointer;
  transition: all 0.18s var(--ease);
}
.dropzone.compact { padding: 16px; }
.dropzone:hover, .dropzone:focus-visible {
  border-color: var(--brand);
  background: var(--brand-soft);
  outline: none;
}
.dropzone.dragging {
  border-color: var(--brand);
  background: var(--brand-soft);
  transform: scale(0.995);
}
.dropzone-ic { width: 26px; height: 26px; color: var(--brand); margin-bottom: 3px; }
.dropzone strong { font-size: 13px; font-weight: 620; }
.dropzone.busy { pointer-events: none; }
.dz-busy {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border-radius: inherit;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  background: var(--surface);
  z-index: 2;
}
.dz-busy .ic { width: 22px; height: 22px; color: var(--brand); margin-bottom: 4px; animation: spin 2.4s linear infinite; }
.dz-busy strong { font-size: 12.5px; }
.dz-busy span { font-size: 11px; color: var(--text-3); }
@keyframes spin { to { transform: rotate(360deg); } }
.dropzone span { font-size: 11.5px; color: var(--text-3); }

/* ------------------------------------------------------------ 导出 */
.format-list { display: flex; flex-direction: column; gap: 7px; }
.format-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 9px 11px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--surface-2);
  cursor: pointer;
  transition: all 0.16s var(--ease);
}
.format-item:hover { border-color: var(--border-strong); background: var(--surface); }
.format-item.active {
  border-color: var(--brand);
  background: var(--brand-soft);
  box-shadow: var(--shadow-sm);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--brand) 40%, transparent);
}
.format-item { position: relative; }
.format-item input {
  position: absolute;
  left: 0; top: 0;
  width: 1px; height: 1px;
  margin: 0;
  opacity: 0;
  pointer-events: none;
}
.radio-dot {
  width: 14px; height: 14px;
  margin-top: 3px;
  border-radius: 50%;
  border: 1.6px solid var(--border-strong);
  background: var(--surface);
  flex: none;
  position: relative;
  transition: all 0.16s var(--ease);
}
.format-item.active .radio-dot { border-color: var(--brand); }
.format-item.active .radio-dot::after {
  content: "";
  position: absolute;
  inset: 2.6px;
  border-radius: 50%;
  background: var(--brand);
}
.format-item .fmt-body { min-width: 0; display: flex; flex-direction: column; }
.format-item .fmt-name { font-size: 12.5px; font-weight: 620; line-height: 1.4; }
.format-item .fmt-desc { font-size: 11px; color: var(--text-3); line-height: 1.45; margin-top: 1px; }

.export-result {
  padding: 10px 12px;
  border-radius: var(--r-md);
  background: var(--ok-soft);
  border: 1px solid var(--border-strong);
  border: 1px solid color-mix(in srgb, var(--ok) 30%, transparent);
  font-size: 12px;
  color: var(--text);
}
.export-result a {
  display: inline-flex; align-items: center; gap: 5px;
  margin-top: 5px;
  color: var(--brand); font-weight: 650; text-decoration: none;
}
.export-result a:hover { text-decoration: underline; }
.export-result a .ic-wrap { display: inline-flex; }
.export-result a .ic { width: 14px; height: 14px; }
.export-result .muted { color: var(--text-3); font-size: 11px; }

/* ------------------------------------------------------------ 视频 */
.video-meta {
  padding: 9px 11px;
  border-radius: var(--r-md);
  background: var(--surface-3);
  font-size: 11.5px;
  color: var(--text-2);
  display: grid;
  gap: 3px;
}
.video-meta b { color: var(--text); font-weight: 620; }
.video-meta .fname {
  font-weight: 620; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.seg {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px;
  padding: 3px;
  border-radius: var(--r-sm);
  background: var(--surface-3);
  border: 1px solid var(--border);
}
.seg-item {
  padding: 6px 8px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
  transition: all 0.16s var(--ease);
}
.seg-item.active {
  background: var(--surface);
  color: var(--brand);
  box-shadow: var(--shadow-xs);
}
.seg-item:hover:not(.active) { color: var(--text); }

input[type="range"] {
  width: 100%;
  height: 4px;
  border-radius: 999px;
  background: var(--surface-3);
  appearance: none;
  outline: none;
  margin: 6px 0;
}
input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 15px; height: 15px;
  border-radius: 50%;
  background: var(--brand);
  border: 2.5px solid var(--surface);
  box-shadow: var(--shadow-sm);
  box-shadow: 0 1px 5px color-mix(in srgb, var(--brand) 45%, transparent);
  cursor: pointer;
}
input[type="range"]::-moz-range-thumb {
  width: 15px; height: 15px;
  border-radius: 50%;
  background: var(--brand);
  border: 2.5px solid var(--surface);
  cursor: pointer;
}

.estimate {
  padding: 8px 11px;
  border-radius: var(--r-sm);
  background: var(--surface-3);
  font-size: 11.5px;
  color: var(--text-2);
  text-align: center;
}
.estimate strong { color: var(--brand); font-weight: 700; }

/* ------------------------------------------------------------ 结果区 */
.workspace {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.results-card {
  padding: 0;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.results-card > .results-head,
.results-card > .progress-block,
.results-card > .filter-row { flex: none; }

.results-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 22px 14px;
  border-bottom: 1px solid var(--border);
}
.results-title { min-width: 0; flex: 1 1 auto; }
.results-title h2 {
  font-size: 16.5px;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#jobTitle.job-editable {
  cursor: text;
  border-radius: 4px;
  max-width: 100%;
}
#jobTitle.job-editable:hover,
#jobTitle.job-editable:focus {
  outline: 1px dashed color-mix(in srgb, var(--text-3) 70%, transparent);
  outline-offset: 2px;
}
#jobTitleInput {
  display: block;
  width: 100%;
  max-width: 36em;
  margin: 0;
  padding: 1px 6px;
  font: inherit;
  font-size: 16.5px;
  font-weight: 650;
  line-height: 1.3;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--brand, #2f6f9f);
  border-radius: 6px;
}
#jobTitleInput[hidden] { display: none; }
.results-title p { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.results-actions { display: flex; gap: 8px; flex: none; }

.progress-block {
  padding: 14px 22px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.progress-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.progress-hint {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 12px;
  color: var(--text-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  background: var(--surface-3);
  color: var(--text-2);
  border: 1px solid var(--border);
}
.badge.running { background: var(--brand-soft); color: var(--brand); border-color: color-mix(in srgb, var(--brand) 30%, transparent); }
.badge.done { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 30%, transparent); }
.badge.failed { background: var(--err-soft); color: var(--err); border-color: color-mix(in srgb, var(--err) 30%, transparent); }
.badge.partial { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }

.progress-counts {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-2);
  font-weight: 600;
}

.progress-track {
  height: 6px;
  border-radius: 2px;
  background: var(--surface-3);
  overflow: hidden;
  border: 1px solid var(--border);
}
.progress-fill {
  height: 100%;
  width: 0;
  border-radius: 2px;
  background: var(--brand);
  transition: width 0.45s var(--ease);
}

.stat-row { display: flex; flex-wrap: wrap; gap: 6px; }
.stat {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 7px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 11.5px;
  color: var(--text-2);
}
.stat b { font-family: var(--mono); font-weight: 700; color: var(--text); }
.stat.ok b { color: var(--ok); }
.stat.bad b { color: var(--err); }
.stat.warn b { color: var(--warn); }

.filter-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 22px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.filter-left { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-width: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  padding: 5px 10px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
  transition: all 0.15s var(--ease);
}
.chip:hover { border-color: var(--border-strong); color: var(--text); }
.chip.active { background: var(--text); color: var(--surface); border-color: var(--text); }
.chip .n { opacity: 0.6; font-family: var(--mono); font-size: 11px; margin-left: 3px; }

.view-toggle { display: flex; gap: 2px; padding: 2px; background: var(--surface-3); border-radius: 8px; border: 1px solid var(--border); }
.view-btn {
  width: 27px; height: 24px;
  border: 0; border-radius: 6px;
  background: transparent;
  color: var(--text-3);
  font-size: 11.5px; font-weight: 650;
  transition: all 0.15s var(--ease);
}
.view-btn.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-xs); }

/* ------------------------------------------------------------ 网格 */
.grid {
  display: grid;
  gap: 14px;
  padding: 18px 22px 24px;
  grid-template-columns: repeat(auto-fill, minmax(232px, 1fr));
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  /* 网格高度被限制后，行默认会被压扁到容器高度内，必须让每行按内容撑开才会溢出滚动 */
  grid-auto-rows: max-content;
  align-content: start;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: var(--text-3) transparent;
}
.grid::-webkit-scrollbar { width: 11px; }
.grid::-webkit-scrollbar-thumb {
  background: var(--text-3);
  background-clip: padding-box;
  border: 3px solid transparent;
  border-radius: 999px;
}
.grid::-webkit-scrollbar-thumb:hover { background: var(--text-2); background-clip: padding-box; }
.grid::-webkit-scrollbar-track { background: transparent; }
.grid[data-size="s"] { grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 11px; }

.tile {
  position: relative;
  display: flex;
  flex-direction: column;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--surface-2);
  overflow: hidden;
  transition: all 0.18s var(--ease);
  cursor: pointer;
}
.tile:hover {
  border-color: var(--border-strong);
}

.tile-stage {
  position: relative;
  aspect-ratio: 4 / 3;
  background:
    repeating-conic-gradient(from 45deg, var(--surface-3) 0% 25%, var(--surface-2) 0% 50%) 0 0 / 16px 16px;
  overflow: hidden;
}
.tile-stage img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.tile-stage svg.overlay { position: absolute; inset: 0; width: 100%; height: 100%; }

.tile-corner {
  position: absolute;
  top: 7px; left: 7px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 600;
  color: #f7f6f2;
  background: rgba(44, 41, 36, 0.72);
}
.tile-corner .ic { width: 11px; height: 11px; stroke-width: 2.2; }
.tile-corner.success { background: var(--fill-ok, var(--ok)); }
.tile-corner.invalid_response { background: var(--fill-warn, var(--warn)); }
.tile-corner.failed { background: var(--fill-err, var(--err)); }
.tile-corner.pending { background: rgba(16, 22, 32, 0.6); }
.tile-corner.processing { background: var(--fill-brand, var(--brand)); }
.tile-corner.skipped,
.tile-corner.negative { background: color-mix(in srgb, var(--text-3) 80%, #000); }

.tile-count {
  position: absolute;
  top: 7px; right: 7px;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 600;
  font-family: var(--mono);
  color: #f7f6f2;
  background: rgba(44, 41, 36, 0.72);
}

.tile-shimmer {
  position: absolute;
  inset: 0;
  background: var(--surface);
  background: linear-gradient(100deg, transparent 20%, color-mix(in srgb, var(--brand) 14%, transparent) 50%, transparent 80%);
  background-size: 220% 100%;
  animation: shimmer 1.5s linear infinite;
}
@keyframes shimmer { from { background-position: 180% 0; } to { background-position: -80% 0; } }

.tile-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}
.tile-name {
  flex: 1;
  min-width: 0;
  font-size: 11.5px;
  font-weight: 550;
  color: var(--text-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tile-time {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--text-3);
  flex: none;
}

.tile-err {
  padding: 6px 10px 8px;
  font-size: 10.5px;
  line-height: 1.45;
  color: var(--err);
  background: var(--err-soft);
  border-top: 1px solid color-mix(in srgb, var(--err) 18%, transparent);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.tile-err.warn { color: var(--warn); background: var(--warn-soft); border-top-color: color-mix(in srgb, var(--warn) 18%, transparent); }

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex: 1 1 auto;
  min-height: 0;
  padding: 60px 24px;
  text-align: center;
  color: var(--text-3);
}
/* 网格为空时不必占位，让空状态撑满剩余高度居中显示 */
.grid:empty { flex: 0 0 auto; min-height: 0; padding: 0; overflow: hidden; }
.empty-state .ic { width: 42px; height: 42px; opacity: 0.4; stroke-width: 1.3; margin-bottom: 4px; }
.empty-state strong { font-size: 14px; color: var(--text-2); font-weight: 620; }
.empty-state span { font-size: 12.5px; }

/* ------------------------------------------------------------ 弹窗 */
.modal[hidden] { display: none; }
.modal { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; padding: 24px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(28, 27, 25, 0.55); }
.modal-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(1180px, 100%);
  max-height: calc(100vh - 48px);
  border-radius: var(--r-xl);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: pop 0.2s var(--ease);
}
@keyframes pop { from { opacity: 0; transform: scale(0.98) translateY(6px); } to { opacity: 1; transform: none; } }

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.modal-title { min-width: 0; flex: 1 1 auto; display: flex; flex-direction: column; gap: 4px; }
.modal-title strong { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal-title span { font-size: 12.5px; color: var(--text-3); font-family: inherit; letter-spacing: 0; word-spacing: normal; line-height: 1.5; white-space: normal; }
.modal-title .circle-hint {
  display: block;
  width: 100%;
  max-width: 100%;
  font-family: inherit;
  font-variant-ligatures: none;
  letter-spacing: 0;
  word-spacing: normal;
  line-height: 1.5;
  white-space: normal;
  overflow-wrap: break-word;
  word-break: normal;
  font-size: 12.5px;
  color: var(--text-3);
}
.modal-tools { display: flex; align-items: center; gap: 8px; flex: none; }

.modal-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 322px;
  min-height: 0;
  flex: 1;
}
.viewer-stage {
  display: grid;
  place-items: center;
  padding: 18px;
  background:
    repeating-conic-gradient(from 45deg, var(--surface-3) 0% 25%, var(--surface-2) 0% 50%) 0 0 / 20px 20px;
  overflow: auto;
  min-height: 0;
}
.viewer-canvas { position: relative; line-height: 0; box-shadow: var(--shadow-md); border-radius: 6px; overflow: hidden; }
.viewer-canvas img { max-width: 100%; max-height: calc(100vh - 160px); display: block; }
.viewer-canvas svg.overlay { position: absolute; inset: 0; width: 100%; height: 100%; }

.viewer-stage-wrap { position: relative; display: flex; min-width: 0; min-height: 0; }
.viewer-stage-wrap .viewer-stage { flex: 1 1 auto; }
.viewer-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 40px; height: 64px;
  display: grid; place-items: center;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: all 0.16s var(--ease);
  z-index: 2;
}
.viewer-nav:hover:not(:disabled) { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.viewer-nav:disabled { opacity: 0.3; cursor: default; }
.viewer-nav.prev { left: 12px; }
.viewer-nav.next { right: 12px; }
.viewer-nav .ic { width: 20px; height: 20px; }
.viewer-nav.prev .ic { transform: rotate(90deg); }
.viewer-nav.next .ic { transform: rotate(-90deg); }
.viewer-pos {
  display: inline-flex;
  align-items: baseline;
  justify-content: center;
  gap: 4px;
  height: 36px;
  min-width: 68px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-3);
  font-family: var(--mono);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  line-height: 36px;
}
.viewer-pos b { color: var(--text); font-weight: 680; font-size: 14px; }
.viewer-pos[hidden],
.viewer-nav[hidden] { display: none !important; }

.viewer-side {
  border-left: 1px solid var(--border);
  background: var(--surface);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.side-section { padding: 14px 16px; border-bottom: 1px solid var(--border); }
.side-section h3 {
  display: flex; align-items: center; gap: 7px;
  font-size: 13px; font-weight: 600;
  color: var(--text-2);
  margin-bottom: 9px;
}
.viewer-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.viewer-actions .btn { flex: 1 1 auto; align-self: center; min-width: max-content; height: auto; }
.count-chip {
  padding: 1px 7px;
  border-radius: 3px;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 11px;
  font-family: var(--mono);
  font-weight: 700;
}

.ann-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.ann-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 9px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 12px;
  transition: all 0.15s var(--ease);
}
.ann-item { cursor: pointer; }
.ann-item:hover { border-color: var(--border-strong); background: var(--surface); }
.ann-item.active {
  border-color: var(--brand);
  background: var(--brand-soft);
  box-shadow: inset 3px 0 0 var(--brand);
}
.ann-swatch { width: 9px; height: 9px; border-radius: 2.5px; flex: none; }
.ann-label { font-weight: 620; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ann-coord {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--text-3);
  flex: none;
}
.ann-del {
  display: grid; place-items: center;
  width: 22px; height: 22px;
  border: 0; border-radius: 6px;
  background: transparent;
  color: var(--text-3);
  flex: none;
}
.ann-del:hover { color: var(--err); background: var(--err-soft); }
.ann-del .ic { width: 13px; height: 13px; }

.ann-empty { font-size: 12px; color: var(--text-3); padding: 4px 0; }

.raw-block pre {
  margin: 0;
  padding: 10px;
  border-radius: var(--r-sm);
  background: var(--surface-3);
  border: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.62;
  color: var(--text-2);
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 260px;
  overflow: auto;
}

#parseWarn { display: flex; flex-direction: column; gap: 8px; }
.warn-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  background: var(--warn-soft);
  border: 1px solid color-mix(in srgb, var(--warn) 28%, transparent);
  color: var(--text);
}
.warn-item .ic { width: 15px; height: 15px; flex: none; margin-top: 1px; color: var(--warn); }
.warn-copy { min-width: 0; }
.warn-copy strong {
  display: block;
  font-size: 13px;
  font-weight: 650;
  line-height: 1.45;
  color: var(--text);
  overflow-wrap: break-word;
}
.warn-copy p {
  margin: 4px 0 0;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--text-2);
  overflow-wrap: break-word;
}
.warn-copy p:only-child {
  margin: 0;
  font-size: 13px;
  line-height: 1.55;
  color: var(--text);
}

.btn-danger {
  background: var(--err);
  border-color: #8a3129;
  color: #f7f6f2;
}
.btn-danger:hover {
  background: #8a3129;
  border-color: #8a3129;
  color: #f7f6f2;
}

/* ------------------------------------------------------------ 确认框 */
.confirm[hidden] { display: none; }
.confirm {
  position: fixed;
  inset: 0;
  z-index: 160;
  display: grid;
  place-items: center;
  padding: 24px;
}
.confirm-backdrop { position: absolute; inset: 0; background: rgba(28, 27, 25, 0.45); }
.confirm-panel {
  position: relative;
  width: min(420px, 100%);
  padding: 22px 22px 18px;
  border-radius: var(--r-lg);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  animation: pop 0.18s var(--ease);
}
.confirm-panel h2 { font-size: 16px; line-height: 1.35; color: var(--text); }
.confirm-panel p {
  margin-top: 8px;
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--text-2);
}
.confirm-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.shortcut-panel { width: min(420px, 100%); }
.shortcut-table-wrap {
  margin-top: 14px;
  max-height: min(52vh, 420px);
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--r-md, 8px);
}
.shortcut-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.shortcut-table th,
.shortcut-table td {
  padding: 7px 10px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.shortcut-table th {
  font-size: 12px;
  font-weight: 650;
  color: var(--text-2);
  background: var(--surface-2);
  position: sticky;
  top: 0;
}
.shortcut-table tr:last-child td { border-bottom: 0; }
.shortcut-table .shortcut-digit {
  width: 56px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.shortcut-table select {
  width: 100%;
}
.shortcut-actions { align-items: center; }
.shortcut-actions-spacer { flex: 1 1 auto; }

/* ------------------------------------------------------------ Toast */
.toast-stack {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 120;
  display: flex;
  flex-direction: column;
  gap: 9px;
  pointer-events: none;
  max-width: min(400px, calc(100vw - 32px));
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 11px 14px;
  border-radius: var(--r-md);
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--brand);
  box-shadow: var(--shadow-md);
  font-size: 12.5px;
  color: var(--text);
  animation: slide 0.24s var(--ease);
  pointer-events: auto;
}
.toast.ok { border-left-color: var(--ok); }
.toast.err { border-left-color: var(--err); }
.toast.warn { border-left-color: var(--warn); }
.toast .ic { width: 16px; height: 16px; flex: none; margin-top: 1px; }
.toast.ok .ic { color: var(--ok); }
.toast.err .ic { color: var(--err); }
.toast.warn .ic { color: var(--warn); }
.toast .ic { color: var(--brand); }
.toast-body { min-width: 0; }
.toast-body b { display: block; font-weight: 650; margin-bottom: 1px; }
.toast-body span { color: var(--text-2); font-size: 12px; line-height: 1.45; }

@keyframes slide { from { opacity: 0; transform: translateX(14px); } to { opacity: 1; transform: none; } }

/* ------------------------------------------------------------ 响应式 */
@media (max-width: 1180px) {
  :root { --sidebar-w: 330px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(196px, 1fr)); }
}

@media (max-width: 940px) {
  html { height: auto; overflow: visible; }
  body { height: auto; min-height: 100%; overflow: visible; display: block; }
  .layout {
    grid-template-columns: 1fr;
    padding: 14px 14px 32px;
    flex: none;
  }
  .workspace { display: block; }
  .results-card { display: block; }
  .grid { overflow: visible; scrollbar-gutter: auto; }
  .sidebar {
    position: static;
    max-height: none;
    overflow: visible;
    padding-right: 0;
  }
  .topbar { padding: 12px 16px; }
  .brand-text p { display: none; }
  .modal-body { grid-template-columns: 1fr; }
  .viewer-side { border-left: 0; border-top: 1px solid var(--border); max-height: 40vh; }
  .viewer-canvas img { max-height: 46vh; }
  .results-head { padding: 14px 16px 12px; }
  .progress-block, .filter-row { padding-left: 16px; padding-right: 16px; }
  .grid { padding: 14px 16px 20px; }
}

@media (max-width: 560px) {
  .status-pill { max-width: 42vw; padding: 6px 10px; }
  .status-label { font-size: 11px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
  .grid[data-size="s"] { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
  .modal { padding: 0; }
  .modal-panel { border-radius: 0; max-height: 100vh; height: 100vh; width: 100%; }
  .toast-stack { right: 12px; left: 12px; bottom: 12px; max-width: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* 打印 / 无 JS 兜底 */
@media print {
  .sidebar, .topbar-right, .results-actions, .filter-row { display: none; }
}

/* 任务运行时锁住标注设置，避免跑到一半改类别把结果搅乱 */
body.settings-locked #categoryField,
body.settings-locked #descriptionField,
body.settings-locked #modeGrid,
body.settings-locked #roiField,
body.settings-locked #overlapField,
body.settings-locked #exampleField {
  opacity: 0.55;
  pointer-events: none;
}
body.settings-locked #categoryField::after,
body.settings-locked #descriptionField::after,
body.settings-locked #modeGrid::after,
body.settings-locked #roiField::after,
body.settings-locked #overlapField::after,
body.settings-locked #exampleField::after {
  content: "任务运行中，先停止再改设置";
  display: block;
  margin-top: 6px;
  font-size: 11.5px;
  color: var(--warn, #b45309);
}

/* ---------- 多选删除 ---------- */
.filter-tools { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.select-all {
  position: relative;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 8px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 12px; font-weight: 600; color: var(--text-2);
  cursor: pointer;
  user-select: none;
  transition: all 0.15s var(--ease);
}
.select-all:hover { border-color: var(--border-strong); color: var(--text); }
.select-all:focus-within { border-color: var(--brand); }
.select-all input {
  position: absolute;
  width: 1px; height: 1px;
  margin: 0;
  opacity: 0;
  pointer-events: none;
}
.select-all-mark {
  width: 14px; height: 14px;
  display: grid;
  place-items: center;
  flex: none;
  border: 1.5px solid var(--border-strong);
  border-radius: 3px;
  background: var(--surface);
}
.select-all-mark svg { width: 10px; height: 10px; display: block; }
.select-all-mark path {
  fill: none;
  stroke: #fff;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.select-all-mark .tick,
.select-all-mark .dash { opacity: 0; }
.select-all input:checked + .select-all-mark,
.select-all input:indeterminate + .select-all-mark {
  background: var(--fill-brand, var(--brand));
  border-color: var(--fill-brand, var(--brand));
}
.select-all input:checked + .select-all-mark .tick { opacity: 1; }
.select-all input:indeterminate + .select-all-mark .dash { opacity: 1; }
.tool-sep { width: 1px; align-self: stretch; background: var(--border-strong); margin: 2px 6px; }
#deleteSelectedBtn.armed {
  background: var(--fill-err, var(--err));
  border-color: var(--fill-err, var(--err));
  color: #f7f6f2;
}
.btn.tiny { padding: 5px 11px; font-size: 12px; gap: 5px; }
.btn.tiny .ic { width: 13px; height: 13px; }

.tile-check {
  position: absolute;
  top: 7px; left: 7px;
  z-index: 3;
  width: 20px; height: 20px;
  display: grid; place-items: center;
  border-radius: 5px;
  border: 1.6px solid rgba(255, 255, 255, 0.85);
  background: rgba(44, 41, 36, 0.55);
  cursor: pointer;
  opacity: 0;
  transition: all 0.15s var(--ease);
}
.tile:hover .tile-check,
.tile-check.checked,
.tile.selecting .tile-check { opacity: 1; }
.tile-check.checked { background: var(--fill-brand, var(--brand)); border-color: var(--fill-brand, var(--brand)); }
.tile-check svg { width: 12px; height: 12px; stroke: #fff; stroke-width: 3; fill: none; opacity: 0; transform: translateX(-1.5px); }
.tile-check.checked svg { opacity: 1; }
.tile.selected .tile-stage::after {
  content: "";
  position: absolute; inset: 0;
  border: 2.5px solid var(--brand);
  border-radius: 8px;
  pointer-events: none;
  background: color-mix(in srgb, var(--brand) 12%, transparent);
}
/* 勾选框占了左上角，状态角标右移一点，别叠在一起 */
.tile .tile-corner { left: 33px; }


/* ---------- 识别区 / 图圈示例 / 标注编辑 ---------- */
.roi-preview {
  font-size: 12px;
  color: var(--text-2);
  line-height: 1.5;
  padding: 8px 10px;
  border: 1px dashed var(--border-strong, var(--border));
  border-radius: var(--r-sm);
  background: var(--surface-2);
  margin-bottom: 8px;
}
.roi-preview.has-roi { border-style: solid; color: var(--text); }
.setup-block {
  margin: 12px 0 4px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.setup-title {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 650;
  color: var(--text);
}
#overlapField { margin-top: 10px; }
.overlap-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.overlap-row input[type="range"] { flex: 1 1 auto; margin: 0; }
.overlap-contain {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  font-size: 12.5px;
  color: var(--text-2);
  cursor: pointer;
  user-select: none;
}
.overlap-contain input { margin: 0; }
.overlap-num {
  width: 68px;
  flex: none;
  text-align: center;
  padding: 4px 6px;
}
.example-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 8px;
}
.example-cat {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 2px;
  min-height: 76px;
}
.example-cat h4 {
  margin: 0;
  flex: 0 1 auto;
  min-width: 0;
  font-size: 12px;
  font-weight: 650;
}
.example-count { font-weight: 500; color: var(--text-3); }
.example-thumbs {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 6px;
  flex: 1 1 auto;
  min-width: 0;
}
.example-empty {
  font-size: 11.5px;
  color: var(--text-3);
  white-space: nowrap;
}
.example-thumb {
  position: relative;
  width: 64px;
  height: 64px;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface-2);
  cursor: zoom-in;
}
.example-thumb img { width: 100%; height: 100%; object-fit: contain; display: block; background: var(--surface-2); }
.example-thumb svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.example-thumb .ex-del {
  position: absolute;
  top: 1px;
  right: 1px;
  width: 14px;
  height: 14px;
  border: 0;
  border-radius: 3px;
  background: color-mix(in srgb, #000 70%, transparent);
  color: #fff;
  cursor: pointer;
  font-size: 10px;
  line-height: 14px;
  padding: 0;
  z-index: 2;
}
.example-actions { align-items: center; }
.example-actions .input { flex: 1 1 auto; min-width: 0; }
.tile.match-hit { outline: 2px solid var(--brand); outline-offset: -2px; }
.tile-match {
  position: absolute;
  left: 6px;
  bottom: 6px;
  z-index: 2;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--brand) 88%, #000);
  color: #fff;
}
.draw-label-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  margin-top: 10px;
}
.draw-label-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--text-2);
  margin-top: 0;
  flex: 1 1 auto;
  min-width: 0;
}
.draw-label-row .btn { flex: none; }
.digit-legend {
  margin: 6px 0 0;
  font-size: 11.5px;
  line-height: 1.55;
  color: var(--text-3);
}
.digit-legend[hidden] { display: none; }
.digit-legend kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  height: 16px;
  margin-right: 3px;
  padding: 0 4px;
  border-radius: 3px;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  font-size: 10px;
  font-weight: 700;
  font-family: inherit;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
#viewerToolHint {
  display: block;
  line-height: 1.45;
  margin-top: 8px;
  white-space: normal;
}
.viewer-canvas.tool-draw,
.viewer-canvas.tool-roi { cursor: crosshair; }
.box-handle {
  fill: #fff;
  stroke: #111;
  stroke-width: 1;
  cursor: nwse-resize;
}
.box-handle[data-handle="ne"],
.box-handle[data-handle="sw"] { cursor: nesw-resize; }
.roi-guide {
  fill: color-mix(in srgb, var(--brand) 12%, transparent);
  stroke: var(--brand);
  stroke-dasharray: 6 4;
  pointer-events: none;
}
.circle-panel { width: min(860px, 96%); }

.example-source-panel { width: min(860px, 96%); }
.example-source-panel .modal-tools .btn {
  box-sizing: border-box;
  height: 32px;
  padding-top: 0;
  padding-bottom: 0;
}
.example-source-panel .modal-body {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 12px 14px 16px;
}
.example-source-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
  gap: 8px;
  overflow-y: auto;
  min-height: 120px;
  max-height: min(520px, calc(100vh - 220px));
}
.example-source-grid:empty { display: none; }
.example-source-tile {
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface-2);
  overflow: hidden;
  cursor: pointer;
  text-align: left;
  color: inherit;
  font: inherit;
  transition: border-color 0.16s var(--ease), box-shadow 0.16s var(--ease);
}
.example-source-tile:hover,
.example-source-tile:focus-visible {
  border-color: var(--brand);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--brand) 40%, transparent);
  outline: none;
}
.example-source-tile img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  display: block;
  background: var(--surface-3);
}
.example-source-tile span {
  display: block;
  padding: 5px 7px 6px;
  font-size: 11px;
  color: var(--text-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.example-source-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 160px;
  color: var(--text-3);
  text-align: center;
}
.example-source-empty.hidden { display: none; }
.example-source-empty strong { font-size: 13px; color: var(--text-2); font-weight: 620; }
.example-source-empty span { font-size: 12px; }
#downloadSelectedBtn .ic { width: 13px; height: 13px; }

.circle-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 12px;
  min-height: 0;
}
.circle-stage-wrap {
  position: relative;
  width: 100%;
  display: flex;
  justify-content: center;
  min-width: 0;
  min-height: 0;
}
.circle-actions { padding: 0 16px 16px; display: flex; justify-content: flex-end; gap: 8px; }
.circle-guide {
  fill: color-mix(in srgb, #21c45a 12%, transparent);
  stroke: #21c45a;
  stroke-width: 2px;
  vector-effect: non-scaling-stroke;
  pointer-events: auto;
  cursor: move;
}

.ctx-menu {
  position: fixed;
  z-index: 200;
  min-width: 96px;
  padding: 4px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: 0 8px 24px color-mix(in srgb, #000 18%, transparent);
}
.ctx-menu[hidden] { display: none; }
.ctx-menu button {
  display: block;
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--err, #b42318);
  font-size: 13px;
  text-align: left;
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
}
.ctx-menu button:hover { background: var(--surface-3); }
.draw-crosshair {
  pointer-events: none;
}

.example-preview[hidden] { display: none; }
.example-preview {
  position: fixed;
  inset: 0;
  z-index: 220;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  box-sizing: border-box;
  cursor: zoom-out;
}
.example-preview-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(28, 27, 25, 0.72);
}
.example-preview-body {
  position: relative;
  z-index: 1;
  max-width: 100%;
  max-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.example-preview-frame {
  position: relative;
  display: block;
  max-width: 100%;
  max-height: 100%;
  line-height: 0;
  cursor: default;
}
.example-preview-frame img {
  display: block;
  max-width: calc(100vw - 48px);
  max-height: calc(100vh - 48px);
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.45);
  background: #111;
}
.example-preview-frame svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
