/* p.vccx.cn 统一样式 */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
:root {
  --primary: #4f46e5;
  --primary-light: #6366f1;
  --primary-dark: #4338ca;
  --success: #059669;
  --danger: #dc2626;
  --bg: #f1f5f9;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-light: #64748b;
  --radius: 12px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
html { scroll-behavior: smooth; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  padding-bottom: 70px;
}

/* ===== 顶部 ===== */
.header {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  color: white;
  padding: 16px 16px;
  padding-top: calc(16px + env(safe-area-inset-top, 0px));
  box-shadow: 0 2px 10px rgba(79, 70, 229, 0.3);
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.header h1 {
  font-size: 1.2em;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}
.header p {
  opacity: 0.9;
  font-size: 0.78em;
  margin-top: 3px;
}
.header-back {
  background: rgba(255,255,255,0.2);
  border: none;
  color: white;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 1.2em;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  text-decoration: none;
}
.header-back:active { transform: scale(0.9); background: rgba(255,255,255,0.3); }

/* ===== 底部工具栏 ===== */
.bottom-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: white;
  border-top: 1px solid var(--border);
  padding: 8px 12px;
  padding-bottom: calc(8px + var(--safe-bottom));
  display: flex;
  gap: 8px;
  z-index: 100;
  box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
}
.bottom-btn {
  flex: 1;
  padding: 10px 8px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: white;
  cursor: pointer;
  font-size: 0.8em;
  font-weight: 500;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  transition: all 0.2s;
}
.bottom-btn:active { transform: scale(0.95); }
.bottom-btn .icon { font-size: 1.3em; }
.bottom-btn.primary { background: var(--primary); color: white; border-color: var(--primary); }
.bottom-btn.success { background: var(--success); color: white; border-color: var(--success); }
.bottom-btn.danger { background: var(--danger); color: white; border-color: var(--danger); }

/* ===== 主区域 ===== */
.container {
  padding: 12px;
  max-width: 100%;
}
.panel {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  margin-bottom: 12px;
  overflow: hidden;
}
.panel-header {
  padding: 12px 14px;
  font-weight: 600;
  font-size: 0.92em;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  background: #fafbfc;
}
.panel-body { padding: 12px; }

/* ===== 上传区 ===== */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 28px 16px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: #fafbfc;
}
.upload-zone:active, .upload-zone.dragover {
  border-color: var(--primary);
  background: rgba(79, 70, 229, 0.06);
}
.upload-zone .icon { font-size: 2.2em; margin-bottom: 8px; }
.upload-zone .main-text { font-size: 0.95em; color: var(--text); margin-bottom: 3px; }
.upload-zone .sub-text { font-size: 0.78em; color: var(--text-light); }

/* ===== 图片缩略图 ===== */
.image-list {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 8px 0;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.image-list::-webkit-scrollbar { display: none; }
.image-thumb {
  flex-shrink: 0;
  width: 64px;
  height: 64px;
  border-radius: 8px;
  overflow: visible;
  position: relative;
  cursor: pointer;
  border: 2px solid var(--border);
  transition: all 0.2s;
  user-select: none;
}
.image-thumb:active { border-color: var(--primary); }
.image-thumb img { width: 100%; height: 100%; object-fit: cover; border-radius: 6px; }
.image-thumb .remove-btn {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 22px;
  height: 22px;
  background: var(--danger);
  color: white;
  border-radius: 50%;
  border: 2px solid white;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
  line-height: 1;
}
.image-thumb .index {
  position: absolute;
  bottom: 0;
  left: 0;
  background: rgba(0,0,0,0.75);
  color: white;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 0 8px 0 0;
}
.image-thumb.selected { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.2); }

/* ===== 预览区 ===== */
.preview-area {
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  background: repeating-conic-gradient(#f1f5f9 0% 25%, transparent 0% 50%) 50% / 16px 16px;
  overflow: auto;
  position: relative;
}
.preview-area .zoom-controls {
  position: absolute;
  bottom: 12px;
  right: 12px;
  display: flex;
  gap: 6px;
  z-index: 10;
}
.zoom-controls button {
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: white;
  cursor: pointer;
  font-size: 1.1em;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
  transition: all 0.2s;
}
.zoom-controls button:active { transform: scale(0.9); background: var(--bg); }
.zoom-level {
  position: absolute;
  bottom: 16px;
  left: 12px;
  font-size: 0.72em;
  color: var(--text-light);
  background: white;
  padding: 3px 8px;
  border-radius: 6px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  font-weight: 600;
}
.canvas-wrap {
  display: inline-block;
  position: relative;
  max-width: 100%;
}
#resultCanvas {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
  box-shadow: 0 4px 15px rgba(0,0,0,0.15);
}
.empty-hint {
  text-align: center;
  padding: 24px 16px;
  color: var(--text-light);
  font-size: 0.85em;
}
.empty-hint .icon { font-size: 2em; margin-bottom: 8px; }

/* ===== 设置面板 ===== */
.settings-panel {
  background: white;
  position: fixed;
  top: 0;
  right: -100%;
  width: 85%;
  max-width: 360px;
  height: 100vh;
  z-index: 200;
  transition: right 0.3s ease;
  overflow-y: auto;
  padding-bottom: 80px;
}
.settings-panel.open { right: 0; }
.settings-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.4);
  z-index: 199;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}
.settings-overlay.open { opacity: 1; pointer-events: auto; }
.settings-header {
  padding: 16px;
  padding-top: calc(16px + env(safe-area-inset-top, 0px));
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  background: white;
  z-index: 1;
}
.settings-header h2 { font-size: 1.1em; }
.close-btn {
  width: 32px;
  height: 32px;
  border: none;
  background: var(--bg);
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.2em;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ===== 表单 ===== */
.form-group {
  margin-bottom: 14px;
  padding: 0 16px;
}
.form-group label {
  display: block;
  font-size: 0.82em;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--text-light);
}
.form-group select,
.form-group input[type="text"],
.form-group input[type="number"] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.9em;
  background: white;
  transition: border-color 0.2s;
  -webkit-appearance: none;
  appearance: none;
}
.form-group select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
}
.form-group select:focus,
.form-group input:focus {
  outline: none;
  border-color: var(--primary);
}
.form-group input[type="range"] {
  width: 100%;
  height: 6px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--border);
  border-radius: 3px;
  outline: none;
}
.form-group input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 24px;
  height: 24px;
  background: var(--primary);
  border-radius: 50%;
  cursor: pointer;
  border: 3px solid white;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}
.form-group input[type="color"] {
  width: 48px;
  height: 36px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  background: white;
}
.form-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.form-row > label {
  flex-shrink: 0;
  font-size: 0.82em;
  font-weight: 500;
  color: var(--text-light);
}
.form-row input[type="range"] { flex: 1; }
.form-row input[type="color"] { width: 48px; }
.form-row input[type="text"] { flex: 1; }
.form-value {
  min-width: 44px;
  text-align: right;
  font-size: 0.8em;
  color: var(--text-light);
  font-weight: 600;
}
.checkbox-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}
.checkbox-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82em;
  cursor: pointer;
}
.checkbox-item input {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
}
.divider {
  height: 1px;
  background: var(--border);
  margin: 14px 16px;
}
.section-title {
  font-size: 0.78em;
  font-weight: 600;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ===== 工具卡片（首页用） ===== */
.tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  padding: 12px;
}
.tool-card {
  background: white;
  border-radius: var(--radius);
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  padding: 20px 12px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  color: var(--text);
  border: 2px solid transparent;
}
.tool-card:hover { border-color: var(--primary); transform: translateY(-2px); box-shadow: 0 4px 12px rgba(79,70,229,0.15); }
.tool-card:active { transform: scale(0.97); }
.tool-card .tool-icon { font-size: 2em; margin-bottom: 8px; }
.tool-card .tool-name { font-size: 0.85em; font-weight: 600; }
.tool-card .tool-desc { font-size: 0.7em; color: var(--text-light); margin-top: 4px; }

/* ===== 按钮组 ===== */
.btn-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.btn {
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: white;
  cursor: pointer;
  font-size: 0.85em;
  font-weight: 500;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.btn:active { transform: scale(0.95); }
.btn.primary { background: var(--primary); color: white; border-color: var(--primary); }
.btn.success { background: var(--success); color: white; border-color: var(--success); }
.btn.danger { background: var(--danger); color: white; border-color: var(--danger); }
.btn.active { background: var(--primary); color: white; border-color: var(--primary); }

/* ===== 桌面版布局 ===== */
@media (min-width: 768px) {
  body { padding-bottom: 0; }
  .header { padding: 20px 30px; }
  .header h1 { font-size: 1.5em; }
  .container { max-width: 1400px; display: grid; grid-template-columns: 1fr 380px; gap: 20px; padding: 20px; }
  .bottom-bar { display: none; }
  .settings-panel {
    position: static;
    right: auto;
    width: auto;
    max-width: none;
    height: auto;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  }
  .settings-panel.open { right: auto; }
  .settings-overlay { display: none; }
  .settings-header { position: static; }
  .upload-zone { padding: 40px 20px; }
  .image-thumb { width: 70px; height: 70px; }
  .preview-area { min-height: 300px; }
  .tools-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px; padding: 20px; max-width: 1400px; margin: 0 auto; }
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--text);
  color: white;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 0.85em;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  z-index: 300;
  opacity: 0;
  transition: all 0.3s;
  white-space: nowrap;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }

/* ===== 状态栏 ===== */
.stat-bar {
  display: flex;
  gap: 10px;
  font-size: 0.75em;
  color: var(--text-light);
  padding: 8px 12px;
  background: #f8fafc;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}
.stat-item { display: flex; align-items: center; gap: 3px; }
.stat-item strong { color: var(--text); }

/* ===== 通用 ===== */
.hidden { display: none !important; }
#fileInput { display: none; }
