/* ══════════════════════════════════════════════
   黄金比例工具 — style.css
   分区: 1.Tokens  2.Reset  3.布局  4.工具栏
         5.Canvas  6.状态栏  7.Toasts  8.响应式
   ══════════════════════════════════════════════ */

/* ─── 1. Design Tokens ───────────────────────── */
:root {
  --bg:        #0d0e13;
  --surface:   #13141a;
  --surface-2: #1a1b22;
  --border:    rgba(255,255,255,0.08);
  --divider:   rgba(255,255,255,0.12);
  --text:      #d4d5db;
  --text-muted:#7a7c8a;
  --accent:    #4fc3ff;
  --accent-dim:rgba(79,195,255,0.15);
  --primary:   #3b82f6;
  --primary-h: #2563eb;
  --mirror-bg: rgba(168,85,247,0.15);
  --mirror-bd: rgba(168,85,247,0.45);
  --mirror-tx: #c084fc;
  --radius:    6px;
  --mono:      'JetBrains Mono', 'Fira Code', monospace;
  --sans:      'Inter', system-ui, sans-serif;
}

/* ─── 2. Reset ───────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; font-family: var(--sans); background: var(--bg); color: var(--text); font-size: 13px; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; }

/* ─── 3. 布局 ────────────────────────────────── */
#app {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 12px;
}

.panel {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 1600px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 16px 48px rgba(0,0,0,0.5);
}

/* ─── 4. 工具栏 ─────────────────────────────── */
.toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  padding: 7px 10px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  min-height: 44px;
}

.group {
  display: flex;
  align-items: center;
  gap: 4px;
}

.group-pill .btn { border-radius: 0; margin: 0; }
.group-pill .btn:first-child { border-radius: var(--radius) 0 0 var(--radius); }
.group-pill .btn:last-child  { border-radius: 0 var(--radius) var(--radius) 0; }

.sep {
  width: 1px;
  height: 22px;
  background: var(--divider);
  flex-shrink: 0;
  margin: 0 2px;
}

/* 通用按钮 */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  white-space: nowrap;
  user-select: none;
}
.btn:hover { background: rgba(255,255,255,0.06); color: var(--text); border-color: rgba(255,255,255,0.16); }

/* 激活态 (图层切换) */
.btn-toggle.on {
  background: var(--accent-dim);
  border-color: rgba(79,195,255,0.35);
  color: var(--accent);
}

/* 4向镜像按钮（紫色强调） */
.btn-mirror.on {
  background: var(--mirror-bg);
  border-color: var(--mirror-bd);
  color: var(--mirror-tx);
}

/* 主操作按钮 */
.btn-primary {
  background: var(--primary);
  border-color: transparent;
  color: #fff;
  font-weight: 600;
}
.btn-primary:hover { background: var(--primary-h); color: #fff; }

/* 标签式输入组 */
.lbl {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: default;
}
.lbl-txt { font-size: 11px; color: var(--text-muted); }
.unit    { font-size: 10px; color: var(--text-muted); }

.lbl input[type="number"] {
  width: 52px;
  padding: 3px 5px;
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 12px;
  text-align: right;
  font-family: var(--mono);
}
.lbl input[type="number"]:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.lbl input[type="color"] {
  width: 26px; height: 22px;
  padding: 1px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: transparent;
  cursor: pointer;
}

.lbl input[type="range"] {
  width: 72px;
  accent-color: var(--accent);
  cursor: pointer;
}

/* ─── 5. Canvas 区域 ─────────────────────────── */
.canvas-wrap {
  overflow: auto;
  flex: 1;
  min-height: 200px;
  max-height: calc(100vh - 120px);
  background: #08090e;
  position: relative;
}

/* canvas-inner: 始终撑满外容器，用 flex 居中 canvas */
/* min-width/height 由 applyZoom() 通过 JS 动态设置，确保小图也能居中 */
.canvas-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  box-sizing: border-box;
}

#canvas {
  display: block;
  flex-shrink: 0;
  cursor: crosshair;
  touch-action: none;
}

/* 空状态遮罩 */
.empty-state {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: rgba(8,9,14,0.88);
  pointer-events: none;
  z-index: 10;
}
.empty-state.hidden { display: none; }
.empty-state svg { color: rgba(255,255,255,0.15); }
.empty-state h2   { font-size: 16px; font-weight: 600; color: rgba(255,255,255,0.6); }
.empty-state p    { font-size: 12px; color: var(--text-muted); }
.empty-state .hint { font-size: 11px; color: rgba(255,255,255,0.25); }
.empty-state kbd  { background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.15); border-radius: 3px; padding: 1px 4px; }

/* ─── 6. 状态栏 ─────────────────────────────── */
.statusbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 12px;
  background: var(--surface-2);
  border-top: 1px solid var(--border);
  min-height: 32px;
  flex-wrap: wrap;
  gap: 6px;
}

.status-left, .status-right {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-family: var(--mono);
  color: var(--text-muted);
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--text-muted);
}
.status-indicator .dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
}
.status-indicator.on { color: #4ade80; }
.status-indicator.on .dot { background: #4ade80; box-shadow: 0 0 6px #4ade80; }

kbd {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 3px;
  padding: 1px 5px;
  font-size: 10px;
  font-family: var(--mono);
  color: var(--text-muted);
}

/* 缩放控制 */
.zoom-ctrl {
  display: flex;
  align-items: center;
  gap: 2px;
}
.zoom-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 20px;
  padding: 0 5px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: rgba(255,255,255,0.04);
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.zoom-btn:hover { background: rgba(255,255,255,0.1); color: var(--text); }
.zoom-btn.zoom-fit { font-size: 10px; font-weight: 500; }
.zoom-label {
  min-width: 38px;
  text-align: center;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text);
}

/* ─── 7. Toasts ──────────────────────────────── */
#toasts {
  position: fixed;
  top: 16px;
  right: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 9999;
  pointer-events: none;
}
.toast {
  padding: 8px 14px;
  border-radius: var(--radius);
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 12px;
  color: var(--text);
  animation: toastIn 0.2s ease;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}
.toast.ok  { border-color: rgba(74,222,128,0.35); color: #4ade80; }
.toast.err { border-color: rgba(248,113,113,0.35); color: #f87171; }
.toast.out { animation: toastOut 0.2s ease forwards; }

@keyframes toastIn  { from { opacity:0; transform:translateX(12px); } to { opacity:1; transform:none; } }
@keyframes toastOut { to   { opacity:0; transform:translateX(12px); } }

/* ─── 8. 响应式 ──────────────────────────────── */
@media (max-width: 768px) {
  .toolbar { padding: 6px 8px; }
  .status-right { display: none; }
  .lbl input[type="range"] { width: 52px; }
}
