/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary: #4F46E5;
  --primary-hover: #4338CA;
  --accent: #F59E0B;
  --accent-hover: #D97706;
  --bg: #F8FAFC;
  --surface: #FFFFFF;
  --border: #E2E8F0;
  --text: #1E293B;
  --text-muted: #64748B;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-lg: 0 10px 25px rgba(0,0,0,.08);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

.container { max-width: 1100px; margin: 0 auto; padding: 0 20px; }

/* ===== Header ===== */
.header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
}
.header-inner { display: flex; align-items: center; justify-content: space-between; height: 56px; }
.logo { font-size: 1.2rem; font-weight: 700; color: var(--primary); text-decoration: none; }
.nav { display: flex; gap: 8px; }
.nav-link {
  padding: 6px 14px; border-radius: 20px; font-size: .875rem; text-decoration: none;
  color: var(--text-muted); transition: all .2s;
}
.nav-link.active { background: var(--primary); color: #fff; }
.nav-link.disabled { opacity: .5; cursor: not-allowed; }

/* ===== Hero ===== */
.hero {
  background: linear-gradient(135deg, #4F46E5 0%, #7C3AED 100%);
  color: #fff; padding: 48px 0; text-align: center;
}
.hero h1 { font-size: 2rem; margin-bottom: 12px; }
.hero-desc { font-size: 1rem; opacity: .9; line-height: 1.8; margin-bottom: 20px; }
.hero-features { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.feature-tag {
  background: rgba(255,255,255,.2); backdrop-filter: blur(4px);
  padding: 6px 14px; border-radius: 20px; font-size: .85rem;
}

/* ===== Tool Section ===== */
.tool-section { padding: 32px 0 60px; }

/* ===== Step Indicator ===== */
.steps {
  display: flex; justify-content: center; gap: 0; margin-bottom: 32px;
  background: var(--surface); border-radius: var(--radius); padding: 4px;
  box-shadow: var(--shadow); overflow-x: auto;
}
.step {
  display: flex; align-items: center; gap: 6px; padding: 10px 18px;
  font-size: .85rem; color: var(--text-muted); white-space: nowrap;
  transition: all .3s; cursor: default; position: relative;
}
.step:not(:last-child)::after { content: '▸'; margin-left: 4px; opacity: .3; }
.step-num {
  width: 24px; height: 24px; border-radius: 50%; background: var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: .75rem; font-weight: 600; transition: all .3s;
}
.step.active { color: var(--primary); font-weight: 600; }
.step.active .step-num { background: var(--primary); color: #fff; }
.step.done { color: #10B981; }
.step.done .step-num { background: #10B981; color: #fff; }

/* ===== Panels ===== */
.panel {
  background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); padding: 32px;
}
.panel.hidden { display: none; }

/* ===== Upload ===== */
.upload-zone {
  border: 2px dashed var(--border); border-radius: var(--radius);
  padding: 60px 20px; text-align: center; cursor: pointer;
  transition: all .3s; margin-bottom: 24px;
}
.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--primary); background: #EEF2FF;
}
.upload-icon { font-size: 3rem; margin-bottom: 12px; }
.upload-title { font-size: 1.1rem; font-weight: 600; margin-bottom: 8px; }
.upload-hint { color: var(--text-muted); font-size: .85rem; }
.upload-tips {
  background: #FFFBEB; border: 1px solid #FDE68A; border-radius: var(--radius);
  padding: 20px 24px;
}
.upload-tips h4 { font-size: .95rem; margin-bottom: 8px; }
.upload-tips ul { padding-left: 20px; font-size: .9rem; color: var(--text-muted); }
.upload-tips li { margin-bottom: 4px; }

/* ===== Editor Layout ===== */
.editor-layout { display: flex; gap: 24px; }
.editor-main { flex: 1; min-width: 0; }
.editor-sidebar { width: 260px; flex-shrink: 0; }
.editor-sidebar h3 { font-size: 1.05rem; margin-bottom: 16px; }
.editor-sidebar h4 { font-size: .9rem; margin: 12px 0 8px; color: var(--text-muted); }

@media (max-width: 768px) {
  .editor-layout { flex-direction: column; }
  .editor-sidebar { width: 100%; }
}

/* ===== Crop ===== */
.crop-container {
  position: relative; width: 100%; max-height: 500px; overflow: hidden;
  background: #0F172A; border-radius: var(--radius); display: flex;
  align-items: center; justify-content: center; user-select: none;
}
.crop-container canvas { max-width: 100%; max-height: 500px; display: block; }
.crop-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; }

/* ===== Controls ===== */
.control-group { margin-bottom: 16px; }
.control-group label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: 6px; }
.control-group .hint { display: block; font-size: .75rem; color: var(--text-muted); margin-top: 4px; }
.control-group input[type="range"] { width: 100%; accent-color: var(--primary); }
.control-group input[type="color"] { width: 44px; height: 36px; border: 2px solid var(--border); border-radius: 6px; cursor: pointer; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 20px; border-radius: 8px; font-size: .9rem; font-weight: 500;
  border: none; cursor: pointer; transition: all .2s; font-family: inherit;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); transform: translateY(-1px); }
.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover { background: var(--accent-hover); }
.btn-outline { background: var(--surface); border: 2px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-outline.active { border-color: var(--primary); color: var(--primary); background: #EEF2FF; }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { color: var(--text); background: #F1F5F9; }
.btn-sm { padding: 6px 12px; font-size: .8rem; }
.btn-block { width: 100%; margin-top: 8px; }
.btn-row { display: flex; gap: 8px; }
.btn-row .btn { flex: 1; }
.btn-group { display: flex; gap: 4px; flex-wrap: wrap; }
.btn-group .btn { flex: 1; white-space: nowrap; font-size: .8rem; padding: 8px 12px; }

/* ===== Preview ===== */
.preview-box {
  text-align: center; padding: 12px; background: #F1F5F9;
  border-radius: var(--radius);
}
.preview-box canvas { display: block; margin: 0 auto; border: 1px solid var(--border); border-radius: 4px; }
.preview-label { font-size: .75rem; color: var(--text-muted); margin-top: 6px; display: block; }

/* ===== Compare View ===== */
.compare-view { display: flex; align-items: center; justify-content: center; gap: 16px; flex-wrap: wrap; }
.compare-item { text-align: center; }
.compare-item canvas { max-width: 280px; max-height: 380px; border-radius: 8px; box-shadow: var(--shadow); border: 1px solid var(--border); }
.compare-label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: 8px; }
.compare-arrow { font-size: 1.5rem; color: var(--text-muted); }

/* ===== Color Presets ===== */
.color-presets { display: flex; gap: 8px; }
.color-preset {
  width: 44px; height: 44px; border-radius: 50%; border: 3px solid transparent;
  cursor: pointer; transition: all .2s; position: relative; display: flex;
  align-items: center; justify-content: center;
}
.color-preset span { font-size: .65rem; font-weight: 600; color: #333; }
.color-preset.active { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(79,70,229,.3); }
.color-preset:hover { transform: scale(1.1); }

/* ===== Export ===== */
.export-layout { display: flex; gap: 24px; }
.export-left { flex: 1; }
.export-right { width: 320px; flex-shrink: 0; }
.export-right h4 { margin-bottom: 12px; }
.final-preview { text-align: center; }
.final-preview canvas { max-width: 100%; border-radius: 8px; box-shadow: var(--shadow); }

.layout-previews { display: flex; gap: 12px; margin-top: 8px; }
.layout-card {
  flex: 1; text-align: center; padding: 12px;
  border: 1px solid var(--border); border-radius: var(--radius);
}
.layout-card canvas { display: block; margin: 0 auto 8px; border: 1px solid #eee; border-radius: 4px; }
.layout-card span { display: block; font-size: .8rem; margin-bottom: 8px; }

hr { border: none; border-top: 1px solid var(--border); margin: 16px 0; }

@media (max-width: 768px) {
  .export-layout { flex-direction: column-reverse; }
  .export-right { width: 100%; }
}

/* ===== Footer ===== */
.footer {
  text-align: center; padding: 32px 0; border-top: 1px solid var(--border);
  margin-top: 40px; color: var(--text-muted); font-size: .9rem;
}
.footer-small { font-size: .8rem; margin-top: 4px; }

/* ===== Utility ===== */
.hidden { display: none !important; }
