/*
 * Dr.Prompt · Creative Engine finish and state pass (P2)
 *
 * Presentation only. This layer improves material continuity, interaction
 * states, responsive containment, and accessibility without changing DOM,
 * workflow behavior, generated text, or application data.
 */

/* Shared translucent topbar treatment. The same geometry is retained on the
   landing page and functional views so the brand shell stays consistent. */
#app#app[data-active-view] .topbar {
  border-color: rgba(255, 255, 255, .14) !important;
  background:
    linear-gradient(180deg, rgba(28, 25, 37, .58), rgba(8, 8, 11, .46)) !important;
  -webkit-backdrop-filter: blur(22px) saturate(122%) !important;
  backdrop-filter: blur(22px) saturate(122%) !important;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .09),
    inset 0 -1px 0 rgba(255, 255, 255, .025),
    0 18px 52px rgba(0, 0, 0, .2) !important;
}

#app#app[data-active-view] .topbar::before {
  content: "" !important;
  position: absolute !important;
  inset: 0 !important;
  z-index: -1 !important;
  border-radius: inherit !important;
  pointer-events: none !important;
  background:
    radial-gradient(circle at 8% -40%, rgba(206, 188, 255, .15), transparent 35%),
    linear-gradient(90deg, rgba(255, 255, 255, .025), transparent 32% 70%, rgba(122, 71, 239, .045)) !important;
}

#app#app[data-active-view] .topbar-navigation > .workspace-topnav {
  border-color: rgba(255, 255, 255, .095) !important;
  background: rgba(3, 3, 5, .24) !important;
  -webkit-backdrop-filter: blur(14px) !important;
  backdrop-filter: blur(14px) !important;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .035) !important;
}

#app#app[data-active-view] .topbar-home-link,
#app#app[data-active-view] .workspace-topnav-item,
#app#app[data-active-view] .workspace-account-link,
#app#app[data-active-view] .ghost-btn,
#app#app[data-active-view] .primary-btn {
  transition:
    color 160ms ease,
    border-color 160ms ease,
    background-color 160ms ease,
    box-shadow 160ms ease,
    opacity 160ms ease,
    transform 160ms ease !important;
}

#app#app[data-active-view] .topbar-home-link:hover {
  transform: translateY(-1px) !important;
}

/* Guard against legacy layers introducing page-level horizontal overflow. */
html,
body,
#app#app,
#app#app .shell,
#app#app[data-active-view="workbench"] .view[data-view-panel="workbench"] {
  max-width: 100% !important;
}

html,
body {
  overflow-x: clip !important;
}

#app#app[data-active-view="workbench"][data-creation-entry="fast"] .workbench-grid > *,
#app#app[data-active-view="workbench"][data-creation-entry="fast"] .composer-card *,
#app#app[data-active-view="workbench"][data-creation-entry="fast"] .output-panel * {
  box-sizing: border-box !important;
}

/* A soft tonal bridge between the photographic hero and production panels.
   It creates depth without inserting or editing any application content. */
#app#app[data-active-view="workbench"][data-creation-entry="fast"] .view[data-view-panel="workbench"] {
  position: relative !important;
  isolation: isolate !important;
}

#app#app[data-active-view="workbench"][data-creation-entry="fast"] .view[data-view-panel="workbench"]::before {
  content: "" !important;
  position: absolute !important;
  z-index: -1 !important;
  inset: 0 !important;
  pointer-events: none !important;
  background:
    radial-gradient(ellipse 64% 410px at 50% 170px, rgba(35, 28, 49, .12), transparent 72%),
    linear-gradient(180deg, transparent 0 480px, rgba(31, 31, 33, .5) 670px, #272727 920px) !important;
}

/* Main panels: glass edge refraction, consistent light direction, and no
   generic heavy shadows. */
#app#app[data-active-view="workbench"][data-creation-entry="fast"] .output-panel {
  -webkit-backdrop-filter: blur(18px) saturate(112%) !important;
  backdrop-filter: blur(18px) saturate(112%) !important;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .075),
    inset 0 0 0 1px rgba(255, 255, 255, .012),
    0 28px 80px rgba(11, 8, 18, .23) !important;
}


#app#app[data-active-view="workbench"][data-creation-entry="fast"] .idea-input {
  scrollbar-color: rgba(189, 168, 255, .28) transparent !important;
  scrollbar-width: thin !important;
}

#app#app[data-active-view="workbench"][data-creation-entry="fast"] .idea-input::selection,
#app#app[data-active-view="workbench"][data-creation-entry="fast"] .prompt-body::selection {
  background: rgba(122, 71, 239, .38) !important;
  color: #fff !important;
}

/* Reference-image rail: explicit empty/uploaded/hover states. Existing
   buttons and file input remain the only interaction mechanism. */
#app#app[data-active-view="workbench"][data-creation-entry="fast"] .reference-preview.reference-slot-grid button {
  transition:
    border-color 160ms ease,
    background-color 160ms ease,
    box-shadow 160ms ease,
    transform 160ms ease,
    opacity 160ms ease !important;
}

#app#app[data-active-view="workbench"][data-creation-entry="fast"] .reference-preview.reference-slot-grid .reference-slot,
#app#app[data-active-view="workbench"][data-creation-entry="fast"] .reference-preview.reference-slot-grid .reference-thumb,
#app#app[data-active-view="workbench"][data-creation-entry="fast"] .reference-preview.reference-slot-grid .reference-upload-placeholder {
  position: relative !important;
  overflow: hidden !important;
  border-color: rgba(255, 255, 255, .13) !important;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, .055), rgba(255, 255, 255, .018)) !important;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .035) !important;
}

#app#app[data-active-view="workbench"][data-creation-entry="fast"] .reference-preview.reference-slot-grid .reference-slot:hover,
#app#app[data-active-view="workbench"][data-creation-entry="fast"] .reference-preview.reference-slot-grid .reference-slot:focus-visible,
#app#app[data-active-view="workbench"][data-creation-entry="fast"] .reference-preview.reference-slot-grid .reference-thumb-main:hover,
#app#app[data-active-view="workbench"][data-creation-entry="fast"] .reference-preview.reference-slot-grid .reference-thumb-main:focus-visible {
  border-color: rgba(189, 168, 255, .4) !important;
  background-color: rgba(122, 71, 239, .095) !important;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .06),
    0 8px 24px rgba(38, 20, 74, .18) !important;
  transform: translateY(-1px) !important;
}

#app#app[data-active-view="workbench"][data-creation-entry="fast"] .reference-thumb-remove {
  border-color: rgba(255, 255, 255, .16) !important;
  background: rgba(8, 8, 11, .72) !important;
  color: rgba(255, 255, 255, .78) !important;
  -webkit-backdrop-filter: blur(8px) !important;
  backdrop-filter: blur(8px) !important;
}

#app#app[data-active-view="workbench"][data-creation-entry="fast"] .reference-thumb-remove:hover,
#app#app[data-active-view="workbench"][data-creation-entry="fast"] .reference-thumb-remove:focus-visible {
  border-color: rgba(255, 151, 151, .4) !important;
  background: rgba(111, 31, 40, .8) !important;
  color: #fff !important;
}

/* Control modules: complete hover, open, checked, disabled, and keyboard
   states while preserving the current Size / Styles / first-frame controls. */
#app#app[data-active-view="workbench"][data-creation-entry="fast"] .composer-more-control,
#app#app[data-active-view="workbench"][data-creation-entry="fast"] .composer-styles-trigger,
#app#app[data-active-view="workbench"][data-creation-entry="fast"] .first-frame-toggle-compact,
#app#app[data-active-view="workbench"][data-creation-entry="fast"] #reset-demo-btn,
#app#app[data-active-view="workbench"][data-creation-entry="fast"] #run-demo-btn {
  transition:
    filter 160ms ease,
    border-color 160ms ease,
    background-color 160ms ease,
    box-shadow 160ms ease,
    opacity 160ms ease,
    transform 160ms ease !important;
}

#app#app[data-active-view="workbench"][data-creation-entry="fast"] .composer-more-control:has(.composer-more-trigger[aria-expanded="true"]),
#app#app[data-active-view="workbench"][data-creation-entry="fast"] .composer-styles-trigger[aria-expanded="true"] {
  filter: brightness(1.13) !important;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .09),
    0 10px 28px rgba(44, 25, 76, .18) !important;
}

#app#app[data-active-view="workbench"][data-creation-entry="fast"] .first-frame-toggle-compact:has(input:checked) {
  border-color: rgba(94, 205, 179, .62) !important;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .08),
    0 9px 24px rgba(13, 83, 70, .2) !important;
}

#app#app[data-active-view="workbench"][data-creation-entry="fast"] #reset-demo-btn:hover,
#app#app[data-active-view="workbench"][data-creation-entry="fast"] #reset-demo-btn:focus-visible {
  border-color: rgba(255, 255, 255, .24) !important;
  background: rgba(255, 255, 255, .075) !important;
  color: #fff !important;
}

#app#app[data-active-view="workbench"][data-creation-entry="fast"] #run-demo-btn:hover,
#app#app[data-active-view="workbench"][data-creation-entry="fast"] #run-demo-btn:focus-visible {
  filter: brightness(1.09) !important;
  transform: translateY(-1px) !important;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .16),
    0 14px 30px rgba(69, 31, 152, .42) !important;
}

#app#app[data-active-view="workbench"][data-creation-entry="fast"] #run-demo-btn:active,
#app#app[data-active-view="workbench"][data-creation-entry="fast"] #reset-demo-btn:active {
  transform: translateY(0) scale(.985) !important;
}

#app#app[data-active-view="workbench"][data-creation-entry="fast"] button:disabled,
#app#app[data-active-view="workbench"][data-creation-entry="fast"] [aria-disabled="true"] {
  cursor: not-allowed !important;
  filter: saturate(.55) !important;
  opacity: .48 !important;
  transform: none !important;
  box-shadow: none !important;
}

#app#app[data-active-view="workbench"][data-creation-entry="fast"] .composer-card.is-run-locked {
  border-color: rgba(122, 71, 239, .3) !important;
}

#app#app[data-active-view="workbench"][data-creation-entry="fast"] .composer-card.is-run-locked .composer-studio-top {
  background: rgba(122, 71, 239, .055) !important;
}

#app#app[data-active-view="workbench"][data-creation-entry="fast"] #run-demo-btn[data-show-progress="true"] {
  overflow: hidden !important;
  isolation: isolate !important;
}

#app#app[data-active-view="workbench"][data-creation-entry="fast"] #run-demo-btn[data-show-progress="true"] .composer-send-progress {
  position: relative !important;
  z-index: 2 !important;
  color: #fff !important;
  font-variant-numeric: tabular-nums !important;
}

/* Popovers and trays use one consistent floating-surface model. */
#app#app[data-active-view="workbench"][data-creation-entry="fast"] .composer-more-panel,
#app#app[data-active-view="workbench"][data-creation-entry="fast"] .quick-start-style-wheel,
#app#app[data-active-view="workbench"][data-creation-entry="fast"] .composer-style-tray.open,
#app#app[data-active-view="workbench"][data-creation-entry="fast"] .mention-panel {
  -webkit-backdrop-filter: blur(22px) saturate(116%) !important;
  backdrop-filter: blur(22px) saturate(116%) !important;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .075),
    0 26px 70px rgba(0, 0, 0, .42) !important;
}

/* Workflow states: the closed row remains quiet; open state gains a single
   restrained violet cue and clearer separation. */
#app#app[data-active-view="workbench"][data-creation-entry="fast"] .creative-workflow-disclosure {
  transition:
    border-color 180ms ease,
    background-color 180ms ease,
    box-shadow 180ms ease !important;
}

#app#app[data-active-view="workbench"][data-creation-entry="fast"] .creative-workflow-disclosure:hover {
  border-color: rgba(255, 255, 255, .13) !important;
  background: rgba(10, 10, 13, .76) !important;
}

#app#app[data-active-view="workbench"][data-creation-entry="fast"] .creative-workflow-disclosure[open] {
  border-color: rgba(122, 71, 239, .25) !important;
  background: rgba(10, 9, 14, .84) !important;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .035) !important;
}

#app#app[data-active-view="workbench"][data-creation-entry="fast"] .creative-workflow-summary:focus-visible {
  outline: 2px solid rgba(189, 168, 255, .7) !important;
  outline-offset: -3px !important;
  border-radius: 13px !important;
}

/* Output state polish: status badges are legible without competing with the
   actual video prompt, and result tools share a single button treatment. */
#app#app[data-active-view="workbench"][data-creation-entry="fast"] .quality-badge {
  min-height: 25px !important;
  padding-inline: 10px !important;
  font-size: 9px !important;
  font-weight: 700 !important;
  letter-spacing: .04em !important;
  font-variant-numeric: tabular-nums !important;
}

#app#app[data-active-view="workbench"][data-creation-entry="fast"] .quality-badge:not(.warn):not(.empty) {
  border-color: rgba(94, 205, 179, .3) !important;
  background: rgba(35, 129, 111, .13) !important;
  color: #9de4d2 !important;
}

#app#app[data-active-view="workbench"][data-creation-entry="fast"] .quality-badge.warn {
  border-color: rgba(229, 173, 91, .3) !important;
  background: rgba(140, 83, 35, .14) !important;
  color: #e6bb82 !important;
}

#app#app[data-active-view="workbench"][data-creation-entry="fast"] .quality-badge.empty {
  border-color: rgba(255, 255, 255, .1) !important;
  background: rgba(255, 255, 255, .035) !important;
  color: rgba(247, 245, 251, .46) !important;
}

#app#app[data-active-view="workbench"][data-creation-entry="fast"] .prompt-toolbar .small,
#app#app[data-active-view="workbench"][data-creation-entry="fast"] .result-head-actions .small {
  min-height: 30px !important;
  border-radius: 8px !important;
  font-size: 9px !important;
  white-space: nowrap !important;
}

#app#app[data-active-view="workbench"][data-creation-entry="fast"] .prompt-toolbar .ghost-btn,
#app#app[data-active-view="workbench"][data-creation-entry="fast"] .result-head-actions .ghost-btn {
  border-color: rgba(255, 255, 255, .11) !important;
  background: rgba(255, 255, 255, .035) !important;
  color: rgba(247, 245, 251, .67) !important;
}

#app#app[data-active-view="workbench"][data-creation-entry="fast"] .prompt-toolbar .ghost-btn:hover,
#app#app[data-active-view="workbench"][data-creation-entry="fast"] .prompt-toolbar .ghost-btn:focus-visible {
  border-color: rgba(189, 168, 255, .28) !important;
  background: rgba(122, 71, 239, .09) !important;
  color: #fff !important;
}

#app#app[data-active-view="workbench"][data-creation-entry="fast"] .prompt-toolbar .primary-btn,
#app#app[data-active-view="workbench"][data-creation-entry="fast"] .result-head-actions .primary-btn {
  border-color: rgba(189, 168, 255, .34) !important;
  background: rgba(122, 71, 239, .82) !important;
  color: #fff !important;
  box-shadow: none !important;
}

#app#app[data-active-view="workbench"][data-creation-entry="fast"] .prompt-body {
  overflow-wrap: anywhere !important;
  scrollbar-color: rgba(189, 168, 255, .22) transparent !important;
  scrollbar-width: thin !important;
}

#app#app[data-active-view="workbench"][data-creation-entry="fast"] .first-frame-output-switch {
  border-color: rgba(35, 129, 111, .3) !important;
  background: rgba(35, 129, 111, .08) !important;
  color: rgba(241, 255, 251, .74) !important;
}

#app#app[data-active-view="workbench"][data-creation-entry="fast"] .first-frame-output-switch.is-on,
#app#app[data-active-view="workbench"][data-creation-entry="fast"] .first-frame-output-switch[aria-checked="true"] {
  border-color: rgba(94, 205, 179, .46) !important;
  background: rgba(35, 129, 111, .17) !important;
  color: #ecfff9 !important;
}

/* One unambiguous keyboard-focus language across existing workbench controls. */
#app#app[data-active-view="workbench"][data-creation-entry="fast"] button:focus-visible,
#app#app[data-active-view="workbench"][data-creation-entry="fast"] [role="button"]:focus-visible,
#app#app[data-active-view="workbench"][data-creation-entry="fast"] input:focus-visible,
#app#app[data-active-view="workbench"][data-creation-entry="fast"] textarea:focus-visible {
  outline: 2px solid rgba(189, 168, 255, .72) !important;
  outline-offset: 2px !important;
}

/* Medium-width containment. No controls are removed; rows wrap in place. */
@media (max-width: 1100px) {
  #app#app[data-active-view] .topbar {
    background:
      linear-gradient(180deg, rgba(25, 23, 32, .72), rgba(8, 8, 11, .62)) !important;
  }

  #app#app[data-active-view="workbench"][data-creation-entry="fast"] .composer-bottom-left {
    row-gap: 12px !important;
  }

  #app#app[data-active-view="workbench"][data-creation-entry="fast"] .prompt-head {
    align-items: flex-start !important;
    gap: 10px !important;
    flex-wrap: wrap !important;
    padding-block: 12px !important;
  }

  #app#app[data-active-view="workbench"][data-creation-entry="fast"] .prompt-toolbar {
    max-width: 100% !important;
  }
}

/* Phone layout: retain every existing control and allow deliberate wrapping
   rather than horizontal scrolling or clipped action rows. */
@media (max-width: 720px) {
  html,
  body {
    overflow-x: hidden !important;
  }

  #app#app[data-active-view] .topbar {
    -webkit-backdrop-filter: blur(18px) saturate(116%) !important;
    backdrop-filter: blur(18px) saturate(116%) !important;
  }

  #app#app[data-active-view="workbench"][data-creation-entry="fast"] .reference-preview.reference-slot-grid .reference-slot,
  #app#app[data-active-view="workbench"][data-creation-entry="fast"] .reference-preview.reference-slot-grid .reference-thumb,
  #app#app[data-active-view="workbench"][data-creation-entry="fast"] .reference-preview.reference-slot-grid .reference-upload-placeholder {
    min-height: 68px !important;
  }

  #app#app[data-active-view="workbench"][data-creation-entry="fast"] .composer-more-control,
  #app#app[data-active-view="workbench"][data-creation-entry="fast"] .composer-styles-trigger,
  #app#app[data-active-view="workbench"][data-creation-entry="fast"] .first-frame-toggle-compact {
    flex: 1 1 calc(50% - 6px) !important;
    min-width: 132px !important;
  }

  #app#app[data-active-view="workbench"][data-creation-entry="fast"] .composer-bottom-right {
    display: grid !important;
    grid-template-columns: minmax(0, .72fr) minmax(0, 1.28fr) !important;
  }

  #app#app[data-active-view="workbench"][data-creation-entry="fast"] #reset-demo-btn,
  #app#app[data-active-view="workbench"][data-creation-entry="fast"] #run-demo-btn {
    width: 100% !important;
    min-width: 0 !important;
  }

  #app#app[data-active-view="workbench"][data-creation-entry="fast"] .result-head-actions {
    min-width: 0 !important;
  }

  #app#app[data-active-view="workbench"][data-creation-entry="fast"] .prompt-toolbar {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    width: 100% !important;
  }

  #app#app[data-active-view="workbench"][data-creation-entry="fast"] .prompt-toolbar .small {
    width: 100% !important;
    min-width: 0 !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }

  #app#app[data-active-view="workbench"][data-creation-entry="fast"] .first-frame-output-switch {
    grid-column: 1 / -1 !important;
    width: 100% !important;
  }
}

@media (max-width: 420px) {
  #app#app[data-active-view="workbench"][data-creation-entry="fast"] .composer-more-control,
  #app#app[data-active-view="workbench"][data-creation-entry="fast"] .composer-styles-trigger,
  #app#app[data-active-view="workbench"][data-creation-entry="fast"] .first-frame-toggle-compact {
    flex-basis: 100% !important;
    width: 100% !important;
  }

  #app#app[data-active-view="workbench"][data-creation-entry="fast"] .prompt-toolbar {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  #app#app[data-active-view="workbench"][data-creation-entry="fast"] .first-frame-output-switch {
    grid-column: auto !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  #app#app[data-active-view] *,
  #app#app[data-active-view] *::before,
  #app#app[data-active-view] *::after {
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
  }
}

/* Mobile overlay containment overrides are intentionally last because the
   legacy release stylesheet contains later drawer geometry. Reuse the
   existing Back control; do not create a new close action. */
@media (max-width: 720px) {
  #app#app[data-active-view="workbench"][data-creation-entry="fast"] .composer-more-control.is-open .composer-more-trigger {
    position: relative !important;
    z-index: 82 !important;
  }

  #app#app[data-active-view="workbench"][data-creation-entry="fast"] .composer-style-tray.open {
    position: fixed !important;
    inset: 76px 12px 12px !important;
    width: auto !important;
    min-width: 0 !important;
    min-height: 0 !important;
    max-height: none !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
    border-radius: 20px !important;
    transform: none !important;
    z-index: 90 !important;
  }

  #app#app[data-active-view="workbench"][data-creation-entry="fast"] .composer-style-tray.open .style-tray-collapse {
    position: sticky !important;
    top: 0 !important;
    left: 0 !important;
    z-index: 5 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 100% !important;
    min-height: 42px !important;
    padding: 8px 14px !important;
    border: 0 !important;
    border-bottom: 1px solid rgba(255, 255, 255, .1) !important;
    border-radius: 0 !important;
    background: rgba(16, 14, 21, .96) !important;
    color: rgba(247, 245, 251, .8) !important;
    writing-mode: horizontal-tb !important;
    text-orientation: mixed !important;
    transform: none !important;
    box-shadow: none !important;
  }

  #app#app[data-active-view="workbench"][data-creation-entry="fast"] .composer-style-tray.open .chip-wrap {
    max-height: calc(100dvh - 130px) !important;
    padding: 16px !important;
    overflow: auto !important;
  }
}

@media (max-width: 720px) {
  #app#app[data-active-view="workbench"][data-creation-entry="fast"] .composer-card.composer-studio .composer-style-tray.open {
    position: fixed !important;
    inset: 76px 12px 12px !important;
    width: auto !important;
    min-width: 0 !important;
    min-height: 0 !important;
    max-width: none !important;
    max-height: none !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
    border-radius: 20px !important;
    transform: none !important;
  }

  #app#app[data-active-view="workbench"][data-creation-entry="fast"] .composer-card.composer-studio .composer-style-tray.open .style-tray-collapse {
    transform: none !important;
  }
}

/* A fixed mobile tray must escape every frosted ancestor. backdrop-filter
   establishes a containing block for fixed descendants, so suspend it only
   while the existing style tray is open; the tray keeps its own glass. */
@media (max-width: 720px) {
  #app#app[data-active-view="workbench"][data-creation-entry="fast"] .setup-panel:has(.composer-style-tray.open),
  #app#app[data-active-view="workbench"][data-creation-entry="fast"] .composer-card.composer-studio:has(.composer-style-tray.open) {
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
  }

  #app#app[data-active-view="workbench"][data-creation-entry="fast"] .composer-card.composer-studio .composer-style-tray.open {
    transition: none !important;
    animation: none !important;
  }
}
