/* Standardized utility background is now in util-base.css */


.texture-workspace-card {
  max-width: none;
}

.texture-upload-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: var(--space-4);
  align-items: start;
}

.texture-upload-panel {
  display: grid;
  gap: var(--space-3);
  align-content: start;
  min-width: 0;
}

.texture-upload-panel--left,
.texture-preview-block--original {
  grid-column: 1;
}

.texture-upload-panel--right,
.texture-preview-block--quant,
.texture-action-row--right,
.texture-schem-result--right {
  grid-column: 2;
}

.texture-preview-block {
  display: grid;
  gap: var(--space-2);
}

.texture-preview-title {
  font-weight: 600;
}

.texture-preview-empty {
  font-size: 0.85rem;
  color: var(--muted-foreground);
  padding: var(--space-4);
  text-align: center;
  width: 100%;
}

.texture-action-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

.texture-schem-result {
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  background: var(--muted);
  display: grid;
  gap: var(--space-2);
}

.texture-progress {
  display: grid;
  gap: var(--space-3);
}

.texture-progress-meta {
  display: flex;
  justify-content: space-between;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.texture-progress-bar {
  position: relative;
  height: 10px;
  border-radius: 999px;
  background: var(--muted);
  overflow: hidden;
  border: 1px solid var(--border);
}

.texture-progress-fill {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, rgba(56, 189, 248, 0.4), var(--primary));
  transition: width 0.4s ease;
}

.texture-step-grid {
  display: grid;
  gap: var(--space-3);
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.texture-step {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  background: var(--muted);
  display: grid;
  gap: var(--space-2);
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s;
}

.texture-step[data-status="active"] {
  border-color: var(--primary);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

.texture-step[data-status="done"] {
  border-color: rgba(34, 197, 94, 0.6);
  background: rgba(34, 197, 94, 0.08);
}

.texture-step[data-status="error"] {
  border-color: rgba(239, 68, 68, 0.6);
  background: rgba(239, 68, 68, 0.08);
}

.texture-step-header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.texture-step-index {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--card);
  border: 1px solid var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.85rem;
}

.texture-step-title {
  font-weight: 600;
}

.texture-result-grid {
  display: grid;
  gap: var(--space-3);
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.texture-result-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  background: var(--muted);
  display: grid;
  gap: var(--space-2);
}

.texture-result-title {
  font-weight: 600;
}

.texture-preview-frame {
  min-height: 220px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--card);
  padding: var(--space-2);
  display: flex;
  justify-content: center;
  align-items: center;
}

.texture-preview {
  max-width: 100%;
  max-height: 320px;
  height: auto;
  object-fit: contain;
  image-rendering: pixelated;
}

.texture-result-actions {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.texture-palette-grid {
  display: grid;
  gap: var(--space-3);
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  align-items: start;
}

.texture-palette-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  background: var(--muted);
  display: grid;
  gap: var(--space-2);
  overflow: visible;
}

.texture-palette-title {
  font-weight: 600;
}

.texture-palette-split {
  display: grid;
  gap: var(--space-3);
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  align-items: start;
}

.texture-palette-panel {
  display: grid;
  gap: var(--space-2);
  padding: var(--space-2);
  border-radius: var(--radius-md);
  border: 1px dashed var(--border);
  background: var(--card);
  min-width: 0;
}

.texture-palette-panel--excluded {
  border-style: solid;
}

.texture-palette-panel .texture-palette-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 80px;
  grid-column: 1 / -1;
  text-align: center;
  color: var(--muted-foreground);
  font-size: 0.85rem;
  width: 100%;
}

.texture-palette-title-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--space-2);
}

.texture-palette-subtitle {
  font-weight: 600;
  font-size: 0.95rem;
}

.texture-palette-hint {
  color: var(--muted-foreground);
}

.texture-palette-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
}

.texture-palette-swatches {
  --palette-swatch-size: 28px;
  display: grid;
  gap: 0;
  grid-auto-rows: var(--palette-swatch-size);
  justify-content: start;
  align-content: start;
  padding: 0;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--card);
  overflow: visible;
  width: 100%;
  max-width: 100%;
}

.texture-palette-swatches.is-empty {
  grid-auto-rows: minmax(80px, auto);
  min-height: 80px;
}

.texture-palette-swatch {
  width: var(--palette-swatch-size);
  height: var(--palette-swatch-size);
  border-radius: 0;
  border: 0;
  position: relative;
  cursor: pointer;
  z-index: 1;
}

.texture-palette-swatch:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
  z-index: 3;
}

.texture-palette-tooltip {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  transform: translate(-50%, 6px);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 8px;
  box-shadow: var(--shadow-sm);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
  z-index: 2;
}

.texture-palette-swatch:hover .texture-palette-tooltip,
.texture-palette-swatch:focus-visible .texture-palette-tooltip {
  opacity: 1;
  transform: translate(-50%, 0);
}

.mapping-table-wrap {
  overflow-x: auto;
}

.mapping-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 420px;
}

.mapping-table th,
.mapping-table td {
  text-align: left;
  padding: var(--space-2);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.mapping-table th {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted-foreground);
}

.mapping-table tr.is-excluded {
  opacity: 0.45;
}

.color-chip {
  display: inline-block;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
}

.texture-guide-list {
  margin: 0;
  padding-left: var(--space-4);
  display: block;
}

.texture-guide-list li+li {
  margin-top: 6px;
}

.texture-guide-list li {
  line-height: var(--lh-sm);
}

@media (max-width: 1024px) {
  .texture-upload-grid {
    grid-template-columns: 1fr;
  }

  .texture-upload-panel--left,
  .texture-upload-panel--right,
  .texture-preview-block--original,
  .texture-preview-block--quant,
  .texture-action-row--right,
  .texture-schem-result--right {
    grid-column: 1;
  }
}

@media (max-width: 860px) {
  .texture-palette-split {
    grid-template-columns: 1fr;
  }
}

/* Quantization Loading Animation */
@keyframes quantizing-dots {

  0%,
  20% {
    content: '';
  }

  40% {
    content: '.';
  }

  60% {
    content: '..';
  }

  80%,
  100% {
    content: '...';
  }
}

@keyframes frame-glow-pulse {
  0% {
    box-shadow: inset 0 0 0px rgba(56, 189, 248, 0);
    border-color: var(--border);
  }

  50% {
    box-shadow: inset 0 0 25px rgba(56, 189, 248, 0.5);
    border-color: var(--primary);
  }

  100% {
    box-shadow: inset 0 0 0px rgba(56, 189, 248, 0);
    border-color: var(--border);
  }
}

.texture-preview-frame {
  position: relative;
  transition: all 0.3s ease;
}

.texture-preview-frame.is-quantizing {
  animation: frame-glow-pulse 2s infinite ease-in-out;
}

.quantizing-overlay {
  position: absolute;
  inset: 0;
  background: rgba(var(--background-rgb, 10, 10, 10), 0.7);
  backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 20;
  border-radius: inherit;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.is-quantizing .quantizing-overlay {
  opacity: 1;
  visibility: visible;
}

.quantizing-text {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--primary);
  display: flex;
  align-items: baseline;
  gap: 0;
  text-shadow: 0 0 15px rgba(56, 189, 248, 0.4);
}

.quantizing-dots::after {
  content: '...';
  display: inline-block;
  width: 1.5em;
  text-align: left;
  animation: quantizing-dots 2s infinite steps(1);
}
