/* Shared input surface for Fort conversations and creative prompts.
   Studio is the reference. Keep behavior and page-specific tools with their
   owners; new composers can opt in with .fortune-composer and the part classes. */
:root {
  --fortune-composer-radius: 22px;
  --fortune-composer-padding: 12px;
  --fortune-composer-input-size: 15px;
  --fortune-composer-input-min: 104px;
  --fortune-composer-send-size: 38px;
}

@layer fortune-design {
  html body :is(.fortune-composer, #chat-form, #script-form, #studio-form, #academy-chat-form, .ad-chat-composer, .ff-composer, .image-main-composer, .vs-composer, .director-fort-panel-form) {
    box-sizing: border-box !important;
    min-width: 0 !important;
    max-width: 100% !important;
    padding: var(--fortune-composer-padding) !important;
    border: 1px solid var(--fortune-surface-line, #d9d8d2) !important;
    border-radius: var(--fortune-composer-radius) !important;
    background: var(--fortune-composer-surface, var(--fortune-surface-panel, #fff)) !important;
    color: var(--fortune-surface-text, #1a1a1e) !important;
    box-shadow: 0 4px 20px #00000003 !important;
    backdrop-filter: none !important;
    transition: border-color 160ms ease, box-shadow 160ms ease;
  }

  html body :is(.fortune-composer, #chat-form, #script-form, #studio-form, #academy-chat-form, .ad-chat-composer, .ff-composer, .image-main-composer, .vs-composer, .director-fort-panel-form):focus-within {
    border-color: transparent !important;
    box-shadow: none !important;
  }

  html body :is(.fortune-composer, #chat-form, #script-form, #studio-form, #academy-chat-form, .ad-chat-composer, .ff-composer, .image-main-composer, .vs-composer, .director-fort-panel-form) textarea {
    box-sizing: border-box !important;
    display: block;
    width: 100% !important;
    min-width: 0 !important;
    min-height: var(--fortune-composer-input-min) !important;
    max-height: 220px !important;
    padding: 8px 10px 14px !important;
    border: 0 !important;
    border-radius: 0 !important;
    outline: 0 !important;
    background: transparent !important;
    color: var(--fortune-surface-text, #1a1a1e) !important;
    box-shadow: none !important;
    font: var(--fortune-composer-input-size)/1.6 var(--fortune-font-ui, Inter, Arial, sans-serif) !important;
    resize: none !important;
  }

  html body :is(.fortune-composer, #chat-form, #script-form, #studio-form, #academy-chat-form, .ad-chat-composer, .ff-composer, .image-main-composer, .vs-composer, .director-fort-panel-form) textarea::placeholder {
    color: var(--fortune-surface-muted, #707078) !important;
    opacity: 1;
  }

  html body :is(.fortune-composer-toolbar, .composer-toolbar, .script-composer-toolbar, .studio-composer-bottom, .academy-composer-bottom, .ad-chat-composer-footer, .ff-composer-tools, .studio-composer-actions, .vs-composer-toolbar, .director-fort-panel-form-controls) {
    box-sizing: border-box;
    display: flex;
    align-items: center;
    gap: 8px !important;
    min-width: 0;
    margin-top: 0 !important;
    padding: 0 !important;
  }

  html body :is(.fortune-composer-send, #chat-send, #chat-stop, #generate-script, #studio-generate, #academy-chat-send, .ad-chat-send, .ff-send, #generate-image, #generate-video, .director-fort-panel-send) {
    box-sizing: border-box !important;
    align-items: center !important;
    justify-content: center !important;
    width: var(--fortune-composer-send-size) !important;
    height: var(--fortune-composer-send-size) !important;
    min-width: var(--fortune-composer-send-size) !important;
    min-height: var(--fortune-composer-send-size) !important;
    flex: 0 0 var(--fortune-composer-send-size) !important;
    margin-left: auto;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 50% !important;
    background: var(--fortune-surface-text, #1a1a1e) !important;
    color: var(--fortune-surface-panel, #fff) !important;
    box-shadow: none !important;
    font-size: 21px !important;
    line-height: 1 !important;
    cursor: pointer;
  }

  html body :is(.fortune-composer-send, #chat-send, #chat-stop, #generate-script, #studio-generate, #academy-chat-send, .ad-chat-send, .ff-send, #generate-image, #generate-video, .director-fort-panel-send):not([hidden]) {
    display: grid !important;
  }

  html body :is(.fortune-composer-send, #chat-send, #chat-stop, #generate-script, #studio-generate, #academy-chat-send, .ad-chat-send, .ff-send, #generate-image, #generate-video, .director-fort-panel-send):disabled {
    opacity: .28 !important;
    cursor: default;
  }

  html body :is(.fortune-composer-send, #chat-send, #chat-stop, #generate-script, #studio-generate, #academy-chat-send, .ad-chat-send, .ff-send, #generate-image, #generate-video, .director-fort-panel-send) svg {
    width: 20px !important;
    height: 20px !important;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  html body :is(.fortune-composer-tool, .chat-add-context, #composer-brief, #studio-attach, .image-attach, .vs-attach) {
    box-sizing: border-box !important;
    display: grid;
    place-items: center;
    flex: 0 0 36px !important;
    width: 36px !important;
    height: 36px !important;
    min-height: 36px !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 50% !important;
    background: transparent !important;
    color: var(--fortune-surface-text, #1a1a1e) !important;
    box-shadow: none !important;
  }

  html body :is(.fortune-composer-tool, .chat-add-context, #composer-brief, #studio-attach, .image-attach, .vs-attach):hover {
    background: var(--fortune-surface-hover, #ebe9e0) !important;
  }

  html body :is(.fortune-composer-tool, .chat-add-context, #composer-brief, #studio-attach, .image-attach, .vs-attach) svg {
    width: 22px !important;
    height: 22px !important;
  }

  html body :is(.fortune-composer-caption, .composer-label, .academy-composer-bottom > span, .ad-chat-composer-footer > span, .ff-composer-tools > span, .director-fort-panel-form-controls > span) {
    color: var(--fortune-surface-muted, #707078) !important;
    font-size: 11px !important;
    line-height: 1.5;
  }

  /* Side panels keep the same shape with a shorter starting input. */
  html body :is(#script-form, #academy-chat-form, .ad-chat-composer, .ff-composer, .director-fort-panel-form, .founder-workspace #chat-form) {
    --fortune-composer-input-min: 72px;
  }

  html body #script-form {
    display: block !important;
  }

  html body .director-fort-panel-form {
    margin: 0 12px 12px !important;
  }

  html body .director-fort-panel-send[aria-busy=true] svg {
    animation: fortune-composer-working 1.2s ease-in-out infinite;
  }

  /* Home retains every context control, joined to one continuous surface. */
  html body.app-hub.chat-home .chat-composer-area {
    width: 100% !important;
    max-width: 780px !important;
    min-width: 0;
    margin-inline: auto !important;
  }

  html body.app-hub.chat-home .home-composer-stack {
    box-sizing: border-box;
    padding: var(--fortune-composer-padding) !important;
    border: 0 !important;
    border-radius: var(--fortune-composer-radius) !important;
    background: var(--fortune-composer-surface, var(--fortune-surface-panel, #fff)) !important;
    box-shadow: none !important;
    transition: border-color 160ms ease, box-shadow 160ms ease;
  }

  html body.app-hub.chat-home .home-composer-stack:focus-within {
    border-color: transparent !important;
    box-shadow: none !important;
  }

  html body.app-hub.chat-home .home-composer-stack #chat-form {
    display: block !important;
    border: 0 !important;
    border-radius: 0 !important;
    padding: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
  }

  html body.app-hub.chat-home .composer-toolbar {
    display: flex !important;
    align-items: center;
  }

  html body.app-hub.chat-home .home-composer-controls {
    display: flex !important;
    align-items: center;
    margin-left: auto;
  }

  html[data-fortune-theme] body.app-hub.chat-home .home-composer-stack > .home-context-bar {
    flex-wrap: wrap !important;
    gap: 4px !important;
    margin: 10px 0 0 !important;
    padding: 8px 0 0 !important;
    border: 0 !important;
    border-top: 0 !important;
    border-radius: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
  }

  html body.app-hub.chat-home .home-composer-controls {--fortune-composer-send-size:32px}
  html body.app-hub.chat-home :is(#chat-send,#chat-stop) {position:relative;transition:transform .3s cubic-bezier(.2,1.8,.4,1),opacity .2s;border-radius:50%!important}
  html body.app-hub.chat-home :is(#chat-send,#chat-stop)::after {content:'';position:absolute;inset:-5px;border-radius:50%}
  html body.app-hub.chat-home :is(#chat-send,#chat-stop) svg {width:18px!important;height:18px!important}
  html body.app-hub.chat-home :is(#chat-send,#chat-stop):not(:disabled):hover {transform:translateY(-1px) scale(1.06)}
  html body.app-hub.chat-home :is(#chat-send,#chat-stop):not(:disabled):active {transform:scale(1.12,.88)}
  @media(prefers-reduced-motion:reduce){html body.app-hub.chat-home :is(#chat-send,#chat-stop){transition:none!important;transform:none!important}}

  html body.app-hub.chat-home .home-context-bar button,
  html body.app-hub.chat-home .home-store-menu summary {
    min-height: 34px !important;
    padding: 6px 9px !important;
    border-radius: 999px !important;
    font-size: 12px !important;
    line-height: 1.4;
  }

  html body.app-hub.chat-home .home-context-bar svg {
    width: 16px !important;
    height: 16px !important;
  }

  html body.app-hub.chat-home .home-context-bar .home-store-menu {
    margin-left: auto !important;
  }

  html body.app-hub.chat-home .home-context-bar .home-store-popover {
    border-radius: 16px;
  }

  html body.app-hub.chat-home .home-context-bar .home-store-popover button {
    justify-content: flex-start;
    border-radius: 8px;
  }

  /* Keep the editable surface pure white in light mode, independently of
     surrounding panel/inset colors. Dark mode retains its existing palette. */
  html[data-fortune-theme="light"] {
    --fortune-composer-surface: #fff;
  }

  html[data-fortune-theme="light"] body :is(.fortune-composer, #chat-form, #script-form, #studio-form, #academy-chat-form, .ad-chat-composer, .ff-composer, .image-main-composer, .vs-composer, .director-fort-panel-form, .voice-editor-surface, .home-composer-stack) {
    background: var(--fortune-composer-surface) !important;
  }

  @media (max-width: 760px) {
    html body {
      --fortune-composer-padding: 10px;
      --fortune-composer-radius: 20px;
      --fortune-composer-input-size: 16px;
      --fortune-composer-send-size: 36px;
    }
    html body.app-hub.chat-home .home-context-bar { gap: 2px !important; }
    html body.app-hub.chat-home .home-context-bar button,
    html body.app-hub.chat-home .home-store-menu summary {
      gap: 5px !important;
      padding: 6px 7px !important;
      font-size: 11px !important;
    }
    html body :is(.fortune-composer-tool, .chat-add-context, #composer-brief, #studio-attach, .image-attach, .vs-attach) {
      width: 34px !important;
      height: 34px !important;
      min-height: 34px !important;
      flex-basis: 34px !important;
    }
  }

  @media (prefers-reduced-motion: reduce) {
    html body :is(.fortune-composer, #chat-form, #script-form, #studio-form, #academy-chat-form, .ad-chat-composer, .ff-composer, .image-main-composer, .vs-composer, .director-fort-panel-form, .home-composer-stack) {
      transition: none;
    }
    html body .director-fort-panel-send[aria-busy=true] svg { animation: none; }
  }
}

@keyframes fortune-composer-working { 50% { opacity: .4; } }
