﻿:root {
  color-scheme: dark;
  --bg: #0b1120;
  --panel: #131c31;
  --panel-soft: #1a2642;
  --border: rgba(148, 163, 184, 0.22);
  --text: #e5eefc;
  --muted: #9fb1d1;
  --accent: #4f8cff;
  --accent-strong: #2f6ff4;
  --success: #22c55e;
  --danger: #ef4444;
  --warning: #f59e0b;
  font-family: Inter, "Microsoft YaHei", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: radial-gradient(circle at top, #1a2650 0%, var(--bg) 52%);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

.page {
  max-width: 1560px;
  margin: 0 auto;
  padding: 24px;
}

.hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  padding: 20px 24px;
  background: rgba(19, 28, 49, 0.92);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.28);
}

.hero h1 {
  margin: 0 0 8px;
  font-size: 28px;
}

.hero p {
  margin: 0;
  color: var(--muted);
}

.hero-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.batch-panel {
  margin-bottom: 20px;
}

.batch-summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.batch-summary-card {
  min-width: 0;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: 14px;
  line-height: 1.6;
}

.batch-queue {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.batch-queue-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  padding: 12px 14px;
  text-align: left;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  cursor: pointer;
}

.batch-queue-item strong,
.batch-queue-item span {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.batch-queue-item span {
  color: var(--muted);
  font-size: 12px;
}

.batch-queue-item.active {
  border-color: rgba(79, 140, 255, 0.75);
  background: rgba(79, 140, 255, 0.12);
}

.batch-queue-item.done {
  border-color: rgba(34, 197, 94, 0.45);
  background: rgba(34, 197, 94, 0.1);
}

.batch-queue-item:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.layout {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 20px;
}

.section-main,
.section-side,
.section-wide {
  min-width: 0;
}

.section-wide {
  grid-column: 1 / -1;
}

.panel {
  background: rgba(19, 28, 49, 0.94);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 18px;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.22);
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.section-header h2,
.section-header h3,
.result-grid h3 {
  margin: 0;
}

.section-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.primary-button,
.secondary-button,
.file-button {
  border: 0;
  border-radius: 12px;
  padding: 10px 16px;
  cursor: pointer;
  transition:
    transform 0.12s ease,
    opacity 0.12s ease,
    background 0.12s ease;
}

.primary-button {
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #fff;
}

.secondary-button,
.file-button {
  background: var(--panel-soft);
  color: var(--text);
  border: 1px solid var(--border);
}

.primary-button:disabled,
.secondary-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.primary-button:not(:disabled):hover,
.secondary-button:not(:disabled):hover,
.file-button:hover {
  transform: translateY(-1px);
}

.file-button input {
  display: none;
}

.calibrate-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.calibrate-button .button-spinner {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-top-color: transparent;
  opacity: 0.85;
  display: none;
  flex-shrink: 0;
}

.calibrate-button.is-loading {
  cursor: progress;
}

.calibrate-button.is-loading .button-spinner {
  display: inline-block;
  animation: button-spin 0.8s linear infinite;
}

.calibrate-button.is-loading .button-text {
  letter-spacing: 0.02em;
}

.calibrate-button:disabled.is-loading {
  opacity: 0.85;
}

@keyframes button-spin {
  to {
    transform: rotate(360deg);
  }
}

.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  animation: overlay-fade-in 0.18s ease-out;
}

.loading-overlay[hidden] {
  display: none !important;
}

.loading-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 28px 36px;
  min-width: 180px;
  background: #ffffff;
  color: #1f2937;
  border-radius: 14px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.25);
  font-size: 15px;
  font-weight: 500;
}

.loading-spinner {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 3px solid rgba(79, 140, 255, 0.25);
  border-top-color: #4f8cff;
  animation: button-spin 0.85s linear infinite;
}

.loading-text {
  text-align: center;
  letter-spacing: 0.02em;
}

@keyframes overlay-fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.brand-button {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 8px 14px;
  line-height: 1.2;
  text-align: left;
}

.brand-button-label {
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--muted);
  text-transform: uppercase;
}

.brand-button-value {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.modal[hidden] {
  display: none;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 8, 18, 0.65);
  backdrop-filter: blur(6px);
  cursor: pointer;
}

.modal-panel {
  position: relative;
  width: min(520px, 100%);
  max-height: calc(100vh - 80px);
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px 22px;
  background: linear-gradient(180deg, rgba(26, 38, 66, 0.98), rgba(11, 17, 32, 0.98));
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55);
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.modal-header h3 {
  margin: 0 0 4px;
  font-size: 18px;
}

.modal-subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.modal-close {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
}

.modal-close:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
}

.brand-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: auto;
  padding-right: 4px;
}

.brand-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 14px 16px;
  text-align: left;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: 14px;
  color: var(--text);
  cursor: pointer;
  transition:
    border-color 0.15s ease,
    background 0.15s ease,
    transform 0.12s ease;
}

.brand-card:hover {
  border-color: rgba(79, 140, 255, 0.55);
  background: rgba(79, 140, 255, 0.08);
}

.brand-card.active {
  border-color: rgba(34, 197, 94, 0.55);
  background: linear-gradient(135deg, rgba(34, 197, 94, 0.18), rgba(34, 197, 94, 0.06));
}

.brand-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.brand-card-name {
  font-size: 15px;
}

.brand-card-badge {
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
}

.brand-card.active .brand-card-badge {
  border-color: rgba(34, 197, 94, 0.55);
  color: #b8f6c9;
}

.brand-card-description {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.55;
}

.brand-card-meta {
  font-size: 12px;
  color: var(--muted);
  opacity: 0.85;
}

.brand-empty {
  padding: 14px 16px;
  border: 1px dashed var(--border);
  border-radius: 12px;
  color: var(--muted);
  text-align: center;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 4px;
  border-top: 1px solid rgba(148, 163, 184, 0.16);
  margin-top: 4px;
  padding-top: 14px;
}

.modal-hint {
  font-size: 12px;
  color: var(--muted);
}

body.modal-open {
  overflow: hidden;
}

.hint {
  margin: 0 0 14px;
  color: var(--muted);
  line-height: 1.55;
}

.canvas-shell {
  position: relative;
  background: #09111f;
  border: 1px dashed rgba(148, 163, 184, 0.25);
  border-radius: 16px;
  min-height: 340px;
  overflow: hidden;
}

.preview-shell {
  min-height: 300px;
}

.result-shell {
  min-height: 300px;
}

canvas {
  display: block;
  width: 100%;
  height: auto;
}

.canvas-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  color: var(--muted);
  text-align: center;
  pointer-events: none;
}

.magnifier-canvas {
  position: absolute;
  top: 12px;
  left: 12px;
  width: 168px;
  height: 168px;
  display: none;
  pointer-events: none;
  z-index: 3;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.92);
  background: rgba(7, 12, 24, 0.96);
  box-shadow:
    0 18px 42px rgba(0, 0, 0, 0.4),
    0 0 0 1px rgba(79, 140, 255, 0.45);
}

.point-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 14px;
}

.point-item,
.current-patch-card,
.stats-card,
.message-bar {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
}

.controls {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.calibration-controls {
  padding: 12px;
  background: rgba(79, 140, 255, 0.06);
  border: 1px solid rgba(79, 140, 255, 0.22);
  border-radius: 12px;
  margin-top: 4px;
}

.controls label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--muted);
  min-width: 120px;
}

.controls label input[type="number"] {
  min-width: 96px;
}

.controls .toggle-label {
  flex-direction: row;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  min-width: auto;
  user-select: none;
}

.toggle-label input {
  display: none;
}

.toggle-track {
  position: relative;
  width: 40px;
  height: 22px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid var(--border);
  border-radius: 12px;
  flex: 0 0 40px;
  transition: background 0.2s ease;
}

.toggle-label input:checked + .toggle-track {
  background: var(--accent);
  border-color: var(--accent-strong);
}

.toggle-track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s ease;
}

.toggle-label input:checked + .toggle-track::after {
  transform: translateX(18px);
}

.controls input,
.controls select {
  background: rgba(8, 15, 30, 0.85);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  padding: 8px 10px;
}

.progress-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.progress-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 14px 0;
}

.patch-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  max-height: 420px;
  overflow: auto;
}

.patch-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid transparent;
  border-radius: 12px;
  cursor: pointer;
}

.patch-card.active {
  border-color: rgba(79, 140, 255, 0.75);
  background: rgba(79, 140, 255, 0.12);
}

.patch-card.done {
  border-color: rgba(34, 197, 94, 0.45);
}

.patch-swatch {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  flex: 0 0 34px;
}

.patch-meta {
  min-width: 0;
}

.patch-meta strong,
.patch-meta span {
  display: block;
}

.patch-meta span {
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

.current-patch-card {
  margin-bottom: 12px;
  border-color: rgba(79, 140, 255, 0.45);
}

#resultSection {
  scroll-margin-top: 16px;
}

.delta-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.delta-stat-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  padding: 16px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.03));
  border: 1px solid var(--border);
  border-radius: 16px;
}

.delta-stat-card.good {
  border-color: rgba(34, 197, 94, 0.4);
  background: linear-gradient(180deg, rgba(34, 197, 94, 0.14), rgba(34, 197, 94, 0.06));
}

.delta-stat-card.warn {
  border-color: rgba(245, 158, 11, 0.4);
  background: linear-gradient(180deg, rgba(245, 158, 11, 0.14), rgba(245, 158, 11, 0.06));
}

.delta-stat-card.bad {
  border-color: rgba(239, 68, 68, 0.42);
  background: linear-gradient(180deg, rgba(239, 68, 68, 0.14), rgba(239, 68, 68, 0.06));
}

.delta-stat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.delta-stat-label {
  color: var(--muted);
  font-size: 12px;
}

.delta-stat-tone {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 12px;
}

.delta-stat-tone.good {
  border-color: rgba(34, 197, 94, 0.45);
  color: #b8f6c9;
}

.delta-stat-tone.warn {
  border-color: rgba(245, 158, 11, 0.45);
  color: #fcd34d;
}

.delta-stat-tone.bad {
  border-color: rgba(239, 68, 68, 0.45);
  color: #fecaca;
}

.delta-stat-value {
  font-size: 34px;
  line-height: 1;
  letter-spacing: -0.03em;
}

.delta-stat-note {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.overlay-legend {
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
}

.patch-compare-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.compare-card {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
}

.compare-card.good {
  border-color: rgba(34, 197, 94, 0.45);
}

.compare-card.warn {
  border-color: rgba(245, 158, 11, 0.45);
}

.compare-card.bad {
  border-color: rgba(239, 68, 68, 0.45);
}

.compare-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.compare-card-header span {
  color: var(--muted);
  font-size: 12px;
}

.compare-swatches {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.compare-swatch-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.compare-swatch {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.18);
}

.compare-swatch-label {
  font-size: 12px;
  color: var(--text);
}

.compare-swatch-value {
  font-size: 11px;
  color: var(--muted);
  word-break: break-word;
}

.stats-card {
  margin-top: 14px;
  white-space: pre-wrap;
  line-height: 1.6;
}

.message-bar {
  margin-bottom: 14px;
  color: var(--muted);
}

.message-bar.rich {
  padding: 16px 18px;
}

.message-bar-content {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.message-bar-copy {
  min-width: 0;
  flex: 1 1 auto;
}

.message-bar-title {
  margin-bottom: 6px;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.message-bar-text {
  line-height: 1.6;
}

.message-bar-badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  flex: 0 0 auto;
}

.metric-badge {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 108px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.07);
}

.metric-badge.good {
  border-color: rgba(34, 197, 94, 0.3);
  background: rgba(34, 197, 94, 0.14);
}

.metric-badge.warn {
  border-color: rgba(245, 158, 11, 0.3);
  background: rgba(245, 158, 11, 0.14);
}

.metric-badge.bad {
  border-color: rgba(239, 68, 68, 0.3);
  background: rgba(239, 68, 68, 0.14);
}

.metric-badge.neutral {
  border-color: rgba(148, 163, 184, 0.25);
  background: rgba(255, 255, 255, 0.05);
}

.metric-badge-label {
  font-size: 11px;
  opacity: 0.85;
}

.metric-badge-value {
  font-size: 22px;
  line-height: 1.1;
}

.message-bar.success {
  border-color: rgba(34, 197, 94, 0.4);
  color: #b8f6c9;
}

.message-bar.success.rich {
  background: linear-gradient(135deg, rgba(34, 197, 94, 0.2), rgba(34, 197, 94, 0.08));
  border-color: rgba(34, 197, 94, 0.48);
  color: #d8fee5;
}

.message-bar.success.rich .message-bar-title {
  color: #f0fdf4;
}

.message-bar.error {
  border-color: rgba(239, 68, 68, 0.4);
  color: #fecaca;
}

@media (max-width: 1100px) {
  .batch-summary-grid,
  .layout,
  .result-grid {
    grid-template-columns: 1fr;
  }
  .batch-queue,
  .patch-compare-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .page {
    padding: 14px;
  }

  .hero,
  .section-header,
  .progress-row {
    flex-direction: column;
    align-items: stretch;
  }

  .point-list,
  .batch-queue,
  .patch-grid,
  .patch-compare-grid,
  .compare-swatches {
    grid-template-columns: 1fr;
  }

  .message-bar-content {
    flex-direction: column;
  }

  .message-bar-badges {
    width: 100%;
    justify-content: flex-start;
  }

  .metric-badge {
    flex: 1 1 calc(50% - 8px);
  }
}

/* ── ICP备案号 ── */
.icp-footer {
  text-align: center;
  padding: 24px 16px 32px;
  margin-top: 12px;
}

.icp-footer a {
  font-size: 0.8rem;
  color: var(--muted);
  text-decoration: none;
  opacity: 0.55;
  transition: opacity 0.2s;
}

.icp-footer a:hover {
  opacity: 0.85;
  color: var(--accent);
}