@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&family=Carter+One&display=swap');

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

:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #11111a;
  --bg-card: #16161f;
  --bg-card-hover: #1c1c2a;
  --border-color: #2a2a3d;
  --border-glow: #3d3d5c;
  --accent: #00d4ff;
  --accent-dim: #0099cc;
  --accent-glow: rgba(0, 212, 255, 0.15);
  --accent-pencil: #00ff88;
  --accent-eraser: #ff6b6b;
  --accent-invert: #c084fc;
  --text-primary: #e8e8f0;
  --text-secondary: #8888aa;
  --text-dim: #555570;
  --canvas-bg: #000000;
  --canvas-pixel-on: #ffffff;
  --canvas-grid: rgba(255,255,255,0.04);
  --shadow-glow: 0 0 30px rgba(0,212,255,0.1);
  --shadow-card: 0 4px 24px rgba(0,0,0,0.5);
}

html, body {
  min-height: 100%;
  width: 100%;
  max-width: 100vw;
  margin: 0;
  padding: 0;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  overflow-x: clip !important;
  box-sizing: border-box;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  height: auto;
  overflow-x: clip !important;
  width: 100%;
  max-width: 100vw;
}

/* ─── Splash Screen ─── */
#splash {
  position: fixed;
  inset: 0;
  background: #000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 32px;
  z-index: 9999;
  transition: opacity 0.5s ease;
}

#splash.fade-out {
  opacity: 0;
  pointer-events: none;
}

#splash.hidden {
  display: none;
}

.splash-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  animation: splash-glow 1.5s ease-in-out infinite alternate;
}

.splash-logo {
  width: 320px;
  max-width: 85vw;
  height: auto;
  display: block;
  margin: 0 auto;
}

.splash-subtitle {
  font-family: 'Inter', sans-serif;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 5px;
  color: #ffffff;
  text-transform: uppercase;
  margin-right: -5px; /* Compensa o letter-spacing na centralização */
}

@keyframes splash-glow {
  from { filter: drop-shadow(0 0 10px rgba(255,255,255,0.3)); }
  to   { filter: drop-shadow(0 0 30px rgba(255,255,255,0.8)) drop-shadow(0 0 50px rgba(0,212,255,0.5)); }
}

.splash-loader {
  width: min(320px, 70vw);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.splash-bar-track {
  width: 100%;
  height: 3px;
  background: rgba(255,255,255,0.1);
  border-radius: 3px;
  overflow: hidden;
}

.splash-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #00d4ff, #c084fc);
  border-radius: 3px;
  transition: width 0.05s linear;
  box-shadow: 0 0 8px rgba(0,212,255,0.6);
}

.splash-bar-text {
  font-size: 11px;
  color: rgba(255,255,255,0.35);
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: 1px;
}

/* ─── Header ─── */
header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 24px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
  width: 100%;
}

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

.header-logo {
  height: 22px;
  width: auto;
  display: block;
  filter: drop-shadow(0 0 8px rgba(255,255,255,0.2));
}

.header-subtitle {
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 2.5px;
  color: var(--accent);
  text-transform: uppercase;
  padding-top: 1px;
}

.header-badge {
  margin-left: auto;
  padding: 4px 10px;
  background: var(--accent-glow);
  border: 1px solid var(--accent-dim);
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
  color: var(--accent);
  letter-spacing: 0.5px;
}

/* Save indicator */
.save-indicator {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 500;
  color: var(--accent-pencil);
  opacity: 0;
  transition: opacity 0.4s ease;
  white-space: nowrap;
}

.save-indicator.visible {
  opacity: 1;
}

/* ─── Name Field ─── */
.name-field {
  display: flex;
  align-items: center;
  gap: 7px;
}

.name-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 5px;
}

.name-label i {
  font-size: 11px;
  color: var(--accent-dim);
}

.name-input {
  width: 130px;
  padding: 6px 10px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-glow);
  border-radius: 7px;
  color: var(--accent-pencil);
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  font-weight: 500;
  outline: none;
  transition: border-color 0.18s, box-shadow 0.18s, color 0.18s;
}

.name-input:focus {
  border-color: var(--accent-pencil);
  box-shadow: 0 0 0 2px rgba(0,255,136,0.12);
}

.name-input.invalid {
  border-color: var(--accent-eraser);
  color: var(--accent-eraser);
  box-shadow: 0 0 0 2px rgba(255,107,107,0.12);
}

/* ─── Main Layout ─── */
.main-layout {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: auto 1fr;
  gap: 0;
  padding: 12px 20px;
  max-width: 100%;
  margin: 0 auto;
  width: 100%;
  min-height: 0;
  box-sizing: border-box;
}

@media (min-width: 1000px) {
  .main-layout {
    grid-template-columns: minmax(0, 1fr) 380px;
    grid-template-rows: auto;
    gap: 16px;
    align-items: start;
    overflow: visible;
    height: auto;
    max-height: none;
    min-width: 0;
    max-width: 96vw;
    box-sizing: border-box;
  }
}

@media (min-width: 1400px) {
  .main-layout {
    grid-template-columns: minmax(0, 1fr) 440px;
    gap: 24px;
    padding: 16px 28px;
    max-width: 96vw;
  }
}

@media (min-width: 1800px) {
  .main-layout {
    grid-template-columns: minmax(0, 1fr) 520px;
    gap: 32px;
    padding: 20px 40px;
    max-width: 2400px;
  }
}

/* ─── Editor Panel ─── */
.editor-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}

@media (min-width: 1000px) {
  .editor-panel {
    overflow: visible;
    height: auto;
    min-width: 0;
    max-width: 100%;
  }
}

/* ─── Toolbar ─── */
.toolbar {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  box-shadow: var(--shadow-card);
}

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

.toolbar-pair {
  display: contents;
}

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

.tool-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.18s ease;
  white-space: nowrap;
  user-select: none;
}

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

.tool-btn.active-pencil {
  background: rgba(0, 255, 136, 0.12);
  border-color: var(--accent-pencil);
  color: var(--accent-pencil);
  box-shadow: 0 0 12px rgba(0, 255, 136, 0.2);
}

.tool-btn.active-eraser {
  background: rgba(255, 107, 107, 0.12);
  border-color: var(--accent-eraser);
  color: var(--accent-eraser);
  box-shadow: 0 0 12px rgba(255,107,107,0.2);
}

.tool-btn.btn-invert {
  background: rgba(192, 132, 252, 0.1);
  border-color: var(--accent-invert);
  color: var(--accent-invert);
}

.tool-btn.btn-invert:hover {
  background: rgba(192, 132, 252, 0.18);
  box-shadow: 0 0 12px rgba(192,132,252,0.2);
}

.tool-btn.btn-clear {
  border-color: #ff4444;
  color: #ff4444;
}

.tool-btn.btn-clear:hover {
  background: rgba(255,68,68,0.1);
  box-shadow: 0 0 12px rgba(255,68,68,0.15);
}

.tool-btn.btn-gif:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}
.fa-spin {
  display: inline-block;
  animation: spin 0.8s linear infinite;
}

.tool-btn .icon {
  font-size: 15px;
  line-height: 1;
}

/* ─── Zoom Control ─── */
.zoom-control {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.zoom-label {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
}

.zoom-value {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  min-width: 36px;
  text-align: right;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 110px;
  height: 4px;
  background: var(--border-color);
  border-radius: 4px;
  outline: none;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px rgba(0,212,255,0.5);
  cursor: pointer;
  transition: box-shadow 0.15s;
}

input[type="range"]::-webkit-slider-thumb:hover {
  box-shadow: 0 0 14px rgba(0,212,255,0.7);
}

/* ─── Delta Optimization Checkbox ─── */
.delta-opt-label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
  background: var(--bg-primary);
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  transition: border-color 0.15s, color 0.15s;
}

.delta-opt-label:hover {
  border-color: var(--border-glow);
  color: var(--text-primary);
}

.delta-opt-label input {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border: 1px solid var(--text-dim);
  border-radius: 3px;
  background: var(--bg-card);
  cursor: pointer;
  margin: 0;
  position: relative;
  transition: all 0.2s ease;
}

.delta-opt-label input:hover {
  border-color: var(--accent);
}

.delta-opt-label input:checked {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 8px rgba(0, 212, 255, 0.4);
}

.delta-opt-label input:checked::after {
  content: '';
  position: absolute;
  top: 1px;
  left: 4px;
  width: 4px;
  height: 8px;
  border: solid var(--bg-primary);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

/* ─── Toggle Switch (Fullscreen) ─── */
.toggle-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.switch-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}

.switch-text {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  white-space: nowrap;
}

.switch-wrap {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
  flex-shrink: 0;
}

.switch-wrap input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.switch-slider {
  position: absolute;
  inset: 0;
  background: var(--border-color);
  border-radius: 22px;
  transition: background 0.2s ease;
  cursor: pointer;
}

.switch-slider::before {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  left: 3px;
  top: 3px;
  background: var(--text-dim);
  border-radius: 50%;
  transition: transform 0.2s ease, background 0.2s ease;
}

.switch-wrap input:checked + .switch-slider {
  background: var(--accent);
  box-shadow: 0 0 10px rgba(0,212,255,0.35);
}

.switch-wrap input:checked + .switch-slider::before {
  transform: translateX(18px);
  background: #fff;
}

.res-badge {
  font-size: 11px;
  font-weight: 600;
  font-family: 'JetBrains Mono', monospace;
  color: var(--accent);
  background: var(--accent-glow);
  border: 1px solid var(--accent-dim);
  border-radius: 6px;
  padding: 3px 8px;
  white-space: nowrap;
  transition: all 0.2s;
}

/* ─── Display Color Picker ─── */
.color-picker {
  display: flex;
  align-items: center;
  gap: 7px;
}

.color-picker-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  white-space: nowrap;
  margin-right: 2px;
}

.color-swatch {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
  padding: 0;
  flex-shrink: 0;
  position: relative;
  outline: none;
}

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

/* White swatch */
#swatch-white  { background: #ffffff; }
#swatch-white.active  {
  border-color: #ffffff;
  box-shadow: 0 0 0 2px rgba(255,255,255,0.25), 0 0 8px rgba(255,255,255,0.4);
}

/* Blue swatch */
#swatch-blue   { background: #4fc3f7; }
#swatch-blue.active   {
  border-color: #4fc3f7;
  box-shadow: 0 0 0 2px rgba(79,195,247,0.25), 0 0 8px rgba(79,195,247,0.5);
}

/* Yellow swatch */
#swatch-yellow { background: #ffd740; }
#swatch-yellow.active {
  border-color: #ffd740;
  box-shadow: 0 0 0 2px rgba(255,215,64,0.25), 0 0 8px rgba(255,215,64,0.5);
}

/* Split swatch (half yellow top, half blue bottom) */
#swatch-split {
  background: linear-gradient(to bottom, #ffd740 50%, #4fc3f7 50%);
}
#swatch-split.active  {
  border-color: #a0d8ef;
  box-shadow: 0 0 0 2px rgba(160,216,239,0.25), 0 0 8px rgba(160,216,239,0.4);
}

/* ─── Display Size Selector ─── */
.display-size-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.display-size-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 5px;
}

.display-size-label i {
  color: var(--accent-dim);
  font-size: 11px;
}

.display-preset-select {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-glow);
  border: 1px solid var(--accent-dim);
  padding: 4px 10px;
  border-radius: 6px;
  outline: none;
  cursor: pointer;
  transition: all 0.18s ease;
}

.display-preset-select:hover {
  background: rgba(0, 212, 255, 0.22);
  border-color: var(--accent);
  box-shadow: 0 0 10px rgba(0, 212, 255, 0.3);
}

.display-preset-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-glow);
}

.display-preset-select option {
  background: var(--bg-card);
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
  font-weight: 500;
}

.display-custom {
  display: flex;
  align-items: center;
  gap: 5px;
}

.apply-display-btn {
  background: var(--accent-glow);
  border: 1px solid var(--accent-dim);
  color: var(--accent);
  width: 26px;
  height: 26px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.18s;
}

.apply-display-btn:hover {
  background: rgba(0,212,255,0.25);
  box-shadow: 0 0 8px rgba(0,212,255,0.2);
}

/* ─── Options Bar ─── */
.options-bar {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 12px 18px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  box-shadow: var(--shadow-card);
  animation: slide-down 0.2s ease;
}

@keyframes slide-down {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.options-section {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.options-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.options-divider {
  width: 1px;
  height: 30px;
  background: var(--border-color);
}

.res-inputs {
  display: flex;
  align-items: center;
  gap: 6px;
}

.res-input {
  width: 58px;
  padding: 5px 8px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-glow);
  border-radius: 7px;
  color: var(--text-primary);
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  font-weight: 500;
  text-align: center;
  outline: none;
  transition: border-color 0.18s, box-shadow 0.18s;
  -moz-appearance: textfield;
}

.res-input::-webkit-inner-spin-button,
.res-input::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.res-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(0,212,255,0.15);
}

.res-x, .res-unit {
  font-size: 13px;
  color: var(--text-dim);
  font-family: 'JetBrains Mono', monospace;
}

.offset-sliders {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

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

.offset-axis {
  font-size: 11px;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
  color: var(--accent);
  width: 12px;
  text-align: center;
}

.offset-row input[type="range"] {
  width: 120px;
}

.offset-val {
  font-size: 12px;
  font-weight: 600;
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-secondary);
  min-width: 28px;
  text-align: right;
}

.canvas-wrapper {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow-card), var(--shadow-glow);
  position: relative;
  overflow: hidden;
}

.canvas-wrapper::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  opacity: 0.6;
}

.canvas-info {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 11px;
  color: var(--text-dim);
}

.canvas-info .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-pencil);
  box-shadow: 0 0 6px var(--accent-pencil);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.canvas-scroll-area {
  overflow: auto;
  max-width: 100%;
  max-height: 85vh;
  border-radius: 6px;
  cursor: crosshair;
}

.canvas-scroll-area::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.canvas-scroll-area::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.3);
  border-radius: 4px;
}

.canvas-scroll-area::-webkit-scrollbar-thumb {
  background: var(--border-glow);
  border-radius: 4px;
}

.canvas-scroll-area::-webkit-scrollbar-thumb:hover {
  background: var(--accent);
}

#oled-canvas {
  display: block;
  image-rendering: pixelated;
  background: var(--canvas-bg);
  border: 2px solid var(--border-glow);
  border-radius: 4px;
  box-shadow: 0 0 20px rgba(0,0,0,0.8), inset 0 0 40px rgba(0,0,0,0.4);
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

.canvas-coords {
  font-size: 11px;
  color: var(--text-dim);
  font-family: 'JetBrains Mono', monospace;
  min-height: 16px;
  transition: color 0.1s;
}

.canvas-coords.active {
  color: var(--accent);
}

/* ─── Code Panel ─── */
.code-panel {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-card);
  /* Always show at least this much, even on tiny mobile screens */
  min-height: 300px;
}

@media (min-width: 1000px) {
  .code-panel {
    position: -webkit-sticky;
    position: sticky;
    top: 20px;
    align-self: start;
    height: auto;
    min-height: 320px;
    max-height: calc(100vh - 40px);
  }
}

/* Header wraps two rows: title+copy, then stats */
.code-panel-header {
  display: flex;
  flex-direction: column;
  gap: 0;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.code-panel-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
}

.code-stats-row {
  display: flex;
  gap: 0;
  border-top: 1px solid var(--border-color);
  background: var(--bg-secondary);
}

.code-stats-row .stat-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 7px 12px;
  border-right: 1px solid var(--border-color);
}

.code-stats-row .stat-item:last-child {
  border-right: none;
}

.code-stats-row .stat-label {
  font-size: 9px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.code-stats-row .stat-value {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  font-family: 'JetBrains Mono', monospace;
}

.code-stats-row .stat-value.accent { color: var(--accent); }

.code-panel-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.code-panel-title .chip {
  padding: 2px 8px;
  background: rgba(0,212,255,0.1);
  border: 1px solid var(--accent-dim);
  border-radius: 20px;
  font-size: 10px;
  color: var(--accent);
  font-weight: 500;
  letter-spacing: 0.5px;
}

.copy-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  background: var(--accent-glow);
  border: 1px solid var(--accent-dim);
  border-radius: 7px;
  color: var(--accent);
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.18s ease;
}

.copy-btn:hover {
  background: rgba(0,212,255,0.22);
  box-shadow: 0 0 12px rgba(0,212,255,0.2);
}

.copy-btn.copied {
  background: rgba(0,255,136,0.12);
  border-color: var(--accent-pencil);
  color: var(--accent-pencil);
}

.code-output {
  flex: 1;
  /* Both axes scroll — never clip */
  overflow: auto;
  padding: 16px 18px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11.5px;
  line-height: 1.7;
  color: #a8a8cc;
  background: #0c0c14;
  white-space: pre;
  scrollbar-width: thin;
  scrollbar-color: var(--border-glow) transparent;
  /* Minimum visible height on mobile */
  min-height: 220px;
  /* Allow shrinking in the flex column */
  min-width: 0;
}

@media (min-width: 1000px) {
  .code-output {
    min-height: 200px;
    max-height: clamp(340px, 52vh, 560px);
    overflow-y: auto;
    overflow-x: auto;
  }
}

.code-output::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.code-output::-webkit-scrollbar-track {
  background: transparent;
}

.code-output::-webkit-scrollbar-thumb {
  background: var(--border-glow);
  border-radius: 3px;
}

/* Syntax-like coloring via spans */
.c-comment { color: #4a4a6a; }
.c-keyword  { color: #c084fc; }
.c-type     { color: #67e8f9; }
.c-name     { color: #a3e635; }
.c-value    { color: #fb923c; }
.c-punct    { color: #6b7280; }

/* ─── Frames Bar ─── */
.frames-bar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 10px 14px;
  flex-shrink: 0;
  overflow: hidden;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}

.frames-bar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: 12px;
  flex-wrap: wrap;
}

.frames-header-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.frames-title-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.frames-bar-icon {
  color: var(--accent-dim);
  font-size: 13px;
  flex-shrink: 0;
}

.frames-bar-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
  flex-shrink: 0;
}

.frame-tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  width: 100%;
  min-width: 0;
  padding: 4px 0 8px 0;
  scrollbar-width: thin;
}

.frame-tabs::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.frame-tabs::-webkit-scrollbar-track {
  background: transparent;
}

.frame-tabs::-webkit-scrollbar-thumb {
  background: var(--border-glow);
  border-radius: 3px;
}

.frame-tabs::-webkit-scrollbar-thumb:hover {
  background: var(--accent-dim);
}

.frame-tab {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 8px 4px 5px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  cursor: grab;
  transition: all 0.15s ease;
  flex-shrink: 0;
  position: relative;
}

.frame-tab:hover {
  border-color: var(--border-glow);
  background: var(--bg-card-hover);
}

.frame-tab.active {
  border-color: var(--accent-dim);
  background: var(--accent-glow);
  box-shadow: 0 0 8px rgba(0,212,255,0.15);
}

.frame-tab.dragging {
  opacity: 0.38;
  cursor: grabbing;
  transform: scale(0.96);
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
}

.frame-tab.drag-over-left {
  border-left-color: var(--accent);
  background: rgba(0, 212, 255, 0.10);
  box-shadow: -3px 0 0 0 var(--accent);
}

.frame-tab.drag-over-right {
  border-right-color: var(--accent);
  background: rgba(0, 212, 255, 0.10);
  box-shadow: 3px 0 0 0 var(--accent);
}

.frame-thumb {
  width: 32px;
  height: 16px;
  border-radius: 3px;
  background: #000;
  image-rendering: pixelated;
  border: 1px solid rgba(255,255,255,0.08);
  display: block;
  flex-shrink: 0;
}

.frame-tab.active .frame-thumb {
  border-color: rgba(0,212,255,0.3);
}

.frame-tab-label {
  font-size: 10px;
  font-weight: 600;
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-secondary);
}

.frame-tab.active .frame-tab-label {
  color: var(--accent);
}

.frame-tab-actions {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-left: auto;
}

.frame-tab-del, .frame-tab-dup {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 0;
  font-size: 8px;
  line-height: 1;
  width: 14px;
  height: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: all 0.15s;
  flex-shrink: 0;
}

.frame-tab-del:hover:not(:disabled) {
  background: rgba(255,107,107,0.2);
  color: var(--accent-eraser);
}

.frame-tab-dup:hover:not(:disabled) {
  background: rgba(0,212,255,0.2);
  color: var(--accent);
}

.frame-tab-del:disabled, .frame-tab-dup:disabled {
  opacity: 0.2;
  cursor: not-allowed;
}

.btn-add-frame {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  background: transparent;
  border: 1px dashed var(--border-glow);
  border-radius: 7px;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 11px;
  transition: all 0.18s;
  flex-shrink: 0;
}

.btn-add-frame:hover {
  background: var(--accent-glow);
  border-color: var(--accent-dim);
  color: var(--accent);
  box-shadow: 0 0 8px rgba(0,212,255,0.15);
}

.frames-bar-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  border-left: 1px solid var(--border-color);
  padding-left: 12px;
}

.frames-actions-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.frames-delay-group {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: nowrap;
}

.frame-delay-label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--text-secondary);
  white-space: nowrap;
}

.frame-delay-input {
  width: 76px;
  background: var(--bg-card);
  border: 1px solid var(--border-glow);
  color: var(--accent);
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  font-weight: 600;
  padding: 5px 8px;
  border-radius: 7px;
  outline: none;
  text-align: center;
  transition: all 0.18s;
  color-scheme: dark;
  -moz-appearance: textfield;
}

.frame-delay-input::-webkit-inner-spin-button,
.frame-delay-input::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.frame-delay-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(0,212,255,0.18);
}

.frame-delay-unit {
  font-size: 11px;
  color: var(--text-dim);
  font-family: 'JetBrains Mono', monospace;
}

/* ─── Animation Preview ─── */
.anim-preview {
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-secondary);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.anim-preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border-color);
}

.anim-preview-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.anim-preview-title i {
  color: var(--accent-dim);
}

.anim-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.preview-frame-label {
  font-size: 10px;
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-dim);
}

.btn-play-pause {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: var(--accent-glow);
  border: 1px solid var(--accent-dim);
  border-radius: 50%;
  color: var(--accent);
  cursor: pointer;
  font-size: 10px;
  transition: all 0.18s;
}

.btn-play-pause:hover {
  background: rgba(0,212,255,0.25);
  box-shadow: 0 0 12px rgba(0,212,255,0.3);
  transform: scale(1.05);
}

.anim-preview-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  background: #000;
}

#preview-canvas {
  image-rendering: pixelated;
  border-radius: 4px;
  border: 1px solid rgba(0,212,255,0.15);
  box-shadow: 0 0 20px rgba(0,0,0,0.8), 0 0 10px rgba(0,212,255,0.05);
  /* Scale up the canvas visually without changing its logical size */
  width: 100%;
  max-width: 256px;
  height: auto;
}

.anim-memory {
  display: flex;
  gap: 0;
  border-top: 1px solid var(--border-color);
}

.memory-row {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  font-size: 10px;
  color: var(--text-dim);
  font-family: 'JetBrains Mono', monospace;
  border-right: 1px solid var(--border-color);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.memory-row:last-child {
  border-right: none;
}

.memory-row i {
  color: var(--accent-dim);
  flex-shrink: 0;
  font-size: 10px;
}

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

.btn-onion-skin {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 9px;
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: 7px;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 11px;
  transition: all 0.18s;
}

.btn-onion-skin:hover {
  border-color: var(--border-glow);
  color: var(--text-secondary);
  background: var(--bg-card);
}

.btn-onion-skin.active-onion {
  border-color: rgba(60, 220, 180, 0.4);
  background: rgba(60, 220, 180, 0.06);
  color: var(--text-primary);
  box-shadow: 0 0 8px rgba(60, 220, 180, 0.1);
}

.onion-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  opacity: 0.5;
  transition: opacity 0.18s;
}

.btn-onion-skin.active-onion .onion-dot {
  opacity: 1;
}

.onion-prev {
  background: rgb(255, 100, 60);
  box-shadow: 0 0 5px rgba(255, 100, 60, 0.6);
}

.onion-next {
  background: rgb(60, 220, 180);
  box-shadow: 0 0 5px rgba(60, 220, 180, 0.6);
}

/* ─── Footer ─── */
footer {
  flex-shrink: 0;
  border-top: 1px solid var(--border-color);
  background: var(--bg-secondary);
  font-size: 12px;
  color: var(--text-dim);
  margin-top: auto;
  width: 100%;
}

.footer-content {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 14px 24px;
  max-width: 1100px;
  margin: 0 auto;
  flex-wrap: wrap;
  gap: 30px;
}

.footer-julia {
  position: relative;
}

.julia-dropdown-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 6px;
  transition: all 0.2s ease;
}

.julia-dropdown-btn:hover, .julia-dropdown-btn[aria-expanded="true"] {
  color: var(--accent);
  background: rgba(0, 212, 255, 0.1);
}

.julia-dropdown-btn i {
  font-size: 10px;
  transition: transform 0.2s ease;
}

.julia-dropdown-btn[aria-expanded="true"] i {
  transform: rotate(180deg);
}

.julia-dropdown-menu {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  background: var(--bg-card);
  border: 1px solid var(--border-glow);
  border-radius: 8px;
  padding: 8px 0;
  min-width: 160px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
  display: flex;
  flex-direction: column;
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition: all 0.2s ease;
  z-index: 100;
}

.julia-dropdown-menu.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.julia-dropdown-menu a {
  padding: 8px 16px;
  color: var(--text-primary);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: background 0.2s, color 0.2s;
  font-weight: 500;
}

.julia-dropdown-menu a i {
  color: var(--accent);
  width: 16px;
  text-align: center;
}

.julia-dropdown-menu a:hover {
  background: rgba(0, 212, 255, 0.1);
  color: var(--accent);
}

.footer-dev a {
  color: inherit;
  text-decoration: none;
  font-weight: 500;
  transition: color 0.2s;
}

.footer-dev a:hover {
  color: var(--accent);
  text-decoration: underline;
}

@media (max-width: 600px) {
  .footer-content {
    flex-direction: column;
    text-align: center;
    justify-content: center;
  }
  .julia-dropdown-menu {
    left: 50%;
    transform: translateX(-50%) translateY(10px);
  }
  .julia-dropdown-menu.show {
    transform: translateX(-50%) translateY(0);
  }
}

/* ─── Scrollbar global ─── */
::-webkit-scrollbar {
  width: 6px;
}
::-webkit-scrollbar-track {
  background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
  background: var(--border-glow);
  border-radius: 3px;
}

.mobile-only-btn,
.mobile-only-flex {
  display: none !important;
}

/* ─── Responsive Mobile & Tablet Optimizations ─── */
@media (max-width: 999px) {
  html, body {
    overflow-x: hidden !important;
    max-width: 100vw;
  }
  .main-layout {
    grid-template-columns: minmax(0, 1fr) !important;
    height: auto;
    max-height: none;
    overflow: visible;
    width: 100%;
    max-width: 100vw;
    box-sizing: border-box;
  }
  .editor-panel, .code-panel {
    height: auto;
    overflow: visible;
    width: 100%;
    min-width: 0 !important;
    max-width: 100% !important;
    box-sizing: border-box;
  }
}

@media (max-width: 768px) {
  html, body {
    overflow-x: hidden !important;
    width: 100%;
    max-width: 100vw;
    margin: 0;
    padding: 0;
  }

  header {
    padding: 10px 12px;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: space-between;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }
  header h1 {
    font-size: 14px;
  }
  .header-badge {
    font-size: 10px;
    padding: 2px 6px;
  }

  .main-layout {
    padding: 8px;
    gap: 12px;
    width: 100%;
    min-width: 0 !important;
    max-width: 100vw !important;
    overflow-x: hidden !important;
    box-sizing: border-box;
  }

  .editor-panel, .code-panel,
  .toolbar, .options-bar, .frames-bar, .canvas-wrapper {
    min-width: 0 !important;
    max-width: 100% !important;
    width: 100%;
    box-sizing: border-box;
  }

  /* Toolbar re-architected for mobile */
  .toolbar {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    padding: 12px;
    gap: 12px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }

  .tool-separator {
    display: none;
  }

  /* 6 Action buttons in a 3-column grid (2 rows of 3 buttons) */
  .action-buttons-group {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 6px !important;
    width: 100% !important;
  }

  .action-buttons-group .tool-btn {
    width: 100% !important;
    min-width: 0 !important;
    margin: 0 !important;
    padding: 9px 4px !important;
    font-size: 11px !important;
    justify-content: center !important;
  }

  /* Pairs of secondary controls sit side-by-side on 1 row */
  /* Pairs of secondary controls wrap on mobile if screen is narrow */
  .toolbar-pair {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    width: 100% !important;
    gap: 8px 12px !important;
    flex-wrap: wrap !important;
  }

  .toolbar-pair .delta-opt-label {
    flex: 0 1 auto;
    font-size: 11px;
    margin: 0;
  }

  .toolbar-pair .name-field {
    flex: 1 1 140px;
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
  }

  .name-field input {
    flex: 1;
    min-width: 80px;
    width: 100%;
  }

  .zoom-control {
    flex: 1 1 140px;
    display: flex;
    align-items: center;
    gap: 6px;
  }

  .zoom-control input[type="range"] {
    flex: 1;
    min-width: 60px;
  }

  .toggle-group {
    flex: 0 1 auto;
    display: flex;
    align-items: center;
    gap: 6px;
  }

  .color-picker {
    flex: 1 1 120px;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
  }

  .color-picker-label {
    display: none; /* Hide label on mobile to save space */
  }

  .display-size-group {
    flex: 1 1 130px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
  }

  .display-size-label {
    display: none; /* Hide icon/label on mobile */
  }

  .display-preset-select {
    padding: 6px 8px;
    font-size: 11px;
  }

  .options-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 10px;
    width: 100%;
  }

  .options-section {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    width: 100%;
    gap: 8px;
  }

  .options-divider {
    display: none;
  }

  /* Frames bar structured for mobile */
  /* Frames bar structured for mobile: top line has title & tempo side-by-side */
  .frames-bar {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    padding: 10px;
    gap: 10px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }

  .frames-bar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    gap: 8px;
  }

  .frames-header-controls {
    display: contents !important;
  }

  .frames-title-group {
    order: 1;
  }

  .frames-delay-group {
    order: 2;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 6px;
  }

  .frames-actions-group {
    order: 4;
    width: 100%;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
  }

  .frames-actions-group > button {
    flex: 1;
    min-width: 0;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 8px 6px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
  }

  .frame-delay-label {
    white-space: nowrap;
  }

  .btn-frame-del {
    border-color: rgba(255, 107, 107, 0.4) !important;
    color: var(--accent-eraser) !important;
  }
  .btn-frame-del:hover {
    background: rgba(255, 107, 107, 0.15) !important;
  }

  .desktop-only-inline {
    display: none !important;
  }
  .tool-group-pencil-eraser {
    display: none !important;
  }
  .mobile-only-flex {
    display: flex !important;
  }

  .frame-tabs {
    width: 100%;
    order: 3;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding: 4px 0;
  }

  /* Canvas area full width on mobile without margin */
  .canvas-wrapper {
    padding: 12px 0 !important;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow: hidden;
    border-radius: 12px;
  }

  .canvas-info {
    font-size: 11px;
    text-align: center;
    line-height: 1.4;
    padding: 0 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    width: 100%;
    box-sizing: border-box;
  }

  .mobile-canvas-tools {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
    margin: 4px 0 8px 0;
    padding: 0 10px;
    box-sizing: border-box;
  }

  .mobile-canvas-tools .tool-btn {
    flex: 1;
    max-width: 160px;
    padding: 10px 18px;
    font-size: 13px;
    font-weight: 600;
    justify-content: center;
  }

  .canvas-scroll-area {
    width: 100% !important;
    max-width: 100% !important;
    max-height: 85vh !important;
    overflow: auto !important;
    display: flex;
    justify-content: center;
    padding: 0 !important;
    margin: 0 !important;
  }

  #oled-canvas {
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    margin: 0 !important;
    border-left: none !important;
    border-right: none !important;
    border-radius: 0 !important;
    display: block;
  }

  .code-panel {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }

  .code-header {
    flex-wrap: wrap;
    gap: 8px;
  }

  .code-output {
    max-height: 260px;
    font-size: 11px;
    padding: 10px;
  }

  .code-stats-row {
    flex-wrap: wrap;
  }
}

@media (max-width: 480px) {
  .tool-btn {
    flex: 1 1 100%;
  }

  .frames-bar-left, .frames-bar-right {
    flex-direction: column;
    align-items: stretch;
  }

  .btn-add-frame, .btn-play-pause, .btn-onion-skin {
    width: 100%;
    justify-content: center;
  }
}

/* ─── GIF Import Modal ─── */
.gif-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 5, 10, 0.82);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
}

.gif-modal-overlay.visible {
  opacity: 1;
  pointer-events: all;
}

.gif-modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border-glow);
  border-radius: 20px;
  padding: 28px 28px 24px;
  width: min(420px, 92vw);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(0,212,255,0.07);
  display: flex;
  flex-direction: column;
  gap: 20px;
  transform: translateY(12px) scale(0.97);
  transition: transform 0.22s ease;
}

.gif-modal-overlay.visible .gif-modal-card {
  transform: translateY(0) scale(1);
}

/* Header */
.gif-modal-header {
  display: flex;
  align-items: center;
  gap: 14px;
}

.gif-modal-icon {
  font-size: 28px;
  color: var(--accent);
  filter: drop-shadow(0 0 8px rgba(0, 212, 255, 0.5));
  flex-shrink: 0;
}

.gif-modal-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.2px;
}

.gif-modal-subtitle {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* Preview */
.gif-modal-preview-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 2 / 1;
  background: #000;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.gif-modal-preview-img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  image-rendering: pixelated;
}

.gif-modal-preview-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(0, 212, 255, 0.18);
  border: 1px solid rgba(0, 212, 255, 0.35);
  color: var(--accent);
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 20px;
  backdrop-filter: blur(4px);
}

/* Info row */
.gif-modal-info {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.gif-modal-info-item {
  flex: 1;
  min-width: 100px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.gif-modal-info-label {
  font-size: 10px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.gif-modal-info-value {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  font-family: 'JetBrains Mono', monospace;
}

/* Buttons */
.gif-modal-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.gif-modal-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 18px;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.16s ease;
  width: 100%;
}

.gif-modal-btn-all {
  background: rgba(0, 212, 255, 0.10);
  border-color: var(--accent-dim);
  color: var(--accent);
}

.gif-modal-btn-all:hover {
  background: rgba(0, 212, 255, 0.18);
  box-shadow: 0 0 18px rgba(0, 212, 255, 0.2);
  transform: translateY(-1px);
}

.gif-modal-btn-one {
  background: rgba(0, 255, 136, 0.07);
  border-color: var(--accent-pencil);
  color: var(--accent-pencil);
}

.gif-modal-btn-one:hover {
  background: rgba(0, 255, 136, 0.14);
  box-shadow: 0 0 18px rgba(0, 255, 136, 0.15);
  transform: translateY(-1px);
}

.gif-modal-btn-cancel {
  background: transparent;
  border-color: var(--border-color);
  color: var(--text-dim);
}

.gif-modal-btn-cancel:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-secondary);
  border-color: var(--border-glow);
}

/* ─── Crop Modal ─── */
.crop-modal-overlay {
  position: fixed;
  top: 0; left: 0; width: 100vw; height: 100vh;
  background: rgba(5, 5, 5, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.crop-modal-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

.crop-modal-card {
  background: rgba(18, 18, 18, 0.95);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  width: 90%;
  max-width: 800px;
  box-shadow: 0 24px 48px rgba(0,0,0,0.6), inset 0 1px 0 rgba(255,255,255,0.05);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: scale(0.96) translateY(10px);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.crop-modal-overlay.visible .crop-modal-card {
  transform: scale(1) translateY(0);
}

.crop-modal-header {
  padding: 24px 28px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  display: flex;
  align-items: center;
  gap: 16px;
  background: linear-gradient(180deg, rgba(255,255,255,0.03) 0%, transparent 100%);
}

.crop-modal-icon {
  font-size: 28px;
  color: var(--accent);
  filter: drop-shadow(0 0 12px rgba(0, 212, 255, 0.4));
}

.crop-modal-title {
  margin: 0;
  font-size: 18px;
  color: var(--text-primary);
  font-weight: 600;
}

.crop-modal-subtitle {
  margin: 4px 0 0 0;
  font-size: 13px;
  color: var(--text-dim);
}

.crop-modal-body {
  display: flex;
  flex-direction: row;
  padding: 24px 28px;
  gap: 24px;
}

@media (max-width: 768px) {
  .crop-modal-body {
    flex-direction: column;
  }
}

.crop-workspace {
  flex: 1;
  background: var(--bg-tertiary);
  border-radius: 12px;
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
  min-height: 250px;
}

.crop-container {
  position: relative;
  user-select: none;
  /* Dimensões serão calculadas via JS */
}

#crop-source-img {
  display: block;
  max-width: none;
  pointer-events: none;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.crop-box {
  position: absolute;
  border: 2px solid var(--accent);
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.6);
  cursor: move;
  box-sizing: border-box;
}

.crop-box::after {
  content: '';
  position: absolute;
  bottom: -6px; right: -6px;
  width: 12px; height: 12px;
  background: var(--accent);
  border-radius: 50%;
  cursor: se-resize;
  box-shadow: 0 0 8px rgba(0,212,255,0.6);
}

.crop-sidebar {
  width: 200px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

@media (max-width: 768px) {
  .crop-sidebar {
    width: 100%;
    flex-direction: row;
    align-items: flex-end;
  }
}

.crop-label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-dim);
  margin-bottom: 8px;
}

.crop-preview-wrap {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.crop-preview-canvas {
  image-rendering: pixelated;
  width: 100%;
  height: auto;
  border: 1px solid rgba(255,255,255,0.1);
  background: #000;
}

.crop-controls {
  flex: 1;
}

#crop-threshold {
  width: 100%;
  accent-color: var(--accent);
  cursor: pointer;
}

.crop-modal-actions {
  padding: 16px 28px;
  border-top: 1px solid rgba(255,255,255,0.05);
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  background: rgba(0,0,0,0.15);
}

.crop-modal-btn {
  padding: 10px 18px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.16s ease;
  display: flex;
  align-items: center;
  gap: 8px;
}

.crop-modal-btn-confirm {
  background: rgba(0, 212, 255, 0.10);
  border-color: var(--accent-dim);
  color: var(--accent);
}

.crop-modal-btn-confirm:hover {
  background: rgba(0, 212, 255, 0.18);
  box-shadow: 0 0 18px rgba(0, 212, 255, 0.2);
  transform: translateY(-1px);
}

.crop-modal-btn-cancel {
  background: transparent;
  border-color: var(--border-color);
  color: var(--text-dim);
}

.crop-modal-btn-cancel:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-secondary);
  border-color: var(--border-glow);
}
