* {
  box-sizing: border-box;
}

body {
  font-family: "Fira Code", "SF Mono", "Monaco", "Inconsolata", "Roboto Mono",
    monospace;
  margin: 0;
  padding: 0;
  background-color: #f8fafc;
  height: 100vh;
  overflow: hidden;
  color: #09090b;
}

.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: relative;
}

/* Command Palette */
.command-palette {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 600px;
  max-height: 80vh;
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  z-index: 1000;
  display: none;
  overflow: hidden;
  border: 1px solid #e4e4e7;
}

.command-palette.active {
  display: block;
  animation: commandPaletteIn 0.2s ease-out;
}

@keyframes commandPaletteIn {
  from {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}

.command-palette-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid #e4e4e7;
  background: #fafafa;
}

.command-palette-header svg {
  color: #71717a;
  flex-shrink: 0;
}

.command-palette-header input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 16px;
  background: transparent;
  color: #09090b;
  font-family: "Fira Code", monospace;
}

.command-palette-header input::placeholder {
  color: #a1a1aa;
}

.close-palette {
  background: none;
  border: none;
  padding: 4px;
  border-radius: 4px;
  color: #71717a;
  cursor: pointer;
  transition: all 0.15s ease;
}

.close-palette:hover {
  background: #f4f4f5;
  color: #09090b;
}

.command-palette-content {
  max-height: 60vh;
  overflow-y: auto;
  padding: 8px;
}

.command-section {
  margin-bottom: 24px;
}

.command-section:last-child {
  margin-bottom: 8px;
}

.command-section-title {
  font-size: 11px;
  font-weight: 600;
  color: #71717a;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
  padding: 0 12px;
}

.command-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: #09090b;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: "Fira Code", monospace;
  font-size: 13px;
  text-align: left;
}

.command-item:hover,
.command-item:focus {
  background: #f4f4f5;
  outline: none;
}

.command-item svg {
  flex-shrink: 0;
  color: #71717a;
}

.command-item span:first-of-type {
  flex: 1;
}

.shortcut {
  font-size: 11px;
  color: #a1a1aa;
  background: #f4f4f5;
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid #e4e4e7;
}

/* Color Presets in Command Palette */
.color-presets {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 8px;
  margin: 12px 0;
}

.preset-color {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all 0.15s ease;
  position: relative;
}

.preset-color:hover {
  scale: 1.05;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.preset-color.active {
  border-color: #09090b;
  box-shadow: 0 0 0 2px rgba(9, 9, 11, 0.1);
}

.preset-color.active::after {
  content: "✓";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: rgba(255, 255, 255, 0.9);
  font-size: 18px;
  font-weight: bold;
  text-shadow: 0 0 3px rgba(0, 0, 0, 0.7);
}

.preset-color[data-color="#ffffff"].active::after,
.preset-color[data-color="#f59e0b"].active::after {
  color: #09090b;
  text-shadow: 0 0 3px rgba(255, 255, 255, 0.7);
}

.custom-color-section {
  margin-top: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.custom-color-section label {
  font-size: 12px;
  font-weight: 500;
  color: #09090b;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

input[type="color"] {
  width: 40px;
  height: 32px;
  border: 1px solid #e4e4e7;
  border-radius: 6px;
  cursor: pointer;
  transition: border-color 0.15s ease;
  background: #ffffff;
  padding: 0;
}

input[type="color"]:hover {
  border-color: #d4d4d8;
}

input[type="color"]:focus {
  outline: none;
  border-color: #09090b;
  box-shadow: 0 0 0 2px rgba(9, 9, 11, 0.1);
}

/* Floating Toolbar */
.floating-toolbar {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 24px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(20px);
  border: 1px solid #e4e4e7;
  border-radius: 16px;
  padding: 8px 12px;
  z-index: 100;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.command-palette-trigger {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background-color: #ffffff;
  border: 1px solid #e4e4e7;
  cursor: pointer;
  transition: all 0.15s ease;
  color: #71717a;
}

.command-palette-trigger:hover {
  background-color: #f4f4f5;
  border-color: #d4d4d8;
  color: #09090b;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  font-weight: 600;
  color: #09090b;
  letter-spacing: -0.025em;
}

.logo svg {
  flex-shrink: 0;
}

.toolbar-center {
  display: flex;
  align-items: center;
  gap: 16px;
}

.tool-buttons {
  display: flex;
  gap: 4px;
  background: #f4f4f5;
  border-radius: 10px;
}

.toolbar-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  border: 1px solid transparent;
  background-color: transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  position: relative;
  width: 40px;
  height: 40px;
  color: #71717a;
}

.toolbar-btn:hover {
  background-color: rgba(255, 255, 255, 0.8);
  border-color: #e4e4e7;
  color: #09090b;
}

.toolbar-btn.active {
  background-color: #ffffff;
  color: #09090b;
  border-color: #e4e4e7;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.tool-btn svg {
  flex-shrink: 0;
}

.clear-btn {
  background-color: #dc2626 !important;
  color: #ffffff !important;
  border-color: #dc2626 !important;
  width: auto !important;
  gap: 8px;
  padding: 0 12px;
  font-size: 12px;
  font-weight: 500;
  font-family: "Fira Code", monospace;
}

.clear-btn:hover {
  background-color: #b91c1c !important;
  border-color: #b91c1c !important;
}

.brush-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 12px;
  border: 1px solid #e4e4e7;
  border-radius: 10px;
  background-color: rgba(255, 255, 255, 0.8);
  height: 40px;
}

.brush-control-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brush-controls svg {
  flex-shrink: 0;
  color: #71717a;
}

.brush-controls label {
  font-size: 12px;
  font-weight: 500;
  color: #71717a;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.brush-size-container {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Range Slider */
input[type="range"] {
  width: 120px;
  height: 4px;
  border-radius: 2px;
  background-color: #e4e4e7;
  outline: none;
  -webkit-appearance: none;
  margin: 0;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background-color: #09090b;
  cursor: pointer;
  border: 2px solid #ffffff;
  box-shadow: 0 0 0 1px #e4e4e7;
}

input[type="range"]::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background-color: #09090b;
  cursor: pointer;
  border: 2px solid #ffffff;
  box-shadow: 0 0 0 1px #e4e4e7;
}

.size-display {
  font-weight: 600;
  color: #09090b;
  font-size: 12px;
  font-family: "Fira Code", monospace;
  min-width: 12px;
  text-align: center;
}

.toolbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.action-buttons {
  display: flex;
  gap: 4px;
}

.current-color-display {
  display: flex;
  align-items: center;
}

.color-preview {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 2px solid #e4e4e7;
  cursor: pointer;
  transition: all 0.15s ease;
}

.color-preview:hover {
  scale: 1.05;
  border-color: #09090b;
}

/* Canvas Section */
.canvas-section {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 80px 40px 40px 40px;
}

.canvas-container {
  display: flex;
  justify-content: center;
  align-items: center;
  border-radius: 12px;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
}

#pixelCanvas {
  border: 1px solid #e4e4e7;
  cursor: crosshair;
  background-color: #ffffff;
  transition: box-shadow 0.15s ease;
  touch-action: none;
  width: 100%;
}

#pixelCanvas:hover {
  box-shadow: 0 4px 4px rgba(0, 0, 0, 0.1);
}

/* Command Palette Backdrop */
.command-palette-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 999;
  display: none;
}

.command-palette-backdrop.active {
  display: block;
  animation: backdropIn 0.2s ease-out;
}

@keyframes backdropIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* Color Popover */
.color-popover {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 500;
  display: none;
  opacity: 0;
  transform: translateY(-10px);
  transition: all 0.2s ease;
}

.color-popover.active {
  display: block;
  opacity: 1;
  transform: translateY(0);
}

.color-popover-content {
  background: #ffffff;
  border: 1px solid #e4e4e7;
  border-radius: 12px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1),
    0 10px 10px -5px rgba(0, 0, 0, 0.04);
  padding: 16px;
  min-width: 280px;
  max-width: 320px;
}

.popover-section {
  margin-bottom: 16px;
}

.popover-section:last-child {
  margin-bottom: 0;
}

.popover-title {
  font-size: 12px;
  font-weight: 600;
  color: #374151;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.color-presets-popover {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 8px;
  margin-bottom: 8px;
}

.color-presets-popover .preset-color {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all 0.15s ease;
  position: relative;
}

.color-presets-popover .preset-color:hover {
  scale: 1.1;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.color-presets-popover .preset-color.active {
  border-color: #09090b;
  box-shadow: 0 0 0 2px rgba(9, 9, 11, 0.1);
}

.color-presets-popover .preset-color.active::after {
  content: "✓";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: rgba(255, 255, 255, 0.9);
  font-size: 14px;
  font-weight: bold;
  text-shadow: 0 0 3px rgba(0, 0, 0, 0.7);
}

.color-presets-popover .preset-color[data-color="#ffffff"].active::after,
.color-presets-popover .preset-color[data-color="#f59e0b"].active::after {
  color: #09090b;
  text-shadow: 0 0 3px rgba(255, 255, 255, 0.7);
}

.custom-color-popover {
  display: flex;
  align-items: center;
  gap: 12px;
}

.custom-color-popover input[type="color"] {
  width: 48px;
  height: 32px;
  border: 1px solid #e4e4e7;
  border-radius: 6px;
  cursor: pointer;
  transition: border-color 0.15s ease;
}

.custom-color-popover input[type="color"]:hover {
  border-color: #d4d4d8;
}

.custom-color-popover input[type="color"]:focus {
  outline: none;
  border-color: #09090b;
  box-shadow: 0 0 0 2px rgba(9, 9, 11, 0.1);
}

#colorHex {
  font-family: "Fira Code", monospace;
  font-size: 12px;
  color: #6b7280;
  font-weight: 500;
  text-transform: uppercase;
}

.current-color-display .color-preview {
  cursor: pointer;
  position: relative;
}

.current-color-display .color-preview:hover {
  scale: 1.1;
  border-color: #09090b;
}

.current-color-display .color-preview::after {
  content: "";
  position: absolute;
  top: -2px;
  right: -2px;
  width: 8px;
  height: 8px;
  background: #6b7280;
  border-radius: 50%;
  border: 2px solid #ffffff;
  opacity: 0.7;
  transition: opacity 0.15s ease;
}

.current-color-display .color-preview:hover::after {
  opacity: 1;
}

.floating-toolbar-bottom {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  background-color: #ffffff;
  border: 1px solid #e4e4e7;
  border-radius: 16px;
  padding: 8px 12px;
  z-index: 100;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
  display: flex;
  align-items: center;
  gap: 64px;
}

/* Responsive Design */
@media (max-width: 1200px) {
  .floating-toolbar {
    gap: 12px;
    padding: 10px 12px;
  }

  .command-palette {
    width: 500px;
  }
}

@media (max-width: 768px) {
  .floating-toolbar {
    position: relative;
    top: auto;
    left: auto;
    transform: none;
    width: 100%;
    border-radius: 0;
    border-left: none;
    border-right: none;
    border-top: none;
    gap: 12px;
    padding: 12px 16px;
  }

  .toolbar-center {
    justify-content: flex-end;
    flex-grow: 1;
  }

  .floating-toolbar-bottom {
    position: relative;
    left: auto;
    transform: none;
    width: 100%;
    border-radius: 0;
    border-left: none;
    border-right: none;
    border-top: none;
    gap: 12px;
    padding: 12px 16px;
    bottom: 0;
    justify-content: space-between;
  }

  input[type="range"] {
    width: 100%;
  }

  .canvas-section {
    padding-top: 16px;
    padding-bottom: 16px;
  }

  .command-palette {
    width: calc(100vw - 32px);
    max-height: 70vh;
  }

  .color-presets {
    grid-template-columns: repeat(6, 1fr);
  }

  .preset-color {
    width: 28px;
    height: 28px;
  }
}

@media (max-width: 480px) {
  .logo {
    display: none;
  }

  .canvas-section {
    padding: 16px 12px;
  }

  .toolbar-center {
    justify-content: space-between;
  }

  #pixelCanvas {
    max-width: 100%;
    height: auto;
  }

  .command-palette {
    width: calc(100vw - 24px);
  }

  .color-presets {
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
  }

  .preset-color {
    width: 24px;
    height: 24px;
  }

  /* Color Popover Mobile */
  .color-popover {
    position: fixed !important;
    top: auto !important;
    bottom: 80px !important;
    left: 16px !important;
    right: 16px !important;
    width: auto !important;
  }

  .color-popover-content {
    min-width: auto;
    max-width: none;
  }

  .color-presets-popover {
    grid-template-columns: repeat(6, 1fr);
  }

  .color-presets-popover .preset-color {
    width: 32px;
    height: 32px;
  }
}
