/* ==========================================================================
   Mobile layout fixes (phones, <= 760px). Loaded after the app CSS.
   The AI Actions panel used to be squeezed into a 73px column beside the
   workspace; on phones it now sits under the workspace as a full-width,
   two-column grid of compact buttons.
   ========================================================================== */
@media (max-width: 760px) {
  /* One column: workspace first, actions below it */
  .dg-mobile-notebook-grid {
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 0.75rem !important;
  }
  .dg-mobile-input-panel,
  .dg-mobile-result-panel {
    grid-column: 1 !important;
    grid-row: 1 !important;
  }
  .dg-mobile-action-sidebar {
    grid-column: 1 !important;
    grid-row: 2 !important;
    position: static !important;
    top: auto !important;
    width: 100% !important;
  }
  .dg-mobile-action-sidebar .dg-panel {
    width: 100% !important;
    max-width: none !important;
    max-height: none !important;
    min-height: 0 !important;
    height: auto !important;
    overflow: visible !important;
  }

  /* Panel header: one tidy row, no tall paragraph */
  .dg-mobile-action-sidebar .dgp2-head { display: block !important; padding: 12px 14px 6px !important; width: auto !important; }
  .dg-mobile-action-sidebar .dgp2-head > p,
  .dg-mobile-action-sidebar .dgp2-hud { display: none !important; }
  .dg-mobile-action-sidebar .dgp2-head-top { display: flex !important; align-items: center !important; gap: 10px !important; width: auto !important; }
  .dg-mobile-action-sidebar .dgp2-title { font-size: 16px !important; width: auto !important; white-space: nowrap !important; }

  /* Actions: two-column grid of compact buttons */
  .dg-mobile-action-sidebar .dgp2-body { padding: 8px 12px 12px !important; overflow: visible !important; max-height: none !important; }
  .dg-mobile-action-sidebar .dgp2-stack {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 8px !important;
  }
  .dg-mobile-action-sidebar .dgp2-action,
  .dg-mobile-action-sidebar .dgp2-toggle {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 8px !important;
    min-height: 52px !important;
    height: auto !important;
    width: 100% !important;
    padding: 8px 10px !important;
    text-align: left !important;
    border-radius: 12px !important;
  }
  .dg-mobile-action-sidebar .dgp2-tool-icon { flex: none !important; width: 28px !important; height: 28px !important; }
  .dg-mobile-action-sidebar .dgp2-gtext { display: block !important; min-width: 0 !important; width: auto !important; flex: 1 1 auto !important; }
  .dg-mobile-action-sidebar .dgp2-tl {
    display: block !important;
    font-size: 12px !important;
    line-height: 1.25 !important;
    white-space: normal !important;
    overflow-wrap: anywhere !important;
  }
  .dg-mobile-action-sidebar .dgp2-desc,
  .dg-mobile-action-sidebar .dgp2-code { display: none !important; }
  .dg-mobile-action-sidebar .dgp2-tl span { display: inline !important; font-size: 10px !important; opacity: .8; }

  /* Groups (e.g. Upscaler) and the add button take a full row */
  .dg-mobile-action-sidebar .dgp2-group,
  .dg-mobile-action-sidebar .dgp2-add { grid-column: 1 / -1 !important; width: 100% !important; }
  .dg-mobile-action-sidebar .dgp2-gbody { width: 100% !important; }
  .dg-mobile-action-sidebar .dgp2-ginner { display: grid !important; grid-template-columns: 1fr 1fr !important; gap: 8px !important; padding-top: 8px !important; }
  .dg-mobile-action-sidebar .dgp2-foot { padding: 8px 14px 12px !important; }

  /* Workspace takes the full width */
  .dg-mobile-main .dg-workspace-shell { border-radius: 1.1rem !important; }
  .dg-mobile-main { padding-left: 10px !important; padding-right: 10px !important; }

  /* Header buttons: one swipeable row instead of spilling off the screen */
  .dg-mobile-header-bar { flex-wrap: wrap !important; gap: 8px !important; padding-left: 10px !important; padding-right: 10px !important; min-height: 0 !important; }
  .dg-mobile-header-actions {
    flex-wrap: nowrap !important;
    justify-content: flex-start !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    max-width: 100% !important;
    width: 100% !important;
    padding-bottom: 4px !important;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    mask-image: linear-gradient(90deg, #000 88%, transparent);
  }
  .dg-mobile-header-actions::-webkit-scrollbar { display: none; }
  .dg-mobile-header-actions > * { flex: none !important; }
}
