@layer features {
  html,
  body {
    width: 100%;
    height: 100%;
    margin: 0;
    overflow: hidden;
    background: #07090d !important;
  }

  .overlay-preview-window-stage {
    position: relative;
    width: 100%;
    height: 100%;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    overflow: hidden;
  }

  .overlay-preview-window-viewport {
    min-width: 0;
    min-height: 0;
    display: grid;
    place-items: center;
    overflow: hidden;
  }

  .overlay-preview-window-frame {
    position: relative;
    width: 100%;
    aspect-ratio: var(--overlay-aspect, 16 / 9);
    overflow: hidden;
    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;
  }

  .overlay-preview-window-canvas {
    position: absolute;
    inset: 0;
    overflow: hidden;
    outline: none;
    touch-action: none;
    user-select: none;
  }

  .overlay-preview-window-canvas:focus-visible {
    box-shadow: inset 0 0 0 3px #38bdf8;
  }

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

  .overlay-preview-window-toolbar {
    position: relative;
    z-index: 4000;
    width: min(42rem, calc(100% - 1.2rem));
    display: grid;
    gap: 0.45rem;
    padding: 0.65rem;
    border: 1px solid rgba(255, 255, 255, 0.24);
    border-radius: 0.75rem;
    background: rgba(7, 9, 13, 0.86);
    color: #f8fafc;
    box-shadow: 0 1rem 2.5rem rgba(0, 0, 0, 0.35);
    font: 600 0.78rem/1.25 system-ui, sans-serif;
    backdrop-filter: blur(12px);
    margin: max(0.6rem, env(safe-area-inset-top)) max(0.6rem, env(safe-area-inset-right)) 0 max(0.6rem, env(safe-area-inset-left));
  }

  .overlay-preview-window-fields,
  .overlay-preview-window-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: end;
    gap: 0.45rem;
  }

  .overlay-preview-window-fields label {
    display: grid;
    gap: 0.2rem;
  }

  .overlay-preview-window-fields label:first-child,
  .overlay-preview-window-fields label:nth-child(2) {
    flex: 1 1 10rem;
  }

  .overlay-preview-window-fields select,
  .overlay-preview-window-actions button {
    min-height: 2rem;
    border: 1px solid rgba(255, 255, 255, 0.28);
    border-radius: 0.45rem;
    background: #151a22;
    color: #f8fafc;
    font: inherit;
  }

  .overlay-preview-window-fields select {
    width: 100%;
    padding: 0.25rem 0.45rem;
  }

  .overlay-preview-window-actions button {
    padding: 0.3rem 0.65rem;
    cursor: pointer;
  }

  .overlay-preview-window-fields select:focus-visible,
  .overlay-preview-window-actions button:focus-visible {
    outline: 3px solid #38bdf8;
    outline-offset: 2px;
  }

  .overlay-preview-window-snap {
    min-height: 2rem;
    display: flex !important;
    grid-auto-flow: column;
    align-items: center;
    gap: 0.35rem !important;
  }

  .overlay-preview-window-readout,
  .overlay-preview-window-status {
    margin: 0;
    color: rgba(255, 255, 255, 0.76);
  }

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

  .overlay-preview-window-canvas .lumi-overlay-module.is-selected {
    z-index: 2000 !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: #fff;
    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,
  .is-selected > .overlay-resize-handle {
    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 #fff;
    border-radius: 1px;
    background: #ef4444;
    transform: translate(-50%, -50%);
  }

  .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-preview-window-guide {
    position: absolute;
    z-index: 3000;
    display: none;
    pointer-events: none;
    background: #38bdf8;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.5);
  }

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

  @media (max-width: 640px) {
    .overlay-preview-window-toolbar {
      width: calc(100% - 1.2rem);
    }

    .overlay-preview-window-fields label:first-child,
    .overlay-preview-window-fields label:nth-child(2) {
      flex-basis: calc(50% - 0.5rem);
    }
  }

  @media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
      scroll-behavior: auto !important;
    }
  }
}
