* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: #0d1117;
  color: #c9d1d9;
  font-family: system-ui, -apple-system, sans-serif;
  display: flex;
  height: 100vh;
}

#app {
  display: flex;
  width: 100%;
  height: 100%;
}

/* Main layout */
.editor-panel {
  width: 440px;
  min-width: 440px;
  padding: 15px;
  display: flex;
  flex-direction: column;
  border-right: 1px solid #30363d;
  overflow-y: auto;
}

.preview-panel {
  flex: 1;
  padding: 15px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 0;
  margin-bottom: 10px;
  border-bottom: 1px solid #30363d;
}

.tab {
  padding: 8px 14px;
  cursor: pointer;
  border: 1px solid transparent;
  border-bottom: none;
  border-radius: 6px 6px 0 0;
  font-size: 12px;
  color: #8b949e;
}

.tab:hover {
  color: #c9d1d9;
}

.tab.active {
  background: #161b22;
  border-color: #30363d;
  color: #58a6ff;
  margin-bottom: -1px;
  padding-bottom: 9px;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* Sub tabs */
.sub-tabs {
  display: flex;
  gap: 5px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.sub-tab {
  padding: 5px 10px;
  cursor: pointer;
  border-radius: 4px;
  font-size: 11px;
  background: #21262d;
  border: 1px solid #30363d;
  display: flex;
  align-items: center;
  gap: 6px;
}

.sub-tab:hover {
  background: #30363d;
}

.sub-tab.active {
  background: #238636;
  border-color: #238636;
}

.sub-tab.add-tab {
  color: #58a6ff;
  font-weight: bold;
  padding: 5px 12px;
}

.sub-tab .color-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.sub-tab-content {
  display: none;
}

.sub-tab-content.active {
  display: block;
}

/* Radio Group */
.radio-group {
  display: flex;
  gap: 0;
}

.radio-btn {
  padding: 3px 8px;
  font-size: 10px;
  background: #21262d;
  border: 1px solid #30363d;
  color: #8b949e;
  cursor: pointer;
}

.radio-btn:first-child {
  border-radius: 4px 0 0 4px;
}

.radio-btn:last-child {
  border-radius: 0 4px 4px 0;
}

.radio-btn:not(:first-child) {
  border-left: none;
}

.radio-btn:hover {
  background: #30363d;
  color: #c9d1d9;
}

.radio-btn.active {
  background: #238636;
  border-color: #238636;
  color: #fff;
}

.radio-btn.active + .radio-btn {
  border-left-color: #238636;
}

/* Buttons */
button {
  background: #21262d;
  border: 1px solid #30363d;
  color: #c9d1d9;
  padding: 5px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 11px;
}

button:hover {
  background: #30363d;
}

button.primary {
  background: #238636;
  border-color: #238636;
}

button.primary:hover {
  background: #2ea043;
}

button.danger {
  background: transparent;
  border-color: #da3633;
  color: #da3633;
}

button.danger:hover {
  background: #da363322;
}

button.small {
  padding: 3px 8px;
  font-size: 10px;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Form elements */
.field {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.field label {
  font-size: 10px;
  opacity: 0.6;
  text-transform: uppercase;
}

.field input,
.field select {
  background: #0d1117;
  border: 1px solid #30363d;
  color: #c9d1d9;
  padding: 5px 8px;
  border-radius: 4px;
  font-size: 12px;
}

.field input:focus,
.field select:focus {
  outline: none;
  border-color: #58a6ff;
}

.field input[type="number"] {
  width: 70px;
}

.field select {
  min-width: 90px;
}

/* Layer styles */
.layer {
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 8px;
}

/* Toggle switch component */
.toggle-switch {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  flex-shrink: 0;
}

.toggle-track {
  display: block;
  width: 28px;
  height: 16px;
  background: #30363d;
  border-radius: 8px;
  position: relative;
  transition: background 0.15s ease;
}

.toggle-thumb {
  display: block;
  width: 12px;
  height: 12px;
  background: #8b949e;
  border-radius: 50%;
  position: absolute;
  top: 2px;
  left: 2px;
  transition: transform 0.15s ease, background 0.15s ease;
}

.toggle-switch.on .toggle-track {
  background: #238636;
}

.toggle-switch.on .toggle-thumb {
  background: #fff;
  transform: translateX(12px);
}

.toggle-switch:hover .toggle-track {
  background: #3d444d;
}

.toggle-switch.on:hover .toggle-track {
  background: #2ea043;
}

/* Move arrows component */
.move-arrows {
  display: inline-flex;
  gap: 2px;
}

.move-arrows.vertical {
  flex-direction: column;
}

.move-arrows.horizontal {
  flex-direction: row;
}

.move-arrows button {
  padding: 0 4px;
  line-height: 1;
  font-size: 10px;
}

/* Move animations (used by layers and processors) */
.moving-up {
  animation: move-up 0.2s ease;
}

.moving-down {
  animation: move-down 0.2s ease;
}

@keyframes move-up {
  0% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
  100% { transform: translateY(0); }
}

@keyframes move-down {
  0% { transform: translateY(0); }
  50% { transform: translateY(8px); }
  100% { transform: translateY(0); }
}

.layer-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.layer-title {
  flex: 1;
  font-weight: 600;
  font-size: 12px;
  color: #58a6ff;
}

.layer-actions {
  display: flex;
  gap: 4px;
  align-items: center;
}

.layer-row {
  display: flex;
  gap: 8px;
  margin-bottom: 6px;
  align-items: center;
  flex-wrap: wrap;
}

/* Checkbox */
.checkbox-field {
  flex-direction: row;
  align-items: center;
  gap: 5px;
}

.checkbox-field input {
  width: auto;
}

.checkbox-field label {
  font-size: 11px;
  text-transform: none;
  opacity: 0.9;
}

/* Mask section */
.mask-section {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed #30363d;
}

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

.mask-label {
  font-size: 11px;
  color: #8b949e;
}

.mask-content {
  background: #0d1117;
  border: 1px solid #30363d;
  border-radius: 6px;
  padding: 8px;
}

.mask-content .layer {
  margin-bottom: 0;
  background: #161b22;
}

/* Add layer button */
.add-layer-btn {
  width: 100%;
  padding: 8px;
  margin-top: 8px;
  border-style: dashed;
}

/* Sections */
.section {
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 10px;
}

.section h3 {
  margin: 0 0 8px 0;
  font-size: 11px;
  color: #8b949e;
  text-transform: uppercase;
}

/* Color Ramp / Thresholds */
.color-ramp-container {
  margin-bottom: 15px;
}

.color-ramp {
  height: 28px;
  border-radius: 4px;
  margin-bottom: 5px;
  cursor: crosshair;
  position: relative;
}

.color-stops-container {
  position: relative;
  height: 20px;
  margin-bottom: 10px;
}

.color-stop {
  position: absolute;
  width: 14px;
  height: 14px;
  border: 2px solid white;
  border-radius: 50%;
  transform: translate(-50%, 0);
  top: 0;
  cursor: grab;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
}

.color-stop:hover {
  transform: translate(-50%, 0) scale(1.15);
  transition: transform 0.1s;
}

.color-stop.selected {
  border-color: #58a6ff;
  box-shadow: 0 0 0 3px #58a6ff44, 0 2px 4px rgba(0, 0, 0, 0.4);
  transform: translate(-50%, 0) scale(1.15);
}

/* Threshold editor */
.threshold-editor {
  background: #0d1117;
  border: 1px solid #30363d;
  border-radius: 6px;
  padding: 10px;
  margin-top: 10px;
}

.threshold-editor-row {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 8px;
}

.threshold-editor-row:last-child {
  margin-bottom: 0;
}

.threshold-editor input[type="color"] {
  width: 40px;
  height: 30px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  padding: 0;
}

.threshold-editor input[type="text"] {
  flex: 1;
  background: #161b22;
  border: 1px solid #30363d;
  color: #c9d1d9;
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 12px;
}

.threshold-editor input[type="range"] {
  flex: 1;
}

.threshold-editor .pos-value {
  font-size: 11px;
  color: #7ee787;
  width: 40px;
  text-align: right;
}

/* Threshold list */
.threshold-list {
  margin-top: 10px;
}

.threshold-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  background: #0d1117;
  border-radius: 4px;
  margin-bottom: 4px;
  cursor: pointer;
  border: 1px solid transparent;
}

.threshold-item:hover {
  background: #161b22;
}

.threshold-item.selected {
  border-color: #58a6ff;
  background: #161b22;
}

.threshold-item .color-swatch {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.threshold-item .name {
  flex: 1;
  font-size: 12px;
}

.threshold-item .pos {
  font-size: 11px;
  color: #8b949e;
}

/* Slider field */
.slider-row {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 8px;
}

.slider-row label {
  font-size: 11px;
  width: 70px;
}

.slider-row input[type="range"] {
  flex: 1;
}

.slider-row .value {
  font-size: 11px;
  color: #7ee787;
  width: 40px;
  text-align: right;
}

/* Preview component */
.preview-component {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.preview-controls {
  display: flex;
  gap: 15px;
  margin-bottom: 10px;
  flex-wrap: wrap;
  align-items: center;
  width: 100%;
}

.preview-canvas-container {
  position: relative;
  cursor: grab;
  border-radius: 8px;
  overflow: hidden;
}

.preview-canvas-container:active {
  cursor: grabbing;
}

.preview-canvas-container canvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
}

.preview-info {
  display: flex;
  gap: 15px;
  margin-top: 8px;
  font-size: 11px;
  color: #8b949e;
}

.preview-info .perf {
  color: #7ee787;
}

.layer-thumbs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
  justify-content: center;
}

.layer-thumb {
  text-align: center;
}

.layer-thumb canvas {
  width: 70px;
  height: auto;
  border: 1px solid #30363d;
  border-radius: 4px;
  image-rendering: pixelated;
}

.layer-thumb .thumb-label {
  font-size: 9px;
  opacity: 0.6;
  margin-top: 3px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
}

.layer-thumb .thumb-time {
  font-size: 8px;
  color: #7ee787;
  opacity: 1;
}

.preview-main-row {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.preview-canvas-area {
  flex-shrink: 0;
}

.preview-thumbs-sidebar {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 70px;
}

.preview-thumbs-sidebar .layer-thumb {
  cursor: pointer;
  opacity: 0.6;
  transition: opacity 0.15s;
}

.preview-thumbs-sidebar .layer-thumb:hover {
  opacity: 0.9;
}

.preview-thumbs-sidebar .layer-thumb.selected {
  opacity: 1;
}

.preview-thumbs-sidebar .layer-thumb.selected canvas {
  outline: 2px solid #58a6ff;
  outline-offset: 1px;
}

.preview-thumbs-sidebar .layer-thumb canvas {
  width: 70px;
  height: auto;
  image-rendering: pixelated;
}

/* Sub preview */
.sub-preview {
  margin-top: 15px;
  padding-top: 15px;
  border-top: 1px solid #30363d;
}

.sub-preview h4 {
  margin: 0 0 10px 0;
  font-size: 12px;
  color: #8b949e;
}

/* Noise preview component */
.noise-preview {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.noise-preview-controls {
  display: flex;
  align-items: center;
  gap: 15px;
  margin-bottom: 10px;
}

.noise-preview-controls label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: #8b949e;
}

.noise-preview-controls input[type="range"] {
  width: 120px;
}

.noise-preview-controls .zoom-value {
  min-width: 32px;
  color: #c9d1d9;
}

.noise-preview-controls .perf {
  color: #7ee787;
  font-size: 11px;
}

.noise-preview-row {
  display: flex;
  gap: 20px;
  justify-content: center;
}

.noise-preview-col {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.noise-preview-col .preview-label {
  font-size: 11px;
  color: #8b949e;
  margin-bottom: 6px;
  font-weight: 500;
}

.noise-preview-col canvas {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 8px;
  image-rendering: pixelated;
}

/* Preview details (coords, timing, biome legend) */
.preview-details {
  margin-top: 8px;
  flex-shrink: 0;
}

.preview-details .preview-info {
  margin-top: 0;
}

.preview-details .biome-legend {
  margin-top: 6px;
}

/* Biome legend */
.biome-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  justify-content: center;
}

.biome-legend:empty {
  display: none;
}

.biome-legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  color: #8b949e;
}

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

/* Titles */
h1 {
  margin: 0 0 5px 0;
  font-size: 18px;
  color: #58a6ff;
}

.subtitle {
  font-size: 11px;
  opacity: 0.6;
  margin-bottom: 10px;
}

/* Biome info */
.biome-info-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.biome-info-header .color-swatch {
  width: 24px;
  height: 24px;
  border-radius: 4px;
  border: 2px solid rgba(255, 255, 255, 0.2);
}

.biome-info-header .biome-name {
  font-size: 14px;
  font-weight: 600;
  color: #58a6ff;
}

.biome-requirements {
  background: #21262d;
  border-radius: 6px;
  padding: 8px 10px;
}

.req-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
  flex-wrap: wrap;
}

.req-row:last-child {
  margin-bottom: 0;
}

.req-label {
  font-size: 11px;
  color: #8b949e;
  width: 80px;
  flex-shrink: 0;
}

.req-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 10px;
  background: var(--tag-color, #808080);
  color: #ffffff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  margin-right: 2px;
}

.any-tag {
  font-size: 10px;
  color: #6e7681;
  font-style: italic;
}

/* Condition groups */
.condition-groups {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
}

.condition-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.condition-group-label {
  font-size: 10px;
  color: #6e7681;
  text-transform: uppercase;
  width: 70px;
  flex-shrink: 0;
}

.condition-group .sub-tabs {
  margin-bottom: 0;
  flex: 1;
}

/* Requirement groups */
.req-group {
  margin-bottom: 12px;
  padding: 8px;
  background: #0d1117;
  border-radius: 6px;
}

.req-group:last-child {
  margin-bottom: 0;
}

.req-group-label {
  font-size: 10px;
  color: #6e7681;
  text-transform: uppercase;
  margin-bottom: 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid #21262d;
}

/* Biome definition */
.biome-def {
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 8px;
}

.biome-def.collapsed .biome-def-details {
  display: none;
}

.biome-def-header {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.biome-def-header .color-swatch {
  width: 24px;
  height: 24px;
  border-radius: 4px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  cursor: pointer;
  padding: 0;
}

.biome-def-header .color-swatch:hover {
  border-color: #58a6ff;
}

.biome-def-header .biome-name-input {
  flex: 1;
  background: transparent;
  border: none;
  color: #58a6ff;
  font-size: 13px;
  font-weight: 600;
  padding: 2px 4px;
}

.biome-def-header .biome-name-input:focus {
  background: #0d1117;
  border-radius: 4px;
  outline: 1px solid #58a6ff;
}

.biome-def-header .expand-btn {
  font-size: 10px;
  color: #8b949e;
}

.biome-def-header .biome-color-indicator {
  width: 16px;
  height: 16px;
  border-radius: 3px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  flex-shrink: 0;
}

.biome-def-header .biome-name-display {
  flex: 1;
  color: #c9d1d9;
  font-size: 13px;
  font-weight: 500;
}

.biome-def-details {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed #30363d;
}

.biome-color-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.biome-color-row label {
  font-size: 11px;
  color: #8b949e;
  min-width: 40px;
}

.biome-color-row .color-swatch {
  width: 32px;
  height: 32px;
  border-radius: 4px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  cursor: pointer;
  padding: 0;
}

.biome-color-row .color-swatch:hover {
  border-color: #58a6ff;
}

.biome-color-row .biome-name-input {
  flex: 1;
  background: #0d1117;
  border: 1px solid #30363d;
  border-radius: 4px;
  color: #c9d1d9;
  font-size: 12px;
  padding: 6px 8px;
}

.biome-color-row .biome-name-input:focus {
  border-color: #58a6ff;
  outline: none;
}

/* Condition definition (list style like biomes) */
.condition-def {
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 8px;
}

.condition-def.collapsed .condition-def-details {
  display: none;
}

.condition-def-header {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.condition-def-header .condition-color-indicator {
  width: 40px;
  height: 16px;
  border-radius: 3px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  flex-shrink: 0;
}

.condition-def-header .condition-name-display {
  flex: 1;
  color: #c9d1d9;
  font-size: 13px;
  font-weight: 500;
}

.condition-def-header .expand-btn {
  font-size: 10px;
  color: #8b949e;
}

.condition-def-details {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed #30363d;
}

.condition-name-row {
  margin-bottom: 12px;
}

.condition-name-input {
  width: 100%;
  background: #0d1117;
  border: 1px solid #30363d;
  border-radius: 4px;
  color: #58a6ff;
  font-size: 13px;
  font-weight: 600;
  padding: 6px 10px;
}

.condition-name-input:focus {
  border-color: #58a6ff;
  outline: none;
}

.condition-section {
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid #21262d;
}

.condition-section:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.condition-section-label {
  display: block;
  font-size: 10px;
  color: #8b949e;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.condition-select {
  width: 100%;
  padding: 6px 8px;
  font-size: 12px;
  background: #0d1117;
  border: 1px solid #30363d;
  border-radius: 4px;
  color: #c9d1d9;
}

.condition-thresholds {
  margin-bottom: 8px;
}

.condition-threshold-row {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-bottom: 6px;
}

.condition-threshold-row select {
  flex: 1;
  font-size: 11px;
  padding: 4px 6px;
  background: #0d1117;
  border: 1px solid #30363d;
  border-radius: 4px;
  color: #c9d1d9;
}

.condition-threshold-row input[type="number"] {
  width: 55px;
  font-size: 11px;
  padding: 4px 6px;
  background: #0d1117;
  border: 1px solid #30363d;
  border-radius: 4px;
  color: #c9d1d9;
}

.condition-threshold-row input[type="number"]::placeholder {
  color: #6e7681;
}

.condition-req-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid #21262d;
}

.condition-req-row .condition-req-label {
  font-size: 11px;
  color: #8b949e;
  min-width: 80px;
  flex-shrink: 0;
}

.condition-req-row .threshold-chips {
  flex: 1;
}

.condition-req-row:last-of-type {
  border-bottom: none;
  padding-bottom: 0;
}

.condition-req-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.condition-req-label {
  color: #58a6ff;
  font-size: 12px;
  font-weight: 500;
  text-transform: capitalize;
}

.condition-remove-btn {
  background: transparent;
  border: 1px solid #da3633;
  color: #da3633;
  width: 20px;
  height: 20px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.condition-remove-btn:hover {
  background: #da363322;
}

/* Add condition chips */
.add-condition-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed #30363d;
}

.add-condition-label {
  font-size: 11px;
  color: #8b949e;
  flex-shrink: 0;
}

.add-condition-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.add-condition-chip {
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 11px;
  cursor: pointer;
  background: #21262d;
  border: 1px dashed #30363d;
  color: #8b949e;
  transition: all 0.15s ease;
}

.add-condition-chip:hover {
  border-color: #58a6ff;
  color: #58a6ff;
  border-style: solid;
}

/* No conditions message */
.no-conditions-msg {
  font-size: 11px;
  color: #6e7681;
  font-style: italic;
  padding: 4px 0;
}

/* Biome thresholds section */
.biome-thresholds-section {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #30363d;
}

.biome-thresholds-header {
  font-size: 10px;
  color: #8b949e;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.biome-threshold-row {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-bottom: 6px;
}

.biome-threshold-row select {
  flex: 1;
  font-size: 11px;
  padding: 4px 6px;
  background: #0d1117;
  border: 1px solid #30363d;
  border-radius: 4px;
  color: #c9d1d9;
}

.biome-threshold-row input[type="number"] {
  width: 55px;
  font-size: 11px;
  padding: 4px 6px;
  background: #0d1117;
  border: 1px solid #30363d;
  border-radius: 4px;
  color: #c9d1d9;
}

.biome-threshold-row input[type="number"]::placeholder {
  color: #6e7681;
}

.threshold-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
}

.threshold-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 11px;
  cursor: pointer;
  background: #21262d;
  border: 1px solid #30363d;
  color: #c9d1d9;
  transition: all 0.15s ease;
}

.threshold-chip:hover {
  border-color: #58a6ff;
}

.threshold-chip.selected {
  background: var(--chip-color, #238636);
  border-color: var(--chip-color, #238636);
  color: #ffffff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.threshold-chip input[type="checkbox"] {
  display: none;
}

.any-indicator {
  font-size: 10px;
  color: #6e7681;
  font-style: italic;
  margin-left: 4px;
}

/* Header row */
.header-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 10px;
}

.header-row h1 {
  margin: 0;
}

.header-row .subtitle {
  margin: 4px 0 0 0;
}

.header-actions {
  display: flex;
  gap: 8px;
}

.action-btn {
  padding: 6px 12px;
  background: #238636;
  border: none;
  border-radius: 6px;
  color: #fff;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
}

.action-btn:hover {
  background: #2ea043;
}

.action-btn.danger {
  background: #6e4030;
}

.action-btn.danger:hover {
  background: #8b4513;
}

.action-btn.small {
  padding: 4px 8px;
  font-size: 11px;
}

/* JSON tab */
.json-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.json-output {
  background: #0d1117;
  border: 1px solid #30363d;
  border-radius: 6px;
  padding: 12px;
  font-size: 11px;
  color: #8b949e;
  overflow: auto;
  max-height: calc(100vh - 200px);
  white-space: pre-wrap;
  word-break: break-all;
}


/* Disabled state for biomes and conditions */
.biome-def.disabled,
.condition-def.disabled {
  opacity: 0.5;
}

.biome-def.disabled .biome-def-header,
.condition-def.disabled .condition-def-header {
  opacity: 0.7;
}

.biome-def.disabled .biome-name-display,
.condition-def.disabled .condition-name-display {
  text-decoration: line-through;
  color: #8b949e;
}

/* Processor editor */
.processor-editor {
  margin-top: 10px;
}

.processor-item {
  background: #0d1117;
  border: 1px solid #30363d;
  border-radius: 6px;
  padding: 8px;
  margin-bottom: 6px;
}

.processor-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.processor-type {
  flex: 1;
  font-size: 11px;
  font-weight: 600;
  color: #58a6ff;
  text-transform: capitalize;
}

.processor-actions {
  display: flex;
  gap: 3px;
}

.processor-controls {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.processor-controls .field {
  flex: 1;
}

/* Disabled source items */
.section > div.disabled {
  opacity: 0.5;
  border-left-color: #21262d !important;
}

.section > div.disabled select {
  color: #6e7681;
}

/* Disabled processor items */
.processor-item.disabled {
  opacity: 0.5;
}

.processor-item.disabled .processor-type {
  text-decoration: line-through;
  color: #6e7681;
}

/* Detail panel header (for condition/biome detail views) */
.detail-panel-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px dashed #30363d;
}

.detail-panel-name {
  flex: 1;
  background: #0d1117;
  border: 1px solid #30363d;
  border-radius: 4px;
  color: #58a6ff;
  font-size: 13px;
  font-weight: 600;
  padding: 6px 10px;
}

.detail-panel-name:focus {
  border-color: #58a6ff;
  outline: none;
}

.color-swatch-small {
  width: 28px;
  height: 28px;
  border-radius: 4px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
}

.color-swatch-small:hover {
  border-color: #58a6ff;
}

/* Tooltip */
.tooltip-wrapper {
  position: relative;
  display: inline-flex;
  flex: 1;
}

.tooltip-text {
  visibility: hidden;
  opacity: 0;
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: #1c2128;
  color: #c9d1d9;
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 400;
  white-space: nowrap;
  max-width: 250px;
  white-space: normal;
  text-transform: none;
  line-height: 1.4;
  z-index: 100;
  border: 1px solid #30363d;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  pointer-events: none;
  transition: opacity 0.15s, visibility 0.15s;
}

.tooltip-text::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: #30363d;
}

.tooltip-wrapper:hover .tooltip-text {
  visibility: visible;
  opacity: 1;
}

/* Add Popover */
.add-popover-wrapper {
  position: relative;
  display: inline-flex;
}

.add-popover {
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  min-width: 120px;
  max-width: 280px;
  max-height: 400px;
  overflow-y: auto;
}

.add-popover-item {
  padding: 8px 12px;
  font-size: 11px;
  color: #c9d1d9;
  cursor: pointer;
  transition: background 0.1s;
}

.add-popover-item:hover {
  background: #21262d;
}

.add-popover-item:hover .add-popover-label {
  color: #58a6ff;
}

.add-popover-item.has-description {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 12px;
}

.add-popover-label {
  font-weight: 500;
}

.add-popover-description {
  font-size: 10px;
  color: #8b949e;
  line-height: 1.3;
}

.add-popover-separator {
  padding: 6px 12px;
  font-size: 10px;
  color: #6e7681;
  border-top: 1px solid #30363d;
  margin-top: 4px;
  text-align: center;
}

/* Layer type label */
.layer-type-label {
  font-size: 12px;
  color: #58a6ff;
  font-weight: 500;
}

/* Toast notification */
.toast {
  background: #238636;
  color: #fff;
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 11px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  z-index: 1000;
  pointer-events: none;
  animation: toast-fade 1.5s ease-in-out;
}

@keyframes toast-fade {
  0% { opacity: 0; transform: translateX(-50%) translateY(5px); }
  15% { opacity: 1; transform: translateX(-50%) translateY(0); }
  85% { opacity: 1; transform: translateX(-50%) translateY(0); }
  100% { opacity: 0; transform: translateX(-50%) translateY(-5px); }
}

.copy-button-wrapper {
  position: relative;
  display: inline-flex;
}

/* Unified Preview Component */
.unified-preview {
  display: flex;
  flex-direction: column;
  gap: 15px;
  flex: 1;
  min-height: 0;
}

.unified-preview-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.zoom-slider {
  display: flex;
  align-items: center;
  gap: 8px;
}

.zoom-slider .zoom-label {
  font-size: 12px;
  min-width: 45px;
  text-align: right;
}

.zoom-slider input[type="range"] {
  width: 100px;
}

.unified-preview-section {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

/* Main preview uses layer-thumb structure with responsive canvas */
.layer-thumb.main-preview {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
}

.layer-thumb.main-preview .canvas-clip {
  position: relative;
  overflow: hidden;
  border-radius: 8px;
  cursor: grab;
  /* Canvas sized to available height minus labels (~40px), aspect-ratio set inline */
  height: calc(100cqh - 40px);
  max-width: calc(100cqw - 80px); /* subtract sidebar + gap */
  touch-action: none; /* Prevent browser touch gestures */
  background: repeating-conic-gradient(#1a1a1a 0% 25%, #141414 0% 50%) 50% / 16px 16px;
}

.layer-thumb.main-preview .canvas-clip:active {
  cursor: grabbing;
}

.layer-thumb.main-preview canvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
}

/* Region box overlay - fixed center, always visible above canvas */
.layer-thumb.main-preview .region-box-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  /* Size set dynamically via inline style (100 / regionWorldRatio)% */
  /* Fallback for default ratio of 8 */
  width: 12.5%;
  height: 12.5%;
  transform: translate(-50%, -50%);
  border: 2px dashed white;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.5);
  pointer-events: none;
  box-sizing: border-box;
  z-index: 10;
}

.layer-thumb.main-preview .thumb-label {
  font-size: 11px;
  opacity: 1;
  flex-shrink: 0;
}

.unified-preview-section .preview-main-row {
  display: flex;
  gap: 10px;
  flex: 1;
  min-height: 0;
  container-type: size;
}

.unified-preview-section .preview-thumbs-sidebar {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 70px;
  flex-shrink: 0;
  overflow-y: auto;
  align-self: stretch;
}

.unified-preview-section.sub-preview {
  padding-top: 15px;
  border-top: 1px solid #30363d;
}

/* Position bar above main preview */
.preview-pos-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 10px;
  color: #8b949e;
  margin-bottom: 4px;
  padding: 0 2px;
  font-family: monospace;
  flex-shrink: 0;
}

.preview-pos-bar .pos-center {
  color: #7ee787;
}

.preview-pos-bar .pos-mouse {
  color: #58a6ff;
}
