:root {
  --bg-primary: #0a0c10;
  --bg-secondary: #121620;
  --bg-tertiary: #191f2d;
  --bg-card: #151a24;
  --bg-card-hover: #1c2230;
  
  --border-color: #242c3f;
  --border-active: #3c4866;
  --border-accent: #ffd37f;
  
  --accent-gold: #ffd37f;
  --accent-cyan: #84f4ff;
  --accent-blue: #8da1e3;
  --accent-green: #5bda90;
  --accent-red: #ff795e;
  
  --text-primary: #f0f3fa;
  --text-secondary: #9aa5be;
  --text-muted: #5e6b85;
  
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  
  --font-mono: 'JetBrains Mono', 'Consolas', 'Fira Code', monospace;
}

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

body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  background-image: 
    radial-gradient(circle at 15% 15%, rgba(132, 244, 255, 0.03) 0%, transparent 40%),
    radial-gradient(circle at 85% 85%, rgba(255, 211, 127, 0.03) 0%, transparent 40%);
}

/* Header */
header {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(8px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, #ffd37f, #df824d);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  color: #101216;
  font-size: 20px;
  box-shadow: 0 0 16px rgba(255, 211, 127, 0.3);
}

.brand-title h1 {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-badge {
  font-size: 0.65rem;
  background: rgba(132, 244, 255, 0.15);
  color: var(--accent-cyan);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(132, 244, 255, 0.3);
  font-family: var(--font-mono);
}

.brand-subtitle {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

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

.nav-link {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: color 0.2s;
}

.nav-link:hover {
  color: var(--accent-gold);
}

/* Language Switcher */
.lang-switcher {
  display: inline-flex;
  align-items: center;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 2px 4px;
  gap: 2px;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.2);
}

.lang-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
  line-height: 1.2;
}

.lang-btn:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
}

.lang-btn.active {
  background: rgba(255, 211, 127, 0.18);
  color: var(--accent-gold);
  border-color: rgba(255, 211, 127, 0.4);
  box-shadow: 0 0 8px rgba(255, 211, 127, 0.2);
}

.lang-divider {
  color: var(--border-color);
  font-size: 0.7rem;
  user-select: none;
}

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

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

/* Sidebar Controls */
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.panel {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.panel-title {
  font-size: 0.9rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--accent-gold);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Upload Dropzone */
.dropzone {
  border: 2px dashed var(--border-color);
  border-radius: var(--radius-md);
  padding: 24px 16px;
  text-align: center;
  cursor: pointer;
  background: rgba(18, 22, 32, 0.6);
  transition: all 0.2s ease;
  position: relative;
}

.dropzone:hover, .dropzone.dragover {
  border-color: var(--accent-gold);
  background: rgba(255, 211, 127, 0.05);
  box-shadow: 0 0 12px rgba(255, 211, 127, 0.1);
}

.dropzone input[type="file"] {
  display: none;
}

.dropzone-icon {
  font-size: 28px;
  margin-bottom: 8px;
}

.dropzone-text {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.dropzone-subtext {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.kbd-badge {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 3px;
  padding: 1px 4px;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--accent-cyan);
}

/* Sample Images Bar */
.sample-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}

.sample-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.sample-btn {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.75rem;
  padding: 4px 8px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 4px;
}

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

/* Form Controls */
.control-group {
  margin-bottom: 12px;
}

.control-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.control-val {
  font-family: var(--font-mono);
  color: var(--accent-cyan);
  font-size: 0.75rem;
}

.dimension-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.input-num {
  width: 100%;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  padding: 6px 10px;
  text-align: center;
}

.input-num:focus {
  outline: none;
  border-color: var(--accent-gold);
}

.aspect-btn {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  width: 34px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}

.aspect-btn.active {
  color: var(--accent-gold);
  border-color: var(--accent-gold);
  background: rgba(255, 211, 127, 0.1);
}

.preset-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 6px;
}

.preset-pill {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  font-size: 0.7rem;
  padding: 2px 8px;
  color: var(--text-muted);
  cursor: pointer;
  font-family: var(--font-mono);
  transition: all 0.15s;
}

.preset-pill:hover, .preset-pill.active {
  background: var(--bg-tertiary);
  color: var(--accent-gold);
  border-color: var(--accent-gold);
}

select, input[type="text"] {
  width: 100%;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.85rem;
  padding: 6px 10px;
  outline: none;
}

select:focus, input[type="text"]:focus {
  border-color: var(--accent-gold);
}

input[type="range"] {
  width: 100%;
  height: 5px;
  border-radius: 3px;
  background: var(--bg-tertiary);
  accent-color: var(--accent-gold);
  cursor: pointer;
}

/* Checkbox styling */
.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  user-select: none;
  background: var(--bg-secondary);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  transition: all 0.2s ease;
}

.checkbox-row:hover {
  border-color: var(--border-active);
  background: var(--bg-tertiary);
}

.custom-checkbox {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: color 0.2s;
}

.custom-checkbox:hover {
  color: var(--text-primary);
}

.custom-checkbox input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  background: var(--bg-tertiary);
  border: 1.5px solid var(--border-color);
  border-radius: 4px;
  cursor: pointer;
  display: grid;
  place-content: center;
  margin: 0;
  flex-shrink: 0;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.custom-checkbox input[type="checkbox"]:hover {
  border-color: var(--accent-gold);
}

.custom-checkbox input[type="checkbox"]:checked {
  background: var(--accent-gold);
  border-color: var(--accent-gold);
  box-shadow: 0 0 8px rgba(255, 211, 127, 0.35);
}

.custom-checkbox input[type="checkbox"]:checked::before {
  content: "";
  width: 10px;
  height: 5.5px;
  border-left: 2px solid #14151e;
  border-bottom: 2px solid #14151e;
  transform: rotate(-45deg) translate(1px, -1px);
}

/* Palette selection tabs */
.tab-row {
  display: flex;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 10px;
}

.tab-btn {
  flex: 1;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-size: 0.75rem;
  padding: 6px;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.2s;
}

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

.tab-btn.active {
  color: var(--accent-gold);
  border-bottom-color: var(--accent-gold);
}

.palette-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(28px, 1fr));
  gap: 5px;
  max-height: 125px;
  overflow-y: auto;
  padding: 4px;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}

.palette-item {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 4px;
  cursor: pointer;
  border: 2px solid transparent;
  position: relative;
  transition: transform 0.1s, border-color 0.1s;
}

.palette-item:hover {
  transform: scale(1.15);
  z-index: 2;
}

.palette-item.disabled {
  opacity: 0.25;
  filter: grayscale(1);
}

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

/* Viewport Area */
.viewport-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.preview-container {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.preview-toolbar {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  padding: 8px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.view-mode-buttons {
  display: flex;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  padding: 2px;
  border: 1px solid var(--border-color);
}

.view-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 0.75rem;
  padding: 5px 12px;
  border-radius: 3px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 5px;
}

.view-btn.active {
  background: var(--bg-secondary);
  color: var(--accent-gold);
  font-weight: 600;
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

.canvas-tools {
  display: flex;
  align-items: center;
  gap: 6px;
}

.tool-btn {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s;
}

.tool-btn:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border-color: var(--accent-gold);
}

.tool-btn.active {
  background: rgba(255, 211, 127, 0.15);
  color: var(--accent-gold);
  border-color: var(--accent-gold);
}

/* Canvas viewport */
.canvas-wrapper {
  position: relative;
  width: 100%;
  height: 520px;
  background-color: #0d0f14;
  background-image: 
    linear-gradient(45deg, #131720 25%, transparent 25%),
    linear-gradient(-45deg, #131720 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #131720 75%),
    linear-gradient(-45deg, transparent 75%, #131720 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
  overflow: hidden;
  cursor: grab;
  user-select: none;
}

.canvas-wrapper:active {
  cursor: grabbing;
}

canvas {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  image-rendering: pixelated;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.6);
}

/* Hover tooltip in canvas */
.pixel-tooltip {
  position: absolute;
  bottom: 12px;
  left: 12px;
  background: rgba(18, 22, 32, 0.9);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-primary);
  pointer-events: none;
  display: flex;
  align-items: center;
  gap: 8px;
  backdrop-filter: blur(4px);
  z-index: 10;
}

.tooltip-color-chip {
  width: 12px;
  height: 12px;
  border-radius: 2px;
  border: 1px solid rgba(255,255,255,0.2);
}

/* Stats Bar */
.stats-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  font-size: 0.8rem;
  color: var(--text-secondary);
}

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

.stat-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.stat-val {
  font-family: var(--font-mono);
  color: var(--accent-gold);
  font-weight: 600;
}

/* Item breakdown chips */
.item-breakdown {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 90px;
  overflow-y: auto;
  margin-top: 8px;
}

.item-chip {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 2px 8px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.item-chip-color {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.item-chip-count {
  font-family: var(--font-mono);
  color: var(--text-primary);
  font-weight: 600;
}

/* Output Panels */
.output-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

@media (max-width: 900px) {
  .output-grid {
    grid-template-columns: 1fr;
  }
}

.output-box {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: flex;
  flex-direction: column;
}

.output-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.output-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent-cyan);
  display: flex;
  align-items: center;
  gap: 6px;
}

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

.btn {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.75rem;
  font-weight: 500;
  padding: 6px 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}

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

.btn-primary {
  background: var(--accent-gold);
  border-color: var(--accent-gold);
  color: #12141a;
  font-weight: 700;
}

.btn-primary:hover {
  background: #ffe099;
  box-shadow: 0 0 12px rgba(255, 211, 127, 0.4);
}

.btn-cyan {
  background: var(--accent-cyan);
  border-color: var(--accent-cyan);
  color: #0b141d;
  font-weight: 700;
}

.btn-cyan:hover {
  background: #aef8ff;
  box-shadow: 0 0 12px rgba(132, 244, 255, 0.4);
}

.btn:disabled,
.btn.btn-disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
  box-shadow: none !important;
}

/* Schematic Metadata Panel */
.schematic-meta-panel {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 12px 16px;
  margin-top: 14px;
}

.meta-panel-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--accent-gold);
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
}

.meta-fields-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

@media (max-width: 800px) {
  .meta-fields-grid {
    grid-template-columns: 1fr;
  }
}

.meta-input-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.meta-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.meta-hint {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 400;
}

.text-input {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  font-size: 0.82rem;
  color: var(--text-primary);
  outline: none;
  transition: all 0.2s;
  width: 100%;
}

.text-input:focus {
  border-color: var(--accent-gold);
  box-shadow: 0 0 8px rgba(255, 211, 127, 0.25);
}

.tag-input-wrapper {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.tag-chips-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag-chip {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  color: var(--text-muted);
  font-size: 0.7rem;
  padding: 2px 10px;
  cursor: pointer;
  transition: all 0.15s;
}

.tag-chip:hover {
  border-color: var(--accent-gold);
  color: var(--text-primary);
}

.tag-chip.active {
  background: rgba(255, 211, 127, 0.18);
  border-color: var(--accent-gold);
  color: var(--accent-gold);
  font-weight: 600;
}

.code-area {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 10px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-secondary);
  height: 120px;
  overflow: auto;
  white-space: pre;
  word-break: break-all;
  user-select: all;
  transition: border-color 0.2s, box-shadow 0.2s, opacity 0.2s;
}

.code-area.loading-code {
  opacity: 0.55;
  border-color: var(--accent-gold);
  background: rgba(255, 211, 127, 0.05);
}

.code-area.code-updated-pulse {
  animation: codeUpdatePulse 0.7s ease-out;
}

@keyframes codeUpdatePulse {
  0% {
    border-color: var(--accent-gold);
    box-shadow: 0 0 16px rgba(255, 211, 127, 0.7);
    color: var(--accent-gold);
  }
  100% {
    border-color: var(--border-color);
    box-shadow: none;
    color: var(--text-secondary);
  }
}

/* Instructions Accordion */
.instructions-panel {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-top: 10px;
}

.instruction-steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin-top: 10px;
}

.instruction-step {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px;
}

.step-num {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent-gold);
  font-family: var(--font-mono);
  margin-bottom: 4px;
}

.step-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.step-desc {
  font-size: 0.75rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

/* Toast Notification */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #1c2333;
  border: 1px solid var(--accent-gold);
  color: #fff;
  padding: 10px 18px;
  border-radius: var(--radius-md);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 8px;
  opacity: 0;
  transform: translateY(12px);
  transition: all 0.25s ease;
  pointer-events: none;
  z-index: 1000;
}

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

/* Schematic View Button in Header */
.nav-btn-highlight {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(132, 244, 255, 0.08);
  border: 1px solid var(--accent-cyan);
  color: var(--accent-cyan);
  padding: 6px 14px;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.nav-btn-highlight:hover {
  background: rgba(132, 244, 255, 0.18);
  box-shadow: 0 0 12px rgba(132, 244, 255, 0.25);
  transform: translateY(-1px);
}

/* Modal Window Styles */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(6, 8, 12, 0.78);
  backdrop-filter: blur(6px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: modalFadeIn 0.2s ease;
}

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

.modal-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-active);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 580px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6), 0 0 20px rgba(132, 244, 255, 0.1);
  overflow: hidden;
  animation: modalSlideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalSlideUp {
  from { transform: translateY(18px) scale(0.97); }
  to { transform: translateY(0) scale(1); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-tertiary);
}

.modal-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-primary);
}

.modal-close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
  border-radius: var(--radius-sm);
  transition: color 0.15s;
}

.modal-close-btn:hover {
  color: var(--accent-red);
}

.modal-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-primary);
}

.modal-tab {
  flex: 1;
  padding: 12px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.modal-tab:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.02);
}

.modal-tab.active {
  color: var(--accent-cyan);
  border-bottom-color: var(--accent-cyan);
  background: rgba(132, 244, 255, 0.04);
  font-weight: 600;
}

.modal-tab-pane {
  padding: 20px;
}

.modal-hint {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.modal-hint code {
  color: var(--accent-cyan);
  background: var(--bg-primary);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.8rem;
}

.modal-textarea {
  width: 100%;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  padding: 12px;
  resize: vertical;
  line-height: 1.4;
  outline: none;
  transition: border-color 0.2s;
  box-sizing: border-box;
}

.modal-textarea:focus {
  border-color: var(--accent-cyan);
}

.modal-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}

.modal-file-dropzone {
  border: 2px dashed var(--border-color);
  border-radius: var(--radius-md);
  padding: 36px 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--bg-primary);
}

.modal-file-dropzone:hover,
.modal-file-dropzone.dragover {
  border-color: var(--accent-cyan);
  background: rgba(132, 244, 255, 0.04);
}

/* Credits & Acknowledgements Panel */
.credits-panel {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 18px 22px;
  margin-top: 16px;
}

.credits-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
  margin-top: 14px;
}

.credit-card {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: all 0.2s ease;
}

.credit-card:hover {
  border-color: var(--accent-gold);
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}

.credit-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.credit-card-title {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.credit-badge {
  font-size: 0.65rem;
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  background: rgba(255, 211, 127, 0.15);
  color: var(--accent-gold);
  border: 1px solid rgba(255, 211, 127, 0.3);
  font-weight: 500;
}

.credit-badge.repo {
  background: rgba(132, 244, 255, 0.15);
  color: var(--accent-cyan);
  border-color: rgba(132, 244, 255, 0.3);
}

.credit-card-desc {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.45;
}

.credit-card-link {
  font-size: 0.78rem;
  color: var(--accent-cyan);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 2px;
  font-weight: 500;
  transition: color 0.2s;
}

.credit-card-link:hover {
  color: var(--accent-gold);
  text-decoration: underline;
}

/* Site Footer */
.site-footer {
  border-top: 1px solid var(--border-color);
  background: var(--bg-secondary);
  padding: 16px 24px;
  margin-top: 28px;
}

.footer-inner {
  max-width: 1750px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

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

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

.footer-right a {
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 0.2s;
}

.footer-right a:hover {
  color: var(--accent-gold);
}

/* ==========================================================================
   Pixel Art Drawing Studio Styles
   ========================================================================== */

.drawing-studio-card {
  max-width: 1300px;
  width: 96vw;
  height: 92vh;
  max-height: 940px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-secondary);
  border: 1px solid var(--border-active);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.75), 0 0 30px rgba(255, 211, 127, 0.08);
}

.studio-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.studio-badge {
  font-size: 0.7rem;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  background: rgba(255, 211, 127, 0.12);
  color: var(--accent-gold);
  border: 1px solid rgba(255, 211, 127, 0.25);
  margin-left: 8px;
}

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

.studio-dim-selector {
  display: flex;
  align-items: center;
  gap: 8px;
}

.studio-dim-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
}

.studio-dim-pills {
  display: flex;
  gap: 4px;
}

.studio-dim-pill {
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.studio-dim-pill:hover {
  border-color: var(--accent-gold);
  color: var(--text-primary);
}

.studio-dim-pill.active {
  background: rgba(255, 211, 127, 0.15);
  border-color: var(--accent-gold);
  color: var(--accent-gold);
  font-weight: 600;
}

/* Studio Workspace: Split 2 columns */
.studio-workspace {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 16px;
  flex: 1;
  min-height: 0;
  padding: 14px 18px;
  overflow: hidden;
  background: var(--bg-primary);
}

/* Left: Painter Column */
.studio-paint-column {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  overflow: hidden;
}

/* Studio Toolbar */
.studio-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  padding: 6px 10px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  flex-shrink: 0;
}

.tool-group {
  display: flex;
  align-items: center;
  gap: 4px;
}

.tool-divider {
  width: 1px;
  height: 20px;
  background: var(--border-color);
  margin: 0 4px;
}

.studio-tool-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.studio-tool-btn:hover {
  background: var(--bg-primary);
  color: var(--text-primary);
  border-color: var(--border-active);
}

.studio-tool-btn.active {
  background: rgba(255, 211, 127, 0.15);
  color: var(--accent-gold);
  border-color: var(--accent-gold);
  font-weight: 600;
}

.brush-size-group {
  display: flex;
  align-items: center;
  gap: 4px;
}

.tool-sublabel {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-right: 2px;
}

.brush-size-btn {
  padding: 4px 7px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.72rem;
  cursor: pointer;
  transition: all 0.15s;
}

.brush-size-btn:hover {
  color: var(--text-primary);
}

.brush-size-btn.active {
  background: rgba(132, 244, 255, 0.15);
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
  font-weight: 600;
}

.studio-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
}

.studio-icon-btn:hover:not(:disabled) {
  background: var(--bg-primary);
  color: var(--text-primary);
  border-color: var(--border-active);
}

.studio-icon-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.studio-icon-btn.active {
  background: rgba(132, 244, 255, 0.15);
  color: var(--accent-cyan);
  border-color: var(--accent-cyan);
}

.studio-icon-btn.danger:hover {
  background: rgba(239, 68, 68, 0.15);
  color: var(--accent-red);
  border-color: var(--accent-red);
}

.studio-zoom-val {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  min-width: 36px;
  text-align: center;
}

/* Canvas Viewport */
.studio-canvas-container {
  flex: 1;
  min-height: 220px;
  background: #0f1118;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  position: relative;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
}

.studio-canvas-checker {
  position: relative;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.1);
  background-image: repeating-conic-gradient(#1c1e27 0% 25%, #252836 0% 50%) 50% / 16px 16px;
  image-rendering: pixelated;
}

#drawingCanvas {
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

#drawingGridCanvas {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
  image-rendering: pixelated;
}

.draw-cursor-pencil { cursor: crosshair; }
.draw-cursor-bucket { cursor: cell; }
.draw-cursor-eraser { cursor: grab; }
.draw-cursor-eyedropper { cursor: crosshair; }

.studio-coords-badge {
  position: absolute;
  bottom: 8px;
  right: 10px;
  background: rgba(15, 17, 24, 0.85);
  backdrop-filter: blur(4px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 2px 8px;
  font-size: 0.72rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
  pointer-events: none;
}

/* Studio Palette Section */
.studio-palette-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 10px;
  flex-shrink: 0;
}

.studio-active-color-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.active-color-preview-box {
  display: flex;
  align-items: center;
  gap: 8px;
}

.active-color-swatch {
  width: 26px;
  height: 26px;
  border-radius: var(--radius-sm);
  border: 2px solid #ffffff;
  box-shadow: 0 0 8px rgba(0, 0, 0, 0.5);
}

.active-color-swatch.air-pattern {
  background-image: repeating-conic-gradient(#3a3d4d 0% 25%, #1e2029 0% 50%) 50% / 8px 8px !important;
}

.active-color-info {
  display: flex;
  flex-direction: column;
}

.active-color-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-primary);
}

.active-color-hex {
  font-size: 0.7rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
}

.custom-color-picker-wrap {
  position: relative;
}

.custom-color-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
}

.custom-color-label:hover {
  border-color: var(--accent-gold);
  color: var(--text-primary);
}

.custom-color-label input[type="color"] {
  width: 18px;
  height: 18px;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: 2px;
}

.studio-air-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
}

.studio-air-btn:hover {
  border-color: var(--accent-red);
  color: var(--text-primary);
}

.studio-air-btn.active {
  background: rgba(239, 68, 68, 0.15);
  border-color: var(--accent-red);
  color: var(--accent-red);
  font-weight: 600;
}

.air-checker-icon {
  width: 14px;
  height: 14px;
  border-radius: 2px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  background-image: repeating-conic-gradient(#555 0% 25%, #222 0% 50%) 50% / 4px 4px;
}

/* Swatches Grid */
.studio-swatches-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(78px, 1fr));
  gap: 4px;
  max-height: 90px;
  overflow-y: auto;
  padding-right: 4px;
}

.studio-swatch-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
  text-align: left;
}

.studio-swatch-item:hover {
  border-color: rgba(255, 255, 255, 0.3);
  transform: translateY(-1px);
}

.studio-swatch-item.active {
  border-color: var(--accent-gold);
  background: rgba(255, 211, 127, 0.12);
  box-shadow: 0 0 6px rgba(255, 211, 127, 0.3);
}

.swatch-color {
  width: 14px;
  height: 14px;
  border-radius: 2px;
  flex-shrink: 0;
  box-shadow: 0 0 3px rgba(0, 0, 0, 0.5);
}

.swatch-label {
  font-size: 0.68rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Right: Preview Column */
.studio-preview-column {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  overflow: hidden;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px;
}

.studio-preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.preview-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.preview-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
}

.live-sync-indicator {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.7rem;
  font-weight: 500;
  color: #34d399;
  background: rgba(52, 211, 153, 0.1);
  padding: 2px 7px;
  border-radius: 10px;
  border: 1px solid rgba(52, 211, 153, 0.25);
}

.pulse-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #34d399;
  box-shadow: 0 0 6px #34d399;
  animation: pulseDot 1.6s infinite ease-in-out;
}

@keyframes pulseDot {
  0% { transform: scale(0.9); opacity: 0.6; }
  50% { transform: scale(1.3); opacity: 1; box-shadow: 0 0 10px #34d399; }
  100% { transform: scale(0.9); opacity: 0.6; }
}

.studio-view-toggle {
  display: flex;
  gap: 4px;
}

.studio-view-btn {
  padding: 4px 8px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.72rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.studio-view-btn:hover {
  color: var(--text-primary);
}

.studio-view-btn.active {
  background: rgba(132, 244, 255, 0.15);
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
  font-weight: 600;
}

.studio-block-selector-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.selector-label {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.studio-select {
  flex: 1;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 5px 8px;
  color: var(--text-primary);
  font-size: 0.8rem;
  outline: none;
  cursor: pointer;
  transition: border-color 0.15s;
}

.studio-select:focus {
  border-color: var(--accent-gold);
}

/* Studio Preview Viewport */
.studio-preview-viewport {
  flex: 1;
  min-height: 220px;
  background: #12141a;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

#studioPreviewCanvas {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* Stats Card */
.studio-stats-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  flex-shrink: 0;
}

.studio-stats-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.studio-stat-col {
  display: flex;
  flex-direction: column;
}

.stat-col-title {
  font-size: 0.68rem;
  color: var(--text-muted);
  text-transform: uppercase;
}

.stat-col-val {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
}

.studio-resource-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  max-height: 48px;
  overflow-y: auto;
}

.studio-chip-text {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.studio-item-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 2px 6px;
  font-size: 0.68rem;
  color: var(--text-secondary);
}

.chip-color {
  width: 8px;
  height: 8px;
  border-radius: 1px;
}

/* Action Footer */
.studio-actions-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.btn-copy-game {
  flex: 1.4;
  justify-content: center;
  background: linear-gradient(135deg, #f59e0b, #d97706);
  border-color: #d97706;
  color: #ffffff;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.25);
}

.btn-copy-game:hover {
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
}

/* Responsive Layout */
@media (max-width: 960px) {
  .studio-workspace {
    grid-template-columns: 1fr;
    overflow-y: auto;
  }
  .drawing-studio-card {
    height: 96vh;
  }
}
