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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #1a1a2e;
  font-family: system-ui, -apple-system, sans-serif;
}

#toolbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  background: #16213e;
  border-bottom: 1px solid #0f3460;
  z-index: 10;
}

.toolbar-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
}

.toolbar-row-tools {
  height: 48px;
  flex-shrink: 0;
}

.toolbar-row-settings {
  height: 44px;
  flex-shrink: 0;
  background: rgba(15, 52, 96, 0.25);
  border-top: 1px solid rgba(15, 52, 96, 0.5);
}

.toolbar-row-portals {
  min-height: 40px;
  flex-shrink: 0;
  flex-wrap: wrap;
  gap: 8px;
  padding: 6px 12px;
  background: rgba(157, 78, 221, 0.12);
  border-top: 1px solid rgba(157, 78, 221, 0.35);
  font-size: 13px;
}

.toolbar-row-portals .toolbar-group {
  display: flex;
  align-items: center;
  gap: 4px;
}

.toolbar-row-portals .portal-coords-label {
  font-weight: 600;
  color: rgba(157, 78, 221, 0.95);
  margin-right: 2px;
}

.toolbar-row-portals .portal-input {
  width: 56px;
  padding: 2px 4px;
}

.toolbar-row-portals #portal-cooldown {
  width: 80px;
}

.toolbar-row-counter {
  min-height: 32px;
  padding: 4px 12px;
  background: rgba(45, 198, 83, 0.15);
  border-top: 1px solid rgba(45, 198, 83, 0.3);
  font-size: 13px;
  color: #2dc653;
  font-weight: 600;
  align-items: center;
  gap: 10px;
}

.finish-by-color {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.finish-color-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 22px;
  padding: 0 6px;
  border-radius: 11px;
  font-size: 12px;
  font-weight: 700;
  color: rgba(0, 0, 0, 0.75);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.25);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.4);
}

.toolbar-row-counter .counter-sep {
  color: rgba(45, 198, 83, 0.5);
  margin: 0 4px;
  font-weight: 600;
}

.toolbar-row-save {
  padding: 4px 12px;
  gap: 6px;
  flex-wrap: nowrap;
  align-items: stretch;
  background: rgba(15, 52, 96, 0.4);
  border-top: 1px solid rgba(15, 52, 96, 0.6);
  min-height: 72px;
}

.save-actions {
  display: flex;
  flex-direction: column;
  gap: 3px;
  justify-content: center;
  flex-shrink: 0;
  min-width: 100px;
}

.save-actions .save-slot-num {
  font-size: 11px;
  color: #a0a0a0;
  font-weight: 600;
}

.save-actions #slot-title {
  width: 100px;
  padding: 3px 6px;
  font-size: 11px;
  border: 1px solid #0f3460;
  border-radius: 4px;
  background: #0f3460;
  color: #e8e8e8;
}

.save-actions button {
  padding: 3px 8px !important;
  font-size: 11px !important;
  min-height: 22px;
}

.slot-strip {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  overflow-y: hidden;
  flex: 1;
  align-items: center;
  padding: 2px 0;
  scrollbar-width: thin;
  scrollbar-color: #0f3460 transparent;
}

.slot-strip::-webkit-scrollbar {
  height: 6px;
}

.slot-strip::-webkit-scrollbar-thumb {
  background: #0f3460;
  border-radius: 3px;
}

.slot-thumb {
  flex-shrink: 0;
  width: 76px;
  cursor: pointer;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.slot-thumb canvas {
  display: block;
  width: 72px;
  height: 48px;
  border-radius: 3px;
  background: #1a1a2e;
  border: 2px solid transparent;
  transition: border-color 0.15s;
}

.slot-thumb .slot-thumb-label {
  display: block;
  font-size: 9px;
  color: #a0a0a0;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 72px;
  height: 12px;
  line-height: 12px;
}

.slot-thumb:hover canvas {
  border-color: rgba(255,255,255,0.35);
}

.slot-thumb.active canvas {
  border-color: #e94560;
}

.slot-thumb.empty canvas {
  opacity: 0.35;
}

#color-swatches {
  gap: 3px !important;
}

#color-swatches .swatch-label {
  font-size: 12px;
  color: #a0a0a0;
  margin-right: 2px;
}

.color-swatch {
  width: 22px;
  height: 22px;
  min-width: 22px;
  padding: 0;
  border: 3px solid transparent;
  border-radius: 50%;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.1s, box-shadow 0.15s;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.3);
  outline: none;
}

.color-swatch:hover {
  transform: scale(1.15);
  border-color: rgba(255,255,255,0.5);
}

.color-swatch.active {
  width: 28px;
  height: 28px;
  min-width: 28px;
  border: 4px solid #fff;
  box-shadow: 0 0 0 2px rgba(0,0,0,0.5), 0 0 10px rgba(255,255,255,0.6);
  transform: scale(1.1);
}

.color-swatch-gradient {
  min-width: 28px;
  width: 28px;
  height: 22px;
  border-radius: 4px;
}

.gradient-editor {
  position: fixed;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: rgba(15, 52, 96, 0.98);
  border: 1px solid #1a4a7a;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  z-index: 25;
  font-size: 12px;
  color: #e8e8e8;
}

.gradient-editor .gradient-editor-label {
  width: 100%;
  font-weight: 600;
  color: #4cc9f0;
}

.gradient-editor label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.gradient-editor input[type="color"] {
  width: 28px;
  height: 22px;
  padding: 0;
  border: 1px solid #0f3460;
  border-radius: 4px;
  cursor: pointer;
  background: transparent;
}

.gradient-editor #gradient-editor-done {
  padding: 4px 10px;
  font-size: 11px;
}


#toolbar button {
  padding: 8px 14px;
  border: none;
  border-radius: 6px;
  background: #0f3460;
  color: #e8e8e8;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s;
}

#toolbar button:hover {
  background: #1a4a7a;
}

#toolbar button.active {
  background: #e94560;
  color: #fff;
}

#toolbar .hotkey {
  font-size: 10px;
  opacity: 0.85;
  margin-left: 2px;
}

.toolbar-radio-group {
  display: inline-flex;
}

.toolbar-radio-group button {
  border-radius: 0;
}

.toolbar-radio-group button:first-child {
  border-radius: 6px 0 0 6px;
}

.toolbar-radio-group button:last-child {
  border-radius: 0 6px 6px 0;
}

.toolbar-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #a0a0a0;
}

.toolbar-right {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding-left: 12px;
  border-left: 1px solid #0f3460;
}

.toolbar-timed-section {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border-left-color: rgba(249, 199, 79, 0.25) !important;
  background: rgba(249, 199, 79, 0.06);
  border-radius: 6px;
  padding: 4px 10px 4px 12px !important;
}

.timed-timing {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.timed-label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  color: rgba(249, 199, 79, 0.95);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.timed-label-text {
  min-width: 2.2em;
}

.toolbar-timed-section .timed-input,
.toolbar-timed-section #timed-cycle,
.toolbar-timed-section #timed-off {
  width: 4.5em;
  min-width: 4.5em;
  padding: 4px 6px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid rgba(249, 199, 79, 0.35);
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.2);
  color: #f9c74f;
  text-align: center;
}

.toolbar-timed-section .timed-input:focus,
.toolbar-timed-section #timed-cycle:focus,
.toolbar-timed-section #timed-off:focus {
  outline: none;
  border-color: rgba(249, 199, 79, 0.7);
  background: rgba(0, 0, 0, 0.3);
}

.timed-btn {
  background: rgba(249, 199, 79, 0.18) !important;
  color: #f9c74f !important;
  border: 1px solid rgba(249, 199, 79, 0.35) !important;
  padding: 6px 12px !important;
}

.timed-btn:hover {
  background: rgba(249, 199, 79, 0.3) !important;
}

#toolbar button.timed-btn.active {
  background: #f9c74f !important;
  color: #1a1a2e !important;
  border-color: #f9c74f !important;
}

.toolbar-group label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: default;
}

.toolbar-group input[type="range"] {
  width: 72px;
  accent-color: #e94560;
}

#speed-value, #interval-value {
  min-width: 2.5em;
  color: #e8e8e8;
}


.toolbar-checkbox {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: #e8e8e8;
  cursor: pointer;
  user-select: none;
}

.toolbar-checkbox input[type="checkbox"] {
  accent-color: #e94560;
  cursor: pointer;
}


#canvas {
  display: block;
  position: fixed;
  top: 200px;
  left: 0;
  width: 100%;
  height: calc(100% - 200px);
  cursor: crosshair;
}

#canvas.edit-mode {
  cursor: default;
}

#canvas.erase-mode {
  cursor: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="%23e94560" stroke-width="2"><path d="M20 20H7L3 16l10-10 7 7-7 7z"/></svg>') 4 4, crosshair;
}

#canvas.arrow-mode {
  cursor: default;
}

#inspect-tooltip {
  position: fixed;
  pointer-events: none;
  z-index: 20;
  max-width: 280px;
  padding: 10px 12px;
  background: rgba(15, 52, 96, 0.97);
  border: 1px solid #1a4a7a;
  border-radius: 8px;
  font-size: 12px;
  color: #e8e8e8;
  line-height: 1.45;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  display: none;
}

#inspect-tooltip.visible {
  display: block;
}

#inspect-tooltip .inspect-title {
  font-weight: 600;
  color: #4cc9f0;
  margin-bottom: 6px;
  font-size: 13px;
}

#inspect-tooltip .inspect-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

#inspect-tooltip .inspect-row .key {
  color: #a0a0a0;
}

#inspect-tooltip .inspect-row .val {
  color: #fff;
  text-align: right;
}

#inspect-tooltip .inspect-bio {
  margin-top: 6px;
  font-style: italic;
  color: #c8c8c8;
}

#version-label {
  position: fixed;
  bottom: 6px;
  right: 10px;
  font-size: 10px;
  color: rgba(255,255,255,0.25);
  pointer-events: none;
  z-index: 5;
  font-family: monospace;
}

.spawn-beacon {
  position: fixed;
  pointer-events: none;
  z-index: 15;
  width: 0;
  height: 0;
  border-radius: 50%;
  border: 3px solid;
  transform: translate(-50%, -50%);
  animation: spawn-ring 1.2s ease-out forwards;
}

.spawn-beacon-2 {
  animation-delay: 0.15s;
}

.spawn-beacon-3 {
  animation-delay: 0.3s;
}

@keyframes spawn-ring {
  0% { width: 20px; height: 20px; opacity: 1; border-width: 4px; }
  100% { width: 160px; height: 160px; opacity: 0; border-width: 1px; }
}

.spawn-crosshair {
  position: fixed;
  pointer-events: none;
  z-index: 15;
  transform: translate(-50%, -50%);
  animation: spawn-cross 1s ease-out forwards;
}

.spawn-crosshair::before,
.spawn-crosshair::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.spawn-crosshair::before {
  width: 60px;
  height: 3px;
  background: inherit;
}

.spawn-crosshair::after {
  width: 3px;
  height: 60px;
  background: inherit;
}

@keyframes spawn-cross {
  0% { opacity: 1; }
  70% { opacity: 0.8; }
  100% { opacity: 0; }
}

.spawn-label {
  position: fixed;
  pointer-events: none;
  z-index: 15;
  transform: translate(-50%, -100%);
  font-size: 13px;
  font-weight: 700;
  font-family: system-ui, sans-serif;
  padding: 2px 8px;
  border-radius: 4px;
  white-space: nowrap;
  animation: spawn-label-fade 1.5s ease-out forwards;
}

@keyframes spawn-label-fade {
  0% { opacity: 1; transform: translate(-50%, -100%); }
  100% { opacity: 0; transform: translate(-50%, calc(-100% - 30px)); }
}
