* { box-sizing: border-box; }
/* 作者样式 display:flex 会覆盖 hidden，必须显式声明 */
[hidden] { display: none !important; }

:root {
  --bg: #080c14;
  --bg-2: #0d1420;
  --panel: #101927;
  --panel-2: #142033;
  --line: #223150;
  --line-soft: #1b2940;
  --text: #e8f0ff;
  --muted: #8ca0bf;
  --blue: #2f6fed;
  --cyan: #0ea5b7;
  --green: #16a34a;
  --amber: #d97706;
  --red: #dc2626;
  --shadow: 0 18px 50px rgba(0, 0, 0, .35);
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
}

/* 顶部兼容提示 */
.compat-banner {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin: 14px 24px 0;
  padding: 13px 18px;
  border: 1px solid #7c3f13;
  border-left: 4px solid #f59e0b;
  border-radius: 8px;
  background: #2a1b0c;
  color: #ffedd5;
}
.compat-banner .rw-icon {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #f59e0b;
  color: #1c1305;
  font-weight: 800;
  text-align: center;
  line-height: 22px;
}
.compat-banner b { color: #ffdca8; }
.compat-banner .rw-detail { margin-top: 4px; color: #f5c98a; }
.compat-banner code { background: rgba(255, 255, 255, .08); padding: 1px 6px; border-radius: 4px; }

/* 顶栏 */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 24px 14px;
  border-bottom: 1px solid var(--line-soft);
  background: rgba(8, 12, 20, .82);
  backdrop-filter: blur(10px);
}
.title-block { display: flex; align-items: center; gap: 12px; min-width: 0; }
.logo {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--blue), var(--cyan));
  color: #fff;
  font-weight: 900;
  letter-spacing: -.5px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 24px rgba(47, 111, 237, .3);
}
.title-block h1 { margin: 0; font-size: 19px; font-weight: 750; letter-spacing: .3px; }
.version-badge {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 9px;
  border: 1px solid rgba(126, 231, 241, .45);
  border-radius: 20px;
  background: rgba(14, 165, 183, .16);
  color: #7ee7f1;
  font-size: 10.5px;
  font-weight: 700;
  vertical-align: middle;
}
.title-block p { margin: 3px 0 0; color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.header-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.btn {
  border: 0;
  border-radius: 7px;
  padding: 9px 14px;
  color: #fff;
  font-weight: 650;
  font-size: 12.5px;
  cursor: pointer;
  box-shadow: 0 5px 16px rgba(0, 0, 0, .25);
  transition: transform .12s ease, filter .12s ease;
  white-space: nowrap;
}
.btn:hover:not(:disabled) { filter: brightness(1.12); transform: translateY(-1px); }
.btn:active:not(:disabled) { transform: translateY(0); }
.btn:disabled { opacity: .42; cursor: not-allowed; }
.btn.blue { background: var(--blue); }
.btn.cyan { background: var(--cyan); }
.btn.green { background: var(--green); }
.btn.amber { background: var(--amber); }
.btn.red { background: var(--red); }

/* 状态条 */
.status-strip {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 12px 24px 0;
  padding: 9px 12px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: rgba(16, 25, 39, .72);
  color: var(--muted);
}
.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 280px;
  padding: 4px 9px;
  border-radius: 20px;
  background: #0b1220;
  border: 1px solid var(--line-soft);
  font-size: 11.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.status-chip b { color: var(--text); font-weight: 600; max-width: 180px; overflow: hidden; text-overflow: ellipsis; }
.status-chip.good b, .status-chip.good { color: #6ee7b7; }
.status-chip.bad, .status-chip.bad b { color: #fca5a5; }
.dot { width: 7px; height: 7px; flex: 0 0 auto; border-radius: 50%; background: var(--muted); }
.dot-blue { background: var(--blue); }
.dot-cyan { background: var(--cyan); }
.dot-amber { background: var(--amber); }
.status-hint { margin-left: auto; color: #cbd5e1; font-size: 12px; }

/* 主体两栏 */
.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 390px;
  gap: 14px;
  height: calc(100vh - 156px);
  min-height: 640px;
  padding: 14px 24px 20px;
}
.panel {
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(20, 32, 51, .95), rgba(13, 20, 32, .95));
  box-shadow: var(--shadow);
  overflow: hidden;
}
.panel-head, .settings-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line-soft);
  background: rgba(9, 15, 25, .55);
}
.panel-kicker { display: block; color: #6383b5; font-size: 9.5px; font-weight: 800; letter-spacing: 1.4px; }
.panel h2 { margin: 2px 0 0; font-size: 15px; font-weight: 700; }

/* 预览区 */
.preview-panel { display: flex; flex-direction: column; }
.preview-nav { display: flex; align-items: center; gap: 8px; }
.nav-btn {
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #0c1523;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
}
.nav-btn:hover:not(:disabled) { border-color: var(--cyan); color: #bff6ff; }
.nav-btn:disabled { opacity: .35; cursor: not-allowed; }
.preview-count { color: var(--text); font-family: Consolas, monospace; font-size: 12px; min-width: 58px; text-align: center; }
.preview-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 16px;
  color: #a9bad3;
  font-family: Consolas, monospace;
  font-size: 11.5px;
  border-bottom: 1px solid var(--line-soft);
}
.preview-mode { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.mode-btn { min-width: 70px; padding: 5px 9px; border: 0; border-right: 1px solid var(--line); background: #0a1220; color: var(--muted); cursor: pointer; font-size: 11px; }
.mode-btn:last-child { border-right: 0; }
.mode-btn.active { background: var(--blue); color: #fff; }
.mode-btn:disabled { opacity: .35; cursor: not-allowed; }
.badge {
  padding: 2px 8px;
  border-radius: 20px;
  background: rgba(14, 165, 183, .14);
  border: 1px solid rgba(14, 165, 183, .35);
  color: #7ee7f1;
  font-family: inherit;
  font-size: 10.5px;
}
.preview-stage {
  position: relative;
  flex: 1;
  min-height: 320px;
  margin: 12px 16px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 9px;
  background:
    linear-gradient(45deg, #0b1220 25%, transparent 25%),
    linear-gradient(-45deg, #0b1220 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #0b1220 75%),
    linear-gradient(-45deg, transparent 75%, #0b1220 75%),
    #111a29;
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
}
.preview-stage img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.preview-stage canvas { position: absolute; inset: 0; pointer-events: none; }
.preview-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  text-align: center;
}
.ph-icon { font-size: 44px; color: #35527f; line-height: 1; }
.ph-title { margin-top: 12px; color: #c6d5ec; font-weight: 650; }
.ph-sub { margin-top: 5px; font-size: 11.5px; }

.folder-paths {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 0 16px 8px;
}
.path-field label { display: block; margin-bottom: 4px; color: var(--muted); font-size: 11px; }
.path-field input {
  width: 100%;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #0a1220;
  color: #cfe0f8;
  font-family: Consolas, monospace;
  font-size: 11.5px;
}
.preview-foot {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 0 16px 12px;
}
.dataset-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  padding: 0 16px 10px;
}
.dataset-metrics > div { padding: 8px 10px; border: 1px solid var(--line-soft); border-radius: 6px; background: #0a1220; }
.dataset-metrics span { display: block; color: var(--muted); font-size: 10px; }
.dataset-metrics strong { display: block; margin-top: 2px; color: #dce9fb; font-family: Consolas, monospace; font-size: 15px; }
.class-stats { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 16px 10px; padding: 8px; border: 1px solid var(--line-soft); border-radius: 6px; background: #0a1220; }
.class-chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 8px; border: 1px solid #294066; border-radius: 4px; color: #a9bdd8; font: 11px Consolas, monospace; }
.class-chip b { color: #7ee7f1; }
.folder-info { color: var(--muted); font-size: 11.5px; }
.folder-info.good { color: #6ee7b7; }
.folder-info.bad { color: #fca5a5; }
.notes {
  margin: 0 16px 14px;
  padding: 9px 12px;
  max-height: 100px;
  overflow-y: auto;
  border: 1px solid #6b4a13;
  border-radius: 7px;
  background: #2a210e;
  color: #fcd34d;
  font-size: 11.5px;
  white-space: pre-wrap;
}

/* 参数区 */
.settings-panel { display: flex; flex-direction: column; }
.config-row { display: flex; gap: 6px; align-items: center; }
.config-row select {
  max-width: 132px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #0a1220;
  color: var(--text);
  font-size: 11.5px;
}
.mini-btn {
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #101c2e;
  color: #b8c9e2;
  cursor: pointer;
  font-size: 11.5px;
  white-space: nowrap;
}
.mini-btn:hover { border-color: var(--cyan); color: #bff6ff; }
.mini-btn.danger:hover { border-color: var(--red); color: #fca5a5; }
.params-host { flex: 1; min-height: 0; overflow-y: auto; padding: 12px 14px; }
.params-host::-webkit-scrollbar { width: 8px; }
.params-host::-webkit-scrollbar-thumb { background: #243654; border-radius: 8px; }

.presets { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 11px; }
.presets > span:first-child { color: var(--muted); font-size: 11.5px; }
.preset {
  padding: 5px 11px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: #0d1727;
  color: #a9bdd8;
  cursor: pointer;
  font-size: 11.5px;
}
.preset:hover { border-color: var(--blue); color: #bfd4ff; }
.preset-hint { display: none; }

.grid { display: flex; flex-direction: column; gap: 10px; }
fieldset {
  margin: 0;
  padding: 9px 11px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(10, 18, 32, .55);
}
legend { padding: 0 6px; color: #7fb0ff; font-size: 11.5px; font-weight: 700; }
.row {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 30px;
  margin: 4px 0;
  font-size: 11.5px;
}
.row > span:first-child { flex: 0 0 96px; color: #b6c6dd; }
.row input[type="checkbox"] { width: 14px; height: 14px; margin: 0; accent-color: var(--blue); }
.row input[type="number"], .row select {
  flex: 1;
  min-width: 0;
  padding: 5px 7px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #08111e;
  color: var(--text);
  font-size: 11.5px;
  outline: none;
}
.row input[type="number"].mini { flex: 0 0 58px; }
.row input[type="number"]:focus, .row select:focus { border-color: var(--blue); box-shadow: 0 0 0 2px rgba(47, 111, 237, .18); }
.row input[type="range"] {
  flex: 1;
  min-width: 60px;
  height: 4px;
  accent-color: var(--blue);
  cursor: pointer;
}
.row.slider-row > span:first-child { flex-basis: 92px; }
.note {
  margin: 5px 0 0;
  color: #6f86a8;
  font-size: 10.5px;
  line-height: 1.55;
}
.advanced { margin-top: 10px; border-top: 1px dashed var(--line); padding-top: 8px; }
.advanced summary { cursor: pointer; color: #93a9c8; font-weight: 650; font-size: 11.5px; }
.settings-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 14px;
  border-top: 1px solid var(--line-soft);
  color: var(--muted);
  font-size: 10.5px;
}
.safe-tag { padding: 2px 7px; border: 1px solid rgba(22, 163, 74, .4); border-radius: 20px; color: #86efac; }

footer { padding: 0 24px 16px; color: #5e7292; font-size: 10.5px; text-align: center; }

/* 进度遮罩 */
.busy-overlay, .toast {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(3, 7, 13, .74);
  backdrop-filter: blur(3px);
}
.busy-card, .toast-card {
  width: min(440px, 92vw);
  padding: 30px 32px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(180deg, #141f31, #0c1422);
  box-shadow: 0 24px 70px rgba(0, 0, 0, .55);
  text-align: center;
}
.busy-spinner {
  width: 46px;
  height: 46px;
  margin: 0 auto 14px;
  border: 4px solid #1d3358;
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.busy-card h2, .toast-card h2 { margin: 0 0 5px; font-size: 17px; }
.busy-pct { font-size: 34px; font-weight: 850; line-height: 1.15; color: #7fb0ff; }
.progress { height: 9px; margin: 12px 0; overflow: hidden; border-radius: 20px; background: #0a1220; }
.progress.big { height: 11px; }
.progress-fill { height: 100%; width: 0; border-radius: 20px; background: linear-gradient(90deg, var(--blue), var(--cyan)); transition: width .25s ease; }
.busy-detail { margin: 13px 0 18px; color: var(--muted); font-size: 11.5px; }
.busy-detail #busyFile { margin-top: 4px; color: #c7d7ee; font-family: Consolas, monospace; word-break: break-all; }
.busy-detail .busy-elapsed { margin-top: 5px; color: #7fb0ff; font-weight: 650; }
.ghost {
  padding: 8px 16px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #0d1727;
  color: var(--muted);
  cursor: pointer;
}
.ghost:hover { border-color: var(--blue); color: #cfe0ff; }
.toast-icon {
  width: 50px;
  height: 50px;
  margin: 0 auto 12px;
  border-radius: 50%;
  background: rgba(22, 163, 74, .18);
  color: #86efac;
  font-size: 26px;
  font-weight: 800;
  line-height: 50px;
}
.toast-card p { color: var(--muted); font-size: 12px; word-break: break-all; }
.toast-actions { display: flex; justify-content: center; margin-top: 16px; }

@media (max-width: 1180px) {
  .workspace { grid-template-columns: minmax(0, 1fr) 350px; }
  .header-actions .btn { padding: 8px 10px; }
}
@media (max-width: 900px) {
  .app-header { align-items: flex-start; flex-direction: column; }
  .header-actions { justify-content: flex-start; }
  .workspace { grid-template-columns: 1fr; height: auto; }
  .preview-panel { min-height: 560px; }
  .settings-panel { min-height: 720px; }
  .status-hint { margin-left: 0; }
}
@media (max-width: 560px) {
  .dataset-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 620px) {
  .workspace { padding: 12px; }
  .status-strip { margin: 10px 12px 0; }
  .folder-paths, .preview-foot { grid-template-columns: 1fr; }
  .btn { flex: 1 1 auto; }
}
