*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0a0e1a;
  --surface: #0f1729;
  --surface2: #1e293b;
  --border: #334155;
  --fg: #f8fafc;
  --muted: #64748b;
  --hint: #bae6fd;
  --green: #22c55e;
  --red: #ef4444;
  --accent: #22c55e;
  --sky: #38bdf8;
  --gold: #fbbf24;
  --radius: 12px;
}

body {
  background: var(--bg);
  color: var(--fg);
  font-family: 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  font-size: 14px;
  min-height: 100vh;
}

/* ── Header ── */
.header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 24px;
}
.header-title {
  font-size: 18px;
  font-weight: 700;
  white-space: nowrap;
}
.tabs {
  display: flex;
  gap: 4px;
}
.tab {
  padding: 6px 16px;
  border-radius: 8px;
  cursor: pointer;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  transition: all .15s;
}
.tab:hover { color: var(--fg); background: var(--surface2); }
.tab.active {
  color: var(--accent);
  background: rgba(34,197,94,.1);
  border-color: rgba(34,197,94,.3);
}
.status-bar {
  margin-left: auto;
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
}
.status-bar .ok { color: var(--green); }
.status-bar .warn { color: var(--gold); }

/* ── Layout ── */
.view { padding: 24px; max-width: 960px; margin: 0 auto; }

/* ── Sub-tabs (鼠标/滚轮 selector within a view) ── */
.sub-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.sub-tab {
  padding: 6px 18px;
  border-radius: 6px;
  cursor: pointer;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  transition: all .15s;
}
.sub-tab:hover { color: var(--fg); background: var(--surface2); }
.sub-tab.active {
  color: var(--sky);
  background: rgba(56,189,248,.08);
  border-color: rgba(56,189,248,.25);
}

/* ── Form ── */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.field label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
}
.field input {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--fg);
  padding: 7px 10px;
  font-size: 14px;
  outline: none;
  transition: border-color .15s;
}
.field input:focus { border-color: var(--accent); }
.field input:disabled { opacity: .5; cursor: not-allowed; }

/* ── Buttons ── */
.btn {
  padding: 8px 20px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: all .15s;
}
.btn-primary {
  background: var(--accent);
  color: #000;
}
.btn-primary:hover:not(:disabled) { filter: brightness(1.1); }
.btn-primary:disabled { opacity: .45; cursor: not-allowed; }
.btn-secondary {
  background: var(--surface2);
  color: var(--fg);
  border: 1px solid var(--border);
}
.btn-secondary:hover:not(:disabled) { border-color: var(--accent); }
.btn-secondary:disabled { opacity: .45; cursor: not-allowed; }

/* ── Canvas container ── */
.canvas-wrap {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
}
canvas { display: block; }

/* collect canvas: fixed logical size, cursor hidden (custom cursor drawn inside) */
#collectCanvas {
  cursor: none;
  max-width: 100%;
}

/* ── Progress ── */
.progress-section { margin: 16px 0; }
.progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 6px;
}
.progress-track {
  height: 8px;
  background: var(--surface2);
  border-radius: 4px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
  transition: width .2s;
}
.loss-display {
  font-size: 13px;
  color: var(--hint);
  margin-top: 6px;
}

/* ── Messages ── */
.msg { font-size: 14px; margin: 12px 0; padding: 10px 14px; border-radius: 8px; }
.msg-success { background: rgba(34,197,94,.12); color: var(--green); border: 1px solid rgba(34,197,94,.3); }
.msg-error   { background: rgba(239,68,68,.12);  color: var(--red);   border: 1px solid rgba(239,68,68,.3); }
.msg-info    { background: rgba(56,189,248,.10); color: var(--hint);  border: 1px solid rgba(56,189,248,.3); }

/* ── Verify charts ── */
.verify-stats {
  display: flex;
  gap: 12px;
  margin-top: 16px;
  flex-wrap: wrap;
}
.stat-pill {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 14px;
  font-size: 12px;
  color: var(--muted);
}
.stat-pill span {
  color: var(--hint);
  font-weight: 600;
}
.verify-charts {
  display: flex;
  gap: 16px;
  flex-wrap: nowrap;
  margin-top: 12px;
  align-items: flex-start;
}
.verify-charts .chart-box {
  flex: 1 1 0;
  min-width: 0;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface);
}
.chart-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  padding: 8px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  letter-spacing: .3px;
}
.echarts-box {
  width: 100%;
  height: 320px;
}

/* ── Scroll collection ── */
.scroll-select {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--fg);
  padding: 7px 10px;
  font-size: 14px;
  outline: none;
  transition: border-color .15s;
  cursor: pointer;
}
.scroll-select:focus { border-color: var(--accent); }
.scroll-select:disabled { opacity: .5; cursor: not-allowed; }

.scroll-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 1000;
  background: var(--bg);
  overflow-y: scroll;
}
.scroll-overlay-inner {
  position: relative;
  width: 100%;
  min-height: 100%;
}
.scroll-target-band {
  position: absolute;
  left: 0; right: 0;
  height: 50px;
  background: rgba(239, 68, 68, 0.6);
  border: 2px solid var(--red);
  transition: background .3s, border-color .3s;
}
.scroll-target-band.success {
  background: rgba(34, 197, 94, 0.6);
  border-color: var(--green);
}

/* Fixed HUD elements on top of overlay */
.scroll-hud {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none;
  z-index: 1001;
}
.scroll-hud > * {
  pointer-events: auto;
}

.scroll-success-zone {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none;
}
.scroll-zone-line {
  position: absolute;
  left: 0; right: 0;
  height: 0;
  border-top: 2px dashed rgba(255,255,255,0.5);
}
.scroll-zone-line-top {
  top: calc(50vh - 60px);
}
.scroll-zone-line-bottom {
  top: calc(50vh + 60px);
}

.scroll-direction {
  position: fixed;
  top: 50%;
  right: 40px;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.scroll-arrow {
  font-size: 48px;
  color: var(--sky);
  text-shadow: 0 0 12px rgba(56,189,248,0.5);
  animation: scrollArrowPulse 1.2s ease-in-out infinite;
}
@keyframes scrollArrowPulse {
  0%, 100% { opacity: 1; transform: translateY(0); }
  50% { opacity: 0.6; transform: translateY(4px); }
}
.scroll-dist-label {
  font-size: 14px;
  color: var(--hint);
  background: rgba(15,23,42,0.8);
  padding: 2px 8px;
  border-radius: 4px;
}

.scroll-progress-hud {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15,23,42,0.9);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 20px;
  font-size: 16px;
  font-weight: 600;
  color: var(--fg);
}

.scroll-cancel-btn {
  position: fixed;
  top: 20px;
  right: 20px;
}
