/* Final control layer: overrides only the conflicting late desktop/mobile patches. */

/* Authentication links must keep a reliable interactive contrast. */
.auth-forgot,
.auth-forgot:visited,
.auth-forgot:hover,
.auth-forgot:focus-visible,
.auth-forgot:active,
.auth-forgot-back,
.auth-forgot-back:visited,
.auth-forgot-back:hover,
.auth-forgot-back:focus-visible,
.auth-forgot-back:active {
  color: #065dfd !important;
  background: transparent !important;
  border-color: transparent !important;
  box-shadow: none !important;
  text-decoration-color: currentColor !important;
}

.auth-forgot:hover,
.auth-forgot:focus-visible,
.auth-forgot-back:hover,
.auth-forgot-back:focus-visible {
  color: #004edc !important;
}

/* A single bounded menu contract for every enhanced select. */
.custom-select {
  min-width: 0;
}

.custom-select-menu {
  max-height: var(--picker-max-height, 304px) !important;
  overflow: hidden !important;
  z-index: 10050 !important;
}

.custom-select-options {
  max-height: var(--picker-max-height, 304px) !important;
  overflow-y: auto !important;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}

.custom-select.opens-upward .custom-select-menu {
  top: auto !important;
  bottom: calc(100% + 8px) !important;
}

/* Token packs have stable content hierarchy; text never drives their geometry. */
.modal-scroll-card:has(#plansList) {
  overscroll-behavior: contain;
  scroll-padding-bottom: 44px;
}

.modal-plans {
  padding-bottom: 32px !important;
}

.plan-card {
  display: grid !important;
  grid-template-rows: auto auto auto 1fr auto;
  gap: 12px;
  min-height: 340px;
}

.plan-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.plan-tier-icon {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 50%;
  color: #065dfd;
  background: #e4edff;
  font-size: 22px;
}

.plan-token-amount {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.plan-token-amount strong {
  color: #101114;
  font-size: 42px;
  line-height: .95;
}

.plan-token-amount span,
.plan-benefits span {
  color: #747780;
  font-size: 14px;
  font-weight: 700;
}

.plan-price {
  margin: 0;
  color: #101114;
  font-size: 24px;
  font-weight: 750;
}

.plan-benefits {
  display: grid;
  align-content: end;
  gap: 7px;
  min-height: 54px;
}

.plan-benefits strong {
  color: #101114;
  font-size: 15px;
}

.plan-card .card-foot {
  margin-top: 4px;
}

/* Video is a separate composition, but it stays inside the existing workbench. */
.video-scenario-source,
.video-materials {
  display: none !important;
}

.video-upload-split {
  display: none;
}

.generator-studio.is-video-mode .upload-stage {
  display: grid;
  min-height: 0;
  padding: 12px;
  align-content: stretch;
}

.generator-studio.is-video-mode .upload-stage > .upload-icon,
.generator-studio.is-video-mode .upload-stage > .upload-copy,
.generator-studio.is-video-mode .upload-stage > .upload-action,
.generator-studio.is-video-mode .upload-stage > .upload-previews,
.generator-studio.is-video-mode .upload-stage > input[name="photos"] {
  display: none !important;
}

.generator-studio.is-video-mode .video-upload-split {
  display: grid;
  width: 100%;
  min-height: 100%;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.video-upload-cell {
  position: relative;
  display: grid;
  min-width: 0;
  min-height: 132px;
  grid-template-columns: 34px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  overflow: hidden;
  padding: 18px;
  border: 1px solid rgba(6, 93, 253, .16);
  border-radius: 20px;
  background: rgba(255, 255, 255, .72);
  color: #101114;
  cursor: pointer;
  isolation: isolate;
  transition: border-color .2s ease, background .2s ease, box-shadow .2s ease, transform .2s ease;
}

.video-upload-cell > :not(.video-material-preview) {
  position: relative;
  z-index: 1;
}

.video-upload-cell strong,
.video-upload-cell small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.video-upload-cell strong {
  font-size: 16px;
}

.video-upload-cell small {
  margin-top: 4px;
  color: #767984;
  font-size: 13px;
}

.video-upload-cell:hover,
.video-upload-cell:focus-within {
  border-color: #065dfd;
  background: #e6efff;
  box-shadow: 0 12px 24px rgba(6, 93, 253, .13);
  transform: translateY(-1px);
}

.video-upload-cell.has-files {
  border-color: #065dfd;
  color: white;
  background: #065dfd;
}

.video-upload-cell.has-files small {
  color: rgba(255, 255, 255, .8);
}

.video-upload-cell.is-required-missing {
  border-style: dashed;
}

.video-material-preview {
  position: absolute;
  z-index: -1;
  inset: 0;
  display: none;
  background: center / cover no-repeat;
}

.video-upload-cell.has-files .video-material-preview {
  display: block;
  opacity: .36;
}

.video-upload-cell.has-files::after {
  position: absolute;
  z-index: -1;
  inset: 0;
  content: "";
  background: rgba(6, 93, 253, .66);
}

.video-workbench {
  position: relative;
  z-index: 30;
  min-width: 0;
  overflow: visible !important;
}

.video-workbench-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
}

.video-workbench .custom-select {
  width: 100%;
}

.video-workbench .custom-select-menu {
  right: 0 !important;
  left: 0 !important;
  min-width: 100% !important;
}

.video-reference-control {
  display: inline-flex;
  min-width: 0;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid rgba(6, 93, 253, .16);
  border-radius: 14px;
  color: #5c6170;
  cursor: pointer;
  transition: background .2s ease, color .2s ease, border-color .2s ease;
}

.video-reference-control:hover,
.video-reference-control.has-frame-context {
  border-color: #065dfd;
  background: #e6efff;
  color: #065dfd;
}

.video-reference-control span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* `hidden` must always win over the decorative overlay rule. */
.ai-copy-action[hidden],
.m-ai-copy-action[hidden] {
  display: none !important;
}

/*
  The desktop shell owns a fixed work row.  Video uses that exact row too:
  title, brief, controls and CTA are deliberately compacted into it instead
  of expanding the studio over the scenario rail below.
*/
@media (min-width: 1061px) {
  .generator-studio.is-video-mode {
    grid-template-rows: minmax(0, 1fr) !important;
    min-height: 0 !important;
    height: var(--desktop-work-row) !important;
  }

  .generator-studio.is-video-mode > * {
    min-height: 0;
  }

  .generator-studio.is-video-mode .brief-panel {
    height: 100%;
    min-height: 0;
    grid-template-rows: 72px 108px minmax(0, 1fr) 48px !important;
    align-content: stretch;
    gap: 8px;
    padding: 8px;
  }

  .generator-studio.is-video-mode .brief-panel > .tool-rack {
    display: none !important;
  }

  .generator-studio.is-video-mode .brief-field {
    min-height: 0;
    overflow: hidden;
    gap: 4px;
    padding: 10px 12px;
  }

  .generator-studio.is-video-mode .brief-field > span {
    font-size: 10px;
  }

  .generator-studio.is-video-mode .brief-title input {
    min-height: 30px;
    font-size: 18px;
  }

  .generator-studio.is-video-mode .brief-description textarea {
    min-height: 68px;
    height: 68px;
    resize: none;
    font-size: 14px;
    line-height: 1.38;
  }

  .generator-studio.is-video-mode .video-workbench {
    min-height: 0;
    height: 100%;
    grid-template-columns: max-content minmax(0, 1fr);
    align-content: center;
    gap: 7px 10px;
    padding: 10px 12px;
    border-radius: 20px;
  }

  .generator-studio.is-video-mode .video-workbench-heading,
  .generator-studio.is-video-mode .video-workbench-grid {
    grid-column: 1 / -1;
  }

  .generator-studio.is-video-mode .video-workbench-heading {
    min-height: 18px;
    font-size: 13px;
  }

  .generator-studio.is-video-mode .video-workbench-heading small {
    font-size: 11px;
  }

  .generator-studio.is-video-mode .video-workbench-grid {
    gap: 7px;
  }

  .generator-studio.is-video-mode .video-workbench-grid label {
    gap: 3px;
    font-size: 10px;
  }

  .generator-studio.is-video-mode .video-workbench .custom-select-trigger {
    min-height: 40px;
    padding: 0 9px 0 10px;
    gap: 7px;
    border-radius: 13px;
    font-size: 12px;
  }

  .generator-studio.is-video-mode .video-workbench .custom-select-arrow {
    width: 23px;
    height: 23px;
    font-size: 17px;
  }

  .generator-studio.is-video-mode .video-workbench .custom-select-value .sr-only {
    position: static;
    width: auto;
    height: auto;
    overflow: visible;
    clip: auto;
    white-space: nowrap;
  }

  .generator-studio.is-video-mode .video-upload-split {
    gap: 10px;
  }

  .generator-studio.is-video-mode .video-upload-cell {
    grid-template-columns: 28px minmax(0, 1fr);
    gap: 9px;
    padding: 14px;
  }

  .generator-studio.is-video-mode .video-upload-cell strong {
    font-size: 13px;
  }

  .generator-studio.is-video-mode .video-upload-cell small {
    margin-top: 3px;
    font-size: 11px;
  }

  .generator-studio.is-video-mode .video-sound-toggle,
  .generator-studio.is-video-mode .video-reference-control {
    min-height: 32px;
    padding: 7px 9px;
    border-radius: 11px;
    font-size: 11px;
  }

  .generator-studio.is-video-mode .video-reference-control strong,
  .generator-studio.is-video-mode .video-reference-control small {
    display: block;
    font-size: 10px;
  }

  .generator-studio.is-video-mode .video-reference-control small {
    margin-top: 1px;
  }

  .generator-studio.is-video-mode .generator-footer {
    min-height: 48px;
    padding-top: 0;
  }

  .generator-studio.is-video-mode .generator-footer .generate-button {
    min-height: 42px;
  }
}

/* The document dialog reads as a document, not as a single dense canvas. */
.legal-modal-card {
  grid-template-rows: minmax(0, 1fr);
  height: min(760px, calc(100dvh - 48px));
  overflow: hidden !important;
}

.legal-document-nav,
.legal-document-body {
  min-height: 0;
}

.legal-document-nav {
  overflow-y: auto;
  overscroll-behavior: contain;
}

.legal-document-tabs {
  display: grid;
  min-width: 0;
  align-content: start;
  gap: 6px;
}

.legal-document-body {
  height: 100%;
  max-height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
}

.legal-document-content {
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: #b7c8ec transparent;
}

.legal-document-content > :first-child {
  margin-top: 4px;
}

.legal-document-content h3,
.legal-document-content h4 {
  color: #101114;
  line-height: 1.16;
}

.legal-document-content h3 {
  margin: 38px 0 14px;
  font-size: clamp(22px, 2vw, 30px);
}

.legal-document-content h4 {
  margin: 26px 0 10px;
  font-size: 18px;
}

.legal-document-content p,
.legal-document-content li {
  max-width: 76ch;
  line-height: 1.62;
}

.legal-document-section-nav {
  display: grid;
  gap: 5px;
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid rgba(21, 25, 35, .09);
}

.legal-document-section-nav button {
  overflow: hidden;
  padding: 7px 9px;
  border: 0;
  border-radius: 9px;
  color: #767984;
  background: transparent;
  font: inherit;
  font-size: 12px;
  line-height: 1.25;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}

.legal-document-section-nav button:hover,
.legal-document-section-nav button.is-active {
  color: #065dfd;
  background: #e6efff;
}

@media (max-width: 760px) {
  .legal-modal-card {
    grid-template-rows: auto minmax(0, 1fr);
    height: min(88dvh, 760px);
  }

  .legal-document-nav {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
    overflow: visible;
    padding: 2px 0 0;
  }

  .legal-document-tabs {
    display: flex;
    width: 100%;
    max-width: 100%;
    gap: 8px;
    overflow-x: auto;
    padding: 0 42px 2px 0;
    scrollbar-width: none;
  }

  .legal-document-tabs::-webkit-scrollbar {
    display: none;
  }

  .legal-document-tabs .legal-document-nav-item {
    flex: 0 0 auto;
  }

  .plan-card {
    min-height: 0;
  }

  .m-plan {
    display: grid !important;
    grid-template-columns: 1fr auto;
    gap: 8px 14px;
    align-items: start;
  }

  .m-plan-tier {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: #065dfd;
    font-size: 12px;
    font-weight: 800;
  }

  .m-plan-tier .material-symbols-outlined {
    font-size: 18px;
  }

  .m-plan-token-amount {
    margin-top: 4px;
    color: #101114;
    font-size: 31px;
    font-weight: 850;
    line-height: 1;
  }

  .m-plan-price {
    align-self: end;
    color: #101114;
    font-size: 18px;
    font-weight: 800;
    white-space: nowrap;
  }

  .m-plan-benefit {
    grid-column: 1 / -1;
    display: flex;
    justify-content: space-between;
    gap: 8px;
    color: #727680;
    font-size: 12px;
  }

  .m-plan > button {
    grid-column: 1 / -1;
  }

  body.is-video-mode #mobileUploadButton {
    display: grid;
    min-height: 130px;
    grid-template-columns: 1fr;
    padding: 10px;
  }

  body.is-video-mode #mobileUploadButton > .m-upload-icon,
  body.is-video-mode #mobileUploadButton > .m-tile-arrow,
  body.is-video-mode #mobileUploadButton > .m-upload-copy,
  body.is-video-mode #mobileUploadButton > .m-upload-action,
  body.is-video-mode #mobileUploadButton > .m-upload-preview,
  body.is-video-mode #mobileUploadButton > span:not(.m-video-upload-split):not(.m-upload-icon):not(.m-tile-arrow) {
    display: none !important;
  }

  .m-video-upload-split {
    display: none;
  }

  body.is-video-mode .m-video-upload-split {
    display: grid;
    width: 100%;
    min-height: 108px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px;
  }

  .m-video-upload-cell {
    position: relative;
    display: grid;
    min-width: 0;
    grid-template-columns: 22px minmax(0, 1fr);
    align-items: center;
    gap: 7px;
    padding: 10px;
    overflow: hidden;
    border: 1px solid rgba(6, 93, 253, .18);
    border-radius: 16px;
    background: rgba(255, 255, 255, .85);
    color: #1a1b20;
    isolation: isolate;
  }

  .m-video-upload-cell > :not(.video-material-preview) { position: relative; z-index: 1; }

  .m-video-upload-cell.has-files .video-material-preview {
    display: block;
    z-index: -1;
    opacity: .32;
  }

  .m-video-upload-cell.has-files::after {
    position: absolute;
    z-index: -1;
    inset: 0;
    content: "";
    background: rgba(6, 93, 253, .68);
  }

  .m-video-upload-cell strong,
  .m-video-upload-cell small {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .m-video-upload-cell strong { font-size: 13px; }
  .m-video-upload-cell small { margin-top: 3px; color: #7d8190; font-size: 11px; }

  .m-video-upload-cell.has-files {
    border-color: #065dfd;
    color: white;
    background: #065dfd;
  }

  .m-video-upload-cell.has-files small { color: rgba(255,255,255,.82); }

  .m-video-workbench {
    overflow: visible !important;
  }

  .m-video-workbench .custom-select-menu {
    z-index: 10060 !important;
  }

  .legal-document-body {
    padding-bottom: 24px;
  }

  .legal-document-content h3 {
    margin-top: 28px;
    font-size: 22px;
  }

  .legal-document-section-nav {
    display: flex;
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    margin-top: 0;
    padding-top: 0;
    border-top: 0;
    scrollbar-width: none;
  }

  .legal-document-section-nav::-webkit-scrollbar { display: none; }

  .legal-document-section-nav button { flex: 0 0 auto; max-width: 210px; }
}

@media (min-width: 761px) and (max-width: 1160px) {
  .video-workbench-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  .video-upload-cell,
  .custom-select-menu,
  .legal-document-content {
    scroll-behavior: auto;
    transition: none !important;
  }
}
