/* ---------- 基础 ---------- */
* { margin: 0; padding: 0; box-sizing: border-box; }

/* 修复：自定义 display（flex/block）会覆盖 hidden 属性的 UA 样式，
   导致 loading 遮罩等永久显示，必须显式声明 */
[hidden] { display: none !important; }

:root {
  --bg: #faf9f7;
  --card: #ffffff;
  --ink: #1c1c1e;
  --ink-2: #6b6b70;
  --line: #eceae6;
  --accent: #e8542f;
  --accent-soft: #fdeee9;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 8px 24px rgba(0,0,0,.05);
}

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h1 { font-size: 22px; font-weight: 700; letter-spacing: .02em; }
h2 { font-size: 14px; font-weight: 600; }

.section-title {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .12em;
  color: var(--ink-2);
  text-transform: uppercase;
  margin-bottom: 16px;
}

/* ---------- 头部 ---------- */
.site-header {
  padding: 40px 32px 8px;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
}

.brand { display: flex; align-items: center; gap: 16px; }

.brand-mark {
  display: grid;
  grid-template-columns: repeat(3, 10px);
  grid-gap: 3px;
  padding: 10px;
  background: var(--card);
  border-radius: 12px;
  box-shadow: var(--shadow);
}
.brand-mark i { width: 10px; height: 10px; border-radius: 50%; }
.brand-mark i:nth-child(1) { background: #e1251b; }
.brand-mark i:nth-child(2) { background: #f5821f; }
.brand-mark i:nth-child(3) { background: #ffe600; }
.brand-mark i:nth-child(4) { background: #43b02a; }
.brand-mark i:nth-child(5) { background: #3fa9f5; }
.brand-mark i:nth-child(6) { background: #7a3e9d; }
.brand-mark i:nth-child(7) { background: #f6a5c0; }
.brand-mark i:nth-child(8) { background: #7a4a21; }
.brand-mark i:nth-child(9) { background: #1a1a1a; }

.brand-text p { color: var(--ink-2); font-size: 14px; margin-top: 2px; }

/* ---------- 布局 ---------- */
.layout {
  flex: 1;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 32px;
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 32px;
  align-items: start;
}

.panel {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
}

.panel-right { min-height: 480px; }

/* ---------- 上传区 ---------- */
.dropzone {
  border: 1.5px dashed #d8d5cf;
  border-radius: 14px;
  padding: 36px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s, background .2s;
  outline: none;
}
.dropzone:hover, .dropzone:focus, .dropzone.dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.dz-icon { width: 34px; height: 34px; color: var(--ink-2); margin-bottom: 10px; }
.dz-title { font-size: 14px; font-weight: 600; }
.dz-sub { font-size: 12px; color: var(--ink-2); margin-top: 6px; }

.dz-preview img {
  max-width: 100%;
  max-height: 180px;
  border-radius: 10px;
  display: block;
  margin: 0 auto;
}
.dz-preview-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 10px;
  font-size: 12px;
  color: var(--ink-2);
  gap: 8px;
}
.dz-preview-meta span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.link-btn {
  border: none;
  background: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 12px;
  flex-shrink: 0;
}

/* ---------- 设置 ---------- */
.settings { margin-top: 28px; }

.field { margin-bottom: 20px; }
.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 8px;
}
.field .hint { font-weight: 400; color: var(--ink-2); font-size: 12px; }

.field select, .field input[type="number"] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  color: var(--ink);
}
.field select:focus, .field input[type="number"]:focus {
  outline: 2px solid var(--accent-soft);
  border-color: var(--accent);
}

.custom-width {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}
.custom-width span { font-size: 12px; color: var(--ink-2); white-space: nowrap; }

.field output {
  float: right;
  font-weight: 700;
  color: var(--accent);
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
  cursor: pointer;
}

.field-check .check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}
.field-check input { accent-color: var(--accent); width: 16px; height: 16px; cursor: pointer; }

.field-note { font-size: 12px; color: var(--ink-2); margin-top: 6px; }

/* ---------- 按钮 ---------- */
.btn-primary {
  width: 100%;
  padding: 13px;
  border: none;
  border-radius: 12px;
  background: var(--ink);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background .2s, transform .1s;
}
.btn-primary:hover:not(:disabled) { background: var(--accent); }
.btn-primary:active:not(:disabled) { transform: scale(.98); }
.btn-primary:disabled { background: #cfcdc8; cursor: not-allowed; }

.btn-secondary {
  padding: 11px 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: border-color .2s, color .2s;
}
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- 预览区 ---------- */
.preview-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 16px;
}
.preview-head .section-title { margin-bottom: 0; }

.result-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  font-size: 12px;
  color: var(--ink-2);
}

.canvas-wrap {
  position: relative;
  min-height: 280px;
  border-radius: 12px;
  background: #f4f2ee;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 20px;
}

.empty-state { color: #a9a6a0; font-size: 14px; text-align: center; }

#canvas {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: 6px;
  box-shadow: 0 2px 10px rgba(0,0,0,.08);
}

.loading {
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,.85);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  font-size: 13px;
  color: var(--ink-2);
}
.spinner {
  width: 28px; height: 28px;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 配色清单 ---------- */
.color-section { margin-top: 32px; }

.table-wrap { overflow-x: auto; }

.color-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.color-table th {
  text-align: left;
  font-size: 12px;
  color: var(--ink-2);
  font-weight: 600;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
}
.color-table td {
  padding: 8px 10px;
  border-bottom: 1px solid #f4f2ef;
}
.color-table tr:last-child td { border-bottom: none; }

.swatch {
  display: inline-block;
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 1px solid rgba(0,0,0,.08);
  vertical-align: middle;
}

.pct-bar {
  height: 6px;
  border-radius: 3px;
  background: var(--accent-soft);
  overflow: hidden;
  min-width: 60px;
}
.pct-bar i { display: block; height: 100%; background: var(--accent); border-radius: 3px; }

.downloads {
  display: flex;
  gap: 12px;
  margin-top: 24px;
  flex-wrap: wrap;
}

/* ---------- 页脚 / Toast ---------- */
.site-footer {
  text-align: center;
  padding: 24px;
  font-size: 12px;
  color: #b0ada7;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 32px;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: 10px 20px;
  border-radius: 999px;
  font-size: 13px;
  box-shadow: var(--shadow);
  z-index: 99;
  animation: fadeUp .25s ease;
}
@keyframes fadeUp {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

/* ---------- 响应式 ---------- */
@media (max-width: 900px) {
  .site-header { padding: 28px 20px 4px; }
  .layout {
    grid-template-columns: 1fr;
    padding: 20px;
    gap: 20px;
  }
  .panel { padding: 20px; }
  .downloads .btn-secondary { flex: 1; }
}
