/* ══════════════════════════════════════════
   CSS VARIABLES
   ══════════════════════════════════════════ */
:root {
  --bg: #f3f4f6;
  --surface: #e9eaef;
  --card: #ffffff;
  --border: #e2e4e9;
  --border-active: #c8ccd4;
  --text: #1f2937;
  --text-dim: #6b7280;
  --text-muted: #9ca3b0;
  --accent: #0f766e;
  --accent-light: #14b8a6;
  --accent-dim: rgba(15,118,110,0.06);
  --accent-glow: rgba(15,118,110,0.18);
  --red: #ef4444;
  --green: #10b981;
  --radius: 14px;
  --radius-sm: 8px;
  --font: 'Microsoft YaHei', 'PingFang SC', 'Hiragino Sans GB', sans-serif;
  --mono: 'Microsoft YaHei', 'PingFang SC', 'Hiragino Sans GB', sans-serif;
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ══════════════════════════════════════════
   RESET & BASE
   ══════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ══════════════════════════════════════════
   LAYOUT
   ══════════════════════════════════════════ */
.app { max-width: 1380px; margin: 0 auto; padding: 28px 24px 48px; }

.header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 32px; flex-wrap: wrap; gap: 16px;
}
.header-brand { display: flex; align-items: center; gap: 12px; }
.header-logo {
  width: 40px; height: 40px; border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-light));
  display: flex; align-items: center; justify-content: center;
  font-family: var(--mono); font-size: 1.1rem; font-weight: 500; color: #fff;
}
.header h1 { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.02em; }
.header .tagline {
  font-size: 0.82rem; color: var(--text-dim); margin-top: 2px;
  font-family: var(--mono); letter-spacing: 0.03em;
}

.grid {
  display: grid;
  grid-template-columns: 1fr 1.2fr 1fr;
  gap: 20px;
  align-items: start;
}
@media (max-width: 1100px) { .grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 720px)  { .grid { grid-template-columns: 1fr; } }

/* ══════════════════════════════════════════
   CARD
   ══════════════════════════════════════════ */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.card:hover { border-color: var(--border-active); box-shadow: 0 2px 8px rgba(0,0,0,0.06); }
.card-header {
  display: flex; align-items: center; gap: 8px; margin-bottom: 18px;
  font-size: 0.85rem; font-weight: 600;
  letter-spacing: 0.06em; color: var(--text-dim);
  font-family: var(--mono); text-transform: uppercase;
}
.card-header .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent);
}

/* ══════════════════════════════════════════
   DROP ZONE
   ══════════════════════════════════════════ */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 22px 16px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
  margin-bottom: 14px;
  background: var(--bg);
}
.drop-zone:hover { border-color: var(--border-active); background: var(--surface); }
.drop-zone.drag-over {
  border-color: var(--accent);
  background: var(--accent-dim);
  box-shadow: 0 0 0 4px var(--accent-dim);
}
.drop-zone .label {
  font-size: 0.85rem; font-weight: 600; color: var(--text);
}
.drop-zone .hint {
  font-size: 0.72rem; color: var(--text-muted); margin-top: 4px;
}
.drop-zone input[type="file"] { display: none; }
.drop-zone.filled {
  border-style: solid; border-color: var(--accent);
  background: var(--accent-dim);
}
.file-info {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 0.78rem; color: var(--text-dim); gap: 8px;
  font-family: var(--mono);
}
.file-info .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.file-info .clear-btn {
  background: none; border: none; color: var(--text-muted); cursor: pointer;
  font-size: 0.85rem; padding: 2px 6px; border-radius: 4px; transition: all var(--transition);
}
.file-info .clear-btn:hover { color: var(--red); background: rgba(239,68,68,0.08); }

/* ══════════════════════════════════════════
   FORM CONTROLS
   ══════════════════════════════════════════ */
.control-group { margin-bottom: 14px; }
.control-label {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 0.78rem; font-weight: 500; color: var(--text-dim); margin-bottom: 6px;
  font-family: var(--mono); letter-spacing: 0.02em;
}
.control-label .val { color: var(--accent); font-weight: 600; }

input[type="range"] {
  -webkit-appearance: none; width: 100%; height: 4px;
  background: var(--border); border-radius: 2px; outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%;
  background: var(--accent); cursor: pointer; border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.15);
  transition: transform var(--transition);
}
input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.15); }

/* Coordinate Inputs */
.coord-row {
  display: flex; gap: 10px; margin-bottom: 14px;
}
.coord-item {
  flex: 1; display: flex; align-items: center;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 6px 10px; gap: 6px;
}
.coord-item .axis {
  font-family: var(--mono); font-size: 0.75rem; color: var(--text-muted);
  font-weight: 500;
}
.coord-item input[type="number"] {
  width: 100%; background: none; border: none; color: var(--text);
  font-family: var(--mono); font-size: 0.82rem; outline: none;
  -moz-appearance: textfield;
}
.coord-item input[type="number"]::-webkit-inner-spin-button,
.coord-item input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; }
.coord-item input[type="number"]:disabled {
  color: var(--text-muted);
}

/* Toggle */
.toggle-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 0; margin-bottom: 10px;
}
.toggle-label {
  font-size: 0.78rem; font-weight: 500; color: var(--text-dim);
  font-family: var(--mono); letter-spacing: 0.02em;
}
.toggle-track {
  width: 40px; height: 22px; border-radius: 11px;
  background: var(--border); cursor: pointer;
  transition: background var(--transition); position: relative;
}
.toggle-track.on { background: var(--accent); }
.toggle-track::after {
  content: ''; position: absolute; top: 3px; left: 3px;
  width: 16px; height: 16px; border-radius: 50%; background: #fff;
  transition: transform var(--transition); box-shadow: 0 1px 2px rgba(0,0,0,0.15);
}
.toggle-track.on::after { transform: translateX(18px); }

/* Select */
.select-wrap {
  position: relative; margin-bottom: 14px;
}
.select-wrap select {
  width: 100%; padding: 10px 12px; border-radius: var(--radius-sm);
  background: var(--bg); border: 1px solid var(--border);
  color: var(--text); font-family: var(--mono); font-size: 0.78rem;
  font-weight: 500; outline: none; cursor: pointer; appearance: none;
  transition: border-color var(--transition);
}
.select-wrap select:focus { border-color: var(--accent); }
.select-wrap select option {
  background: #fff; color: var(--text);
}
.select-wrap::after {
  content: ''; position: absolute; right: 14px; top: 50%; transform: translateY(-50%);
  width: 0; height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid var(--text-dim);
  pointer-events: none;
}

/* ══════════════════════════════════════════
   CENTERING HINT
   ══════════════════════════════════════════ */
.center-hint {
  font-size: 0.68rem; color: var(--text-muted); font-family: var(--mono);
  margin-top: 4px; text-align: center; min-height: 18px;
}

/* ══════════════════════════════════════════
   PREVIEW
   ══════════════════════════════════════════ */
.preview-stage {
  position: relative; border-radius: var(--radius-sm);
  overflow: hidden; margin-bottom: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  min-height: 160px; display: flex; align-items: center; justify-content: center;
}
.preview-stage canvas {
  display: block; max-width: 100%; height: auto;
}
.preview-stage .placeholder {
  color: var(--text-muted); font-size: 0.78rem; text-align: center;
  font-family: var(--mono); z-index: 1;
}
.preview-stage .drag-hint {
  position: absolute; bottom: 10px; left: 50%; transform: translateX(-50%);
  font-size: 0.68rem; color: var(--text-dim); background: rgba(255,255,255,0.85);
  padding: 4px 10px; border-radius: 20px; pointer-events: none; z-index: 3;
  font-family: var(--mono); opacity: 0; transition: opacity 0.3s;
  white-space: nowrap;
}
.preview-stage.has-qr .drag-hint { opacity: 1; }

/* ══════════════════════════════════════════
   BUTTONS
   ══════════════════════════════════════════ */
.btn {
  width: 100%; padding: 12px 20px; border: none; border-radius: 10px;
  font-family: var(--mono); font-size: 0.8rem; font-weight: 500;
  letter-spacing: 0.04em; cursor: pointer; transition: all var(--transition);
}
.btn-primary {
  background: var(--accent); color: #fff;
}
.btn-primary:hover:not(:disabled) {
  background: #0c5d57; transform: translateY(-1px);
  box-shadow: 0 4px 16px var(--accent-glow);
}
.btn-primary:active:not(:disabled) { transform: translateY(0); }
.btn-primary:disabled {
  background: var(--border); color: var(--text-muted);
  cursor: not-allowed;
}
.btn-secondary {
  background: var(--bg); color: var(--text-dim);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--surface); color: var(--text); border-color: var(--border-active); }

.btn-row { display: flex; gap: 8px; margin-top: 8px; }

/* ══════════════════════════════════════════
   PROGRESS
   ══════════════════════════════════════════ */
.progress-wrap { margin-top: 16px; display: none; }
.progress-wrap.visible { display: block; }
.progress-track {
  height: 4px; background: var(--border); border-radius: 2px;
  overflow: hidden; margin-bottom: 8px;
}
.progress-fill {
  height: 100%; width: 0%; border-radius: 2px;
  background: linear-gradient(90deg, var(--accent), var(--accent-light));
  transition: width 0.15s linear;
}
.progress-text {
  font-size: 0.72rem; color: var(--text-dim); font-family: var(--mono);
  display: flex; justify-content: space-between;
}

/* ══════════════════════════════════════════
   TOAST
   ══════════════════════════════════════════ */
.toast-container {
  position: fixed; top: 20px; right: 20px; z-index: 9999;
  display: flex; flex-direction: column; gap: 8px; pointer-events: none;
}
.toast {
  background: var(--card); border: 1px solid var(--border-active);
  border-radius: var(--radius-sm); padding: 10px 16px;
  font-size: 0.78rem; color: var(--text); font-family: var(--mono);
  box-shadow: 0 8px 32px rgba(0,0,0,0.12);
  animation: toastIn 0.3s ease-out;
  pointer-events: auto; max-width: 360px;
}
.toast.error { border-left: 3px solid var(--red); }
.toast.success { border-left: 3px solid var(--green); }
.toast.info { border-left: 3px solid var(--accent); }
.toast.removing { animation: toastOut 0.25s ease-in forwards; }

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

/* ══════════════════════════════════════════
   FOOTER
   ══════════════════════════════════════════ */
.footer {
  margin-top: 32px; text-align: center; font-size: 0.7rem;
  color: var(--text-muted); font-family: var(--mono);
}
.footer kbd {
  background: var(--bg); padding: 2px 6px; border-radius: 3px;
  border: 1px solid var(--border); font-family: var(--mono); font-size: 0.65rem;
}

.hidden { display: none !important; }
.disabled-group { opacity: 0.35; pointer-events: none; transition: opacity var(--transition); }
