/* FluidCanvas responsive interaction layer.
 * Desktop keeps the established precision workspace.  Phone-sized coarse pointers
 * get an explicit asset sheet and a compact zoom dock instead of a squeezed sidebar. */
.fc-mobile-asset-fab,
.fc-mobile-assets-backdrop,
.fc-mobile-sheet-head,
.fc-mobile-zoom-dock,
.fc-mobile-card-actions { display:none; }

@media (max-width: 767px), (orientation: landscape) and (max-height: 500px) {
  body:not(.fc-viewmode) { block-size:100dvh; min-block-size:0; overflow:hidden; }
  .editor-header {
    min-height:52px;
    padding:calc(6px + env(safe-area-inset-top)) 10px 6px;
    gap:6px;
    flex-wrap:nowrap;
    overflow-x:auto;
    overscroll-behavior-x:contain;
  }
  .editor-header .btn-sm { min-width:44px; min-height:44px; padding:0 10px; flex:0 0 auto; }
  .editor-header .btn-sm > span:not(.material-symbols-outlined),
  .editor-header .migrate-btn,
  .editor-header > span[style*="flex:1"] { display:none !important; }
  .canvas-body { min-height:0; }
  .editor-body { padding:10px 10px calc(96px + env(safe-area-inset-bottom)); overscroll-behavior:contain; }
  .title-input { min-height:44px; }
  .grid-controls { position:sticky; top:0; z-index:9; min-width:max-content; padding:6px 0; overflow:visible; background:var(--color-background); border-block-end:1px solid var(--divider-line); }
  .grid-controls .btn, .grid-controls .col-btn { min-height:44px; }
  .grid-controls #snapToggle, .grid-controls #alignToggle { display:none; }

  .asset-panel-toggle { display:none !important; }
  .asset-panel {
    position:fixed !important;
    z-index:1002;
    left:0 !important;
    right:0 !important;
    bottom:0 !important;
    width:auto !important;
    /* The sheet height is owned by the direct-manipulation handle in
       fc-responsive-ui.js.  The fallback preserves the original compact
       phone layout when JavaScript is unavailable. */
    height:var(--fc-mobile-asset-sheet-h, min(72dvh, 620px));
    max-height:calc(100dvh - 86px - env(safe-area-inset-top));
    box-sizing:border-box;
    padding:8px 16px calc(20px + env(safe-area-inset-bottom)) !important;
    border:1px solid var(--divider-line-strong) !important;
    border-bottom:0 !important;
    border-radius:22px 22px 0 0;
    background:var(--color-surface-container-lowest, #fff);
    box-shadow:0 -16px 40px rgba(15, 16, 32, .20);
    overflow-y:auto !important;
    transform:translateY(calc(100% + 12px));
    transition:transform 220ms cubic-bezier(.22,1,.36,1) !important;
    will-change:transform;
  }
  .asset-panel.collapsed { width:auto !important; padding:8px 16px calc(20px + env(safe-area-inset-bottom)) !important; border-right:1px solid var(--divider-line-strong) !important; overflow-y:auto !important; }
  body.fc-mobile-assets-open .asset-panel { transform:translateY(0); }
  .fc-mobile-assets-backdrop {
    display:block;
    position:fixed;
    inset:0;
    z-index:1001;
    opacity:0;
    pointer-events:none;
    background:rgba(11,12,24,.32);
    transition:opacity 180ms ease;
  }
  body.fc-mobile-assets-open .fc-mobile-assets-backdrop { opacity:1; pointer-events:auto; }
  .fc-mobile-sheet-head {
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:12px;
    position:sticky;
    top:-8px;
    z-index:2;
    margin:-8px -4px 8px;
    padding:10px 4px 8px;
    background:var(--color-surface-container-lowest, #fff);
  }
  .fc-mobile-sheet-grab {
    width:44px;
    height:28px;
    margin:0 auto -2px;
    padding:0;
    border:0;
    background:transparent;
    touch-action:none;
    cursor:ns-resize;
  }
  .fc-mobile-sheet-grab::before {
    content:'';
    display:block;
    width:38px;
    height:4px;
    margin:auto;
    border-radius:999px;
    background:var(--color-outline-variant, #777680);
    opacity:.72;
  }
  body.fc-mobile-assets-resizing .asset-panel { transition:none !important; user-select:none; }
  .fc-mobile-sheet-title { min-width:0; font-size:15px; font-weight:750; overflow-wrap:anywhere; }
  .fc-mobile-sheet-close { flex:none; width:44px; height:44px; border:0; border-radius:50%; background:var(--color-surface-container, #f2f1f8); color:var(--color-on-surface, #1c1b20); display:grid; place-items:center; }
  .fc-mobile-asset-fab {
    display:inline-flex;
    align-items:center;
    justify-content:center;
    gap:7px;
    position:absolute;
    z-index:999;
    inset-inline-start:12px;
    inset-block-end:12px;
    max-inline-size:calc(100% - 174px);
    min-height:48px;
    padding:6px 16px;
    border:0;
    border-radius:999px;
    background:var(--color-primary, #4648d4);
    color:#fff;
    font:600 14px/1.16 var(--font-family, system-ui);
    overflow-wrap:anywhere;
    box-shadow:0 8px 22px rgba(50,52,180,.28);
  }
  .fc-mobile-zoom-dock {
    display:flex;
    align-items:center;
    position:absolute;
    z-index:999;
    inset-inline-end:12px;
    inset-block-end:12px;
    overflow:hidden;
    border:1px solid var(--divider-line-strong);
    border-radius:999px;
    background:var(--color-surface-container-lowest, #fff);
    box-shadow:0 8px 22px rgba(20,20,40,.14);
  }
  .fc-mobile-zoom-dock button { width:44px; height:48px; border:0; background:transparent; color:var(--color-on-surface, #1c1b20); font:700 18px/1 system-ui; }
  .fc-mobile-zoom-dock button + button { border-left:1px solid var(--divider-line); }
  .fc-mobile-zoom-dock .fc-mobile-zoom-readout { width:56px; font-size:12px; font-weight:700; }
  .fc-mobile-card-actions {
    display:none;
    align-items:center;
    gap:4px;
    position:absolute;
    z-index:999;
    left:50%;
    inset-block-end:12px;
    max-inline-size:calc(100% - 24px);
    transform:translateX(-50%);
    padding:4px;
    border:1px solid var(--divider-line-strong);
    border-radius:999px;
    background:var(--color-surface-container-lowest, #fff);
    box-shadow:0 8px 22px rgba(20,20,40,.14);
  }
  body.fc-mobile-card-selected .fc-mobile-card-actions { display:flex; }
  body.fc-mobile-card-selected .fc-mobile-asset-fab,
  body.fc-mobile-card-selected .fc-mobile-zoom-dock { pointer-events:none; opacity:0; }
  .fc-mobile-card-actions button {
    min-width:48px;
    min-height:48px;
    padding:0 14px;
    border:0;
    border-radius:999px;
    background:transparent;
    color:var(--color-on-surface, #1c1b20);
    font:650 13px/1 var(--font-family, system-ui);
    white-space:normal;
    overflow-wrap:anywhere;
  }
  .fc-mobile-card-actions button:first-child {
    background:var(--color-primary, #4648d4);
    color:#fff;
  }
  .fc-mobile-card-actions button:disabled { opacity:.46; }
  body.fc-mobile-assets-open .fc-mobile-asset-fab,
  body.fc-mobile-assets-open .fc-mobile-zoom-dock,
  body.fc-mobile-assets-open .fc-mobile-card-actions { pointer-events:none; opacity:0; }
  .text-toolbar { z-index:1000; }
  .text-toolbar, .context-menu, .radius-popover { max-width:calc(100vw - 16px); }
  .editor-statusbar { padding-bottom:max(4px, env(safe-area-inset-bottom)); }

  /* A card remains directly manipulable.  These controls only provide
     wayfinding for the canvas; they never sit over the selected card. */
  .grid-card { scroll-margin-bottom:96px; }
}

@media (prefers-reduced-motion: reduce) {
  .asset-panel, .fc-mobile-assets-backdrop { transition:none !important; }
}

body.fc-mobile-keyboard-editing :is(.grid-controls, .editor-statusbar, .fc-mobile-card-actions, .fc-mobile-asset-fab, .fc-mobile-zoom-dock) {
  display:none;
}

@media (orientation: landscape) and (max-height: 340px) {
  body.fc-mobile-keyboard-editing :is(.editor-header, .fc-experience-bar) { display:none; }
}
