.app-shell {
  width: 100%;
  height:100dvh;
  position:relative;
  
}


.file-controls {
  display: flex;
  gap: 12px;
}

/* button {
  font: inherit;
  padding: 10px 18px;
  border-radius: 999px;
  border: none;
  background: linear-gradient(120deg, var(--accent), var(--accent-strong));
  color: var(--text);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.2s;
} */
/* 
button:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 30px rgba(137, 160, 255, 0.35);
} */

button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

button.ghost {
  background: transparent;
  border: 1px solid var(--panel-border);
  color: var(--text);
  box-shadow: none;
}

button.ghost.small {
  padding: 6px 12px;
  font-size: 0.8rem;
}

button.ghost.small.icon {
  padding: 4px 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

button.ghost.danger {
  border-color: rgba(255, 107, 107, 0.5);
  color: var(--danger);
}

/* 
.main-grid {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr) 260px;
  gap: 20px;
  align-items: start;
} */

/* .panel {
  background: var(--panel);
  border-radius: 20px;
  border: 1px solid var(--panel-border);
  padding: 18px 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
} */

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.9rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 12px;
}

.layers-panel,
.inspector-panel {
  max-height:80vh;
  max-width: 200px;
}

.layer-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
}

.layer-list.drag-active {
  cursor: grabbing;
}

.layer-list.drop-end::after {
  content: "";
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 0;
  height: 2px;
  background: var(--accent);
  border-radius: 999px;
}

.layer-item {
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid transparent;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.9rem;
  position: relative;
  touch-action: pan-y;
  transition: transform 0.15s ease;
}

.layer-item.processing {
  opacity: 0.75;
}

.layer-status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  color: var(--muted);
  margin-right: 6px;
}
.layer-item .layer-controls {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.layer-item .layer-visibility {
  background: transparent;
  border: none;
  color: inherit;
  cursor: pointer;
  font-size: 0.9rem;
  padding: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.layer-item span:first-child {
  flex: 1 1 auto;
}

.layer-item span:nth-child(2) {
  font-size: 0.75rem;
  color: var(--muted);
  margin-right: 8px;
}

.layer-item button {
  flex-shrink: 0;
}

.layer-item.selected {
  border-color: var(--accent);
  color: var(--accent);
}

.layer-item.active {
  background: var(--accent2);
}

.layer-item:hover {
  background: var(--hover);
}
.layer-item.dragging {
  opacity: 0.6;
  z-index: 10;
}

.layer-item.drop-target {
  background: #4ea1ffcc;
}


.layer-item.drop-indicator::before {
  content: "";
  position: absolute;
  left: 8px;
  right: 8px;
  top: -4px;
  height: 2px;
  background: var(--accent);
  border-radius: 999px;
}

.empty-text {
  color: var(--muted);
  font-size: 0.85rem;
}

.stage-panel {
  padding: 0;
  display: flex;
  flex-direction: column;
  min-height: 580px;
}

.canvas-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.canvas-controls label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
  padding: 6px 10px;
  border-radius: 999px;
}

.canvas-controls input {
  width: 70px;
  background: transparent;
  border: none;
  color: var(--text);
  font: inherit;
  font-weight: 600;
  text-align: right;
  outline: none;
}

.workspace-shell {
  width:100%;
  height:100dvh;
  flex: 1;
  position: relative;
  overflow: hidden;
  /* padding: 20px; */
  background-color: #cab8a0;
  background-repeat: repeat;
  touch-action: none;
}

.workspace-grid {
  width: max-content;
  margin: 0 auto;
}

.workspace-viewport {
  position: relative;
  /* transform-origin: 0 0; */
  touch-action: none;
  background-color: transparent;
}

.workspace {
  position: relative;
  background-color: transparent;
  /* border-radius: 16px; */
  /* outline: 3px dashed #888; */
  /* box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04); */
}

#workspaceBound{
  position:absolute;
  width:100%;
  height:100%;
  z-index:11;
  pointer-events: none;
}

.node-layer {
  position: relative;
  width: 100%;
  height: 100%;
  z-index: 1;
}

.workspace-hint {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--muted);
  pointer-events: none;
  gap: 4px;
}

.workspace-hint.hidden {
  opacity: 0;
}

.drop-overlay {
  position: absolute;
  inset: 0;
  border-radius: 16px;
  border: 2px dashed rgba(137, 160, 255, 0.6);
  background: rgba(5, 6, 15, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  color: var(--accent);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.drop-overlay.active {
  opacity: 1;
}

.stage-toolbar {
  display: flex;
  gap: 12px;
  padding: 12px 20px 20px;
  flex-wrap: wrap;
  align-items: center;
}

.toggle-field,
.color-field {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
  padding: 6px 12px;
  border-radius: 999px;
}

.toggle-field input[type="checkbox"] {
  width: 16px;
  height: 16px;
}

.color-field input[type="color"] {
  width: 40px;
  height: 24px;
  border: none;
  background: transparent;
  cursor: pointer;
}

.inspector-panel input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.inspector-section {
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.inspector-section.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.inspector-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.8rem;
  color: var(--muted);
}
.inspector-field span {
  font-weight: 600;
}
.inspector-field input[type="number"] {
  width: 100%;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
  color: inherit;
}
.inspector-field input[type="number"]:disabled {
  opacity: 0.5;
}

.muted {
  color: var(--muted);
}

.workspace:focus {
  outline: none;
}

.image-node {
  position: absolute;
  transform: translate(-50%, -50%);
  cursor: grab;
  user-select: none;
}

.image-node.dragging {
  cursor: grabbing;
}

.node-transform {
  position: absolute;
  inset: 0;
  transform-origin: center;
}

.node-content {
  position: absolute;
  inset: 0;
  /* border-radius: 12px; */
  overflow: hidden;
  transform-origin: center;
  /* box-shadow: 0 15px 30px rgba(0, 0, 0, 0.5); */
}

.node-flip-wrapper {
  width: 100%;
  height: 100%;
  transform-origin: center;
}

.image-node.processing .node-content::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 2;
}

.node-processing-indicator {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  z-index: 3;
  pointer-events: none;
  font-size: 1.25rem;
  text-shadow: 0 0 6px rgba(0, 0, 0, 0.4);
}
.node-content:hover{
  outline:3px solid #000;
}

.node-content img {
  width: 100%;
  height: 100%;
  /* object-fit: cover; */
  pointer-events: none;
  display: block;
}

.node-decorator {
  position: absolute;
  inset: 0;
  /* border: 1px solid rgba(255, 255, 255, 0.6); */
  transform-origin: center;
}

.image-node.selected .node-decorator {
  border-color: var(--accent);
  /* box-shadow: 0 0 0 1px var(--accent); */
}

.image-node.shared-source::after {
  content: "";
  position: absolute;
  inset: -6px;
  border: 3px dashed rgba(255, 128, 0, 0.4);
  border-radius: 12px;
  pointer-events: none;
  z-index: 0;
}

.image-node.shared-source.selected::after {
  border-style: solid;
  /* box-shadow: 0 0 12px rgba(0, 0, 0, 0.3); */
}

.handle {
  position: absolute;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  /* background: var(--accent); */
  /* transform: translate(-50%, -50%); */
  cursor: pointer;
  z-index:100;
  background: #f00;
  border:2px solid #000;
}

.node-decorator .handle {
  pointer-events: auto;
}

.handle[data-handle="rotate"] {
  top: -26px;
  left: 50%;
  width: 24px;
  height: 24px;
  /* border: 2px solid var(--panel); */
  transform: translateX(-50%);
  background-color: #f80;
  cursor: grab;
}

.handle.corner {
  width: 24px;
  height: 24px;
  /* background: var(--text); */
  background-color: #fff;
}

.handle[data-handle="nw"] {
  top: 0;
  left: 0;
  transform: translate(-50%, -50%);
}

.handle[data-handle="ne"] {
  top: 0;
  right: 0;
  transform: translate(50%, -50%);
}

.handle[data-handle="se"] {
  bottom: 0;
  right: 0;
  transform: translate(50%, 50%);
}

.handle[data-handle="sw"] {
  bottom: 0;
  left: 0;
  transform: translate(-50%, 50%);
}

.crop-overlay {
  position: absolute;
  inset: 0;
  border: 1px dashed rgba(255, 255, 255, 0.6);
  /* background: rgba(13, 15, 28, 0.45); */
  pointer-events: none;
}

.crop-overlay .handle {
  pointer-events: auto;
  width: 26px;
  height: 8px;
  border-radius: 999px;
  /* background: var(--accent-strong); */
  background: #0d0f1c;
}

.crop-overlay .handle[data-crop-handle="n"] {
  top: 0;
  left: 50%;
  transform: translate(-50%, -50%);
}

.crop-overlay .handle[data-crop-handle="s"] {
  bottom: 0;
  left: 50%;
  transform: translate(-50%, 50%);
}

.crop-overlay .handle[data-crop-handle="e"] {
  top: 50%;
  right: 0;
  transform: translate(50%, -50%) rotate(90deg);
}

.crop-overlay .handle[data-crop-handle="w"] {
  top: 50%;
  left: 0;
  transform: translate(-50%, -50%) rotate(90deg);
}

.preview-panel canvas {
  width: 100%;
  height: auto;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: #04050a;
}

.preview-actions {
  display: flex;
  gap: 8px;
}

.context-menu {
  position: fixed;
  background: var(--bgcolor);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 8px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 1000;
}

.context-menu button {
  width: 180px;
  justify-content: flex-start;
}

.context-menu .processing-action {
  position: relative;
  min-height: 32px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.context-menu .processing-action .action-spinner {
  display: none;
  align-items: center;
  gap: 6px;
  font-size: 0.85em;
}

.context-menu .processing-action.processing .action-label {
  display: none;
}

.context-menu .processing-action.processing .action-spinner {
  display: inline-flex;
}
.context-menu .processing-action.processing {
  opacity: 0.7;
  pointer-events: none;
}
.context-menu .processing-action .action-spinner {
  display: none;
}

.context-menu[hidden] {
  display: none;
}

@media (max-width: 1100px) {
  .main-grid {
    grid-template-columns: 1fr;
  }

  .layers-panel,
  .inspector-panel {
    min-height: auto;
  }
}

@media (max-width: 720px) {
  .topbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
  }

  .file-controls {
    width: 100%;
    flex-direction: column;
  }

  button,
  button.ghost {
    width: 100%;
    text-align: center;
  }
}


.toggle-field,
.color-field {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
  padding: 6px 12px;
  border-radius: 999px;
}

.toggle-field input[type="checkbox"] {
  width: 16px;
  height: 16px;
}

.color-field input[type="color"] {
  width: 40px;
  height: 24px;
  border: none;
  background: transparent;
  cursor: pointer;
}

.inspector-panel input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.inspector-section {
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.inspector-section.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.muted {
  color: var(--muted);
}

.workspace:focus {
  outline: none;
}

.image-node {
  position: absolute;
  transform: translate(-50%, -50%);
  cursor: grab;
  user-select: none;
}

.image-node.dragging {
  cursor: grabbing;
}

.node-transform {
  position: absolute;
  inset: 0;
  transform-origin: center;
}




  @media (max-width: 850px), (max-height: 550px) {

.handle[data-handle="rotate"] {
  top: -80px !important;
  width: 54px;
  height: 54px;
}

.handle.corner {
  width: 54px;
  height: 54px;
}
.crop-overlay .handle {
  width: 56px;
  height: 28px;
}


  }
