*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg-deepest: #080816;
  --bg-deep: #0d0d1a;
  --bg-panel: #12122a;
  --bg-toolbar: #1a1a2e;
  --bg-input: #0f0f24;
  --accent: #00d4ff;
  --accent-dim: rgba(0, 212, 255, 0.2);
  --accent-glow: rgba(0, 212, 255, 0.4);
  --coral: #ff6b6b;
  --lime: #7bed9f;
  --amber: #ffa502;
  --violet: #a855f7;
  --magenta: #ff6bde;
  --text: #e0e0e8;
  --text-dim: #8888a0;
  --text-muted: #55556a;
  --border: #2a2a45;
  --font-sans: 'IBM Plex Sans', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

html, body, #root {
  width: 100%; height: 100%; overflow: hidden;
  background: var(--bg-deepest);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 13px;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

/* Custom scrollbar */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

input[type="number"], input[type="text"], select {
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 4px;
  padding: 4px 6px;
  font-family: var(--font-mono);
  font-size: 12px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  min-width: 0;
}
input[type="number"]:focus, input[type="text"]:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-dim);
}
input[type="number"] { width: 60px; }

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  cursor: pointer;
  height: 16px;
}
input[type="range"]::-webkit-slider-track {
  height: 3px;
  background: var(--border);
  border-radius: 2px;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--accent);
  margin-top: -5.5px;
  box-shadow: 0 0 6px var(--accent-glow);
}

input[type="color"] {
  -webkit-appearance: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  width: 28px; height: 28px;
  padding: 0;
  cursor: pointer;
  background: transparent;
  flex-shrink: 0;
}
input[type="color"]::-webkit-color-swatch-wrapper { padding: 2px; }
input[type="color"]::-webkit-color-swatch { border: none; border-radius: 2px; }

button {
  font-family: var(--font-sans);
  cursor: pointer;
  transition: all 0.15s;
}

.panel-section {
  border-bottom: 1px solid var(--border);
  padding: 12px;
}
.panel-section:last-child { border-bottom: none; }

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

.control-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
  gap: 8px;
}
.control-row label {
  font-size: 12px;
  color: var(--text-dim);
  min-width: 50px;
  flex-shrink: 0;
}

.btn-icon {
  display: flex; align-items: center; justify-content: center;
  width: 32px; height: 32px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  color: var(--text-dim);
  transition: all 0.15s;
  flex-shrink: 0;
}
.btn-icon:hover {
  background: rgba(255,255,255,0.05);
  color: var(--text);
  border-color: var(--border);
}
.btn-icon.active {
  background: var(--accent-dim);
  color: var(--accent);
  border-color: var(--accent);
}

.btn-primary {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px;
  background: var(--accent);
  color: var(--bg-deepest);
  border: none;
  border-radius: 5px;
  font-weight: 600;
  font-size: 12px;
}
.btn-primary:hover {
  background: #33dfff;
  box-shadow: 0 0 12px var(--accent-glow);
}

.btn-danger {
  display: flex; align-items: center; justify-content: center; gap: 4px;
  padding: 4px 10px;
  background: rgba(255, 107, 107, 0.15);
  color: var(--coral);
  border: 1px solid rgba(255, 107, 107, 0.3);
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
}
.btn-danger:hover {
  background: rgba(255, 107, 107, 0.25);
}

.layer-card {
  display: flex; align-items: center; gap: 6px;
  padding: 8px;
  border-radius: 6px;
  border: 1px solid transparent;
  margin-bottom: 4px;
  cursor: pointer;
  transition: all 0.15s;
}
.layer-card:hover { background: rgba(255,255,255,0.03); }
.layer-card.active {
  border-color: var(--accent);
  background: var(--accent-dim);
  box-shadow: 0 0 12px rgba(0, 212, 255, 0.08);
}

.segmented-btn {
  display: flex; border: 1px solid var(--border); border-radius: 5px; overflow: hidden;
}
.segmented-btn button {
  flex: 1;
  padding: 5px 6px;
  font-size: 11px;
  background: transparent;
  border: none;
  border-right: 1px solid var(--border);
  color: var(--text-dim);
  font-family: var(--font-mono);
  white-space: nowrap;
}
.segmented-btn button:last-child { border-right: none; }
.segmented-btn button.active {
  background: var(--accent-dim);
  color: var(--accent);
}
.segmented-btn button:hover:not(.active) {
  background: rgba(255,255,255,0.03);
}

/* Tooltip */
.guide-tooltip {
  position: fixed;
  background: var(--bg-toolbar);
  border: 1px solid var(--accent);
  color: var(--text);
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-family: var(--font-mono);
  pointer-events: none;
  z-index: 1000;
  box-shadow: 0 2px 12px rgba(0,0,0,0.5);
  white-space: nowrap;
}

/* Modal overlay */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  z-index: 9999;
  padding: 16px;
}
.modal-box {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  min-width: 280px;
  max-width: 500px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 8px 40px rgba(0,0,0,0.5);
}
.modal-box h2 {
  font-family: var(--font-mono);
  font-size: 16px;
  margin-bottom: 16px;
  color: var(--accent);
}

/* Floating action toolbar */
.floating-toolbar {
  position: fixed;
  background: var(--bg-toolbar);
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 6px 10px;
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 4px 20px rgba(0, 212, 255, 0.15);
  z-index: 100;
}

/* Export dropdown */
.dropdown {
  position: relative;
}
.dropdown-menu {
  position: absolute;
  top: 100%;
  right: 0;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px;
  min-width: 180px;
  z-index: 1000;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.dropdown-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 7px 12px;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 12px;
  border-radius: 4px;
}
.dropdown-item:hover {
  background: var(--accent-dim);
  color: var(--accent);
}

/* Context menu */
.context-menu {
  position: fixed;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px;
  min-width: 200px;
  z-index: 10000;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}
.context-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  padding: 7px 12px;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 12px;
  border-radius: 4px;
  cursor: pointer;
}
.context-menu-item:hover {
  background: var(--accent-dim);
  color: var(--accent);
}
.context-menu-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

@keyframes fadeIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } }
.animate-in { animation: fadeIn 0.15s ease; }

/* Preset cards */
.preset-card {
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
  text-align: left;
  width: 100%;
  color: var(--text);
}
.preset-card:hover {
  border-color: var(--accent);
  background: var(--accent-dim);
}
.preset-card .preset-name {
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 2px;
}
.preset-card .preset-desc {
  font-size: 11px;
  color: var(--text-dim);
}

/* Mobile sidebar overlay */
.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 40;
}

/* Mobile panel tab buttons */
.mobile-panel-tab {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: var(--bg-toolbar);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-dim);
  cursor: pointer;
  flex-shrink: 0;
}
.mobile-panel-tab.active {
  background: var(--accent-dim);
  color: var(--accent);
  border-color: var(--accent);
}

/* Swatch row */
.swatch-row {
  display: flex;
  gap: 4px;
  align-items: center;
  flex-wrap: wrap;
}
.swatch {
  width: 18px; height: 18px;
  border-radius: 3px;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.1s;
}
.swatch:hover { transform: scale(1.15); }