.arq-topbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--arq-border);
  flex-shrink: 0;
  background: var(--arq-surface);
}
.arq-topbar-title {
  flex: 1;
  display: flex;
  align-items: center;
  font-weight: 600;
  min-width: 0;
}
.arq-inline-input {
  font: inherit;
  color: inherit;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0.15rem 0.35rem;
  min-width: 120px;
  max-width: 360px;
}
.arq-inline-input:focus {
  outline: none;
  border-color: var(--arq-border);
  background: var(--arq-surface2);
}
.arq-topbar-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem; }
.arq-save-pill {
  font-size: 0.75rem;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  background: var(--arq-surface2);
  color: var(--arq-muted);
}
.arq-save-pill.is-dirty { color: var(--arq-success); }
.arq-save-pill.is-saving { color: var(--arq-accent); }

.arq-editor-body {
  flex: 1;
  display: flex;
  min-height: 0;
  position: relative;
}

.arq-toolbar-left {
  width: 72px;
  flex-shrink: 0;
  border-right: 1px solid var(--arq-border);
  background: var(--arq-surface);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.5rem 0;
  gap: 0.5rem;
  overflow-y: auto;
}
.arq-tool-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--arq-border);
  width: 100%;
  align-items: center;
}
.arq-tool {
  width: 52px;
  height: 52px;
  border-radius: var(--arq-radius);
  border: 1px solid transparent;
  background: transparent;
  color: var(--arq-text);
  font-size: 1.1rem;
  cursor: pointer;
}
.arq-tool--active {
  background: var(--arq-surface2);
  border-color: var(--arq-accent);
}
.arq-tool-props {
  width: 100%;
  padding: 0 0.35rem;
}
.arq-tool-props input[type="range"] { width: 100%; }

.arq-canvas-wrap {
  flex: 1;
  position: relative;
  min-width: 0;
  background: #0a0b0d;
  touch-action: none;
}
.arq-canvas-stage {
  position: absolute;
  inset: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.arq-viewport {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}
.arq-viewport-inner {
  position: absolute;
  left: 50%;
  top: 50%;
  transform-origin: center center;
  will-change: transform;
}
#arq-main-canvas {
  display: block;
  box-shadow: var(--arq-shadow);
  touch-action: none;
}

.arq-panel-right {
  width: 300px;
  max-width: 42vw;
  flex-shrink: 0;
  border-left: 1px solid var(--arq-border);
  background: var(--arq-surface);
  display: flex;
  flex-direction: column;
  min-height: 0;
  position: relative;
  transition: margin 0.2s;
}
.arq-panel-right.is-collapsed {
  width: 0;
  max-width: 0;
  border: none;
  overflow: visible;
}
.arq-panel-right.is-collapsed .arq-panel-tabs,
.arq-panel-right.is-collapsed .arq-panel-body { display: none; }
.arq-panel-toggle {
  position: absolute;
  left: -36px;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 64px;
  border-radius: var(--arq-radius) 0 0 var(--arq-radius);
  border: 1px solid var(--arq-border);
  background: var(--arq-surface2);
  color: var(--arq-text);
  z-index: 5;
  cursor: pointer;
}
.arq-panel-right.is-collapsed .arq-panel-toggle { left: -36px; }

.arq-panel-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  padding: 0.5rem;
  border-bottom: 1px solid var(--arq-border);
}
.arq-tab {
  flex: 1 1 auto;
  min-height: 40px;
  padding: 0.25rem 0.35rem;
  font-size: 0.7rem;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--arq-muted);
  cursor: pointer;
}
.arq-tab--active {
  background: var(--arq-surface2);
  color: var(--arq-text);
  border-color: var(--arq-border);
}
.arq-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem;
  min-height: 0;
}
.arq-tab-panel { min-height: 120px; }

/* Iconos compactos: dejar ancho al nombre de capa (panel estrecho) */
.arq-layer-row {
  --arq-layer-icon: 24px;
  display: flex;
  align-items: center;
  gap: 0.12rem;
  padding: 0.2rem 0.28rem;
  border-radius: 8px;
  margin-bottom: 0.25rem;
  background: var(--arq-surface2);
  color: var(--arq-text);
  cursor: pointer;
  border: 1px solid transparent;
}
.arq-layer-row--active { border-color: var(--arq-accent); }
.arq-layer-row--drag-over {
  outline: 2px dashed var(--arq-accent);
  outline-offset: 2px;
}
.arq-layer-row--dragging { opacity: 0.55; }
.js-layer-drag {
  flex-shrink: 0;
  width: 14px;
  min-height: var(--arq-layer-icon);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  color: var(--arq-muted);
  font-size: 0.45rem;
  line-height: 1;
  letter-spacing: -0.08em;
  border-radius: 4px;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
}
.js-layer-drag:active { cursor: grabbing; }
.js-layer-drag:hover { color: var(--arq-text); background: rgba(255, 255, 255, 0.06); }
.arq-layer-row button {
  box-sizing: border-box;
  flex: 0 0 var(--arq-layer-icon);
  min-width: var(--arq-layer-icon);
  max-width: var(--arq-layer-icon);
  min-height: var(--arq-layer-icon);
  max-height: var(--arq-layer-icon);
  width: var(--arq-layer-icon);
  height: var(--arq-layer-icon);
  padding: 0;
  margin: 0;
  border: none;
  background: transparent;
  color: var(--arq-text);
  cursor: pointer;
  font-size: 0.8rem;
  line-height: 1;
}
.js-layer-import,
.js-layer-clear-img {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.88rem;
  line-height: 1;
  opacity: 0.95;
}
.arq-layer-name { flex: 1; font-size: 0.85rem; overflow: hidden; text-overflow: ellipsis; }

/* Contenedor: crece y reserva mínimo para el texto (iconos ya no lo aplastan) */
.arq-layer-name-wrap {
  flex: 1 1 0%;
  min-width: 48px;
  display: flex;
  align-items: center;
  align-self: stretch;
}
.arq-layer-name-input {
  box-sizing: border-box;
  flex: 1 1 auto;
  width: 100%;
  min-width: 0;
  min-height: var(--arq-layer-icon, 24px);
  line-height: 1.3;
  font-size: 0.8rem;
  font-family: var(--arq-font, inherit);
  /* Color literal: evita texto “invisible” si variables no aplican al control nativo */
  color: #e8eaed;
  -webkit-text-fill-color: #e8eaed;
  caret-color: var(--arq-accent, #3d8bfd);
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--arq-border);
  border-radius: 6px;
  padding: 0.25rem 0.45rem;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 1;
  -webkit-appearance: none;
  appearance: none;
}
.arq-layer-name-input:focus {
  outline: none;
  border-color: var(--arq-accent);
  background: rgba(0, 0, 0, 0.35);
  color: #e8eaed;
  -webkit-text-fill-color: #e8eaed;
}
.arq-layer-name-input::selection {
  background: var(--arq-accent);
  color: #fff;
}
.js-layer-del { opacity: 0.75; }
.arq-layer-row:hover .js-layer-del { opacity: 1; }
.arq-layer-del-spacer {
  width: var(--arq-layer-icon, 24px);
  height: var(--arq-layer-icon, 24px);
  flex: 0 0 var(--arq-layer-icon, 24px);
}
.arq-layer-icon-spacer {
  width: var(--arq-layer-icon, 24px);
  height: var(--arq-layer-icon, 24px);
  flex: 0 0 var(--arq-layer-icon, 24px);
}
.js-layer-import:hover,
.js-layer-clear-img:hover { opacity: 1; color: var(--arq-accent); }

.arq-sheets-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem;
  border-top: 1px solid var(--arq-border);
  background: var(--arq-surface);
  flex-shrink: 0;
  overflow-x: auto;
}
.arq-sheets-strip {
  display: flex;
  gap: 0.35rem;
  flex: 1;
  min-width: 0;
}
.arq-sheet-tab-wrap {
  flex-shrink: 0;
  min-width: 120px;
  max-width: 220px;
  cursor: pointer;
}
.arq-sheet-tab-wrap--drag-over {
  outline: 2px dashed var(--arq-accent);
  outline-offset: 2px;
  border-radius: 10px;
}
.arq-sheet-tab-wrap--dragging { opacity: 0.55; }
.js-sheet-drag {
  flex-shrink: 0;
  width: 14px;
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  color: var(--arq-muted);
  font-size: 0.45rem;
  line-height: 1;
  letter-spacing: -0.06em;
  border-radius: 4px;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
}
.js-sheet-drag:active { cursor: grabbing; }
.js-sheet-drag:hover { color: var(--arq-text); background: rgba(255, 255, 255, 0.06); }
.arq-sheet-tab {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  padding: 0.28rem 0.4rem;
  border-radius: 8px;
  border: 1px solid var(--arq-border);
  background: var(--arq-surface2);
  color: var(--arq-text);
  font-size: 0.85rem;
  overflow: hidden;
}
.arq-sheet-tab-wrap.arq-sheet-tab--active .arq-sheet-tab {
  border-color: var(--arq-accent);
  background: var(--arq-bg);
}
.arq-sheet-name-input {
  flex: 1;
  min-width: 0;
  font: inherit;
  color: inherit;
  background: transparent;
  border: 1px solid transparent;
  padding: 0.15rem 0.35rem;
  border-radius: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.arq-sheet-name-input:focus {
  outline: none;
  border-color: var(--arq-border);
  background: rgba(0, 0, 0, 0.15);
}
.arq-sheet-del {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  min-width: 26px;
  padding: 0;
  font-size: 0.85rem;
  line-height: 1;
  border: none;
  background: transparent;
  color: var(--arq-text);
  cursor: pointer;
  opacity: 0.75;
}
.arq-sheet-tab:hover .arq-sheet-del { opacity: 1; }

.arq-asset-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
  margin-top: 0.75rem;
}
.arq-asset-thumb {
  aspect-ratio: 1;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--arq-border);
  cursor: pointer;
  background: var(--arq-bg);
}
.arq-asset-thumb img { width: 100%; height: 100%; object-fit: cover; }

.arq-history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 0.8rem;
  color: var(--arq-muted);
}
.arq-history-list li { padding: 0.35rem 0; border-bottom: 1px solid var(--arq-border); }

.arq-ai-gate {
  padding: 1rem;
  background: var(--arq-surface2);
  border-radius: var(--arq-radius);
}
.arq-ai-status { margin-top: 0.75rem; font-size: 0.85rem; }
.arq-ai-preview { margin-top: 0.75rem; }
.arq-ai-preview img { max-width: 100%; border-radius: 8px; }

.arq-material-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem;
  margin-bottom: 0.35rem;
  background: var(--arq-surface2);
  border-radius: 8px;
}
.arq-material-swatch {
  width: 36px;
  height: 36px;
  border-radius: 6px;
  border: 1px solid var(--arq-border);
  flex-shrink: 0;
}

/* Operaciones bloqueantes (ops.feedback) */
.arq-op-overlay {
  position: fixed;
  inset: 0;
  z-index: 9500;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
/* display:flex del bloque anterior gana sobre [hidden] por especificidad; forzar oculto al cerrar */
.arq-op-overlay[hidden] {
  display: none !important;
  pointer-events: none;
  visibility: hidden;
}
.arq-op-overlay__box {
  background: var(--arq-surface);
  border: 1px solid var(--arq-border);
  border-radius: var(--arq-radius);
  box-shadow: var(--arq-shadow);
  padding: 1.25rem 1.5rem;
  max-width: min(420px, 100%);
  text-align: center;
}
.arq-op-overlay__text {
  margin: 0;
  font-size: 0.95rem;
  color: var(--arq-text);
}
.arq-op-overlay__pct {
  font-size: 1.65rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
  margin: 0.65rem 0 0.5rem;
  color: var(--arq-accent);
  letter-spacing: 0.02em;
}
.arq-op-progress {
  width: 100%;
  min-width: 220px;
}
.arq-op-progress__track {
  height: 6px;
  border-radius: 999px;
  background: var(--arq-border);
  overflow: hidden;
}
.arq-op-progress__fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: var(--arq-accent);
  transition: width 0.2s ease-out;
}
.arq-op-progress__fill--indeterminate {
  width: 35% !important;
  border-radius: 999px;
  animation: arq-op-progress-indet 1.1s ease-in-out infinite;
}
@keyframes arq-op-progress-indet {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(400%); }
}
.arq-op-spinner {
  width: 36px;
  height: 36px;
  margin: 0 auto;
  border: 3px solid var(--arq-border);
  border-top-color: var(--arq-accent);
  border-radius: 50%;
  animation: arq-op-spin 0.75s linear infinite;
}
@keyframes arq-op-spin {
  to { transform: rotate(360deg); }
}
