/* ═══ Layout ═══ */
.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  background: var(--surface, #0d0d1a);
  border-bottom: 1px solid var(--border, #1e1e3a);
  flex-wrap: wrap;
  gap: 0.75rem;
}

.header-left .eyebrow {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #00ffff;
  margin: 0 0 0.15rem;
}

.header-left h1 {
  font-size: 1.4rem;
  margin: 0;
  font-weight: 800;
  background: linear-gradient(90deg, #ff00ff, #00ffff);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.btn-action {
  background: var(--surface-2, #12122a);
  color: var(--text, #e2e8f0);
  border: 1px solid var(--border, #1e1e3a);
  border-radius: 8px;
  padding: 0.4rem 0.8rem;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-action:hover {
  border-color: #00ffff;
  box-shadow: 0 0 8px rgba(0, 255, 255, 0.2);
}

.btn-danger:hover {
  border-color: #ff0066;
  box-shadow: 0 0 8px rgba(255, 0, 102, 0.2);
}

/* ═══ Workspace ═══ */
.workspace {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ═══ Sidebar ═══ */
.sidebar {
  width: 260px;
  background: var(--surface, #0d0d1a);
  border-right: 1px solid var(--border, #1e1e3a);
  overflow-y: auto;
  padding: 0.75rem;
  flex-shrink: 0;
}

.panel-section {
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border, #1e1e3a);
}

.panel-section:last-child {
  border-bottom: none;
}

.section-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: #ff00ff;
  margin: 0 0 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ═══ Controls ═══ */
.size-controls {
  display: flex;
  gap: 0.5rem;
}

.input-select {
  flex: 1;
  background: var(--surface-2, #12122a);
  color: var(--text, #e2e8f0);
  border: 1px solid var(--border, #1e1e3a);
  border-radius: 8px;
  padding: 0.4rem 0.6rem;
  font-size: 0.85rem;
  cursor: pointer;
}

.btn-small {
  background: var(--surface-2, #12122a);
  color: #00ffff;
  border: 1px solid #00ffff30;
  border-radius: 6px;
  padding: 0.4rem 0.7rem;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-small:hover {
  background: #00ffff15;
  border-color: #00ffff;
}

/* ═══ Tools ═══ */
.tool-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.4rem;
}

.tool-btn {
  background: var(--surface-2, #12122a);
  border: 1px solid var(--border, #1e1e3a);
  border-radius: 8px;
  padding: 0.5rem;
  font-size: 1.2rem;
  cursor: pointer;
  transition: all 0.2s;
}

.tool-btn:hover {
  border-color: #ff00ff;
}

.tool-btn.active {
  border-color: #ff00ff;
  background: #ff00ff15;
  box-shadow: 0 0 10px rgba(255, 0, 255, 0.2);
}

/* ═══ Brush Size ═══ */
.brush-size-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.range-input {
  flex: 1;
  -webkit-appearance: none;
  height: 4px;
  background: var(--border, #1e1e3a);
  border-radius: 2px;
  outline: none;
}

.range-input::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #ff00ff;
  cursor: pointer;
  box-shadow: 0 0 8px rgba(255, 0, 255, 0.5);
}

.range-label {
  font-size: 0.8rem;
  color: #00ffff;
  font-weight: 600;
  min-width: 30px;
}

/* ═══ Palette ═══ */
.palette {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 3px;
  margin-bottom: 0.5rem;
}

.palette-color {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 4px;
  border: 2px solid transparent;
  cursor: pointer;
  transition: all 0.15s;
}

.palette-color:hover {
  transform: scale(1.15);
  z-index: 1;
}

.palette-color.active {
  border-color: #fff;
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.4);
}

.color-input-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.color-picker {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  background: none;
  padding: 0;
}

.color-hex {
  font-size: 0.8rem;
  font-family: monospace;
  color: #00ffff;
}

/* ═══ Layers ═══ */
.layers-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 0.5rem;
  max-height: 160px;
  overflow-y: auto;
}

.layer-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.5rem;
  background: var(--surface-2, #12122a);
  border: 1px solid var(--border, #1e1e3a);
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.8rem;
  transition: all 0.15s;
}

.layer-item:hover {
  border-color: #00ffff;
}

.layer-item.active {
  border-color: #ff00ff;
  background: #ff00ff10;
}

.layer-visibility {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.9rem;
  padding: 0;
}

.layer-name {
  flex: 1;
  color: var(--text, #e2e8f0);
}

.layer-actions {
  display: flex;
  gap: 0.4rem;
}

/* ═══ Effects ═══ */
.effect-btns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem;
}

.btn-effect {
  background: var(--surface-2, #12122a);
  color: var(--text, #e2e8f0);
  border: 1px solid var(--border, #1e1e3a);
  border-radius: 8px;
  padding: 0.4rem;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-effect:hover {
  border-color: #a855f7;
  box-shadow: 0 0 8px rgba(168, 85, 247, 0.2);
}

/* ═══ History ═══ */
.history-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.history-count {
  font-size: 0.75rem;
  color: var(--text-muted, #64748b);
  margin-left: auto;
}

/* ═══ Canvas Area ═══ */
.canvas-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #080810;
  position: relative;
  overflow: hidden;
}

.canvas-wrapper {
  position: relative;
  border: 2px solid #1e1e3a;
  box-shadow:
    0 0 40px rgba(255, 0, 255, 0.1),
    0 0 80px rgba(0, 255, 255, 0.05);
}

.pixel-canvas {
  display: block;
  image-rendering: pixelated;
  cursor: crosshair;
}

.grid-overlay {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
  image-rendering: pixelated;
}

.preview-canvas {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
  image-rendering: pixelated;
}

.canvas-info {
  display: flex;
  gap: 1.5rem;
  margin-top: 0.75rem;
  font-size: 0.75rem;
  font-family: monospace;
  color: #00ffff;
  opacity: 0.7;
}

/* ═══ Scrollbar ═══ */
.sidebar::-webkit-scrollbar {
  width: 4px;
}

.sidebar::-webkit-scrollbar-thumb {
  background: #1e1e3a;
  border-radius: 2px;
}

/* ═══ Responsive ═══ */
@media (max-width: 768px) {
  .workspace {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    max-height: 40vh;
    border-right: none;
    border-bottom: 1px solid var(--border, #1e1e3a);
  }

  .palette {
    grid-template-columns: repeat(10, 1fr);
  }
}
