/* === APP NAV === */
.app-nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  height: 60px;
  padding: 0 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 16px;
}
.app-nav-logo {
  font-family: var(--font-serif);
  font-size: 20px;
  font-weight: 700;
  color: var(--fg);
  text-decoration: none;
  letter-spacing: -0.5px;
}
.app-nav-center {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--fg-muted);
}
.app-status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #22c55e;
  transition: background 0.3s;
}
.app-status-dot.loading { background: var(--accent); animation: pulse 1s infinite; }
.app-status-dot.error { background: #ef4444; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }
.app-nav-actions { display: flex; align-items: center; gap: 8px; }
.btn-icon {
  width: 36px; height: 36px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--fg-muted);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-icon:hover:not(:disabled) { background: var(--bg); color: var(--fg); }
.btn-icon:disabled { opacity: 0.35; cursor: not-allowed; }
.btn-primary {
  height: 36px;
  padding: 0 18px;
  background: var(--fg);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}
.btn-primary:hover:not(:disabled) { opacity: 0.8; }
.btn-primary:disabled { opacity: 0.35; cursor: not-allowed; }

/* === MAIN === */
.editor-main {
  padding-top: 60px;
  height: 100vh;
  overflow: hidden;
}

/* === UPLOAD ZONE === */
.upload-zone {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.upload-inner {
  text-align: center;
  max-width: 480px;
  padding: 40px;
}
.upload-icon {
  width: 80px; height: 80px;
  background: var(--surface);
  border: 2px dashed var(--border);
  border-radius: 20px;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 28px;
  color: var(--accent);
}
.upload-headline {
  font-family: var(--font-serif);
  font-size: 28px;
  font-weight: 700;
  color: var(--fg);
  margin-bottom: 12px;
}
.upload-sub {
  font-size: 15px;
  color: var(--fg-muted);
  margin-bottom: 32px;
}
.btn-upload {
  display: inline-block;
  height: 48px;
  padding: 0 32px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 12px;
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-upload:hover { background: var(--accent-dark); transform: translateY(-1px); }

/* === EDITOR LAYOUT === */
.editor-layout {
  display: flex;
  height: 100%;
  overflow: hidden;
}

/* === CANVAS === */
.editor-canvas-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-alt);
  overflow: auto;
  padding: 24px;
}
.canvas-container {
  position: relative;
  display: inline-block;
  max-width: 100%;
  max-height: calc(100vh - 108px);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 8px 40px rgba(26,26,26,0.12);
}
.canvas-container canvas {
  display: block;
  max-width: 100%;
  max-height: calc(100vh - 108px);
}
#overlayCanvas {
  position: absolute;
  top: 0; left: 0;
  pointer-events: none;
}

/* === COMPARE SLIDER === */
.compare-slider {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}
.compare-divider {
  position: absolute;
  top: 0; bottom: 0;
  width: 4px;
  cursor: ew-resize;
  z-index: 10;
}
.compare-line {
  position: absolute;
  top: 0; bottom: 0;
  left: 50%;
  width: 2px;
  transform: translateX(-50%);
  background: #fff;
  box-shadow: 0 0 8px rgba(0,0,0,0.4);
}
.compare-handle {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 36px; height: 36px;
  background: #fff;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 12px rgba(0,0,0,0.25);
  pointer-events: all;
  color: var(--fg);
}
.compare-label {
  position: absolute;
  bottom: 16px;
  padding: 6px 14px;
  background: rgba(0,0,0,0.6);
  color: #fff;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font-sans);
  pointer-events: none;
}
.before-label { left: 16px; }
.after-label { right: 16px; }

/* === CONTROLS === */
.editor-controls {
  width: 300px;
  flex-shrink: 0;
  background: var(--surface);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}
.control-section { }
.control-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--fg-muted);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.control-hint {
  font-size: 12px;
  color: var(--fg-muted);
  line-height: 1.5;
  margin-bottom: 14px;
}
.ai-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  background: var(--accent);
  color: #fff;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0;
}

/* === PRESETS === */
.presets-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.preset-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 8px 4px;
  background: transparent;
  border: 2px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.15s;
}
.preset-btn:hover { background: var(--bg); }
.preset-btn.active { border-color: var(--accent); background: var(--bg); }
.preset-swatch {
  width: 44px; height: 44px;
  border-radius: 8px;
  box-shadow: 0 2px 6px rgba(26,26,26,0.12);
}
.preset-btn span {
  font-size: 10px;
  font-weight: 500;
  color: var(--fg-muted);
}
.preset-btn.active span { color: var(--accent); font-weight: 600; }

/* === BEAUTIFY === */
.beautify-controls { display: flex; flex-direction: column; gap: 12px; }
.beautify-strength-wrap { display: flex; flex-direction: column; gap: 6px; }
.beautify-label {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 500;
  color: var(--fg);
}
.beautify-val { color: var(--accent); font-weight: 600; }
.beautify-range {
  width: 100%;
  height: 4px;
  border-radius: 2px;
  background: var(--bg-alt);
  -webkit-appearance: none;
  appearance: none;
  outline: none;
  cursor: pointer;
}
.beautify-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}
.btn-beautify {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 44px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-warm) 100%);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-beautify:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 4px 16px rgba(200,137,60,0.3); }
.btn-beautify:disabled { opacity: 0.4; cursor: not-allowed; }
.beautify-status {
  font-size: 11px;
  color: var(--fg-muted);
  text-align: center;
  padding: 4px;
}

/* === EXPORT === */
.export-formats { display: flex; gap: 8px; margin-bottom: 12px; }
.format-btn {
  flex: 1;
  height: 36px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 600;
  color: var(--fg-muted);
  cursor: pointer;
  transition: all 0.15s;
}
.format-btn.active {
  background: var(--fg);
  color: #fff;
  border-color: var(--fg);
}
.export-quality-wrap { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.btn-export {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 48px;
  background: var(--fg);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-export:hover:not(:disabled) { opacity: 0.8; transform: translateY(-1px); }
.btn-export:disabled { opacity: 0.35; cursor: not-allowed; }

/* === RESPONSIVE === */
@media (max-width: 768px) {
  .editor-layout { flex-direction: column; }
  .editor-controls {
    width: 100%;
    border-left: none;
    border-top: 1px solid var(--border);
    max-height: 280px;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 16px;
    padding: 16px;
  }
  .control-section { min-width: 140px; }
  .presets-grid { grid-template-columns: repeat(8, 1fr); }
}
@media (max-width: 480px) {
  .app-nav { padding: 0 16px; }
  .editor-controls { max-height: 240px; }
  .control-section { min-width: 100%; }
}