.overlay-url-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--lumi-space-2);
  align-items: center;
}

.overlay-url-row input {
  min-width: 0;
  font: 0.78rem/1.4 var(--lumi-font-mono);
}

.overlay-list-actions,
.overlay-scene-actions,
.overlay-module-actions,
.overlay-editor-actions,
.overlay-editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--lumi-space-2);
  align-items: center;
}

.overlay-settings-disclosure > summary,
.overlay-private-link > summary,
.overlay-add-source > summary {
  margin-bottom: var(--lumi-space-3);
  cursor: pointer;
  font-weight: 800;
}

.overlay-workspace {
  display: grid;
  gap: var(--lumi-space-4);
}

.overlay-settings-column {
  min-width: 0;
}

.overlay-scene-card,
.overlay-source-card,
.overlay-add-source {
  margin-top: var(--lumi-space-3);
  border: 1px solid var(--lumi-border);
  border-radius: var(--lumi-radius-md);
  background: var(--lumi-surface-subtle);
}

.overlay-scene-card > summary,
.overlay-source-card > summary,
.overlay-add-source > summary {
  padding: var(--lumi-space-3);
  cursor: pointer;
}

.overlay-scene-card > summary,
.overlay-source-card > summary span {
  font-weight: 800;
}

.overlay-source-card > summary small {
  display: block;
  margin-top: 0.2rem;
  color: var(--lumi-text-muted);
  font-weight: 600;
}

.overlay-scene-body,
.overlay-source-card > form,
.overlay-source-card > .overlay-module-actions,
.overlay-add-source > form {
  padding: 0 var(--lumi-space-3) var(--lumi-space-3);
}

.overlay-status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
  gap: var(--lumi-space-3);
  margin: var(--lumi-space-3) 0;
}

.overlay-status-grid > div {
  padding: var(--lumi-space-3);
  border: 1px solid var(--lumi-border);
  border-radius: var(--lumi-radius-sm);
  background: var(--lumi-surface-subtle);
}

.overlay-status-grid span,
.overlay-status-grid strong {
  display: block;
}

.overlay-reorder-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--lumi-space-2);
  align-items: center;
}

.overlay-transform-fields,
.overlay-conditional-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr));
  gap: var(--lumi-space-3);
  padding: var(--lumi-space-3);
  border: 1px solid var(--lumi-border);
  border-radius: var(--lumi-radius-sm);
}

.overlay-transform-fields label,
.overlay-conditional-fields > label,
.overlay-color-field {
  display: grid;
  align-content: start;
  gap: var(--lumi-space-1);
}

.overlay-transform-disclosure > summary {
  padding: var(--lumi-space-3);
  border: 1px solid var(--lumi-border);
  border-radius: var(--lumi-radius-sm);
  background: var(--lumi-surface-subtle);
  cursor: pointer;
  font-weight: 800;
}

.overlay-transform-disclosure[open] > summary {
  margin-bottom: var(--lumi-space-2);
}

.overlay-color-inputs {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--lumi-control-height);
  gap: var(--lumi-space-2);
  align-items: stretch;
}

.overlay-color-inputs input[type="color"] {
  width: var(--lumi-control-height);
  min-width: var(--lumi-control-height);
  height: var(--lumi-control-height);
  padding: 0.2rem;
  cursor: pointer;
}

.overlay-css-field {
  grid-column: 1 / -1;
}

.overlay-conditional-fields[hidden] {
  display: none !important;
}

.overlay-help {
  position: relative;
  width: 1.3rem;
  height: 1.3rem;
  display: inline-grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--lumi-border);
  border-radius: 50%;
  background: var(--lumi-surface-raised);
  color: var(--lumi-text-muted);
  font: 800 0.75rem/1 var(--lumi-font-body);
  cursor: help;
}

.overlay-help::after {
  content: attr(data-tooltip);
  position: absolute;
  z-index: 80;
  left: 50%;
  bottom: calc(100% + 0.55rem);
  width: min(17rem, 75vw);
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--lumi-border);
  border-radius: var(--lumi-radius-sm);
  background: var(--lumi-surface-raised);
  color: var(--lumi-text);
  box-shadow: var(--lumi-shadow-md);
  font: 500 0.82rem/1.35 var(--lumi-font-body);
  text-align: left;
  transform: translate(-50%, 0.25rem);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity var(--lumi-transition), transform var(--lumi-transition);
}

.overlay-help:hover::after,
.overlay-help:focus-visible::after {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, 0);
}

.overlay-preview-panel {
  min-width: 0;
  align-self: start;
}

.overlay-editor-toolbar {
  justify-content: space-between;
  margin-bottom: var(--lumi-space-3);
}

.overlay-editor-toolbar label:first-child {
  flex: 1 1 12rem;
}

.overlay-editor-toolbar select {
  width: 100%;
  margin-top: var(--lumi-space-1);
}

.overlay-canvas-frame {
  width: 100%;
  aspect-ratio: var(--overlay-aspect, 16 / 9);
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--lumi-primary) 45%, var(--lumi-border));
  border-radius: var(--lumi-radius-sm);
  background:
    linear-gradient(45deg, #252a2f 25%, transparent 25%),
    linear-gradient(-45deg, #252a2f 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #252a2f 75%),
    linear-gradient(-45deg, transparent 75%, #252a2f 75%),
    #171b1f;
  background-position: 0 0, 0 12px, 12px -12px, -12px 0;
  background-size: 24px 24px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.04);
}

.overlay-canvas {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  user-select: none;
  touch-action: none;
  outline: none;
}

.overlay-canvas-layer {
  position: absolute;
  inset: 0;
}

.overlay-canvas .lumi-overlay-module {
  cursor: move;
  pointer-events: auto;
}

.overlay-canvas .lumi-overlay-module.is-selected {
  z-index: 1000 !important;
  overflow: visible;
  outline: 2px solid #ef4444;
  outline-offset: -1px;
}

.overlay-canvas-source-label {
  position: absolute;
  left: 0;
  bottom: 100%;
  display: none;
  max-width: 12rem;
  padding: 0.2rem 0.4rem;
  overflow: hidden;
  border-radius: 4px 4px 0 0;
  background: #ef4444;
  color: white;
  font: 700 0.7rem/1.2 system-ui, sans-serif;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.is-selected > .overlay-canvas-source-label { display: block; }

.overlay-resize-handle {
  position: absolute;
  z-index: 5;
  width: 10px;
  height: 10px;
  display: none;
  padding: 0;
  border: 1px solid white;
  border-radius: 1px;
  background: #ef4444;
  transform: translate(-50%, -50%);
}

.is-selected > .overlay-resize-handle { display: block; }
.handle-nw { left: 0; top: 0; cursor: nwse-resize; }
.handle-n { left: 50%; top: 0; cursor: ns-resize; }
.handle-ne { left: 100%; top: 0; cursor: nesw-resize; }
.handle-e { left: 100%; top: 50%; cursor: ew-resize; }
.handle-se { left: 100%; top: 100%; cursor: nwse-resize; }
.handle-s { left: 50%; top: 100%; cursor: ns-resize; }
.handle-sw { left: 0; top: 100%; cursor: nesw-resize; }
.handle-w { left: 0; top: 50%; cursor: ew-resize; }

.overlay-snap-guide {
  position: absolute;
  z-index: 2000;
  display: none;
  pointer-events: none;
  background: #38bdf8;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.4);
}

.overlay-snap-guide.is-visible { display: block; }
.overlay-snap-guide.guide-x { top: 0; bottom: 0; width: 1px; }
.overlay-snap-guide.guide-y { left: 0; right: 0; height: 1px; }

.overlay-editor-readout {
  min-height: 2rem;
  display: flex;
  justify-content: space-between;
  gap: var(--lumi-space-2);
  padding: var(--lumi-space-2) 0;
  color: var(--lumi-text-muted);
  font-size: 0.82rem;
}

.overlay-canvas-source-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--lumi-space-1);
  margin-top: var(--lumi-space-3);
}

.overlay-canvas-source-list .is-selected {
  border-color: var(--lumi-primary);
  background: color-mix(in srgb, var(--lumi-primary) 16%, var(--lumi-surface));
}

@media (min-width: 1180px) {
  .overlay-workspace {
    grid-template-columns: minmax(0, 1.15fr) minmax(25rem, 0.85fr);
    align-items: start;
  }
  .overlay-settings-column {
    min-height: 0;
    max-height: var(--overlay-settings-max-height, calc(100dvh - 2 * var(--lumi-space-4)));
    overflow-y: auto;
    overscroll-behavior-y: contain;
    scrollbar-gutter: stable;
    padding: 0 var(--lumi-space-2) var(--lumi-space-4) 0;
  }
  .overlay-preview-panel {
    position: sticky;
    top: var(--lumi-space-4);
  }
}

@media (max-width: 1179px) {
  .overlay-preview-panel { grid-row: 1; }
}

@media (max-width: 700px) {
  .overlay-url-row { grid-template-columns: 1fr; }
  .overlay-transform-fields,
  .overlay-conditional-fields { grid-template-columns: 1fr 1fr; }
  .overlay-resize-handle { width: 14px; height: 14px; }
}
