/* ==========================================================================
   STAAD Helper — Mobile layout (AutoCAD-mobile style)
   Full-screen viewport · compact top bar · bottom dock · slide-up tool
   sheets · bottom-sheet inspector. Applies at <= 760px wide.
   ========================================================================== */
#m-dock, #m-sheet { display: none; }
#viewport-container canvas { touch-action: none; }

@media (max-width: 760px) {
  html, body { height: 100dvh; }
  body { height: 100dvh; }

  /* Top bar: logo + model pill only */
  #ribbon-tabs, #ribbon-panel, .title-menu, .title-badge,
  #solver-status-chip, #cmd-bar, #fp-display, #fp-legend,
  #viewport-tooltip, #left-toolbar, #quick-radial { display: none !important; }
  #title-bar { height: 44px; padding-right: 8px; }
  #title-app-logo { width: 44px; height: 44px; }
  #title-app-name { position: static; transform: none; flex: 1; padding-left: 10px; font-size: 13px; pointer-events: none; }
  .title-spacer { display: none; }
  #status-bar { display: flex !important; height: 30px; padding: 0 6px; }
  #status-bar .sb-item { display: none; }
  #status-bar #sb-model-pill { display: flex; padding: 0; border: none; }
  #sb-model-pill .model-status-indicator { height: 24px; max-width: 100%; }
  #sb-model-pill .model-name-text { max-width: 60vw; }

  /* KPI strip, top-left of the viewport */
  #fp-telemetry { top: 8px; left: 8px; right: auto; max-width: calc(100% - 100px); }
  #fp-telemetry .fp-head, #fp-telemetry .filter-tabs,
  #fp-telemetry .viewport-hud > .hud-divider { display: none; }
  #fp-telemetry .metric-label { display: none; }
  #fp-telemetry .metric-cell { padding: 4px 6px; }
  #fp-telemetry .metric-val { font-size: 12px; }

  /* ViewCube: smaller, still top-right */
  #viewcube-wrap { top: 8px; right: 8px; }
  #viewcube { width: 80px; height: 80px; }
  .viewcube-tools button { width: 30px; height: 28px; }

  /* Empty state: single-column, no folder picker (not supported on phones) */
  .empty-state-card { width: calc(100% - 24px); max-width: 420px; padding: 20px 16px; }
  .supported-formats-box, .drop-hint, #btn-empty-folder { display: none; }
  .empty-state-card > div[style*="display: flex"] { flex-direction: column; }
  .empty-state-title { font-size: 16px; }

  /* Bottom dock */
  #m-dock {
    display: flex;
    flex-shrink: 0;
    background: #0c0c10;
    border-top: 1px solid var(--border-medium);
    padding: 0 4px env(safe-area-inset-bottom, 0px);
    z-index: 320;
  }
  .m-dock-btn {
    flex: 1;
    min-width: 0;
    height: 54px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    background: none;
    border: none;
    color: var(--text-muted);
    font: 600 10px var(--font-sans);
    letter-spacing: 0.03em;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }
  .m-dock-btn svg { width: 22px; height: 22px; }
  .m-dock-btn.active { color: #60a5fa; }

  /* Slide-up tool sheet */
  #m-sheet {
    display: none;
    position: fixed;
    left: 0; right: 0;
    bottom: calc(54px + env(safe-area-inset-bottom, 0px));
    z-index: 310;
    max-height: 46vh;
    overflow-y: auto;
    background: #0f0f14;
    border-top: 1px solid var(--border-medium);
    box-shadow: 0 -12px 30px rgba(0, 0, 0, 0.55);
    padding: 10px 12px 12px;
    padding-left: max(12px, env(safe-area-inset-left, 0px));
    padding-right: max(12px, env(safe-area-inset-right, 0px));
  }
  #m-sheet.open { display: block; }
  .m-pane { display: none; }
  .m-pane.active { display: block; }
  .m-title {
    font-size: 9.5px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase;
    color: var(--text-dim); margin: 2px 2px 6px;
  }
  .m-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 8px; }
  .m-btn {
    min-width: 0;
    height: 62px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 3px;
    color: var(--text-secondary);
    font: 500 10.5px var(--font-sans);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }
  .m-btn svg { width: 20px; height: 20px; }
  .m-btn.active { color: #60a5fa; background: var(--color-accent-subtle); border-color: var(--color-accent-border); }
  .m-btn.disabled { opacity: 0.35; pointer-events: none; }

  /* Inspector becomes a bottom sheet */
  .inspector-sidebar {
    position: fixed;
    left: 0; right: 0;
    bottom: calc(54px + env(safe-area-inset-bottom, 0px));
    width: 100%;
    height: 56vh;
    z-index: 300;
    border-left: none;
    border-top: 1px solid var(--border-medium);
    box-shadow: 0 -12px 30px rgba(0, 0, 0, 0.55);
    transition: transform 0.2s ease;
  }
  .inspector-sidebar.collapsed {
    width: 100%;
    min-width: 0;
    border-top: 1px solid var(--border-medium);
    overflow-y: auto;
    transform: translateY(calc(100% + 80px));
    pointer-events: none;
  }
  #btn-inspector-collapse svg { transform: rotate(90deg); }
  .sidebar-header { padding: 10px 14px; }
  .modal-content { max-width: calc(100vw - 24px); }

  .toast-container { bottom: calc(66px + env(safe-area-inset-bottom, 0px)); right: 8px; left: 8px; max-width: none; }
  #sample-btn { top: auto; bottom: 18px; }
}
