
/* Keep the workspace inside narrow viewports without hiding server features. */
.app,
.workspace-shell,
.panel,
.tab-content,
.form,
.asset-workbench,
.asset-form,
.asset-library,
.asset-picker,
.media-grid,
.media-item {
  min-width: 0;
}

.app {
  width: 100%;
  max-width: 100vw;
  overflow: hidden;
}

.workspace-shell {
  width: 100%;
  overflow: hidden;
}

@media (max-width: 860px) {
  .nav-inner {
    padding: 0 12px;
  }

  .nav-brand {
    min-width: 0;
    gap: 8px;
  }

  .nav-brand .brand-logo-lockup {
    --brand-logo-width: 52px;
  }

  .nav-title {
    font-size: 18px;
  }

  .nav-links {
    display: none;
  }

  .btn-nav-cta {
    flex: 0 0 auto;
    padding: 10px 14px;
    font-size: 13px;
  }

  body.workspace-active {
    height: auto;
    min-height: 100dvh;
    overflow-x: hidden;
    overflow-y: auto;
  }

  body.workspace-active .app {
    height: auto;
    min-height: 100dvh;
    overflow: visible;
  }

  .header {
    height: auto;
    min-height: 72px;
    align-items: stretch;
    flex-direction: column;
    gap: 8px;
    padding: 8px 12px;
  }

  .header-left,
  .header-right,
  .logo {
    min-width: 0;
  }

  .header-left {
    flex: 0 0 auto;
    width: 100%;
    gap: 8px;
  }

  .header-right {
    flex: 0 0 auto;
    width: 100%;
    justify-content: stretch;
    gap: 6px;
  }

  .api-key-control {
    flex: 1 1 auto;
    gap: 4px;
  }

  .api-key-control .user-info {
    flex: 1 1 auto;
    max-width: none;
  }

  .api-key-confirm {
    padding: 6px 7px;
  }

  .header .logo {
    gap: 8px;
  }

  .header .brand-logo-lockup {
    --brand-logo-width: 52px;
  }

  .header .logo h1 {
    max-width: none;
    white-space: nowrap;
  }

  .user-info {
    flex: 0 1 120px;
    gap: 4px;
    max-width: 120px;
    padding: 6px 8px;
  }

  .user-info svg {
    display: none;
  }

  .user-info input {
    width: 100%;
    min-width: 0;
  }

  .workspace-shell {
    grid-template-columns: minmax(0, 1fr);
    display: block;
    min-height: 0;
    overflow: visible;
    perspective: none;
    transform-style: flat;
  }

  .panel {
    width: 100%;
    max-width: 100vw;
    border-right: 0;
  }

  .compose-panel {
    max-height: none;
    border-bottom: 1px solid var(--border);
  }

  .panel-header {
    padding: 16px;
  }

  .panel-header h2 {
    font-size: 18px;
  }

  .job-list {
    min-height: 132px;
    max-height: 34dvh;
    padding: 12px;
  }

  .tab-bar {
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 12px 16px 0;
  }

  .tab-btn {
    flex: 0 0 auto;
    padding: 10px 16px;
  }

  .tab-content {
    padding: 16px;
    overflow: visible;
  }

  .mode-tabs {
    display: flex;
    width: 100%;
    max-width: 100%;
    min-height: 44px;
    align-items: center;
    margin-bottom: 18px;
    overflow-x: auto;
    overflow-y: hidden;
    border-radius: var(--radius);
  }

  .mode-tabs button {
    flex: 0 0 auto;
    min-height: 34px;
    padding: 8px 16px;
    line-height: 1.2;
  }

  .image-inputs,
  .media-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .seedance-grid,
  .seedance-url-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .seedance-url-grid-wide .span-2 {
    grid-column: auto;
  }

  .seedance-modelbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .seedance-brand {
    width: 100%;
    flex-wrap: wrap;
  }

  #generationCapabilitySelect,
  #seedanceModel {
    width: 100%;
    max-width: 100%;
    flex-basis: 100%;
  }

  .seedance-stage,
  .seedance-title-row,
  .seedance-composer,
  .seedance-limit-board,
  .generation-title-copy {
    width: 100%;
    min-width: 0;
    max-width: 100%;
  }

  .seedance-composer-body,
  .seedance-limit-board {
    grid-template-columns: minmax(0, 1fr);
  }

  .seedance-upload-tile {
    width: 100%;
  }

  .file-slot {
    padding: 16px;
  }

  .form-row {
    flex-direction: column;
  }

  .asset-library-head,
  .asset-picker-head {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 860px) {
  body.workspace-active {
    height: auto;
    min-height: 100dvh;
    overflow-x: hidden;
    overflow-y: auto;
  }

  body.workspace-active .app {
    height: auto;
    min-height: 100dvh;
    overflow: visible;
  }

  body.workspace-active .workspace-shell {
    display: block;
    min-height: 0;
    overflow: visible;
    perspective: none;
    transform-style: flat;
  }

  body.workspace-active .panel,
  body.workspace-active .output-panel {
    min-height: auto;
  }

  body.workspace-active .compose-panel {
    max-height: none;
    border-bottom: 1px solid var(--border);
  }

  body.workspace-active .tab-content {
    min-height: 0;
    overflow: visible;
  }

  body.workspace-active .job-list {
    min-height: 132px;
    max-height: 34dvh;
    overflow-y: auto;
  }
}
