/* Image generation final overrides. Loaded after the legacy stylesheet. */
body[data-current-view="image"] .image-generation-layout {
  grid-template-columns: minmax(560px, 620px) minmax(600px, 1fr) !important;
  gap: 18px;
  align-items: start;
}

body[data-current-view="image"] #app {
  grid-template-columns: 276px minmax(0, 1fr);
}

body[data-current-view="image"] .sidebar {
  padding: 22px;
  gap: 24px;
}

body[data-current-view="image"] .brand {
  min-height: 84px;
  justify-content: center;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, rgba(32, 214, 199, 0.09), rgba(125, 124, 255, 0.08)),
    rgba(255, 255, 255, 0.025);
  box-shadow: var(--inner-glow);
}

body[data-current-view="image"] .brand-logo,
body[data-current-view="image"] .sidebar-logo {
  content: url("/assets/juaiju-logo-card.png");
  width: 100%;
  height: auto;
  max-height: 78px;
  padding: 3px;
  border-radius: var(--radius);
  background: #ffffff;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.82),
    0 0 26px rgba(32, 214, 199, 0.28),
    0 0 46px rgba(125, 124, 255, 0.18);
}

body[data-current-view="image"] .nav {
  gap: 10px;
}

body[data-current-view="image"] .nav-item {
  min-height: 44px;
  padding: 11px 12px;
  border-radius: var(--radius);
  font-size: 16px;
}

body[data-current-view="image"] .nav-item::before {
  width: 20px;
  height: 20px;
  flex-basis: 20px;
}

body[data-current-view="builder"] .nav-item.active,
body[data-current-view="storyboard"] .nav-item.active,
body[data-current-view="voice"] .nav-item.active,
body[data-current-view="video"] .nav-item.active {
  border-color: rgba(73, 142, 255, 0.74);
  background:
    linear-gradient(92deg, rgba(28, 159, 255, 0.86), rgba(101, 91, 255, 0.72), rgba(142, 63, 255, 0.78));
  color: #ffffff;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.14),
    0 0 24px rgba(71, 112, 255, 0.28);
}

body[data-current-view="builder"] .nav-item.active::before,
body[data-current-view="builder"] .nav-item.active::after,
body[data-current-view="storyboard"] .nav-item.active::before,
body[data-current-view="storyboard"] .nav-item.active::after,
body[data-current-view="voice"] .nav-item.active::before,
body[data-current-view="voice"] .nav-item.active::after,
body[data-current-view="video"] .nav-item.active::before,
body[data-current-view="video"] .nav-item.active::after {
  background: #ffffff;
}

body[data-current-view="image"] .image-generation-panel,
body[data-current-view="image"] .image-results-panel {
  min-width: 0;
}

body[data-current-view="image"] .image-results-panel {
  min-height: 0;
}

body[data-current-view="image"] .image-prompt-field textarea {
  width: 100%;
  height: 208px;
  min-height: 208px;
  max-height: 320px;
  resize: vertical;
}

body[data-current-view="image"] .asset-type-choice {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  line-height: 1;
}

body[data-current-view="image"] .asset-type-icon,
body[data-current-view="image"] .image-asset-icon {
  display: inline-grid;
  place-items: center;
  color: #dbe7ff;
}

body[data-current-view="image"] .asset-type-icon svg {
  width: 17px;
  height: 17px;
}

body[data-current-view="image"] .asset-type-choice.selected .asset-type-icon {
  color: #ffffff;
}

body[data-current-view="image"] .image-asset-icon {
  width: 46px;
  height: 46px;
  border-radius: 9px;
  background:
    radial-gradient(circle at 45% 24%, rgba(122, 249, 238, 0.38), transparent 44%),
    linear-gradient(135deg, rgba(46, 120, 255, 0.94), rgba(125, 73, 255, 0.92));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12), 0 10px 24px rgba(36, 103, 255, 0.18);
}

body[data-current-view="image"] .image-asset-icon.scene {
  background: linear-gradient(135deg, rgba(40, 198, 255, 0.92), rgba(50, 108, 255, 0.92));
}

body[data-current-view="image"] .image-asset-icon.prop {
  background: linear-gradient(135deg, rgba(84, 227, 154, 0.92), rgba(255, 181, 71, 0.9));
}

body[data-current-view="image"] .image-asset-icon svg {
  width: 24px;
  height: 24px;
}

body[data-current-view="image"] .image-provider-info-trigger {
  align-self: center;
  white-space: nowrap;
}

body[data-current-view="image"] .image-results-panel > .image-provider-info-box {
  width: 100%;
  min-height: 46px;
  display: grid !important;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 2px;
  border: 1px solid rgba(76, 109, 176, 0.54);
  border-radius: 8px;
  padding: 10px 12px;
  color: #c8d7ee;
  text-align: left;
  background: rgba(6, 17, 36, 0.78);
  cursor: pointer;
  margin-bottom: 14px;
}

body[data-current-view="image"] .image-results-panel > .image-provider-info-box .summary-label {
  margin-bottom: 0;
  white-space: nowrap;
}

body[data-current-view="image"] .image-results-panel > .image-provider-info-box #imageProviderTip {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #9fb1ca;
  font-size: 13px;
}

body[data-current-view="image"] #imageResultGrid::before {
  content: none !important;
}

body[data-current-view="image"] .image-provider-info-box:hover {
  border-color: rgba(92, 132, 255, 0.55);
  background: rgba(20, 38, 72, 0.5);
}

body[data-current-view="image"] .image-provider-info-box:focus-visible {
  outline: 2px solid rgba(99, 102, 241, 0.9);
  outline-offset: 3px;
}

.image-provider-info-modal {
  max-width: 720px;
}

.image-provider-info-body {
  display: grid;
  gap: 14px;
}

.provider-info-tip,
.provider-info-doc {
  border: 1px solid rgba(76, 109, 176, 0.52);
  border-radius: 8px;
  padding: 12px;
  background: rgba(6, 17, 36, 0.78);
  color: #c8d7ee;
  line-height: 1.65;
}

.provider-info-grid {
  display: grid;
  gap: 8px;
}

.provider-info-row {
  display: grid;
  grid-template-columns: 124px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  padding: 8px 0;
}

.provider-info-row span {
  color: #8fa4c3;
}

.provider-info-row strong {
  min-width: 0;
  color: #f3f7ff;
  font-weight: 720;
  overflow-wrap: anywhere;
}

body[data-current-view="image"] .image-saved-asset-field > select {
  width: min(360px, 100%);
}

body[data-current-view="image"] .generation-options {
  grid-template-columns: repeat(2, max-content) !important;
  justify-content: start;
}

body[data-current-view="image"] .generation-options.single-note {
  width: min(360px, 100%);
}

body[data-current-view="image"] .image-size-field,
body[data-current-view="image"] .image-count-field {
  width: 170px;
}

body[data-current-view="image"] .image-count-field {
  width: 132px;
}

body[data-current-view="image"] .image-option-select,
body[data-current-view="image"] .generation-options .image-select-like {
  width: 100%;
}

body[data-current-view="image"] .reference-list {
  grid-template-columns: repeat(auto-fill, 112px) !important;
  justify-content: start;
}

body[data-current-view="image"] .reference-chip {
  width: 112px;
  height: 82px;
  min-height: 82px;
}

body[data-current-view="image"] .reference-chip img {
  width: 100%;
  height: 100%;
  object-fit: contain !important;
  background: rgba(2, 8, 18, 0.78);
}

body[data-current-view="image"] .image-result-card-grid {
  display: grid;
  align-items: start;
  gap: 12px;
}

body[data-current-view="image"] .image-result-card-grid.is-single {
  grid-template-columns: 1fr;
}

body[data-current-view="image"] .image-result-card-grid.is-multiple {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

body[data-current-view="image"] .image-preview-button {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  padding: 0;
  border: 0;
  background:
    linear-gradient(135deg, rgba(23, 44, 82, 0.68), rgba(4, 12, 28, 0.96)),
    rgba(3, 10, 22, 0.96);
  cursor: zoom-in;
}

body[data-current-view="image"] .image-result-card-grid.is-single .image-preview-button {
  height: min(52vh, 560px);
  min-height: 420px;
}

body[data-current-view="image"] .image-result-card-grid.is-multiple .image-preview-button {
  height: clamp(198px, 17vw, 250px);
}

body[data-current-view="image"] .image-result-card-grid .image-card img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  aspect-ratio: auto;
  object-fit: contain;
  border-radius: 0;
  max-height: 100%;
}

body[data-current-view="image"] .image-card-body {
  padding: 9px 10px 10px;
  border-top: 1px solid rgba(70, 103, 181, 0.58);
  background: rgba(5, 13, 29, 0.98);
}

body[data-current-view="image"] .image-result-card-grid .item-meta {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  font-size: 13px;
}

body[data-current-view="image"] .image-result-card-grid .item-actions {
  display: grid;
  grid-template-columns: repeat(6, 38px);
  gap: 7px;
  margin-top: 9px;
}

body[data-current-view="image"] .image-action-button,
body[data-current-view="image"] .image-result-card-grid .item-actions .mini-button.image-action-button {
  position: relative;
  width: 38px;
  height: 34px;
  min-height: 34px;
  padding: 0;
  display: grid;
  place-items: center;
  border-radius: 7px;
  border-color: rgba(76, 109, 176, 0.74);
  background: linear-gradient(180deg, rgba(15, 31, 60, 0.98), rgba(6, 16, 35, 0.98));
  color: #dbe7ff;
  font-size: 0;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

body[data-current-view="image"] .image-action-button svg {
  width: 18px;
  height: 18px;
  filter: drop-shadow(0 0 8px rgba(105, 145, 255, 0.18));
}

body[data-current-view="image"] .image-action-button:hover:not(:disabled) {
  border-color: rgba(122, 146, 255, 0.95);
  color: #ffffff;
  background: linear-gradient(180deg, rgba(26, 55, 105, 0.98), rgba(9, 24, 55, 0.98));
}

body[data-current-view="image"] .image-action-button.danger {
  border-color: rgba(255, 87, 103, 0.55);
  color: #ff6d77;
}

body[data-current-view="image"] .image-action-button:disabled {
  opacity: 0.48;
  cursor: not-allowed;
}

body[data-current-view="image"] .image-action-button span {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

body[data-current-view="image"] .image-action-button::after {
  content: attr(data-tooltip);
  position: absolute;
  z-index: 8;
  left: 50%;
  bottom: calc(100% + 8px);
  transform: translateX(-50%) translateY(4px);
  min-width: max-content;
  max-width: 140px;
  padding: 6px 8px;
  border: 1px solid rgba(96, 126, 196, 0.75);
  border-radius: 6px;
  background: rgba(4, 11, 24, 0.96);
  color: #eef5ff;
  font-size: 12px;
  line-height: 1.2;
  opacity: 0;
  pointer-events: none;
  transition: opacity 120ms ease, transform 120ms ease;
}

body[data-current-view="image"] .image-action-button:hover::after,
body[data-current-view="image"] .image-action-button:focus-visible::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

body[data-current-view="image"] [data-copy-text]::before,
body[data-current-view="image"] [data-edit-image-result]::before,
body[data-current-view="image"] [data-use-image-as-reference]::before,
body[data-current-view="image"] [data-save-image-result]::before,
body[data-current-view="image"] [data-download-image]::before,
body[data-current-view="image"] [data-delete-type="imageResult"]::before {
  content: none !important;
}

.image-edit-modal {
  width: min(620px, 100%);
}

.image-edit-modal-body {
  display: grid;
  gap: 16px;
  margin-top: 16px;
}

.image-edit-preview {
  display: grid;
  grid-template-columns: 136px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  border: 1px solid rgba(76, 109, 176, 0.54);
  border-radius: 8px;
  padding: 10px;
  background: rgba(6, 17, 36, 0.78);
}

.image-edit-preview img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 6px;
}

.image-edit-preview strong {
  color: #f4f8ff;
}

.image-edit-preview p {
  margin: 5px 0 0;
  color: #9fb1ca;
  line-height: 1.55;
  font-size: 13px;
}

.image-edit-field textarea {
  min-height: 128px;
}

@media (max-width: 1360px) {
  body[data-current-view="image"] .image-generation-layout {
    grid-template-columns: 1fr !important;
  }
}

@media (max-width: 760px) {
  body[data-current-view="image"] .image-result-card-grid.is-multiple {
    grid-template-columns: 1fr;
  }

  body[data-current-view="image"] .image-result-card-grid.is-single .image-preview-button,
  body[data-current-view="image"] .image-result-card-grid.is-multiple .image-preview-button {
    height: min(64vw, 420px);
    min-height: 240px;
  }
}

/* Storyboard page final overrides live here because this stylesheet loads last. */
body[data-current-view="storyboard"] .topbar {
  min-height: 56px;
  margin: 0 0 14px;
  padding: 0;
  justify-content: flex-end;
  overflow: visible;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

body[data-current-view="storyboard"] .topbar::before,
body[data-current-view="storyboard"] .topbar::after {
  display: none;
}

body[data-current-view="storyboard"] .topbar > div:first-child {
  display: none;
}

body[data-current-view="storyboard"] .top-actions {
  gap: 12px;
}

body[data-current-view="storyboard"] .top-actions .app-version,
body[data-current-view="storyboard"] .top-actions .status-pill,
body[data-current-view="storyboard"] .top-actions .ghost-button {
  min-height: 48px;
  padding: 0 16px;
  border: 1px solid rgba(60, 84, 130, 0.72);
  border-radius: 7px;
  background: rgba(5, 15, 31, 0.82);
  color: #f2f6ff;
  box-shadow: none;
}

body[data-current-view="storyboard"] .top-actions .app-version {
  display: inline-flex;
  align-items: center;
}

body[data-current-view="storyboard"] .storyboard-page-head {
  margin-top: -68px;
  min-height: 68px;
  padding-right: 560px;
}

body[data-current-view="storyboard"] .storyboard-layout {
  grid-template-columns: minmax(640px, 1.04fr) minmax(520px, 0.96fr);
  gap: 12px;
}

@media (max-width: 1360px) {
  body[data-current-view="storyboard"] .storyboard-page-head {
    margin-top: 0;
    padding-right: 0;
  }

  body[data-current-view="storyboard"] .topbar {
    justify-content: flex-start;
  }

  body[data-current-view="storyboard"] .storyboard-layout {
    grid-template-columns: 1fr;
  }
}
/* Unified workspace banner override. This file loads last, so keep the app header consistent across every tab. */
body.is-authenticated .topbar {
  min-height: 92px;
  margin-bottom: 20px;
  padding: 18px 22px;
  border: 1px solid rgba(72, 103, 167, 0.64);
  border-radius: 10px;
  background:
    radial-gradient(circle at 18% 0%, rgba(38, 176, 255, 0.16), transparent 36%),
    radial-gradient(circle at 84% 20%, rgba(133, 82, 255, 0.16), transparent 32%),
    linear-gradient(105deg, rgba(8, 24, 46, 0.96), rgba(7, 15, 32, 0.94));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.05),
    0 18px 42px rgba(0, 0, 0, 0.18);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  overflow: hidden;
}

body.is-authenticated .topbar::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(rgba(120, 159, 229, 0.055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(120, 159, 229, 0.045) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: linear-gradient(90deg, rgba(0, 0, 0, 0.92), transparent 82%);
  -webkit-mask-image: linear-gradient(90deg, rgba(0, 0, 0, 0.92), transparent 82%);
}

body.is-authenticated .topbar::after {
  content: "";
  position: absolute;
  left: 22px;
  right: 22px;
  bottom: 0;
  height: 1px;
  background: linear-gradient(90deg, #26d9ff, rgba(132, 91, 255, 0.72), transparent);
  opacity: 0.72;
}

body.is-authenticated .topbar > * {
  position: relative;
  z-index: 1;
}

body.is-authenticated .topbar > div:first-child {
  display: block;
  min-width: 0;
  max-width: min(760px, calc(100% - 520px));
}

body.is-authenticated .topbar h1 {
  margin: 0;
  color: #f6f9ff;
  font-size: 30px;
  line-height: 1.1;
  letter-spacing: 0;
}

body.is-authenticated .topbar p {
  max-width: 760px;
  margin: 8px 0 0;
  color: #b8c7dc;
  font-size: 15px;
  line-height: 1.45;
}

body.is-authenticated .top-actions {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  white-space: nowrap;
}

body.is-authenticated .top-actions .ghost-button,
body.is-authenticated .top-actions .status-pill,
body.is-authenticated .topbar-version {
  min-height: 44px;
  border: 1px solid rgba(82, 112, 180, 0.58);
  border-radius: 8px;
  background: rgba(7, 15, 32, 0.7);
  color: #dce8f8;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.045);
}

body.is-authenticated .topbar-version {
  display: inline-flex;
  align-items: center;
  padding: 0 13px;
  color: #afbfd6;
}

body.is-authenticated .auth-user-badge {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 0 14px;
}

body.is-authenticated .auth-user-badge::before {
  content: "";
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 34%, #f6fbff 0 4px, transparent 5px),
    radial-gradient(circle at 50% 78%, #f6fbff 0 8px, transparent 9px),
    linear-gradient(135deg, #20d6c7, #4f8cff);
  box-shadow: 0 0 14px rgba(32, 214, 199, 0.28);
}

@media (max-width: 1280px) {
  body.is-authenticated .topbar > div:first-child {
    max-width: 390px;
  }

  body.is-authenticated .topbar h1 {
    font-size: 28px;
  }

  body.is-authenticated .topbar p {
    font-size: 14px;
  }

  body.is-authenticated .top-actions {
    gap: 8px;
  }

  body.is-authenticated .top-actions .ghost-button,
  body.is-authenticated .top-actions .status-pill,
  body.is-authenticated .topbar-version {
    min-height: 42px;
  }
}

@media (max-width: 980px) {
  body.is-authenticated .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  body.is-authenticated .topbar > div:first-child {
    max-width: none;
  }

  body.is-authenticated .top-actions {
    flex-wrap: wrap;
    justify-content: flex-start;
  }
}

@media (min-width: 981px) {
  body[data-current-view="image"].is-authenticated .main {
    padding: 26px;
  }

  body.is-authenticated .topbar {
    height: 117px;
  }

  body.is-authenticated .top-actions .ghost-button,
  body.is-authenticated .top-actions .status-pill,
  body.is-authenticated .top-actions .app-version,
  body.is-authenticated .topbar-version {
    box-sizing: border-box;
    height: 42px !important;
    min-height: 42px !important;
    padding-top: 0;
    padding-bottom: 0;
  }
}
