@media (max-width: 980px) {
  body {
    padding: 12px;
    overflow-y: hidden;
  }

  .container {
    flex: 1;
    min-height: 0;
    flex-direction: column;
    gap: 12px;
    align-items: stretch;
  }

  form.settings-panel,
  .panel {
    flex: 0 0 auto;
    width: 100%;
    max-height: 44dvh;
    overflow-y: auto;
    overflow-x: hidden;
  }

  .output-wrapper {
    flex: 1;
    width: 100%;
    min-height: 0;
    height: 100%;
    overflow-y: auto;
    overflow-x: auto;
  }

  label {
    font-size: 14px;
  }

  .file-name {
    font-size: 13px;
  }
}

@media (max-width: 768px) {
  .settings-panel {
    position: fixed;
    top: calc(50px + env(safe-area-inset-top));
    bottom: calc(10px + env(safe-area-inset-bottom));
    left: 8px;
    width: min(var(--settings-panel-width), calc(100vw - 56px));
    overflow-x: hidden;
    overflow-y: auto;
    height: calc(100vh - 60px);
    height: calc(100dvh - 60px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    max-height: calc(100vh - 60px);
    max-height: calc(100dvh - 60px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    z-index: 1200;
    transform: translateX(calc(-100% - 20px));
    transition: transform 0.22s ease;
    pointer-events: none;
  }

  body.settings-open .settings-panel {
    transform: translateX(0);
    pointer-events: auto;
  }

  .settings-toggle {
    position: fixed;
    top: calc(50% - 24px);
    left: 8px;
    width: 18px;
    height: 48px;
    border: 1px solid var(--border, #1A1A1A);
    border-radius: var(--radius-sm, 4px);
    background: var(--gray-900, #111111);
    color: var(--gray-400, #777777);
    padding: 0;
    cursor: pointer;
    font-family: inherit;
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    z-index: 1300;
    transition: left 0.22s ease, border-color 0.2s ease, color 0.2s ease, background 0.2s ease;
    -webkit-tap-highlight-color: transparent;
  }

  .settings-toggle:hover {
    border-color: var(--border-strong, #252525);
    color: var(--gray-200, #BBBBBB);
  }

  body.settings-open .settings-toggle {
    border-color: var(--accent, #F97316);
    color: var(--accent, #F97316);
    background: var(--orange-dim, rgba(249, 115, 22, 0.15));
  }

  input[type='text'],
  input[type='number'],
  input[type='color'],
  input[type='range'],
  select,
  .main-button {
    min-height: 44px;
  }

  .ingest-actions {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 420px) {
  body {
    padding: 8px;
  }

  h1 {
    font-size: 20px;
    margin: 0 0 8px;
  }

  .settings-toggle {
    height: 44px;
  }
}
