@media (max-width: 1179px) and (min-width: 900px) {
  :root {
    --composer-width: 410px;
  }

  .studio-header {
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 18px;
    padding: 0 22px;
  }

  .product-title {
    padding-left: 18px;
  }

  #generation-form {
    padding-right: 18px;
    padding-left: 18px;
  }

  .select-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .select-grid label:last-child {
    grid-column: 1 / -1;
  }
}

@media (max-width: 899px) {
  :root {
    --header-height: 62px;
  }

  body {
    overflow: hidden;
  }

  .app-shell {
    min-height: 100dvh;
  }

  .studio-header {
    grid-template-columns: minmax(150px, 1fr) auto;
    min-height: var(--header-height);
    padding: 0 14px;
  }

  .brand img {
    width: 36px;
    height: 36px;
  }

  .brand-copy strong {
    font-size: 16px;
  }

  .brand-copy small,
  .product-title,
  .history-trigger,
  .header-controls > a {
    display: none;
  }

  .header-controls {
    gap: 7px;
  }

  .mobile-view-tabs {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    height: 45px;
    border-bottom: 1px solid var(--line);
    background: var(--white);
  }

  .mobile-view-tabs button {
    position: relative;
    border: 0;
    background: transparent;
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
  }

  .mobile-view-tabs button::after {
    content: "";
    position: absolute;
    right: 24%;
    bottom: 0;
    left: 24%;
    height: 3px;
    background: transparent;
  }

  .mobile-view-tabs button.is-active {
    color: var(--ink);
  }

  .mobile-view-tabs button.is-active::after {
    background: var(--cyan-dark);
  }

  .studio-layout {
    display: block;
    height: calc(100dvh - var(--header-height) - 45px);
    min-height: 0;
  }

  .mobile-view {
    display: none;
    width: 100%;
    height: 100%;
  }

  .mobile-view.is-active {
    display: block;
  }

  .composer-panel.mobile-view.is-active {
    display: grid;
    grid-template-rows: minmax(0, 1fr) auto;
  }

  .composer-panel {
    border-right: 0;
    overflow: hidden;
  }

  #generation-form {
    width: min(620px, 100%);
    height: 100%;
    margin: 0 auto;
    padding: 4px 24px 38px;
    overflow: auto;
  }

  .workspace-panel.mobile-view.is-active {
    display: grid;
  }

  .workspace-panel {
    height: 100%;
  }

  .history-drawer {
    position: static;
    width: 100%;
    border-left: 0;
    box-shadow: none;
    transform: none;
  }

  .history-drawer.mobile-view.is-active {
    display: grid;
  }

  .history-drawer .history-header {
    min-height: 66px;
  }

  #close-history,
  .drawer-scrim {
    display: none !important;
  }

  .result-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .result-card {
    min-height: 250px;
  }

  .result-toolbar {
    flex-wrap: wrap;
  }
}

@media (max-width: 759px) {
  .studio-layout {
    height: calc(100dvh - var(--header-height) - 45px - 68px);
  }

  .mobile-generate-bar {
    position: fixed;
    z-index: 35;
    right: 0;
    bottom: 0;
    left: 0;
    display: block;
    height: 68px;
    border-top: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.96);
    padding: 9px 14px;
    backdrop-filter: blur(10px);
  }

  .mobile-generate-bar .generate-button {
    max-width: 560px;
    margin: 0 auto;
  }

  .composer-footer {
    display: none;
  }

  .workspace-header,
  .history-header {
    padding-right: 14px;
    padding-left: 14px;
  }

  .workspace-actions {
    gap: 5px;
  }

  .workspace-heading-row .preview-badge {
    display: none;
  }

  .toolbar-divider,
  .zoom-value {
    display: none;
  }

  .batch-strip {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    padding-right: 14px;
    padding-left: 14px;
  }

  .batch-progress {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .result-stage {
    padding: 14px;
  }

  .empty-state {
    inset: 14px;
  }

  .result-toolbar {
    display: grid;
    gap: 9px;
    padding: 9px 14px;
  }

  .result-commands {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: 100%;
  }

  .result-commands .command-button {
    min-width: 0;
    padding-right: 7px;
    padding-left: 7px;
  }

  .result-commands .command-button span {
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .toast-region {
    right: 12px;
    bottom: 78px;
    width: calc(100vw - 24px);
  }

  body.workspace-maximized .studio-layout {
    height: 100dvh;
  }
}

@media (max-width: 540px) {
  #generation-form {
    padding-right: 16px;
    padding-left: 16px;
  }

  .select-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .select-grid label:last-child {
    grid-column: 1 / -1;
  }

  .check-control {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .check-control small {
    grid-column: 2;
    justify-self: start;
  }

  .history-item {
    grid-template-columns: 60px minmax(0, 1fr) auto;
    min-height: 80px;
  }

  .history-item img,
  .history-corrupt-thumb {
    width: 60px;
    height: 60px;
  }
}

@media (max-width: 419px) {
  .result-grid,
  .result-grid[data-count="1"] {
    grid-template-columns: minmax(0, 1fr);
  }

  .result-card {
    min-height: 320px;
  }

  .reference-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .reference-actions .command-button {
    min-width: 0;
  }

  .empty-stats {
    flex-direction: column;
  }

  .result-commands .command-button span {
    display: none;
  }

  .result-commands .command-button {
    min-height: 40px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
