:root {
  --bg: #f6f3ee;
  --card: #ffffff;
  --ink: #2b2b2b;
  --muted: #7a756e;
  --line: #e7e1d8;
  --accent: #e2555f;
  --accent-dark: #c9424c;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(60, 50, 40, 0.08), 0 6px 20px rgba(60, 50, 40, 0.05);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", sans-serif;
  line-height: 1.55;
}

.wrap {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 20px;
}

.topbar {
  padding: 26px 0 18px;
}

.topbar h1 {
  margin: 0 0 4px;
  font-size: 26px;
  letter-spacing: 0.5px;
}

.sub {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

main.wrap {
  padding-bottom: 40px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  margin-bottom: 16px;
}

.card h2 {
  margin: 0 0 12px;
  font-size: 16px;
}

.dim {
  color: var(--muted);
  font-weight: 400;
  font-size: 13px;
}

/* ---------- 上传区 ---------- */
.controls {
  display: grid;
  grid-template-columns: minmax(260px, 360px) 1fr;
  gap: 20px;
  align-items: start;
}

.dropzone {
  border: 2px dashed #d8cfc3;
  border-radius: 12px;
  padding: 22px 16px;
  text-align: center;
  cursor: pointer;
  background: #fdfbf8;
  transition: border-color 0.15s, background 0.15s;
  outline: none;
}

.dropzone:hover, .dropzone:focus-visible, .dropzone.dragover {
  border-color: var(--accent);
  background: #fff7f6;
}

.dropzone p {
  margin: 8px 0 4px;
  font-size: 14px;
}

.dz-icon {
  font-size: 30px;
}

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

.params {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 20px;
}

.param {
  display: block;
  font-size: 13px;
  color: var(--muted);
}

.param b {
  color: var(--ink);
}

.param input[type="range"], .param select {
  width: 100%;
  margin-top: 4px;
}

.param select {
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-size: 13px;
}

.checks {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  font-size: 13px;
  color: var(--ink);
}

.checks label {
  display: flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
}

.actions {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 2px;
}

.btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 9px;
  padding: 8px 14px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.btn:hover { background: #f7f4ef; }

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn.primary:hover { background: var(--accent-dark); }

.btn.ghost {
  border-color: transparent;
  background: transparent;
  color: var(--accent);
  text-decoration: underline;
  padding: 4px 8px;
}

.btn.ghost:hover { background: transparent; }

/* ---------- 预览面板 ---------- */
.panels {
  display: grid;
  grid-template-columns: minmax(260px, 340px) 1fr;
  gap: 16px;
}

.panel {
  min-width: 0;
}

.origin-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 220px;
  max-height: 520px;
}

.origin-wrap img {
  max-width: 100%;
  max-height: 520px;
  object-fit: contain;
  border-radius: 8px;
}

.chart-wrap {
  position: relative;
  overflow: auto;
  max-height: 760px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.zoombar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.zoombar input[type="range"] {
  flex: 1;
  min-width: 0;
}

.btn.mini {
  padding: 2px 12px;
  font-size: 15px;
  line-height: 1.3;
  border-radius: 7px;
}

#chart {
  display: block;
  image-rendering: pixelated;
}

.empty-hint {
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  padding: 40px 10px;
  margin: 0;
}

.tooltip {
  position: absolute;
  pointer-events: none;
  background: rgba(30, 30, 30, 0.92);
  color: #fff;
  font-size: 12px;
  padding: 5px 9px;
  border-radius: 7px;
  white-space: nowrap;
  z-index: 10;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

/* ---------- 色号清单 ---------- */
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 5px 10px 5px 6px;
  font-size: 13px;
  background: #fdfbf8;
  break-inside: avoid;
}

.swatch {
  width: 22px;
  height: 22px;
  border-radius: 5px;
  border: 1px solid rgba(0, 0, 0, 0.14);
  flex: none;
}

.chip .symbol {
  font-weight: 700;
  color: var(--accent-dark);
  min-width: 14px;
  text-align: center;
}

.chip .code {
  font-weight: 600;
}

.chip .count {
  color: var(--muted);
  font-size: 12px;
}

.footnote {
  color: var(--muted);
  font-size: 12px;
  margin: 14px 0 0;
}

footer {
  border-top: 1px solid var(--line);
  padding: 18px 0 30px;
  color: var(--muted);
  font-size: 12px;
}

footer a {
  color: var(--accent-dark);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  background: rgba(30, 30, 30, 0.92);
  color: #fff;
  font-size: 13px;
  padding: 9px 16px;
  border-radius: 9px;
  z-index: 100;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

/* ---------- 广告弹窗 ---------- */
.admodal {
  position: fixed;
  inset: 0;
  background: rgba(30, 25, 20, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 16px;
}

.admodal[hidden] {
  display: none !important;
}

.admodal-box {
  background: #fff;
  border-radius: 16px;
  max-width: 540px;
  width: 100%;
  padding: 26px 24px 22px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
}

.admodal h3 {
  margin: 0 0 6px;
  font-size: 18px;
}

.admodal .hint {
  margin: 0;
}

.ad-slot {
  margin: 16px 0;
  border: 1px dashed #c9c1b5;
  border-radius: 10px;
  min-height: 150px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #faf7f2;
  color: #9a9288;
  font-size: 14px;
}

.admodal .btn {
  width: 100%;
  margin-top: 6px;
}

.admodal .btn.ghost {
  margin-top: 2px;
}

/* ---------- 打印 ---------- */
@media print {
  .topbar, .controls, footer, .toast {
    display: none !important;
  }
  body {
    background: #fff;
  }
  .card {
    border: none;
    box-shadow: none;
    padding: 0;
    margin: 0 0 14px;
  }
  .panels {
    grid-template-columns: 1fr;
    gap: 14px;
  }
  .panel:first-child {
    display: none;
  }
  .chart-wrap {
    overflow: visible;
    max-height: none;
    border: none;
  }
  .origin-wrap, .empty-hint {
    display: none;
  }
}

/* ---------- 响应式 ---------- */
@media (max-width: 900px) {
  .controls, .panels {
    grid-template-columns: 1fr;
  }
  .params {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 560px) {
  .params {
    grid-template-columns: 1fr;
  }
  .checks, .actions {
    grid-column: 1;
  }
}
