:root {
  --blue: #2563eb;
  --blue-dark: #1d4ed8;
  --bg: #f1f5f9;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --radius: 16px;
  --shadow: 0 10px 30px -12px rgba(15, 23, 42, .25);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: linear-gradient(180deg, #eef4ff 0%, var(--bg) 240px);
  color: var(--text);
  min-height: 100vh;
  padding-bottom: 40px;
  -webkit-text-size-adjust: 100%;
}

/* Header */
.app-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; max-width: 1080px; margin: 0 auto;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-logo {
  display: grid; place-items: center; width: 44px; height: 44px;
  background: #fff; border-radius: 12px; box-shadow: var(--shadow);
}
.brand-text h1 { font-size: 19px; letter-spacing: .5px; }
.brand-text p { font-size: 12px; color: var(--muted); margin-top: 2px; }

.btn-install {
  border: none; background: var(--blue); color: #fff; font-weight: 600;
  padding: 9px 16px; border-radius: 10px; cursor: pointer; font-size: 14px;
  box-shadow: var(--shadow);
}
.btn-install:active { transform: scale(.97); }

/* Container */
.container { max-width: 1080px; margin: 0 auto; padding: 0 16px; }

.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 20px; margin-bottom: 18px;
}
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.step-no {
  width: 26px; height: 26px; border-radius: 50%; background: var(--blue); color: #fff;
  display: grid; place-items: center; font-size: 14px; font-weight: 700;
}
.card-head h2 { font-size: 17px; }

.hidden { display: none !important; }

/* Dropzone */
.dropzone {
  display: block; border: 2px dashed var(--line); border-radius: 14px;
  padding: 40px 20px; text-align: center; cursor: pointer; transition: .2s;
  background: #f8fafc;
}
.dropzone.drag { border-color: var(--blue); background: #eef4ff; }
.dz-inner svg { margin-bottom: 8px; }
.dz-inner p { color: var(--text); font-size: 15px; margin-bottom: 6px; }
.dz-inner small { color: var(--muted); font-size: 12px; }

/* Editor grid */
.editor-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 22px; }
@media (max-width: 820px) { .editor-grid { grid-template-columns: 1fr; } }

.preview-wrap { display: flex; flex-direction: column; gap: 12px; }
.canvas-stage {
  position: relative; background:
    repeating-conic-gradient(#e9eef5 0% 25%, #f7fafc 0% 50%) 50% / 22px 22px;
  border-radius: 12px; overflow: hidden; min-height: 320px;
  display: grid; place-items: center; touch-action: none;
}
#previewCanvas { max-width: 100%; max-height: 60vh; display: block; cursor: grab; }
#previewCanvas:active { cursor: grabbing; }
.crop-hint {
  position: absolute; bottom: 8px; left: 50%; transform: translateX(-50%);
  background: rgba(15,23,42,.7); color: #fff; font-size: 12px;
  padding: 5px 12px; border-radius: 20px; pointer-events: none;
}
.preview-actions { display: flex; gap: 10px; }
.btn-ghost {
  flex: 1; border: 1px solid var(--line); background: #fff; color: var(--text);
  padding: 9px; border-radius: 10px; cursor: pointer; font-size: 14px;
}
.btn-ghost:active { background: #f1f5f9; }

/* Controls */
.controls { display: flex; flex-direction: column; gap: 18px; }
.ctrl-block { display: flex; flex-direction: column; gap: 10px; }
.ctrl-label { font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; }

.swatches { display: flex; gap: 12px; align-items: center; }
.swatch {
  width: 42px; height: 42px; border-radius: 10px; cursor: pointer;
  border: 2px solid var(--line); background: var(--c); position: relative;
  transition: .15s;
}
.swatch[data-color="white"] { box-shadow: inset 0 0 0 1px #e2e8f0; }
.swatch.active { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(37,99,235,.25); }
.swatch-custom {
  display: grid; place-items: center; overflow: hidden; border-style: solid;
  background: conic-gradient(red, yellow, lime, aqua, blue, magenta, red);
}
.swatch-custom input { width: 100%; height: 100%; border: none; background: none; cursor: pointer; opacity: 0; position: absolute; }

.slider-row { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--text); }
.slider-row span { width: 64px; color: var(--muted); }
.slider-row input[type=range] { flex: 1; accent-color: var(--blue); }
.slider-row output { width: 30px; text-align: right; font-variant-numeric: tabular-nums; color: var(--blue); font-weight: 600; }

.size-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.size-btn {
  border: 1px solid var(--line); background: #fff; border-radius: 10px;
  padding: 9px 10px; text-align: left; cursor: pointer; transition: .15s;
}
.size-btn:hover { border-color: #c7d2fe; }
.size-btn.active { border-color: var(--blue); background: #eef4ff; }
.size-btn .sz-name { font-weight: 600; font-size: 14px; }
.size-btn .sz-spec { font-size: 11px; color: var(--muted); margin-top: 2px; }

.tip { font-size: 12px; color: var(--muted); line-height: 1.5; }
.tip strong { color: var(--blue); }

/* 分段按钮 / 工具切换 */
.seg { display: flex; gap: 8px; }
.seg-btn {
  flex: 1; border: 1px solid var(--line); background: #fff; color: var(--text);
  padding: 9px; border-radius: 10px; cursor: pointer; font-size: 13.5px; font-weight: 600;
  transition: .15s;
}
.seg-btn.active { border-color: var(--blue); background: var(--blue); color: #fff; }
.seg-btn:active { transform: scale(.98); }

.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 4px; }
.btn-ghost.slim { flex: 0 0 auto; padding: 7px 12px; font-size: 13px; }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); cursor: pointer; }
.check input { accent-color: var(--blue); width: 16px; height: 16px; }

.btn-primary {
  margin-top: 4px; border: none; background: var(--blue); color: #fff;
  font-weight: 700; font-size: 15px; padding: 13px; border-radius: 12px;
  cursor: pointer; box-shadow: var(--shadow);
}
.btn-primary:disabled { background: #cbd5e1; cursor: not-allowed; box-shadow: none; }
.btn-primary:not(:disabled):active { transform: scale(.98); }

/* Result */
.result-wrap { display: flex; flex-direction: column; align-items: center; gap: 14px; }
#resultCanvas {
  max-width: 100%; border-radius: 8px; box-shadow: var(--shadow);
  background: repeating-conic-gradient(#e9eef5 0% 25%, #f7fafc 0% 50%) 50% / 16px 16px;
}
.result-meta { font-size: 13px; color: var(--muted); text-align: center; }

.app-footer { text-align: center; color: var(--muted); font-size: 12px; margin-top: 8px; }

/* 轻提示 toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 32px;
  transform: translateX(-50%) translateY(12px);
  background: rgba(15, 23, 42, .92);
  color: #fff;
  font-size: 13px;
  padding: 10px 18px;
  border-radius: 999px;
  box-shadow: 0 8px 24px -10px rgba(0, 0, 0, .5);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  z-index: 1000;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
