@layer features {
.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-browser-source-setup {
  margin-top: var(--lumi-space-3);
  padding: var(--lumi-space-3);
  border: 1px solid var(--lumi-border);
  border-radius: var(--lumi-radius-sm);
  background: var(--lumi-surface-subtle);
}

.overlay-browser-source-setup > summary {
  cursor: pointer;
  font-weight: 800;
}

.overlay-browser-source-setup[open] > summary {
  margin-bottom: var(--lumi-space-3);
}

.overlay-browser-dimensions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--lumi-space-2);
  margin: var(--lumi-space-3) 0;
}

.overlay-browser-dimensions > div {
  padding: var(--lumi-space-2) var(--lumi-space-3);
  border: 1px solid var(--lumi-border);
  border-radius: var(--lumi-radius-sm);
  background: var(--lumi-surface-raised);
}

.overlay-browser-dimensions span,
.overlay-browser-dimensions strong,
.overlay-copy-label {
  display: block;
}

.overlay-browser-dimensions span {
  color: var(--lumi-text-muted);
  font-size: 0.78rem;
}

.overlay-copy-label {
  margin-bottom: var(--lumi-space-1);
  font-weight: 700;
}

.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 {
  cursor: pointer;
  font-weight: 800;
}

.overlay-settings-disclosure,
.overlay-private-link,
[data-obs-connector] > details {
  border: 1px solid var(--lumi-border);
  border-radius: var(--lumi-radius-md);
  background: color-mix(in srgb, var(--lumi-surface-subtle) 72%, transparent);
  overflow: clip;
}

.overlay-settings-disclosure > summary,
.overlay-private-link > summary,
[data-obs-connector] > details > summary {
  padding: var(--lumi-space-3) var(--lumi-space-4);
  background: var(--lumi-surface-subtle);
}

.overlay-settings-disclosure[open] > summary,
.overlay-private-link[open] > summary,
[data-obs-connector] > details[open] > summary {
  border-bottom: 1px solid var(--lumi-border);
}

.overlay-settings-disclosure > form,
.overlay-settings-disclosure > .overlay-list-actions,
.overlay-private-link > :not(summary),
[data-obs-connector] > details > :not(summary) {
  margin: var(--lumi-space-4);
}

.overlay-settings-disclosure > .overlay-list-actions,
.overlay-private-link > .overlay-list-actions {
  padding-top: var(--lumi-space-3);
  border-top: 1px solid var(--lumi-border);
}

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

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

.overlay-settings-column > .card + .card {
  margin-top: var(--lumi-space-4);
}

.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[open] > summary,
.overlay-source-card[open] > summary,
.overlay-add-source[open] > summary {
  border-bottom: 1px solid var(--lumi-border);
  background: color-mix(in srgb, var(--lumi-primary) 6%, var(--lumi-surface-subtle));
}

.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: var(--lumi-space-3);
}

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

.overlay-scene-body > * {
  margin-block: 0;
}

.overlay-source-card > .overlay-module-actions {
  padding-top: 0;
}

.overlay-source-card > .overlay-module-actions::before {
  content: "";
  width: 100%;
  border-top: 1px solid var(--lumi-border);
  margin-bottom: var(--lumi-space-1);
}

.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,
.overlay-switch-field {
  display: grid;
  align-content: start;
  gap: var(--lumi-space-1);
}

.overlay-field-label,
.overlay-color-field > span:first-child {
  color: var(--lumi-text);
  font-weight: 700;
}

.overlay-switch-field .switch {
  min-height: var(--lumi-control-height);
  align-content: center;
}

.overlay-order-form {
  display: grid;
  gap: var(--lumi-space-3);
  margin-top: var(--lumi-space-4);
  padding: var(--lumi-space-3);
  border: 1px solid var(--lumi-border);
  border-radius: var(--lumi-radius-sm);
  background: var(--lumi-surface-subtle);
}

.overlay-live-scene-form {
  margin-top: var(--lumi-space-4);
  padding-top: var(--lumi-space-4);
  border-top: 1px solid var(--lumi-border);
}

.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-chat-fields > .full,
.overlay-fieldset.full {
  grid-column: 1 / -1;
}

.overlay-fieldset {
  min-width: 0;
  margin: 0;
  padding: var(--lumi-space-3);
  border: 1px solid var(--lumi-border);
  border-radius: var(--lumi-radius-sm);
}

.overlay-fieldset legend {
  padding-inline: var(--lumi-space-1);
  font-weight: 800;
}

.overlay-check-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(8rem, 1fr));
  gap: var(--lumi-space-2) var(--lumi-space-3);
}

.overlay-check-grid label {
  display: flex;
  align-items: center;
  gap: var(--lumi-space-2);
  min-height: var(--lumi-control-height);
}

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

.overlay-event-alerts .callout {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--lumi-space-3);
  margin-bottom: var(--lumi-space-4);
}

.overlay-event-alerts .callout p {
  flex: 1 1 28rem;
  margin: 0;
}

.overlay-event-hook-list {
  display: grid;
  gap: var(--lumi-space-3);
  margin-bottom: var(--lumi-space-4);
}

.overlay-event-hook-card {
  border: 1px solid var(--lumi-border-strong, var(--border));
  border-radius: var(--lumi-radius-md, 10px);
  background: color-mix(in srgb, var(--surface-2) 82%, transparent);
}

.overlay-event-hook-card > summary {
  padding: var(--lumi-space-3) var(--lumi-space-4);
}

.overlay-event-hook-card > summary span {
  display: grid;
  gap: var(--lumi-space-1);
}

.overlay-event-hook-card > form {
  margin: 0 var(--lumi-space-3) var(--lumi-space-3);
  padding: var(--lumi-space-4);
  border: 1px solid var(--border);
  border-radius: var(--lumi-radius-sm, 8px);
  background: var(--card);
}

.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;
  display: grid;
  grid-template-rows: repeat(7, auto);
  gap: var(--lumi-space-2);
  overflow: clip;
}

.overlay-preview-launcher,
.overlay-preview-close {
  display: none;
}

.overlay-preview-header {
  margin: 0;
}

.overlay-preview-header-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: var(--lumi-space-2);
}

.overlay-preview-popout {
  min-height: 2rem;
  padding-block: 0.3rem;
}

.overlay-editor-toolbar {
  justify-content: space-between;
  margin: 0;
}

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

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

.overlay-preview-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--lumi-space-2);
  margin: 0;
  color: var(--lumi-text-muted);
  font-size: 0.82rem;
}

.overlay-preview-tools .button {
  min-height: 2rem;
  padding-block: 0.3rem;
  font-size: 0.78rem;
}

.overlay-preview-tools [aria-pressed="true"] {
  border-color: var(--lumi-primary);
  background: color-mix(in srgb, var(--lumi-primary) 20%, var(--lumi-surface));
}

.overlay-canvas-frame {
  width: 100%;
  max-width: 100%;
  max-height: 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-preview-stage {
  min-width: 0;
  min-height: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.overlay-canvas-frame.preview-bg-dark {
  background: #070b12;
}

.overlay-canvas-frame.preview-bg-light {
  background: #f4f7fb;
}

.overlay-canvas-frame.show-grid .overlay-canvas::after {
  content: "";
  position: absolute;
  z-index: 900;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(to right, rgba(56,189,248,.28) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(56,189,248,.28) 1px, transparent 1px),
    linear-gradient(to right, rgba(56,189,248,.6) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(56,189,248,.6) 1px, transparent 1px);
  background-size: 5% 5%, 5% 5%, 50% 50%, 50% 50%;
}

.overlay-source-card.is-dirty {
  border-color: color-mix(in srgb, var(--lumi-accent, var(--lumi-primary)) 70%, var(--lumi-border));
  box-shadow: inset 3px 0 color-mix(in srgb, var(--lumi-accent, var(--lumi-primary)) 75%, transparent);
}

.overlay-source-save-row {
  position: sticky;
  z-index: 10;
  bottom: 0;
  margin: 0 calc(-1 * var(--lumi-space-3)) calc(-1 * var(--lumi-space-3));
  padding: var(--lumi-space-3);
  border-top: 1px solid var(--lumi-border);
  background: color-mix(in srgb, var(--lumi-surface) 94%, transparent);
  backdrop-filter: blur(10px);
}

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

.overlay-canvas:focus-visible {
  box-shadow: inset 0 0 0 3px var(--lumi-focus, var(--lumi-primary));
}

.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: var(--lumi-editor-outline-size, 2px) solid #ef4444;
  outline-offset: -1px;
}

.overlay-canvas-source-label {
  position: absolute;
  left: 0;
  bottom: 100%;
  display: none;
  max-width: var(--lumi-editor-label-max-width, 12rem);
  padding: var(--lumi-editor-label-padding-y, 0.2rem) var(--lumi-editor-label-padding-x, 0.4rem);
  overflow: hidden;
  border-radius: var(--lumi-editor-label-radius, 4px) var(--lumi-editor-label-radius, 4px) 0 0;
  background: #ef4444;
  color: white;
  font: 700 var(--lumi-editor-label-font-size, 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: var(--lumi-editor-handle-size, 10px);
  height: var(--lumi-editor-handle-size, 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: 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-2);
}

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

.overlay-preview-details {
  min-height: 0;
  border-top: 1px solid var(--lumi-border);
}

.overlay-preview-details > summary {
  padding-block: var(--lumi-space-2);
  cursor: pointer;
  font-weight: 700;
}

.overlay-preview-details-body {
  max-height: min(9rem, 22dvh);
  padding-right: var(--lumi-space-1);
  overflow: auto;
  overscroll-behavior: contain;
}

.overlay-preview-details-body > .hint {
  margin: 0;
}

@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-workspace-height, calc(100dvh - (2 * var(--lumi-space-4))));
    overflow-x: clip;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
    padding: 0 var(--lumi-space-2) max(var(--lumi-space-7), env(safe-area-inset-bottom)) 0;
  }
  .overlay-preview-panel {
    position: sticky;
    top: calc(var(--lumi-space-4) + env(safe-area-inset-top));
    height: auto;
    max-height: var(--overlay-workspace-height, calc(100dvh - (2 * var(--lumi-space-4))));
  }
}

@media (max-width: 1179px) {
  .overlay-workspace {
    display: block;
  }

  .overlay-preview-panel {
    position: fixed;
    z-index: 1200;
    inset: max(var(--lumi-space-2), env(safe-area-inset-top)) max(var(--lumi-space-2), env(safe-area-inset-right)) auto auto;
    width: min(46rem, calc(100vw - (2 * var(--lumi-space-2))));
    max-width: calc(100vw - (2 * var(--lumi-space-2)));
    height: auto;
    max-height: calc(100dvh - (2 * var(--lumi-space-2)));
    overflow-x: clip;
    overflow-y: auto;
    overscroll-behavior-y: auto;
    scrollbar-gutter: stable;
    visibility: hidden;
    opacity: 0;
    transform: translateX(calc(100% + var(--lumi-space-4)));
    transition: transform 180ms ease, opacity 140ms ease, visibility 0s linear 180ms;
    box-shadow: var(--lumi-shadow-lg);
  }

  .overlay-preview-panel.is-open {
    visibility: visible;
    opacity: 1;
    transform: translateX(0);
    transition-delay: 0s;
  }

  .overlay-preview-launcher {
    position: fixed;
    z-index: 1190;
    top: calc(100dvh - max(var(--lumi-space-3), env(safe-area-inset-bottom)) - var(--lumi-control-height));
    right: max(var(--lumi-space-3), env(safe-area-inset-right));
    bottom: auto;
    display: inline-flex;
    box-shadow: var(--lumi-shadow-lg);
  }

  .overlay-settings-column :where(summary, button, input, select, textarea) {
    scroll-margin-block: calc(var(--lumi-control-height) + (2 * var(--lumi-space-4)));
  }

  .overlay-preview-close {
    display: inline-grid;
  }
}

@media (max-width: 700px), (pointer: coarse) {
  .overlay-preview-popout {
    display: none;
  }
}

@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: var(--lumi-editor-handle-size, 14px); height: var(--lumi-editor-handle-size, 14px); }
}

@media (max-width: 480px) {
  .overlay-transform-fields,
  .overlay-conditional-fields { grid-template-columns: 1fr; }
}

@media (max-height: 620px) {
  .overlay-preview-panel {
    grid-template-rows: repeat(7, auto);
    gap: var(--lumi-space-1);
  }

  .overlay-preview-stage {
    min-height: 0;
  }

  .overlay-preview-details-body {
    max-height: 5rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .overlay-preview-panel {
    transition: none;
  }
}
}
