:root {
  --bg: #f7f8fa;
  --panel: #ffffff;
  --ink: #1f2430;
  --muted: #6b7280;
  --line: #e5e7eb;
  --accent: #ff6b6b;
  --accent-d: #e85555;
  --shadow: 0 6px 24px rgba(20, 24, 40, .08);
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
}

h1, h2, h3 { margin: 0; }

/* ===== Header ===== */
.site-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
  padding: 16px 28px;
  background: linear-gradient(120deg, #fff 0%, #fff6f3 100%);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 50;
}
.brand-block { display: flex; align-items: center; gap: 12px; }
.logo { font-size: 32px; }
.site-header h1 { font-size: 20px; }
.tagline { margin: 0; color: var(--muted); font-size: 13px; }
.top-nav { display: flex; gap: 8px; flex-wrap: wrap; }

/* ===== Buttons ===== */
.btn {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  padding: 9px 16px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
  transition: .15s;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn-ghost { background: transparent; }
.btn-accent { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-accent:hover { background: var(--accent-d); color: #fff; }
.mini { width: 26px; height: 24px; border: 1px solid var(--line); background: #fff; border-radius: 6px; cursor: pointer; }

/* ===== Uploader ===== */
.uploader {
  margin: 24px auto; max-width: 1060px; padding: 0 20px;
}
.upload-inner {
  border: 2px dashed #cfd4dc; border-radius: var(--radius);
  background: var(--panel); padding: 40px 20px; text-align: center;
  transition: .15s;
}
.uploader.drag { border-color: var(--accent); background: #fff6f3; }
.upload-icon { font-size: 34px; }
.upload-title { font-size: 16px; font-weight: 600; margin: 8px 0 4px; }
.upload-sub { color: var(--muted); font-size: 13px; margin: 0; }

/* ===== Sections ===== */
.section { max-width: 1060px; margin: 32px auto; padding: 0 20px; }
.section-title { font-size: 22px; margin-bottom: 6px; }
.section-desc { color: var(--muted); margin: 0 0 18px; }

/* Showcase */
.showcase { display: flex; gap: 20px; flex-wrap: wrap; }
.showcase figure { margin: 0; flex: 1 1 280px; }
.showcase-box {
  aspect-ratio: 1/1; border-radius: var(--radius); background: #eef1f5;
  display: flex; align-items: center; justify-content: center; overflow: hidden;
  border: 1px solid var(--line);
}
.showcase-box img { width: 100%; height: 100%; object-fit: contain; }
.showcase-box .ph { color: var(--muted); font-size: 14px; }
.showcase figcaption { margin-top: 8px; text-align: center; color: var(--muted); }
.bead-intro { margin-top: 16px; color: var(--muted); }

/* Features */
.feature-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.feature { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.feat-ico { font-size: 26px; }
.feature h3 { font-size: 16px; margin: 8px 0; }
.feature p { color: var(--muted); font-size: 13px; margin: 0; }

/* ===== Tool ===== */
.tool-layout { display: grid; grid-template-columns: 300px 1fr; gap: 20px; align-items: start; }
.settings-panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.field { margin-bottom: 16px; }
.field > label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 8px; }
.field.check label { font-weight: 400; }
.field input[type=range] { width: 100%; }
.seg { display: flex; gap: 6px; }
.seg button { flex: 1; padding: 8px; border: 1px solid var(--line); background: #fff; border-radius: 8px; cursor: pointer; font-size: 13px; }
.seg button.active { background: var(--accent); color: #fff; border-color: var(--accent); }
select { width: 100%; padding: 8px; border-radius: 8px; border: 1px solid var(--line); background: #fff; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }
.btn-row .btn { flex: 1 1 auto; padding: 8px 10px; font-size: 13px; }

.preview-col { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.preview-toolbar { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 12px; }
.preview-toolbar .check { font-size: 13px; color: var(--muted); }
.canvas-wrap {
  position: relative; border: 1px solid var(--line); border-radius: 10px;
  background: #fafbfc; overflow: auto; max-height: 70vh; min-height: 240px;
  display: flex; align-items: center; justify-content: center; padding: 10px;
}
#patternCanvas { image-rendering: pixelated; max-width: 100%; }
.empty-hint { color: var(--muted); font-size: 14px; }

.manual-bar { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; padding: 10px; border: 1px dashed var(--accent); border-radius: 10px; background: #fff6f3; }
.manual-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.manual-tools { display: flex; gap: 6px; }
.tool-btn { padding: 6px 10px; border: 1px solid var(--line); background: #fff; border-radius: 8px; cursor: pointer; font-size: 13px; }
.tool-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.zoom-ctrl { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.manual-palette-row { display: flex; align-items: center; gap: 10px; }
.palette-label { font-size: 13px; font-weight: 600; white-space: nowrap; }
.manual-palette { display: flex; flex-wrap: wrap; gap: 6px; max-width: 520px; }
.palette-swatch { width: 22px; height: 22px; border-radius: 5px; border: 2px solid transparent; cursor: pointer; box-shadow: 0 0 0 1px rgba(0,0,0,.12); }
.palette-swatch:hover { transform: scale(1.1); }
.palette-swatch.active { border-color: #fff; box-shadow: 0 0 0 2px var(--accent); }
.add-color { font-size: 12px; padding: 5px 10px; }

/* Count */
.count-block { margin-top: 20px; border-top: 1px solid var(--line); padding-top: 16px; }
.count-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.count-head h3 { font-size: 16px; }
.count-tip { color: var(--muted); font-size: 13px; margin: 4px 0 12px; }
.color-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
.color-chip {
  display: flex; align-items: center; gap: 8px; padding: 6px 8px;
  border: 1px solid var(--line); border-radius: 8px; cursor: pointer; font-size: 12px;
  background: #fff; user-select: none;
}
.color-chip .sw { width: 18px; height: 18px; border-radius: 4px; border: 1px solid rgba(0,0,0,.15); flex: none; }
.color-chip .meta { line-height: 1.2; overflow: hidden; }
.color-chip .meta b { font-weight: 600; }
.color-chip .meta span { color: var(--muted); display: block; }
.color-chip.excluded { opacity: .4; text-decoration: line-through; }
.color-chip .cnt { margin-left: auto; font-weight: 700; }

/* Steps */
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.step { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.step-num { width: 34px; height: 34px; border-radius: 50%; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; margin-bottom: 10px; }
.step h3 { font-size: 16px; margin-bottom: 6px; }
.step p { color: var(--muted); font-size: 13px; margin: 0; }

/* FAQ */
.faq details { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px 16px; margin-bottom: 10px; }
.faq summary { cursor: pointer; font-weight: 600; }
.faq p { color: var(--muted); font-size: 14px; margin: 8px 0 0; }

/* Footer */
.site-footer { border-top: 1px solid var(--line); background: #fff; padding: 24px 20px; text-align: center; margin-top: 40px; }
.foot-nav { display: flex; gap: 18px; justify-content: center; flex-wrap: wrap; margin-bottom: 10px; }
.foot-nav a { color: var(--muted); text-decoration: none; font-size: 14px; }
.foot-nav a:hover { color: var(--accent); }
.copyright { color: var(--muted); font-size: 12px; margin: 0; }

/* ===== Modal ===== */
.modal-mask { position: fixed; inset: 0; background: rgba(15,18,30,.5); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px; }
.modal { position: relative; background: #fff; border-radius: var(--radius); padding: 26px; width: 380px; max-width: 100%; box-shadow: var(--shadow); }
.modal-wide { width: 720px; }
.modal h3 { margin-bottom: 12px; }
.modal p { color: var(--muted); font-size: 14px; margin: 6px 0; }
.modal-label { display: block; font-size: 13px; font-weight: 600; margin: 12px 0 6px; }
.modal input[type=text] { width: 100%; padding: 10px; border: 1px solid var(--line); border-radius: 8px; letter-spacing: 2px; }
.modal-actions { display: flex; gap: 10px; margin-top: 16px; }
.modal-actions .btn { flex: 1; }
.modal-hint { font-size: 12px; color: var(--muted); margin-top: 12px; }
.modal-close { position: absolute; top: 12px; right: 14px; border: none; background: transparent; font-size: 22px; cursor: pointer; color: var(--muted); }
.zoom-canvas-wrap { max-height: 70vh; overflow: auto; border: 1px solid var(--line); border-radius: 10px; background: #fafbfc; padding: 8px; text-align: center; }
.zoom-canvas-wrap canvas { image-rendering: pixelated; max-width: 100%; }

[hidden] { display: none !important; }

@media (max-width: 860px) {
  .tool-layout { grid-template-columns: 1fr; }
  .feature-grid, .steps { grid-template-columns: 1fr; }
}

/* ===== License Banner ===== */
.license-banner { max-width: 1060px; margin: 16px auto 0; padding: 0 20px; }
.license-banner .lb-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-radius: 12px; font-size: 14px; }
.license-banner.locked .lb-inner { background: #fff4f4; border: 1px solid #ffd2d2; color: #c0392b; }
.license-banner.active .lb-inner { background: #f0fbf3; border: 1px solid #bfe9c9; color: #1f7a3d; }
.lb-text { font-weight: 600; }

/* ===== Keygen Page ===== */
.keygen-wrap { max-width: 1060px; margin: 24px auto; padding: 0 20px; display: grid; gap: 20px; }
.kg-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); }
.kg-hint { color: var(--muted); font-size: 12px; margin: 6px 0 12px; }
.kg-num { width: 140px; padding: 8px; border-radius: 8px; border: 1px solid var(--line); }
.kg-actions { display: flex; gap: 10px; margin-top: 8px; }
.kg-result-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.kg-result-actions { display: flex; gap: 8px; }
.kg-table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 10px; }
.kg-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.kg-table th, .kg-table td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--line); }
.kg-table th { background: #fafbfc; font-weight: 600; color: var(--muted); }
.kg-table tr:last-child td { border-bottom: none; }
.kg-key { font-family: ui-monospace, Menlo, Consolas, monospace; letter-spacing: 1px; }

/* ===== Xianyu buy modal ===== */
.xianyu-box { text-align: center; }
.xianyu-box img { max-width: 220px; border: 1px solid var(--line); border-radius: 10px; display: block; margin: 12px auto; }
.xianyu-link { display: inline-block; margin-top: 10px; text-decoration: none; }
.xianyu-placeholder { display: none; color: var(--accent); font-size: 13px; margin: 8px 0; }
