/* Design dept asset editor — selection rect + editor panel. */

.asset-stage.is-selecting,
.asset-stage.is-selecting * {
  cursor: crosshair;
}

.asset-stage.is-selecting button,
.asset-stage.is-selecting input,
.asset-stage.is-selecting textarea,
.asset-stage.is-selecting select,
.asset-stage.is-selecting a,
.asset-stage.is-selecting .patch-ui,
.asset-stage.is-selecting .patch-ui *,
.asset-stage.is-selecting .selection-popover,
.asset-stage.is-selecting .selection-popover * {
  cursor: pointer;
}

.asset-stage.is-hand-tool,
.asset-stage.is-hand-tool * {
  cursor: grab;
}

.asset-stage.is-hand-tool:active,
.asset-stage.is-hand-tool:active * {
  cursor: grabbing;
}

.select-rect {
  position: absolute;
  border: 1px solid #46f0ff;
  background: rgba(70, 240, 255, 0.06);
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.74),
    0 0 10px rgba(70, 240, 255, 0.38);
  pointer-events: none;
  z-index: 18;
}

.selection-popover {
  position: absolute;
  z-index: 20;
  padding: 12px;
  border: 1px solid rgba(201, 168, 91, 0.65);
  border-radius: 8px;
  background: rgba(22, 23, 26, 0.98);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.55);
}

.selection-popover.is-busy {
  pointer-events: none;
  opacity: 0.86;
}

.selection-popover[hidden] {
  display: none;
}

.selection-popover-head {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  margin-bottom: 9px;
}

.selection-popover-head strong {
  color: #f1d28a;
  font-size: 1rem;
}

.selection-popover-head span {
  color: rgba(232, 230, 225, 0.82);
  font-size: 0.82rem;
  text-align: right;
}

.popover-close {
  width: 28px;
  height: 28px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.04);
  color: inherit;
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
}

.popover-close:hover {
  border-color: rgba(201, 168, 91, 0.65);
  color: #f1d28a;
}

.popover-status {
  min-height: 1.2em;
  margin-top: 7px;
  color: rgba(232, 230, 225, 0.75);
}

.popover-status.ok {
  color: #7bb87b;
}

.popover-status.error {
  color: #e0795f;
}

.de-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 9px;
}

.de-preset {
  cursor: pointer;
  font-size: 0.8rem;
  line-height: 1.1;
  padding: 4px 10px;
  border: 1px solid rgba(201, 168, 91, 0.38);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  color: rgba(232, 230, 225, 0.9);
}

.de-preset:hover {
  border-color: rgba(201, 168, 91, 0.85);
  color: #f1d28a;
  background: rgba(201, 168, 91, 0.12);
}

.de-preset.is-text {
  border-color: rgba(217, 180, 95, 0.7);
  color: #f1d28a;
  font-weight: 650;
}

.de-preset:disabled {
  opacity: 0.5;
  cursor: default;
}

/* Резиновые плавающие окна: max-height ставит JS = высоте сцены, а тут textarea
   ужимается под нехватку места → шапка/чипы/кнопка всегда видны и кликабельны. */
.selection-popover,
.de-markup.markup-popover {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.selection-popover > *,
.de-markup.markup-popover > * {
  flex: 0 0 auto;
}

#de-prompt,
.de-markup textarea {
  flex: 0 1 auto;
  min-height: 44px;
}

/* «Ведро» — убрать патч; тёплый предупреждающий тон на ховере */
.patch-ui button.is-discard:hover {
  color: #e0795f;
  border-color: rgba(224, 121, 95, 0.7);
}

.selection-progress {
  position: absolute;
  z-index: 18;
  display: grid;
  place-items: center;
  min-width: 30px;
  min-height: 30px;
  border: 2px solid rgba(217, 180, 95, 0.95);
  background:
    linear-gradient(135deg, rgba(217, 180, 95, 0.22) 25%, transparent 25% 50%, rgba(217, 180, 95, 0.22) 50% 75%, transparent 75%) 0 0 / 22px 22px,
    rgba(10, 10, 12, 0.36);
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.82),
    inset 0 0 0 1px rgba(255, 255, 255, 0.26);
  pointer-events: none;
  animation: selection-progress-stripes 0.8s linear infinite;
}

.selection-progress[hidden] {
  display: none;
}

.selection-progress-panel {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 112px;
  justify-content: center;
  padding: 6px 9px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.84);
  color: #f1d28a;
  font-size: 0.9rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}

.selection-progress-panel strong {
  font-size: 0.92rem;
}

.selection-progress.is-done {
  animation: none;
  border-color: rgba(123, 184, 123, 0.95);
  background: rgba(123, 184, 123, 0.24);
}

.selection-progress.is-done .selection-progress-panel {
  color: #a8d9a8;
}

.selection-progress.is-error {
  animation: none;
  border-color: rgba(224, 121, 95, 0.96);
  background: rgba(224, 121, 95, 0.2);
}

.selection-progress.is-error .selection-progress-panel {
  color: #f0a18d;
}

@keyframes selection-progress-stripes {
  from {
    background-position: 0 0, 0 0;
  }
  to {
    background-position: 22px 0, 0 0;
  }
}

.mark-layer {
  position: absolute;
  left: 0;
  top: 0;
  width: 0;
  height: 0;
  z-index: 3;
  pointer-events: none;
  overflow: visible;
}

.patch-layer {
  position: absolute;
  left: 0;
  top: 0;
  width: 0;
  height: 0;
  z-index: 4;
  overflow: visible;
  pointer-events: none;
}

.patch-ui-layer {
  position: absolute;
  inset: 0;
  z-index: 19;
  pointer-events: none;
}

.asset-stage.patches-hidden .patch-layer,
.asset-stage.patches-hidden .patch-ui-layer {
  display: none;
}

.asset-patch {
  position: absolute;
  box-sizing: border-box;
  overflow: visible;
  border: 0;
  background: transparent;
  pointer-events: none;
}

.patch-outline {
  position: absolute;
  box-sizing: border-box;
  border: 1px solid #46f0ff;
  background: rgba(70, 240, 255, 0.035);
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.72),
    0 0 11px rgba(70, 240, 255, 0.32);
  pointer-events: none;
}

.patch-clip {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.asset-patch img {
  display: block;
  max-width: none;
  max-height: none;
  object-fit: fill;
  pointer-events: none;
}

.asset-patch > img {
  position: absolute;
  left: 0;
  top: 0;
}

.patch-clip > img {
  position: absolute;
  left: 0;
  top: 0;
}

.patch-ui {
  position: absolute;
  display: inline-flex;
  gap: 5px;
  padding: 6px;
  border: 1px solid rgba(52, 55, 61, 0.95);
  border-radius: 8px;
  background: rgba(9, 10, 12, 0.93);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.42);
  pointer-events: auto;
  transform: translate(-50%, 0);
}

.patch-ui,
.patch-ui * {
  cursor: default;
}

.patch-slot-stack {
  position: relative;
  display: grid;
  place-items: center;
  isolation: isolate;
}

.patch-slot-stack::before {
  content: "";
  position: absolute;
  left: -6px;
  right: -6px;
  top: -32px;
  bottom: -32px;
  z-index: -1;
  border: 1px solid rgba(217, 180, 95, 0.18);
  border-radius: 10px;
  background:
    linear-gradient(to bottom, rgba(217, 180, 95, 0.13), transparent 34%, transparent 66%, rgba(217, 180, 95, 0.13)),
    rgba(6, 7, 9, 0.28);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.2);
  opacity: 0;
  transition: opacity 0.12s ease;
}

.patch-slot-stack:hover::before {
  opacity: 1;
}

.patch-ui button {
  min-width: 28px;
  height: 28px;
  padding: 0 8px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.035);
  color: rgba(232, 230, 225, 0.85);
  cursor: pointer;
  font-size: 0.78rem;
  line-height: 1;
}

.patch-ui button.is-active {
  color: #15130f;
  border-color: #d9b45f;
  background: #d9b45f;
}

.patch-ui button.is-empty {
  color: rgba(232, 230, 225, 0.42);
  border-style: dashed;
}

.patch-ui button.is-icon {
  position: absolute;
  left: 50%;
  width: 24px;
  min-width: 24px;
  height: 22px;
  padding: 0;
  transform: translateX(-50%);
  opacity: 0;
  pointer-events: none;
  border-color: rgba(217, 180, 95, 0.42);
  background: rgba(14, 15, 18, 0.96);
  color: #f1d28a;
  box-shadow: 0 7px 18px rgba(0, 0, 0, 0.34);
  font-size: 0.72rem;
}

.patch-slot-stack:hover button.is-icon:not(:disabled) {
  opacity: 1;
  pointer-events: auto;
}

.patch-ui button[data-action="reuse"] {
  bottom: calc(100% + 4px);
}

.patch-ui button[data-action="delete"] {
  top: calc(100% + 4px);
}

.patch-ui button:disabled {
  opacity: 0.3;
  cursor: default;
}

.patch-ui button.is-icon:disabled {
  opacity: 0;
  pointer-events: none;
}

.asset-mark {
  position: absolute;
  box-sizing: border-box;
  min-width: 18px;
  min-height: 18px;
  border: 1.5px solid #d9b45f;
  background: rgba(217, 180, 95, 0.13);
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.55),
    inset 0 0 0 1px rgba(255, 255, 255, 0.25);
}

.asset-mark span {
  position: absolute;
  left: 0;
  top: 0;
  transform: translate(-1px, -100%);
  padding: 1px 5px;
  border-radius: 4px 4px 0 0;
  background: rgba(0, 0, 0, 0.82);
  color: #f1d28a;
  font: 700 11px/1.4 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  white-space: nowrap;
}

.asset-mark--logo {
  border-color: #7fc7d9;
  background: rgba(127, 199, 217, 0.13);
}

.asset-mark--palette {
  border-color: #9fc16f;
  background: rgba(159, 193, 111, 0.13);
}

.asset-mark--shape {
  border-color: #d58fc5;
  background: rgba(213, 143, 197, 0.13);
}

.asset-mark--problem {
  border-color: #e0795f;
  background: rgba(224, 121, 95, 0.16);
}

.asset-mark--approved {
  border-color: #7bb87b;
  background: rgba(123, 184, 123, 0.15);
}

.asset-footer {
  display: grid;
  grid-template-columns: auto minmax(220px, 1fr) auto;
  gap: 10px;
  align-items: center;
  margin-top: 0;
  padding: 9px 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background: rgba(26, 28, 32, 0.94);
  min-height: 54px;
}

.footer-group {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.footer-group strong {
  color: #f1d28a;
}

.footer-actions {
  justify-content: flex-end;
}

.de-cost {
  opacity: 0.85;
}

@media (max-width: 720px) {
  .asset-footer {
    grid-template-columns: 1fr;
  }
}

.de-selection {
  font-size: 1rem;
  color: rgba(232, 230, 225, 0.86);
  margin-bottom: 10px;
}

.de-modes {
  display: flex;
  gap: 12px;
  font-size: 0.95rem;
  margin: 9px 0 0;
  flex-wrap: wrap;
}

.de-modes label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

#de-prompt {
  width: 100%;
  box-sizing: border-box;
  resize: vertical;
  font: inherit;
  min-height: 92px;
  padding: 10px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(0, 0, 0, 0.2);
  color: inherit;
  font-size: 0.98rem;
  line-height: 1.35;
}

#de-prompt:focus {
  outline: none;
  border-color: rgba(201, 168, 91, 0.85);
  box-shadow: 0 0 0 2px rgba(201, 168, 91, 0.18);
}

.de-markup {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 10px;
  border: 1px solid rgba(201, 168, 91, 0.22);
  border-radius: 8px;
  background: rgba(201, 168, 91, 0.06);
}

.markup-popover {
  position: absolute;
  z-index: 20;
  width: min(390px, calc(100% - 24px));
  left: 12px;
  top: 12px;
  background: rgba(22, 23, 26, 0.98);
  border-color: rgba(201, 168, 91, 0.65);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.55);
}

.markup-popover[hidden] {
  display: none;
}

.de-mark-fields {
  display: grid;
  grid-template-columns: minmax(72px, 0.45fr) minmax(120px, 1fr);
  gap: 8px;
}

.de-mark-fields label {
  display: grid;
  gap: 4px;
  font-size: 0.76rem;
  opacity: 0.86;
}

.de-mark-fields input,
.de-mark-fields select,
.de-markup textarea {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.22);
  color: inherit;
  font: inherit;
}

.de-mark-fields input,
.de-mark-fields select {
  height: 32px;
  padding: 0 8px;
}

.de-markup textarea {
  resize: vertical;
  padding: 8px;
}

.de-prompt-refs {
  min-height: 1.2em;
  margin-top: 5px;
  opacity: 0.72;
}

.de-prompt-refs.ok {
  color: #7bb87b;
}

.de-prompt-refs.error {
  color: #e0795f;
}

.de-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.de-actions .pill {
  cursor: pointer;
  font-size: 0.95rem;
}

.de-actions .pill.primary {
  color: #15130f;
  border-color: #d9b45f;
  background: #d9b45f;
  font-weight: 750;
}

.de-actions .pill.primary:hover {
  color: #15130f;
  border-color: #f1d28a;
  background: #f1d28a;
}

.de-actions .pill:disabled {
  opacity: 0.5;
  cursor: default;
}

.de-status {
  margin-top: 10px;
  min-height: 1.2em;
  font-size: 0.98rem;
}

.de-status.error {
  color: #e0795f;
}

.de-status.ok {
  color: #7bb87b;
}

#toggle-select.is-active,
#toggle-markup.is-active {
  color: #c1654a;
  font-weight: 600;
}

.de-version-strip {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.de-version {
  margin: 0;
  width: 92px;
  text-align: center;
}

.de-version img {
  width: 92px;
  height: 92px;
  object-fit: contain;
  background: repeating-conic-gradient(#2a2a2a 0 25%, #232323 0 50%) 50% / 16px 16px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
}

.de-version.current img {
  border-color: #c1654a;
  box-shadow: 0 0 0 1px #c1654a;
}

.de-version figcaption {
  font-size: 0.8rem;
  line-height: 1.25;
  margin-top: 4px;
  word-break: break-word;
}

.de-marks-title {
  margin-top: 16px;
}

.de-mark-list {
  display: grid;
  gap: 8px;
}

.de-mark-card {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2px 8px;
  width: 100%;
  padding: 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.de-mark-card:hover {
  border-color: rgba(201, 168, 91, 0.5);
  background: rgba(201, 168, 91, 0.07);
}

.de-mark-card strong {
  color: #f1d28a;
}

.de-mark-card span {
  font-size: 0.86rem;
  opacity: 0.78;
}

.de-mark-card small,
.de-mark-card em {
  grid-column: 1 / -1;
  font-style: normal;
  overflow-wrap: anywhere;
}

.de-mark-card small {
  line-height: 1.3;
}

.de-mark-card em {
  opacity: 0.58;
  font-size: 0.8rem;
}
