/* ===== LOVESHOP 格子广场 · 样式 ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #eef1f5;
  --panel: #ffffff;
  --ink: #1a2333;
  --ink-2: #5c6b82;
  --ink-3: #8b98ad;
  --line: #dfe5ee;
  --primary: #1769e0;
  --primary-hover: #0f58c4;
  --danger: #c93636;
  --radius: 10px;
  --shadow: 0 8px 28px rgba(20, 35, 60, .14);
}

html, body { height: 100%; }

body {
  font: 14px/1.6 -apple-system, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ===== 顶栏 ===== */
.topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 10px 18px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  z-index: 20;
  flex-shrink: 0;
}

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.logo-mark { display: grid; grid-template-columns: 8px 8px; gap: 2px; padding: 4px; border-radius: 6px; background: var(--ink); }
.logo-cell { width: 8px; height: 8px; border-radius: 1px; }
.brand-text h1 { font-size: 17px; font-weight: 700; letter-spacing: .2px; white-space: nowrap; }
.brand-text h1 .dot { color: var(--primary); margin: 0 2px; }
.brand-text .sub { font-size: 11px; color: var(--ink-3); white-space: nowrap; }

.search-box { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.search-box input {
  width: 220px; padding: 8px 12px;
  border: 1px solid var(--line); border-radius: 8px;
  font: inherit; color: var(--ink); background: #f7f9fc; outline: none;
}
.search-box input:focus { border-color: var(--primary); background: #fff; box-shadow: 0 0 0 3px rgba(23,105,224,.12); }
.search-box button { padding: 8px 14px; }

.top-actions { display: flex; gap: 8px; }

/* ===== 按钮 ===== */
.btn {
  padding: 9px 16px; border: 1px solid transparent; border-radius: 8px;
  font: inherit; font-weight: 500; cursor: pointer; transition: background .15s, border-color .15s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--ink-2); }
.btn-ghost:hover { background: #f2f5fa; color: var(--ink); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ===== 画布舞台 ===== */
.stage { position: relative; flex: 1; overflow: hidden; }
#canvas { display: block; width: 100%; height: 100%; cursor: grab; touch-action: none; }
#canvas.selecting { cursor: crosshair; }
#canvas.dragging { cursor: grabbing; }

/* ===== HUD ===== */
.hud {
  position: absolute; left: 14px; bottom: 14px; z-index: 10;
  padding: 10px 14px; border-radius: var(--radius);
  background: rgba(255,255,255,.92); border: 1px solid var(--line);
  box-shadow: var(--shadow); font-size: 12px; min-width: 168px;
  backdrop-filter: blur(6px);
}
.hud-row { display: flex; justify-content: space-between; gap: 16px; padding: 1px 0; }
.hud-label { color: var(--ink-3); }
.hud-row span:last-child { font-variant-numeric: tabular-nums; color: var(--ink); font-weight: 500; }

/* ===== 框选信息 ===== */
.selection-info {
  position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 10;
  display: flex; gap: 14px; align-items: center;
  padding: 9px 18px; border-radius: 999px;
  background: var(--ink); color: #fff; font-size: 13px;
  box-shadow: var(--shadow); white-space: nowrap;
}
.selection-info b { color: #7db3ff; }
.selection-info.hidden { display: none; }

.crosshair {
  position: absolute; z-index: 9; pointer-events: none;
  border: 1px dashed rgba(23,105,224,.75); background: rgba(23,105,224,.08);
  border-radius: 2px;
}
.crosshair.hidden { display: none; }

/* ===== 引导卡片 ===== */
.guide {
  position: absolute; top: 16px; left: 50%; transform: translateX(-50%); z-index: 10;
  padding: 12px 18px; border-radius: var(--radius);
  background: rgba(255,255,255,.95); border: 1px solid var(--line);
  box-shadow: var(--shadow); font-size: 12.5px; text-align: center;
  backdrop-filter: blur(6px);
}
.guide p { color: var(--ink-2); margin: 2px 0; }
.guide .btn { margin-top: 8px; }

/* ===== 弹窗 ===== */
.modal {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  background: rgba(18, 26, 40, .45); backdrop-filter: blur(2px);
}
.modal.hidden { display: none; }
.modal-card {
  width: 440px; max-width: calc(100vw - 40px); max-height: calc(100vh - 60px); overflow-y: auto;
  background: var(--panel); border-radius: 14px; box-shadow: var(--shadow);
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px 12px; border-bottom: 1px solid var(--line);
}
.modal-head h2 { font-size: 16px; font-weight: 600; }
.modal-close {
  width: 30px; height: 30px; border: 0; border-radius: 8px;
  background: #f2f5fa; color: var(--ink-2); font-size: 18px; line-height: 1; cursor: pointer;
}
.modal-close:hover { background: #e6ebf3; color: var(--ink); }

.form { padding: 16px 20px 20px; }
.form label { display: block; margin: 12px 0 4px; font-size: 12.5px; color: var(--ink-2); }
.form input[type="text"], .form input[type="number"] {
  width: 100%; padding: 9px 12px;
  border: 1px solid var(--line); border-radius: 8px; font: inherit; color: var(--ink); outline: none;
}
.form input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(23,105,224,.12); }
.row-2 { display: flex; gap: 14px; }
.row-2 label { flex: 1; }
.row-2 input[type="color"] {
  width: 100%; height: 38px; padding: 3px; border: 1px solid var(--line); border-radius: 8px;
  background: #fff; cursor: pointer;
}

.sel-preview {
  display: flex; justify-content: space-between; padding: 10px 20px;
  background: #f4f7fb; font-size: 12.5px; color: var(--ink-2);
  border-bottom: 1px solid var(--line);
}
.sel-preview b { color: var(--ink); }

.price-line {
  display: flex; align-items: center; gap: 12px; margin-top: 16px; padding: 10px 12px;
  border-radius: 8px; background: #f4f7fb; font-size: 12.5px; color: var(--ink-2);
}
.price-line .price-total { margin-left: auto; font-size: 13px; }
.price-line .price-total b { color: var(--primary); font-size: 16px; }
.form-note { margin-top: 10px; font-size: 11.5px; color: var(--ink-3); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

.detail-body { padding: 16px 20px; }
.detail-card { display: flex; gap: 14px; align-items: center; }
.detail-swatch { width: 74px; height: 74px; border-radius: 10px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 600; text-align: center; padding: 6px; overflow: hidden; word-break: break-all; }
.detail-meta { flex: 1; min-width: 0; font-size: 13px; }
.detail-meta .row { display: flex; justify-content: space-between; padding: 3px 0; border-bottom: 1px dashed var(--line); }
.detail-meta .row:last-child { border-bottom: 0; }
.detail-meta .k { color: var(--ink-3); }
.detail-meta .v { font-variant-numeric: tabular-nums; }

.stats-body { padding: 16px 20px; }
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat-card { padding: 12px 14px; border-radius: 10px; background: #f4f7fb; }
.stat-card .n { font-size: 20px; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }
.stat-card .t { font-size: 12px; color: var(--ink-3); margin-top: 2px; }
.stat-card.accent { background: #e8f0fe; }
.stat-card.accent .n { color: var(--primary); }
.stat-card.amber { background: #fdf3e0; }
.stat-card.amber .n { color: #b07d12; }
.stat-card.green { background: #e8f6ec; }
.stat-card.green .n { color: #1e7d3c; }

.help-body { padding: 14px 20px 20px; font-size: 13px; }
.help-body h3 { font-size: 13.5px; margin: 12px 0 4px; color: var(--ink); }
.help-body p { color: var(--ink-2); }
.help-body code { background: #eef2f8; padding: 1px 6px; border-radius: 5px; font-size: 12px; color: var(--primary); }

/* ===== Toast ===== */
.toast {
  position: fixed; left: 50%; bottom: 34px; transform: translateX(-50%); z-index: 80;
  padding: 11px 22px; border-radius: 999px;
  background: var(--ink); color: #fff; font-size: 13.5px;
  box-shadow: var(--shadow); white-space: nowrap;
}
.toast.hidden { display: none; }
.toast.ok { background: #1e7d3c; }
.toast.err { background: var(--danger); }

/* ===== 响应式 ===== */
@media (max-width: 900px) {
  .search-box { display: none; }
  .brand-text .sub { display: none; }
  .guide { display: none; }
}
