@media (max-width: 900px) {
  html,
  body {
    height: 100%;
    overflow: hidden;
  }

  body {
    min-width: 0;
  }

  .topbar-wrapper {
    position: sticky;
    top: 0;
    z-index: 240;
    border-bottom: 1px solid var(--rule2);
    background: var(--bg);
  }

  .topbar {
    min-height: 58px;
    height: auto;
    padding: 8px 12px;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
  }

  .mobile-menu-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    padding: 0;
    border: 1px solid var(--rule2);
    border-radius: 5px;
    background: var(--ink3);
    color: var(--text2);
    order: 1;
  }

  .topbar-center {
    order: 3;
    flex: 1 0 100%;
    width: 100%;
    height: auto;
    padding: 0;
    border-right: 0;
  }

  .usage-bar {
    order: 2;
    margin-left: auto;
    padding: 0;
    gap: 7px;
  }

  .usage-bar #usageText,
  .usage-bar .usage-track,
  .usage-bar #planBadge,
  .breadcrumb {
    display: none !important;
  }

  #workflowSwitcher {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 4px;
  }

  #workflowSwitcher .workflow-switch-btn {
    min-width: 0;
    min-height: 40px;
    padding: 8px 6px;
    font-size: 12px;
    text-align: center;
  }

  .topbar-memory-btn,
  .topbar-tour-btn {
    min-height: 34px;
    padding: 6px 9px;
    font-size: 10px;
  }

  .theme-toggle,
  .user-avatar {
    width: 34px;
    height: 34px;
  }

  .app-body {
    height: calc(100dvh - 106px);
    min-height: 0;
    overflow: hidden;
  }

  .main {
    width: 100%;
    min-width: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 12px 12px calc(88px + env(safe-area-inset-bottom));
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  body.mobile-activity-lock .main {
    overflow: hidden;
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: min(300px, 82vw);
    z-index: 520;
    transform: translateX(-105%);
    transition: transform .24s ease;
    border-right: 1px solid var(--rule2);
    box-shadow: 24px 0 80px rgba(0,0,0,.5);
  }

  .sidebar.open {
    left: 0;
    transform: translateX(0);
  }

  body.workspace-modal-open .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 220;
    transform: translateX(-105%);
  }

  body.workspace-modal-open .sidebar.open {
    transform: translateX(0);
  }

  .sidebar.is-collapsed {
    width: min(300px, 82vw);
  }

  .sidebar.is-collapsed .app-nav-brand {
    min-height: 76px;
    flex-direction: row;
    justify-content: flex-start;
    padding-inline: 14px;
  }

  .sidebar.is-collapsed .app-nav-logo-full,
  .sidebar.is-collapsed .app-nav-label {
    display: inline;
  }

  .sidebar.is-collapsed .app-nav-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: auto;
  }

  .config-panel {
    position: static;
    transform: none;
    width: 100%;
    min-width: 0;
    height: auto;
    max-height: none;
    border: 1px solid var(--rule2);
    border-radius: 7px;
    order: 1;
  }

  .config-panel::before,
  .sheet-close,
  .sheet-overlay,
  .mobile-fab {
    display: none !important;
  }

  .panel-body {
    padding: 10px;
    overflow: visible;
  }

  .composer-stepper-shell {
    position: sticky;
    top: 0;
    z-index: 30;
    padding: 0 0 10px;
    margin: 0;
    background: var(--ink2);
  }

  .composer-stepper {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 0;
    border-radius: 6px;
  }

  .composer-stepper-item {
    min-height: 50px;
    padding: 0 2px;
  }

  .composer-stepper-label strong {
    font-size: 11px;
    letter-spacing: 0;
  }

  .composer-step {
    min-height: 0;
    padding: 18px 14px 20px;
    border-radius: 6px;
  }

  .composer-step:first-child {
    padding-top: 18px;
  }

  .composer-step-title {
    font-size: 27px;
  }

  .composer-step-note {
    max-width: none;
    font-size: 13px;
  }

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

  .scenario-category-modal {
    inset: auto 12px calc(12px + env(safe-area-inset-bottom)) 12px;
    height: min(72dvh, 620px);
  }

  .scenario-category-list {
    grid-template-columns: minmax(0, 1fr);
  }

  .composer-choice-grid,
  .platform-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .tone-pills,
  .composer-chip-grid,
  .variation-selector {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
  }

  .field input,
  .field select,
  .field textarea {
    font-size: 16px;
  }

  .panel-footer {
    position: sticky;
    bottom: 0;
    z-index: 40;
    padding: 10px 10px calc(10px + env(safe-area-inset-bottom));
    border-radius: 0 0 7px 7px;
  }

  .panel-footer-row,
  .panel-step-nav {
    flex-direction: row;
    align-items: stretch;
    width: 100%;
  }

  .panel-reset-btn,
  .panel-nav-btn {
    flex: 1 1 0;
    width: auto;
    min-width: 0;
    min-height: 46px;
  }

  .panel-footer-meta {
    align-items: flex-start;
    flex-direction: column;
    gap: 5px;
  }

  .panel-autosave-status {
    white-space: normal;
  }

  .generate-btn {
    min-height: 48px;
  }

  .output-area {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: calc(10px + env(safe-area-inset-bottom));
    z-index: 180;
    width: auto;
    max-width: none;
    height: 62px;
    margin: 0;
    padding-bottom: 0;
    border: 1px solid var(--rule2);
    border-radius: 7px;
    background: var(--ink2);
    box-shadow: 0 -18px 60px rgba(0,0,0,.42);
    overflow: hidden;
    transition: height .22s ease, box-shadow .22s ease;
    touch-action: pan-y;
    overscroll-behavior: contain;
  }

  .output-area.mobile-activity-open {
    height: min(62dvh, 560px);
    box-shadow: 0 -24px 80px rgba(0,0,0,.58);
  }

  .mobile-activity-toggle {
    width: 100%;
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 0 16px;
    border: 0;
    border-bottom: 1px solid transparent;
    background: var(--ink2);
    color: var(--text);
    font: inherit;
    font-size: 12px;
    font-weight: 700;
    text-align: left;
    cursor: pointer;
  }

  .mobile-activity-toggle span:first-child {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mobile-activity-chevron {
    flex: 0 0 auto;
    font-size: 18px;
    color: var(--text2);
    transition: transform .18s ease;
  }

  .output-area.mobile-activity-open .mobile-activity-toggle {
    border-bottom-color: var(--rule2);
  }

  .output-area.mobile-activity-open .mobile-activity-chevron {
    transform: rotate(180deg);
  }

  .output-topbar {
    padding: 10px 12px;
  }

  .output-scroll {
    height: calc(100% - 61px);
    max-height: none;
    padding: 12px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    touch-action: pan-y;
  }

  .output-area:not(.mobile-activity-open) .output-topbar,
  .output-area:not(.mobile-activity-open) .output-scroll,
  .output-area:not(.mobile-activity-open) .status-bar {
    display: none !important;
  }

  .brief-snapshot {
    padding: 14px;
  }

  .brief-snapshot-head {
    padding-bottom: 12px;
  }

  .brief-snapshot-title {
    font-size: 28px;
  }

  .brief-row {
    grid-template-columns: minmax(88px, 34%) minmax(0, 1fr);
    gap: 8px;
    font-size: 12px;
  }

  body.workspace-modal-open .workspace-shell {
    left: 12px;
    right: 12px;
    top: 108px;
    height: min(74dvh, 720px);
    z-index: 640;
  }

  .sidebar.is-collapsed ~ .main .workspace-shell {
    left: 12px;
  }

  body.workspace-modal-open .workspace-panel.active,
  body.workspace-modal-open .workspace-panel-output.active {
    padding: 16px 14px 44px;
  }

  body.workspace-modal-open .workspace-grid-two {
    grid-template-columns: minmax(0, 1fr);
  }

  .workspace-popup-head {
    min-height: 86px;
    padding: 32px 14px 16px;
    align-items: center;
    overflow: visible;
  }

  .workspace-popup-title {
    font-size: 24px;
    line-height: 1.3;
    padding-top: 4px;
    overflow: visible;
  }
}

@media (max-width: 430px) {
  .main {
    padding: 8px 8px calc(88px + env(safe-area-inset-bottom));
  }

  .composer-stepper-item {
    min-height: 44px;
  }

  .composer-stepper-label strong {
    font-size: 10px;
  }

  .composer-step-title {
    font-size: 24px;
  }

  .tone-pills,
  .composer-chip-grid,
  .variation-selector {
    grid-template-columns: minmax(0, 1fr);
  }

  .panel-footer-row,
  .panel-step-nav {
    flex-direction: column;
  }
}
