:root {
  --bg: #f4f6f9; --card: #ffffff; --text: #1d2433; --muted: #6b7486; --line: #e2e6ee; --soft: #f0f3f8;
  --primary: #1268c4; --primary-d: #0d529c; --primary-soft: #e6f0fb;
  --ok: #1a8a4a; --ok-soft: #e5f5ec; --warn: #b26a00; --warn-soft: #fff4e0; --err: #c62f2f; --err-soft: #fdeaea;
  --c0: #1f77d0; --c1: #e8590c; --c2: #2f9e44; --c3: #c2255c; --c4: #7048e8;
  --c5: #0c8599; --c6: #e67700; --c7: #5c940d; --c8: #862e9c; --c9: #495057;
  --radius: 10px; --shadow: 0 1px 2px rgba(20, 30, 50, .06), 0 2px 8px rgba(20, 30, 50, .04);
  font-family: "Segoe UI", "Microsoft JhengHei", "PingFang TC", "Noto Sans TC", system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12161d; --card: #1b2029; --text: #e3e7ee; --muted: #8d96a8; --line: #2b323e; --soft: #222833;
    --primary: #4b9be8; --primary-d: #6aaef0; --primary-soft: #1d2c40;
    --ok: #4cc27c; --ok-soft: #173023; --warn: #f0a640; --warn-soft: #33270f; --err: #f06464; --err-soft: #3a1c1c;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font-size: 14.5px; line-height: 1.55; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 4px; font-weight: 650; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
h2 { font-size: 16px; margin: 0 0 12px; font-weight: 650; }
h2.inline { display: inline; margin: 0; }
h3 { font-size: 14px; margin: 16px 0 8px; font-weight: 650; }
code { background: var(--soft); padding: 1px 5px; border-radius: 4px; font-size: 12.5px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.err-text { color: var(--err); }
.spacer { flex: 1; }
.center { text-align: center; }

/* 頂部導覽 */
.topbar { display: flex; align-items: center; gap: 24px; padding: 0 24px; height: 56px; background: var(--card);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; color: var(--text); white-space: nowrap; }
.brand img { width: 26px; height: 26px; }
.brand:hover { text-decoration: none; }
.nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.nav a { padding: 8px 12px; border-radius: 8px; color: var(--muted); white-space: nowrap; }
.nav a:hover { background: var(--soft); text-decoration: none; color: var(--text); }
.nav a.on { color: var(--primary); background: var(--primary-soft); font-weight: 600; }
.who { display: flex; align-items: center; gap: 12px; white-space: nowrap; }
.who-name { color: var(--text); }
.who form { margin: 0; }
button.link { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 0; font: inherit; }
button.link:hover { color: var(--text); }
.pill { font-size: 12px; padding: 2px 10px; border-radius: 99px; background: var(--soft); }
.pill.busy { background: var(--warn-soft); color: var(--warn); }
.pill.idle { background: var(--ok-soft); color: var(--ok); }

.wrap { max-width: 1240px; margin: 0 auto; padding: 24px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head p { margin: 2px 0 0; }
.crumbs { font-size: 12.5px; color: var(--muted); margin-bottom: 2px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 18px; box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.card-head h2, .card-head h3 { margin: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid2.wide-left { grid-template-columns: 3fr 2fr; }
.grid2 > .card, .grid3 > .card { margin-bottom: 0; }
.grid2 + .card, .grid3 + .card, .grid2 + .grid2 { margin-top: 18px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; margin-bottom: 18px; }
@media (max-width: 900px) { .grid2, .grid2.wide-left, .grid3 { grid-template-columns: 1fr; } .who-name, .brand span { display: none; } }

/* 按鈕 */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 16px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--card); color: var(--text); font: inherit; font-weight: 550; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--soft); text-decoration: none; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-d); }
.btn.danger { background: var(--err); border-color: var(--err); color: #fff; }
.btn.danger-outline { color: var(--err); border-color: var(--err); }
.btn.danger-outline:hover { background: var(--err-soft); }
.btn.small { padding: 4px 10px; font-size: 12.5px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

/* 表單 */
.form label, form.card label { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; font-weight: 550; }
.form label .small, form.card label .small { font-weight: 400; }
input, select, textarea { font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); color: var(--text); width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }
textarea { resize: vertical; }
label.check { flex-direction: row !important; align-items: center; gap: 8px !important; }
label.check input { width: auto; }
.grid-params { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.grid-params.four { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) { .grid-params.four { grid-template-columns: 1fr 1fr; } }
.advanced { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 4px; }
.advanced summary { cursor: pointer; font-weight: 600; margin-bottom: 12px; color: var(--muted); }
.form-foot { display: flex; justify-content: flex-end; align-items: center; gap: 14px; border-top: 1px solid var(--line); padding-top: 14px; margin-top: 8px; }
.inline-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; background: var(--soft); padding: 14px; border-radius: 8px; margin-bottom: 14px; }
.inline-form label { margin: 0; min-width: 130px; flex: 1; }
.inline-form .btn { margin-bottom: 1px; }

.drop { border: 2px dashed var(--line); border-radius: 10px; padding: 22px; text-align: center; cursor: pointer; position: relative; background: var(--soft); }
.drop.over { border-color: var(--primary); background: var(--primary-soft); }
.drop input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

/* 區段切換 */
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--card); }
.seg button, .seg a { border: 0; background: none; padding: 6px 14px; font: inherit; color: var(--muted); cursor: pointer; border-right: 1px solid var(--line); }
.seg > :last-child { border-right: 0; }
.seg .on { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.seg.small button { padding: 4px 10px; font-size: 12.5px; }
.seg.big { display: grid; grid-template-columns: repeat(3, 1fr); margin-bottom: 18px; width: 100%; }
.seg.big a { display: flex; flex-direction: column; padding: 12px 18px; color: var(--text); }
.seg.big a span { font-size: 12.5px; color: var(--muted); }
.seg.big a:hover { text-decoration: none; background: var(--soft); }
.seg.big a.on { background: var(--primary-soft); }
.seg.big a.on b { color: var(--primary); }

/* 表格 */
.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-size: 12.5px; color: var(--muted); font-weight: 550; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl.compact td, .tbl.compact th { padding: 5px 8px; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl tr.clickable { cursor: pointer; }
.tbl tr.clickable:hover td { background: var(--soft); }
.ellipsis { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tbl td .small { display: block; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }

.tag { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 6px; font-weight: 600; white-space: nowrap; }
.t-float { background: #e6f0fb; color: #1268c4; }
.t-qat { background: #f1e9fd; color: #6e3fd6; }
.t-infer { background: #e4f6f6; color: #0b7d85; }
@media (prefers-color-scheme: dark) { .t-float { background: #1d2c40; color: #7ab4ee; } .t-qat { background: #2b2140; color: #b49af5; } .t-infer { background: #15302f; color: #5fcfd5; } }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; white-space: nowrap; }
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.status.big { font-size: 16px; font-weight: 650; }
.s-succeeded::before, .s-ready::before { background: var(--ok); }
.s-running::before, .s-processing::before, .s-uploading::before { background: var(--primary); animation: pulse 1.2s infinite; }
.s-queued::before { background: var(--warn); }
.s-failed::before { background: var(--err); }
.s-cancelled::before { background: var(--muted); }
@keyframes pulse { 50% { opacity: .3; } }

/* 進度條 */
.bar { height: 8px; background: var(--soft); border-radius: 99px; overflow: hidden; margin: 6px 0 10px; }
.bar i { display: block; height: 100%; background: var(--primary); border-radius: 99px; transition: width .4s; }
.bar.warn i { background: var(--warn); }
.bar.big { height: 12px; }
.bar.thin { height: 6px; margin: 0; }

.kv { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.kv:last-of-type { border-bottom: 0; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 12px; margin-bottom: 14px; }
.stats > div { background: var(--soft); border-radius: 8px; padding: 12px 14px; }
.stats b { display: block; font-size: 22px; font-weight: 650; font-variant-numeric: tabular-nums; }
.stats span { font-size: 12.5px; color: var(--muted); }
.stats .good b { color: var(--ok); }
.stats .bad b { color: var(--err); }

.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 12px; }
.alert.err { background: var(--err-soft); color: var(--err); }
.alert.ok { background: var(--ok-soft); color: var(--ok); }
.alert.warn { background: var(--warn-soft); color: var(--warn); }
.alert.info { background: var(--primary-soft); color: var(--primary); }
.alert ol { margin: 6px 0 0; padding-left: 22px; }
.warn-list { margin: 0 0 12px; padding: 0; list-style: none; }
.warn-list li { padding: 7px 12px 7px 32px; background: var(--warn-soft); color: var(--warn); border-radius: 8px; margin-bottom: 6px; position: relative; }
.warn-list li::before { content: "!"; position: absolute; left: 11px; top: 7px; width: 14px; height: 14px; border-radius: 50%; background: var(--warn); color: #fff; font-size: 10px; font-weight: 700; text-align: center; line-height: 14px; }
.empty { text-align: center; color: var(--muted); padding: 26px 10px; }
.empty.big { padding: 80px 10px; }

/* 流程步驟 */
.steps { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; list-style: none; padding: 0; margin: 0; }
.steps li { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; position: relative; }
.steps li span { font-size: 12.5px; color: var(--muted); }
.steps li a, .steps li em { font-size: 13px; margin-top: 6px; font-style: normal; }
.steps li em { color: var(--muted); }
.steps li.done { border-color: var(--ok); background: var(--ok-soft); }
.steps li.done b::after { content: " ✓"; color: var(--ok); }
.steps li.now { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.steps li.later { opacity: .6; border-style: dashed; }
@media (max-width: 900px) { .steps { grid-template-columns: 1fr 1fr; } }

pre.tree, pre.code { background: var(--soft); padding: 10px 12px; border-radius: 8px; font-size: 12.5px; line-height: 1.5; overflow-x: auto; margin: 8px 0; }
pre.log { background: #0f141b; color: #cfd7e3; padding: 12px 14px; border-radius: 8px; font-size: 12px; line-height: 1.45; max-height: 460px; overflow: auto; white-space: pre-wrap; word-break: break-all; margin: 10px 0 0; }
details summary { cursor: pointer; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; background: var(--c); margin-right: 6px; }

/* 圖庫與標註框 */
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 6px 0 10px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; }
.legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.legend i.dash { background: none !important; border: 2px dashed var(--muted); }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; }
.tile { position: relative; background: var(--soft); border-radius: 8px; overflow: hidden; cursor: zoom-in; border: 1px solid var(--line); }
.tile .imgbox { position: relative; min-height: 90px; }
.tile img { display: block; width: 100%; height: auto; }
.tile .cap { font-size: 11.5px; padding: 4px 8px; color: var(--muted); display: flex; justify-content: space-between; gap: 6px; }
.tile .cap .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile .badge { position: absolute; top: 6px; left: 6px; font-size: 11px; padding: 1px 6px; border-radius: 4px; background: rgba(0,0,0,.6); color: #fff; }
.overlay { position: absolute; inset: 0; pointer-events: none; }
.overlay svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.overlay .lbl { position: absolute; font-size: 10.5px; line-height: 1.2; padding: 0 3px; color: #fff; white-space: nowrap; transform: translateY(-100%); border-radius: 2px 2px 0 0; }
.lb-body .overlay .lbl { font-size: 13px; }
.pager { display: flex; justify-content: center; align-items: center; gap: 8px; margin-top: 14px; }
.plots { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.plots figure { margin: 0; } .plots img { width: 100%; border-radius: 6px; border: 1px solid var(--line); cursor: zoom-in; }
.plots figcaption { font-size: 12.5px; color: var(--muted); text-align: center; }

.lightbox { position: fixed; inset: 0; background: rgba(5, 8, 12, .82); z-index: 100; display: flex; align-items: center; justify-content: center; padding: 30px; }
.lightbox[hidden] { display: none; }
.lb-inner { position: relative; max-width: min(1100px, 95vw); max-height: 92vh; display: flex; flex-direction: column; align-items: center; }
.lb-body { position: relative; display: inline-block; }
.lb-body img { display: block; max-width: min(1100px, 95vw); max-height: 82vh; min-width: min(560px, 90vw); height: auto; }
.lb-caption { color: #dde3ec; font-size: 13px; margin-top: 8px; text-align: center; }
.lb-close { position: absolute; top: -34px; right: -6px; background: none; border: 0; color: #fff; font-size: 30px; cursor: pointer; line-height: 1; }

/* 任務頁 */
.status-line { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.chart { width: 100%; height: 240px; }
.chart svg { width: 100%; height: 100%; display: block; }
.chart .axis { stroke: var(--line); }
.chart text { fill: var(--muted); font-size: 11px; }
.chart .grid { stroke: var(--line); stroke-dasharray: 2 3; }
.chart .empty-msg { fill: var(--muted); font-size: 13px; }
.next { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; border-color: var(--ok); background: var(--ok-soft); }
.next p { margin: 0; flex: 1; min-width: 220px; }
.param-list { display: flex; flex-wrap: wrap; gap: 6px 18px; }
.param-list b { color: var(--muted); font-weight: 500; margin-right: 4px; }

.spinner { width: 34px; height: 34px; border: 3px solid var(--primary-soft); border-top-color: var(--primary); border-radius: 50%; animation: spin 1s linear infinite; margin: 10px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

#toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast { background: #1d2433; color: #fff; padding: 10px 16px; border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.2); max-width: 380px; animation: tin .2s; }
.toast.err { background: var(--err); } .toast.ok { background: var(--ok); }
.toast a { color: #fff; text-decoration: underline; font-weight: 600; }
@keyframes tin { from { transform: translateY(8px); opacity: 0; } }

/* 說明頁 */
.help-layout { display: grid; grid-template-columns: 180px 1fr; gap: 18px; align-items: start; }
.toc { position: sticky; top: 74px; display: flex; flex-direction: column; gap: 4px; padding: 12px; }
.toc a { padding: 4px 8px; border-radius: 6px; color: var(--muted); }
.toc a:hover { background: var(--soft); color: var(--text); text-decoration: none; }
.help-body .card { scroll-margin-top: 74px; }
.help-body li { margin-bottom: 4px; }
@media (max-width: 900px) { .help-layout { grid-template-columns: 1fr; } .toc { position: static; flex-direction: row; flex-wrap: wrap; } }

/* 登入頁 */
.login-body { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px;
  background: radial-gradient(circle at 20% 10%, var(--primary-soft), transparent 50%), var(--bg); }
.login-card { width: 100%; max-width: 380px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 30px 28px; box-shadow: 0 10px 40px rgba(20,30,50,.08); }
.login-card label { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; font-weight: 550; }
.login-brand { display: flex; align-items: center; gap: 10px; }
.login-brand img { width: 34px; height: 34px; }
.login-brand h1 { font-size: 19px; margin: 0; }

/* ===================== v10 新增 ===================== */
.warn-text { color: var(--warn); }
kbd { display: inline-block; min-width: 18px; padding: 0 5px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; font-size: 11.5px; text-align: center; background: var(--card); font-family: inherit; }
.btn.big { padding: 12px 24px; font-size: 16px; border-radius: 10px; }
.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.toolbar select, .toolbar input { width: auto; min-width: 140px; padding: 5px 8px; }
.toolbar #sel-bar { display: inline-flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.toolbar #sel-bar[hidden] { display: none !important; }
.inline-row { display: flex; gap: 10px; }
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; font-weight: 550; }
.field .small { font-weight: 400; }
.field-label { font-weight: 550; margin: 6px 0; }

/* 公告 */
.announce { background: var(--warn-soft); color: var(--warn); text-align: center; padding: 8px 16px; font-weight: 550; border-bottom: 1px solid var(--line); }


/* 對話框 / 導覽 */
.modal { position: fixed; inset: 0; background: rgba(5, 8, 12, .55); z-index: 150; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal-card { background: var(--card); border-radius: 14px; padding: 24px 26px; width: 100%; max-width: 520px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal-card.small-card { max-width: 400px; }
.modal-card .pick { margin: 8px 0 4px; }
.modal-foot { display: flex; align-items: center; gap: 8px; margin-top: 18px; }

/* 說明小提示 */
.help-tip { display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; border-radius: 50%; background: var(--soft); border: 1px solid var(--line);
  color: var(--muted); font-size: 11px; font-weight: 700; cursor: help; position: relative; vertical-align: middle; margin-left: 2px; }
.help-tip:hover::after, .help-tip:focus::after { content: attr(data-tip); position: absolute; left: 50%; bottom: calc(100% + 8px); transform: translateX(-50%); width: max-content; max-width: 280px;
  background: #1d2433; color: #fff; padding: 8px 10px; border-radius: 8px; font-size: 12.5px; font-weight: 400; line-height: 1.5; z-index: 60; white-space: normal; box-shadow: 0 6px 20px rgba(0,0,0,.2); }

/* 範例資料集 */
.pub-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.pub { border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; background: var(--soft); display: flex; flex-direction: column; gap: 6px; }
.pub p { margin: 0; }
.pub .actions { margin-top: 4px; }
.ds-name-label { display: flex; flex-direction: column; gap: 5px; font-weight: 550; margin-bottom: 12px; max-width: 520px; }
.add-card > summary { list-style: none; display: flex; gap: 12px; align-items: baseline; flex-wrap: wrap; }
.add-card > summary::-webkit-details-marker { display: none; }
.add-card[open] > summary { margin-bottom: 14px; }

/* 上傳 */
.up-drop { border: 2px dashed var(--line); border-radius: 12px; padding: 28px 20px; display: flex; align-items: center; gap: 18px; justify-content: center; text-align: left;
  background: var(--soft); cursor: pointer; transition: border-color .15s, background .15s; flex-wrap: wrap; }
.up-drop.over { border-color: var(--primary); background: var(--primary-soft); }
.up-drop.compact { padding: 12px 16px; }
.up-drop.compact .up-drop-icon { font-size: 22px; width: 36px; height: 36px; }
.up-drop-icon { font-size: 30px; width: 56px; height: 56px; border-radius: 50%; background: var(--card); display: flex; align-items: center; justify-content: center; color: var(--primary); border: 1px solid var(--line); }
.up-pick { display: flex; gap: 8px; }
.up-busy { display: flex; align-items: center; gap: 10px; justify-content: center; padding: 10px; }
.up-busy .spinner { margin: 0; width: 22px; height: 22px; }
.up-preview { margin-top: 16px; }
.up-config { margin: 6px 0 4px; }
.up-config label { display: flex; flex-direction: column; gap: 5px; font-weight: 550; margin-bottom: 6px; }
.up-filter { flex-wrap: wrap; }
.up-gallery { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.up-progress { margin: 12px 0 0; }
.stats .warnc b { color: var(--warn); }
.tile.has-problem { border-color: var(--err); box-shadow: 0 0 0 1px var(--err) inset; }
.tile .badge.bad { background: var(--err); }
.tile-x { position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; border-radius: 50%; border: 0; background: rgba(0,0,0,.6); color: #fff; cursor: pointer; font-size: 15px; line-height: 22px; padding: 0; opacity: 0; transition: opacity .15s; }
.tile:hover .tile-x { opacity: 1; }
.tile .imgbox.noimg { min-height: 120px; background: repeating-linear-gradient(45deg, var(--soft), var(--soft) 8px, var(--line) 8px, var(--line) 9px); }

/* 選取模式 */
.gallery.selecting .tile { cursor: pointer; }
.tile .tick { position: absolute; top: 6px; right: 6px; width: 22px; height: 22px; border-radius: 50%; border: 2px solid #fff; background: rgba(0,0,0,.35); color: transparent; font-size: 13px; text-align: center; line-height: 18px; font-weight: 700; }
.tile.sel { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary); }
.tile.sel .tick { background: var(--primary); color: #fff; border-color: var(--primary); }
.tile-acts { position: absolute; left: 6px; right: 6px; bottom: 6px; display: flex; gap: 6px; justify-content: flex-end; opacity: 0; transition: opacity .15s; }
.tile:hover .tile-acts { opacity: 1; }
.tile-acts .btn { background: rgba(255,255,255,.92); color: #1d2433; border-color: transparent; }
.sel-panel { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; background: var(--primary-soft); padding: 10px 12px; border-radius: 8px; margin-bottom: 10px; }
.sel-panel select { width: auto; max-width: 360px; padding: 5px 8px; }

/* 標註編輯器 */
.ed { position: fixed; inset: 0; z-index: 120; background: var(--bg); display: flex; flex-direction: column; }
.ed-top { display: flex; align-items: center; gap: 10px; padding: 10px 16px; background: var(--card); border-bottom: 1px solid var(--line); }
.ed-name { max-width: 40vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ed-saved.ok { color: var(--ok); } .ed-saved.warn { color: var(--warn); } .ed-saved.err { color: var(--err); }
.ed-main { flex: 1; display: flex; min-height: 0; }
.ed-stage { flex: 1; display: flex; align-items: center; justify-content: center; overflow: hidden; background: #0f141b; padding: 10px; }
.ed-wrap { position: relative; display: inline-block; user-select: none; }
.ed-wrap img { display: block; max-width: none; }
.ed-layer { position: absolute; inset: 0; cursor: crosshair; }
.ed-box { position: absolute; border: 2px solid var(--bc); box-sizing: border-box; cursor: move; }
.ed-box.sel { box-shadow: 0 0 0 1px #fff, 0 0 0 3px var(--bc); background: color-mix(in srgb, var(--bc) 14%, transparent); }
.ed-lbl { position: absolute; left: -2px; top: 0; transform: translateY(-100%); background: var(--bc); color: #fff; font-size: 11px; padding: 0 4px; white-space: nowrap; border-radius: 2px 2px 0 0; pointer-events: none; }
.ed-h { position: absolute; width: 10px; height: 10px; background: #fff; border: 2px solid var(--bc); border-radius: 2px; }
.ed-h.nw { left: -6px; top: -6px; cursor: nwse-resize; } .ed-h.se { right: -6px; bottom: -6px; cursor: nwse-resize; }
.ed-h.ne { right: -6px; top: -6px; cursor: nesw-resize; } .ed-h.sw { left: -6px; bottom: -6px; cursor: nesw-resize; }
.ed-side { width: 290px; background: var(--card); border-left: 1px solid var(--line); padding: 14px 16px; overflow-y: auto; }
.ed-side h3:first-of-type { margin-top: 0; }
.ed-classes { display: flex; flex-direction: column; gap: 4px; }
.ed-cls { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); color: var(--text); font: inherit; cursor: pointer; text-align: left; }
.ed-cls i { width: 12px; height: 12px; border-radius: 3px; }
.ed-cls.on { border-color: var(--primary); background: var(--primary-soft); font-weight: 600; }
.ed-boxes { max-height: 30vh; overflow-y: auto; }
.ed-row { display: flex; align-items: center; gap: 8px; padding: 4px 6px; border-radius: 6px; cursor: pointer; }
.ed-row i { width: 10px; height: 10px; border-radius: 3px; }
.ed-row .muted { margin-left: auto; }
.ed-row.on { background: var(--primary-soft); }
.ed-tools { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 12px; }
.ed-tools select { width: auto; flex: 1; padding: 4px 8px; }
.ed-help { margin-top: 14px; color: var(--muted); }
.ed-help ul { padding-left: 18px; }
@media (max-width: 900px) { .ed-main { flex-direction: column; } .ed-side { width: auto; border-left: 0; border-top: 1px solid var(--line); max-height: 40vh; } }

/* 新增任務精靈 */
.wizard { padding: 8px 20px 18px; }
.wz-step { display: flex; gap: 16px; padding: 18px 0; border-bottom: 1px solid var(--line); }
.wz-step:last-of-type { border-bottom: 0; }
.wz-num { flex: none; width: 30px; height: 30px; border-radius: 50%; background: var(--primary); color: #fff; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.wz-body { flex: 1; min-width: 0; }
.wz-body h2 { margin-top: 4px; }
.check-list { display: flex; flex-direction: column; gap: 6px; }
.check-list label { margin: 0 !important; font-weight: 400 !important; }
.preset-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 12px; }
@media (max-width: 900px) { .preset-grid { grid-template-columns: 1fr 1fr; } }
.preset { border: 1.5px solid var(--line); border-radius: 10px; padding: 12px 14px; cursor: pointer; display: flex !important; flex-direction: column; gap: 2px !important; margin: 0 !important; position: relative; }
.preset input { position: absolute; opacity: 0; pointer-events: none; }
.preset:hover { background: var(--soft); }
.preset.on { border-color: var(--primary); background: var(--primary-soft); box-shadow: 0 0 0 2px var(--primary-soft); }
.preset.on b { color: var(--primary); }
.preset .est { color: var(--primary); font-weight: 600; }
.chain-check { align-items: flex-start !important; background: var(--ok-soft); border-radius: 8px; padding: 10px 12px; font-weight: 400 !important; }
.chain-check input { margin-top: 4px; }
.foot-info { flex: 1; }

/* 任務頁 */
.chain { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.chain-step { padding: 2px 10px; border-radius: 99px; background: var(--soft); border: 1px solid var(--line); }
.chain-step.on { background: var(--primary-soft); color: var(--primary); border-color: var(--primary); font-weight: 600; }
.chain-arr { color: var(--muted); }
.chain-step.done { background: var(--ok-soft); color: var(--ok); border-color: var(--ok); }
.chip-card .chip-files { margin: 8px 0 12px; }
.chip-card .chip-files td { padding: 6px 10px; }
.fw-thr { margin: 6px 0 14px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; }
.fw-thr[open] summary { margin-bottom: 6px; }
.thr-tbl { max-width: 560px; margin: 6px 0 10px; }
.thr-tbl input { width: 76px; }
.spinner.sm { width: 12px; height: 12px; border-width: 2px; display: inline-block; vertical-align: -2px; }
.tips { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.tips li { padding: 8px 12px 8px 34px; border-radius: 8px; position: relative; }
.tips li::before { position: absolute; left: 13px; top: 8px; font-weight: 700; }
.tip-good { background: var(--ok-soft); color: var(--ok); } .tip-good::before { content: "✓"; }
.tip-warn { background: var(--warn-soft); color: var(--warn); } .tip-warn::before { content: "!"; }
.tip-info { background: var(--soft); } .tip-info::before { content: "i"; color: var(--muted); }
.tip-next { background: var(--primary-soft); color: var(--primary); font-weight: 550; } .tip-next::before { content: "→"; }
.stats em { display: block; font-style: normal; font-size: 12px; color: var(--muted); margin-top: 2px; }
.stats .up em { color: var(--ok); } .stats .down em { color: var(--err); }
.smp-ctl { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.smp-ctl input[type=range] { width: 220px; padding: 0; }
.smp-ctl label { margin: 0; }
.conf-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.conf-row input[type=range] { flex: 1; min-width: 200px; padding: 0; accent-color: var(--primary); }
.conf-val { font-size: 20px; min-width: 52px; font-variant-numeric: tabular-nums; color: var(--primary); }
.chart.small-chart { height: 200px; margin-top: 4px; }
input[type=range] { border: 0; background: none; }

/* 比較 */
.cmp-tbl tr.diff td { background: var(--warn-soft); }
.cmp-tbl td.best b { color: var(--ok); }
.cmp-tbl td.best { background: var(--ok-soft); }
.tbl td.cb { width: 28px; }
.tbl td.cb input { width: auto; }

/* 快速測試：模型清單 */
.model-list { max-height: 320px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; padding: 4px; }
.model-list label { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 6px; cursor: pointer; font-weight: 400; }
.model-list label:hover { background: var(--soft); }
.model-list label.off { opacity: .5; cursor: not-allowed; }
.model-list input { width: auto; margin: 0; }
.model-list .mname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 排行榜 */
.lb-head { display: flex; align-items: flex-end; gap: 18px; flex-wrap: wrap; margin-bottom: 8px; }
.lb-pick { min-width: 320px; margin-bottom: 0; }
.table-scroll { overflow-x: auto; }
.lb-tbl td { vertical-align: middle; }
.lb-tbl tr.lb-first td { background: var(--primary-soft); }
.lb-rank { display: inline-block; min-width: 26px; height: 26px; line-height: 26px; border-radius: 50%; text-align: center; font-weight: 700; }
.lb-rank.r1 { background: #f2c94c; color: #4a3800; }
.lb-rank.r2 { background: #cfd6de; color: #2c3640; }
.lb-rank.r3 { background: #e0a878; color: #45250a; }
.lb-bar { height: 4px; background: var(--line); border-radius: 2px; margin-top: 4px; min-width: 70px; }
.lb-bar i { display: block; height: 100%; background: var(--primary); border-radius: 2px; }
.t-warn { background: var(--warn-soft); color: var(--warn); margin-left: 4px; }
.alert.info { background: var(--primary-soft); color: var(--text); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

input[readonly] { background: var(--soft); color: var(--muted); }
/* 上傳：缺少的欄位 */
textarea.need, input.need { border-color: var(--err); box-shadow: 0 0 0 3px color-mix(in srgb, var(--err) 25%, transparent); }
/* 背景上傳 */
#up-pill { text-decoration: none; cursor: pointer; }
.up-task { margin-bottom: 12px; }
.up-task .card-head b { min-width: 0; }
body[data-page="uploads"] .wrap { max-width: 640px; }
