/* 贴图编辑页 */
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@700&display=swap');

.texture-page .admin-content {
  max-width: none;
}

.texture-layout {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  flex: 1;
  min-height: 0;
}

.texture-progress-card {
  flex-shrink: 0;
}

.texture-progress-card.is-compact .texture-progress-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.35rem 0.75rem 0;
}

.texture-progress-title {
  font-size: 11px;
  color: var(--muted-foreground);
}

.texture-progress-title strong {
  margin-left: 0.35rem;
  font-size: 12px;
  color: var(--foreground);
  font-variant-numeric: tabular-nums;
}

.texture-progress-card.is-compact .convert-card-body,
.texture-progress-card.is-compact .texture-progress-body {
  padding: 0.45rem 0.75rem 0.55rem;
}

.texture-progress-card.is-compact .convert-overall {
  display: none;
}

.texture-progress-card.is-compact .convert-bar {
  height: 4px;
  margin-bottom: 0.15rem;
}

.texture-progress-card.is-compact .convert-stepper {
  margin-top: 0.35rem;
  gap: 0.1rem;
}

.texture-progress-card.is-compact .convert-stepper::before {
  top: 0.5rem;
  left: 8%;
  right: 8%;
  height: 1px;
}

.texture-progress-card.is-compact .convert-stepper-dot {
  width: 1.15rem;
  height: 1.15rem;
  font-size: 9px;
  border-width: 1.5px;
}

.texture-progress-card.is-compact .convert-stepper-item.is-active .convert-stepper-dot {
  box-shadow: 0 0 0 2px hsl(221 83% 53% / 0.15);
}

.texture-progress-card.is-compact .convert-stepper-label {
  font-size: 9px;
  line-height: 1.2;
}

.texture-progress-card.is-compact .convert-status-line {
  margin-top: 0.35rem;
  padding: 0.3rem 0.5rem;
  font-size: 11px;
  min-height: 0;
  text-align: left;
  line-height: 1.35;
  max-height: none;
  overflow: hidden;
  display: block;
}

.texture-progress-card .convert-status-line.is-active {
  background: hsl(221 80% 97%);
  color: hsl(221 45% 28%);
  animation: texture-status-pulse 2.4s ease-in-out infinite;
}

@keyframes texture-status-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.82; }
}

.texture-progress-card.is-idle .convert-bar,
.texture-progress-card.is-idle .convert-overall {
  display: none;
}

.texture-progress-card.is-idle .convert-stepper {
  margin-top: 0.15rem;
}

.texture-progress-card.is-idle .convert-status-line.is-done {
  margin-top: 0.25rem;
  background: hsl(142 76% 96%);
  color: hsl(142 50% 28%);
  max-height: none;
  -webkit-line-clamp: unset;
  display: block;
}

.texture-progress-card.is-idle.is-body-collapsed .texture-progress-title strong {
  color: hsl(142 50% 28%);
}

.texture-progress-card:not(.is-idle) .convert-status-line.is-error,
.texture-progress-card .convert-status-line.is-failed {
  background: hsl(0 86% 97%);
  color: hsl(0 60% 40%);
  max-height: none;
  -webkit-line-clamp: unset;
  display: block;
}

.texture-progress-card.is-body-collapsed .texture-progress-body {
  display: none;
}

.texture-progress-card.is-body-collapsed .texture-progress-toolbar {
  padding-bottom: 0.35rem;
}

.texture-progress-resume {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.5rem;
  padding: 0.35rem 0.75rem 0.5rem;
  font-size: 12px;
  color: hsl(221 60% 35%);
  background: hsl(221 80% 97%);
  border-bottom: 1px solid hsl(221 60% 90%);
}

.texture-progress-resume-text {
  flex: 1 1 auto;
  min-width: 0;
}

.texture-progress-card.is-body-collapsed .texture-progress-resume {
  border-bottom: none;
  padding-bottom: 0.35rem;
}

.texture-progress-card .convert-status-line.is-done a {
  color: hsl(142 45% 28%);
  font-weight: 600;
  text-decoration: underline;
}

.texture-progress-card .convert-progress {
  display: block;
}

.texture-status.is-active {
  color: var(--foreground);
}

.texture-editor {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr) 300px;
  gap: 1rem;
  flex: 1;
  min-height: 0;
  align-items: stretch;
}

@media (max-width: 1100px) {
  .texture-editor {
    grid-template-columns: 1fr;
  }
}

.texture-part-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.texture-part-list li button:not(.texture-part-delete) {
  width: 100%;
  text-align: left;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 4px);
  background: var(--background);
  cursor: pointer;
  font-size: 12px;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.texture-part-list li button:not(.texture-part-delete):hover {
  border-color: var(--ring);
}

.texture-part-list li button:not(.texture-part-delete).is-active {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 8%, var(--background));
}

.texture-part-list .texture-part-name {
  display: block;
  font-weight: 600;
  color: var(--foreground);
}

.texture-part-list .texture-part-meta {
  display: block;
  margin-top: 0.15rem;
  color: var(--muted-foreground);
  font-size: 11px;
}

.texture-part-list li button:not(.texture-part-delete).is-edited::after {
  content: '已保存';
  float: right;
  font-size: 10px;
  color: var(--primary);
}

.texture-part-list li button:not(.texture-part-delete).is-dirty::before {
  content: '●';
  color: #f59e0b;
  margin-right: 0.25rem;
  font-size: 8px;
  vertical-align: middle;
}

.texture-list-tools {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin-bottom: 0.65rem;
}

.texture-search {
  width: 100%;
  padding: 0.4rem 0.55rem;
  font-size: 12px;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 4px);
  background: var(--background);
}

.texture-filter-edited {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 11px;
  color: var(--muted-foreground);
  cursor: pointer;
}

.texture-preview-list-tools {
  display: flex;
  gap: 0.35rem;
  margin-bottom: 0.55rem;
  flex-wrap: wrap;
}

.texture-part-row {
  display: flex;
  align-items: stretch;
  gap: 0.35rem;
}

.texture-part-row.is-preview-on .texture-preview-pick {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 10%, var(--background));
}

.texture-preview-pick {
  flex: 0 0 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 4px);
  background: var(--background);
  cursor: pointer;
  margin: 0;
}

.texture-preview-pick input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

.texture-preview-pick-icon {
  font-size: 14px;
  line-height: 1;
  opacity: 0.45;
}

.texture-part-row.is-preview-on .texture-preview-pick-icon,
.texture-preview-pick:has(input:checked) .texture-preview-pick-icon {
  opacity: 1;
}

.texture-part-row > button {
  flex: 1;
  min-width: 0;
}

.texture-part-delete {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  min-width: 28px;
  align-self: center;
  margin-left: 0.1rem;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--muted-foreground);
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease, background 0.15s ease, color 0.15s ease, transform 0.12s ease;
}

.texture-part-delete-icon {
  width: 15px;
  height: 15px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.texture-part-row:hover .texture-part-delete,
.texture-part-row:focus-within .texture-part-delete {
  opacity: 1;
  pointer-events: auto;
}

.texture-part-delete:hover {
  color: hsl(0 72% 50%);
  background: hsl(0 86% 97%);
}

.texture-part-delete:active {
  transform: scale(0.92);
}

.texture-part-delete:focus-visible {
  opacity: 1;
  pointer-events: auto;
  outline: 2px solid color-mix(in srgb, var(--primary) 40%, transparent);
  outline-offset: 1px;
}

@media (hover: none) {
  .texture-part-delete {
    opacity: 0.5;
    pointer-events: auto;
  }
}

.texture-delete-btn:not(:disabled):hover {
  border-color: #f87171;
  color: #f87171;
}

.texture-part-btn-inner {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.texture-part-thumb {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border-radius: 4px;
  background: #111 center/cover no-repeat;
  border: 1px solid var(--border);
}

.texture-part-text {
  flex: 1;
  min-width: 0;
}

.texture-select {
  padding: 0.3rem 0.4rem;
  font-size: 11px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--background);
  max-width: 110px;
}

.texture-layer-list {
  list-style: none;
  margin: 0 0 0.75rem;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  max-height: 200px;
  overflow-y: auto;
}

.texture-layer-list li button {
  width: 100%;
  text-align: left;
  padding: 0.45rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 4px);
  background: var(--background);
  cursor: pointer;
  font-size: 11px;
}

.texture-layer-list li button.is-active {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 8%, var(--background));
}

.texture-layer-list li button.is-locked {
  opacity: 0.65;
}

.texture-layer-list li button.is-hidden-layer {
  opacity: 0.45;
  font-style: italic;
}

.texture-layer-empty {
  font-size: 11px;
  color: var(--muted-foreground);
  padding: 0.35rem 0;
}

.texture-transform {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.texture-transform-row {
  display: grid;
  grid-template-columns: 2.5rem 1fr 2.5rem;
  align-items: center;
  gap: 0.35rem;
  font-size: 11px;
  color: var(--muted-foreground);
}

.texture-transform-row input[type="range"] {
  width: 100%;
}

.texture-transform-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.texture-side-divider {
  height: 1px;
  background: var(--border);
  margin: 0.75rem 0;
}

.texture-status-label {
  font-weight: normal;
  color: var(--primary);
  font-size: 10px;
}

.texture-side-body {
  overflow-y: auto;
  max-height: calc(100vh - 180px);
}

.texture-panel--list {
  min-height: 0;
  max-height: calc(100vh - 160px);
}

.texture-panel--list .convert-card-body {
  flex: 1;
  min-height: 0;
  max-height: none;
  overflow: hidden;
  padding-bottom: 0.75rem;
}

.texture-panel--list .texture-list-tools,
.texture-panel--list .texture-preview-list-tools {
  flex-shrink: 0;
}

.texture-panel--list .texture-part-list {
  flex: 1 1 auto;
  min-height: 140px;
  max-height: min(52vh, 520px);
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 4px;
  margin-right: -2px;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: hsl(0 0% 68% / 0.85) hsl(0 0% 94%);
}

.texture-panel--list .texture-part-list::-webkit-scrollbar {
  display: block;
  width: 8px;
}

.texture-panel--list .texture-part-list::-webkit-scrollbar-track {
  background: hsl(0 0% 93%);
  border-radius: 4px;
}

.texture-panel--list .texture-part-list::-webkit-scrollbar-thumb {
  background: hsl(0 0% 72%);
  border-radius: 4px;
  border: 2px solid hsl(0 0% 93%);
}

.texture-panel--list .texture-part-list::-webkit-scrollbar-thumb:hover {
  background: hsl(0 0% 55%);
}

.map-page .texture-panel--list .texture-part-list {
  max-height: min(40vh, 420px);
}

.texture-panel--list .map-entity-panel {
  flex-shrink: 0;
  margin-top: 0.5rem;
}

.texture-ytd-group {
  margin-bottom: 0.65rem;
}

.texture-ytd-group:last-child {
  margin-bottom: 0;
}

.texture-ytd-title {
  font-size: 10px;
  font-weight: 600;
  color: var(--muted-foreground);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.35rem;
  padding: 0 0.15rem;
  word-break: break-all;
}

.texture-part-sublist {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.texture-part-sublist .texture-part-row > button {
  padding: 0.45rem 0.55rem;
}

.texture-part-sublist .texture-part-name {
  font-weight: 500;
  font-size: 11px;
}

.texture-region-title {
  margin-top: 0.65rem;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted-foreground);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.texture-region-hint {
  margin: 0.2rem 0 0.45rem;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.35;
}

.texture-region-btns .texture-part-text-btn.is-active {
  background: rgba(59, 130, 246, 0.22);
  border-color: rgba(59, 130, 246, 0.55);
}

.texture-region-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.5rem;
}

.btn-sm {
  padding: 0.35rem 0.55rem;
  font-size: 11px;
}

.texture-panel--canvas .convert-card-body {
  overflow: hidden;
}

.texture-canvas-head {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.texture-canvas-head-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  flex-wrap: wrap;
  width: 100%;
}

.texture-canvas-head-title {
  min-width: 0;
  flex: 1 1 200px;
}

.texture-canvas-head-title h3 {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.texture-preview-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.4rem 0.55rem;
  flex: 1 1 420px;
  min-width: 0;
}

.texture-preview-toolbar-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--foreground);
  white-space: nowrap;
}

.texture-model-label--head {
  flex-shrink: 0;
}

.texture-model-label--head .texture-model-label-text {
  color: var(--muted-foreground);
  font-size: 11px;
}

.texture-model-label--head .texture-model-select {
  max-width: min(300px, 36vw);
  font-size: 11px;
  padding: 0.25rem 0.45rem;
  border: 1px solid var(--border);
  background: var(--background);
  color: var(--foreground);
}

.texture-preview-toggle--head {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 11px;
  color: var(--muted-foreground);
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
}

.texture-preview-toggle--head input {
  margin: 0;
}

.texture-canvas-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.texture-tool {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 12px;
  color: var(--muted-foreground);
}

.texture-tool input[type="text"],
.texture-tool input[type="number"] {
  width: 100px;
  padding: 0.3rem 0.45rem;
  font-size: 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--background);
}

.texture-tool input[type="number"] {
  width: 64px;
}

.texture-sticker-btn {
  cursor: pointer;
  margin: 0;
}

.texture-canvas-wrap {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  gap: 0.65rem;
  background: repeating-conic-gradient(#e8e8e8 0% 25%, #f5f5f5 0% 50%) 50% / 16px 16px;
  padding: 0.65rem;
  overflow: hidden;
}

.texture-viewer-panel {
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 4px);
  background: #111;
  overflow: hidden;
  flex: 0 0 auto;
}

.texture-viewer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.45rem 0.65rem;
  font-size: 11px;
  color: #ddd;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  flex-wrap: wrap;
}

.texture-viewer-head-main {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-width: 0;
  flex: 1 1 auto;
  flex-wrap: wrap;
}

.texture-model-label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-width: 0;
}

.texture-model-label-text {
  flex-shrink: 0;
  font-size: 10px;
  color: #9ca3af;
  white-space: nowrap;
}

.texture-model-select {
  display: inline-block;
  max-width: min(280px, 42vw);
  font-size: 10px;
  padding: 0.2rem 0.35rem;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: #1f1f24;
  color: #eee;
}

.texture-model-select:disabled {
  opacity: 0.6;
}

.texture-viewer-head span {
  color: #9ca3af;
  font-size: 10px;
}

.texture-preview-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 10px;
  color: #9ca3af;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.texture-preview-toggle input {
  margin: 0;
}

.texture-viewer-foot {
  padding: 0.35rem 0.65rem 0.5rem;
  font-size: 10px;
  color: #9ca3af;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.texture-drive-tools {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.texture-drive-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
  user-select: none;
  color: #cbd5e1;
}

.texture-drive-toggle input {
  margin: 0;
}

.texture-drive-speed {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: #94a3b8;
}

.texture-drive-speed input[type="range"] {
  width: 5.5rem;
  margin: 0;
}

#textureViewer3d canvas.is-part-text-pick,
.texture-viewer-box.is-part-text-pick,
.texture-viewer-box.is-part-text-pick canvas {
  cursor: crosshair !important;
}

#textureViewer3d canvas.is-text-label-drag {
  cursor: grabbing !important;
}

.btn.is-active,
.texture-part-text-btn.is-active {
  background: rgba(59, 130, 246, 0.22);
  border-color: rgba(59, 130, 246, 0.55);
  color: #dbeafe;
}

.texture-part-text-btn {
  flex-shrink: 0;
}

.texture-viewer-foot span {
  display: block;
  line-height: 1.4;
}

.texture-edit-section {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.texture-section-label {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  flex-wrap: wrap;
  font-size: 11px;
  color: var(--muted-foreground);
}

.texture-section-label strong {
  font-size: 12px;
  color: var(--foreground);
}

.texture-model-label {
  font-size: 10px;
  color: #9ca3af;
  max-width: min(280px, 40vw);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.texture-viewer-body.is-collapsed {
  display: none;
}

.texture-viewer-box {
  position: relative;
  width: 100%;
  height: clamp(220px, 28vh, 340px);
  min-height: 200px;
  overflow: hidden;
  background: #1a1a1f;
}

.texture-viewer-box canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100% !important;
  height: 100% !important;
}

.texture-viewer-fly-hint {
  position: absolute;
  left: 8px;
  bottom: 8px;
  z-index: 2;
  max-width: calc(100% - 16px);
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 11px;
  line-height: 1.35;
  color: rgba(255, 255, 255, 0.88);
  background: rgba(0, 0, 0, 0.55);
  pointer-events: none;
  user-select: none;
}

.texture-viewer-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  min-height: 200px;
  padding: 1rem;
  text-align: center;
  font-size: 12px;
  color: var(--muted-foreground);
  box-sizing: border-box;
}

.texture-viewer-placeholder.is-error {
  color: hsl(0 72% 42%);
}

.texture-canvas-box {
  position: relative;
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 220px;
  max-width: 100%;
  overflow: auto;
  box-shadow: var(--shadow-sm);
}

#editCanvas {
  display: block;
  max-width: 100%;
  height: auto;
  cursor: crosshair;
}

.texture-region-overlay {
  position: absolute;
  border: 2px dashed rgba(59, 130, 246, 0.85);
  background: rgba(59, 130, 246, 0.12);
  pointer-events: none;
  display: none;
  box-sizing: border-box;
}

.texture-region-overlay.is-visible {
  display: block;
}

.texture-canvas-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border);
}

.texture-canvas-foot .btn-accent {
  margin-left: auto;
}

#editCanvas {
  cursor: crosshair;
}

#editCanvas.is-dragging {
  cursor: grabbing;
}

.texture-panel--side .convert-card-body {
  overflow-y: auto;
}
