:root {
  --bg-main: #161618;
  --bg-card: #202023;
  --bg-card-hover: #26262a;
  --border-color: rgba(255, 255, 255, 0.08);
  --border-focus: #0071e3;
  --text-main: #f5f5f7;
  --text-muted: #8e8e93;
  --accent: #0071e3;
  --accent-hover: #0077ed;
  --success: #34c759;
  --danger: #ff453a;
  --radius-lg: 14px;
  --radius-md: 10px;
  --radius-sm: 6px;
  --font-stack: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Helvetica Neue", sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: var(--font-stack);
  background-color: var(--bg-main);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* Header */
.app-header {
  height: 56px;
  border-bottom: 1px solid var(--border-color);
  background: #1a1a1d;
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-main);
}

.logo-title {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.2px;
  color: var(--text-main);
}

.logo-badge {
  font-size: 11px;
  font-weight: 500;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
  padding: 2px 7px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Main Layout */
.app-main {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 400px;
  max-width: 1500px;
  width: 100%;
  margin: 0 auto;
  padding: 20px;
  gap: 20px;
}

@media (max-width: 1024px) {
  .app-main {
    grid-template-columns: 1fr;
  }
}

/* Preview Stage */
.preview-stage {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.viewport-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 8px 14px;
  border-radius: var(--radius-md);
}

.bg-switcher {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
}

.bg-btn {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.15);
  cursor: pointer;
  transition: transform 0.15s;
}

.bg-btn:hover {
  transform: scale(1.08);
}

.bg-btn.active {
  outline: 2px solid #ffffff;
  outline-offset: 2px;
}

.bg-checker {
  background-color: #2a2a2e;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16'%3E%3Crect width='8' height='8' fill='%23222226'/%3E%3Crect x='8' y='8' width='8' height='8' fill='%23222226'/%3E%3C/svg%3E");
}

.bg-sequoia {
  background: #1c1c1e;
}

.bg-sonoma {
  background: #2c2c2e;
}

.bg-light {
  background: #f2f2f7;
}

.bg-black {
  background: #000000;
}

.viewport-info {
  font-size: 12px;
  color: var(--text-muted);
}

/* Canvas Area */
.canvas-wrapper {
  flex: 1;
  min-height: 520px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  user-select: none;
}

.canvas-wrapper.drag-over {
  border-color: var(--accent);
  background: rgba(255, 255, 255, 0.03);
}

#folderCanvas {
  max-width: 90%;
  max-height: 500px;
  width: auto;
  height: auto;
  cursor: grab;
}

#folderCanvas:active {
  cursor: grabbing;
}

.drop-overlay-prompt {
  position: absolute;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  color: var(--text-muted);
  background: rgba(26, 26, 29, 0.9);
  padding: 24px 32px;
  border-radius: var(--radius-md);
  border: 1px dashed rgba(255, 255, 255, 0.15);
}

.drop-overlay-prompt.hidden {
  display: none;
}

.drop-icon {
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
}

.canvas-hint {
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
}

/* Quick Actions Below Canvas */
.canvas-actions-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: rgba(255, 255, 255, 0.07);
  color: var(--text-main);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  text-decoration: none;
}

.btn:hover {
  background: rgba(255, 255, 255, 0.11);
  border-color: rgba(255, 255, 255, 0.14);
}

.btn:active {
  background: rgba(255, 255, 255, 0.05);
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn svg {
  flex-shrink: 0;
  stroke: currentColor;
}

/* Sidebar Controls */
.controls-sidebar {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  height: fit-content;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
}

.controls-sidebar::-webkit-scrollbar {
  width: 5px;
}
.controls-sidebar::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
}

.section-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 8px;
}

/* Mode Switcher Tabs */
.mode-tabs {
  display: flex;
  background: rgba(0, 0, 0, 0.25);
  border-radius: var(--radius-sm);
  padding: 3px;
  gap: 3px;
  border: 1px solid var(--border-color);
}

.tab-btn {
  flex: 1;
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 500;
  background: transparent;
  color: var(--text-muted);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tab-btn:hover {
  color: var(--text-main);
}

.tab-btn.active {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
}

/* Form Controls & Sliders */
.control-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: rgba(0, 0, 0, 0.15);
  padding: 12px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.slider-row {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.slider-label {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 400;
  color: var(--text-main);
}

.slider-val {
  color: var(--text-muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 2px;
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #ffffff;
  cursor: pointer;
  border: 1px solid rgba(0, 0, 0, 0.2);
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.1);
}

/* Color Palette */
.color-palette {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  margin-top: 6px;
}

.color-swatch {
  height: 28px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.1);
  cursor: pointer;
  transition: transform 0.15s;
  position: relative;
}

.color-swatch:hover {
  transform: scale(1.05);
}

.color-swatch.active {
  outline: 2px solid #ffffff;
  outline-offset: 2px;
}

.custom-color-picker {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}

.custom-color-picker input[type="color"] {
  -webkit-appearance: none;
  border: none;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  cursor: pointer;
  background: transparent;
}

/* Shape / Effect Pills */
.pill-group {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}

.pill-btn {
  padding: 7px 10px;
  font-size: 12px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  cursor: pointer;
  text-align: center;
  transition: background 0.15s, color 0.15s;
}

.pill-btn:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.08);
}

.pill-btn.active {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.22);
  color: #ffffff;
}

/* Toggle Checkbox */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  cursor: pointer;
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: rgba(255, 255, 255, 0.18);
  transition: 0.2s;
  border-radius: 20px;
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 14px;
  width: 14px;
  left: 3px;
  bottom: 3px;
  background-color: #ffffff;
  transition: 0.2s;
  border-radius: 50%;
}

input:checked + .toggle-slider {
  background-color: var(--accent);
}

input:checked + .toggle-slider:before {
  transform: translateX(16px);
}

/* Notifications Toast */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #252528;
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 12px 18px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  transform: translateY(100px);
  opacity: 0;
  transition: transform 0.25s ease-out, opacity 0.25s ease-out;
  z-index: 9999;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.toast.success {
  border-color: var(--success);
}

.toast.error {
  border-color: var(--danger);
}

.toast.info {
  border-color: rgba(255, 255, 255, 0.18);
}

.toast-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}

.toast.success .toast-dot {
  background: var(--success);
}

.toast.error .toast-dot {
  background: var(--danger);
}

.toast.info .toast-dot {
  background: #a1a1a6;
}
