/* Swipera studio — mobile layer (≤768px). Desktop layout is untouched above this breakpoint.
   Canvas is the hero; the left panel and inspector become bottom sheets; the rail becomes a bottom tab bar. */
@media (max-width: 768px) {
  :root { --m-nav: 60px; --m-sheet-top: 12vh; }
  html, body { height: 100%; overscroll-behavior-y: none; }
  #app { height: 100dvh; }

  /* ---- top bar: compact ---- */
  #topbar { height: 52px; padding: 0 10px; gap: 6px; }
  #topbar .app-name { display: none; }
  #btn-undo, #btn-redo, #btn-projects, #btn-theme, #btn-lang, #btn-shortcuts, #topbar .w-px { display: none !important; }
  #btn-m-more { display: inline-flex; }
  #btn-export { height: 36px; padding: 0 12px; font-size: 13px; border-radius: 10px; }
  #acct-badge { display: none; }
  #m-title { display: block; flex: 1; min-width: 0; font-size: 13px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--muted); }

  /* ---- workspace: canvas only, sheets overlay ---- */
  #workspace { position: relative; display: block; padding-bottom: var(--m-nav); }
  #rail { display: none !important; }
  #canvas-area { position: absolute; inset: 0 0 var(--m-nav) 0; display: flex; }
  #slide-toolbar { height: 44px; padding: 0 6px; gap: 2px; overflow-x: auto; scrollbar-width: none; }
  #slide-toolbar::-webkit-scrollbar { display: none; }
  #slide-toolbar .tb-btn { width: 36px; height: 36px; }
  #slide-toolbar [data-act="zoom-in"], #slide-toolbar [data-act="zoom-out"], #zoom-label, #slide-toolbar [data-act="zoom-fit"] { display: none !important; }
  #slide-toolbar [data-act="ai-menu"] span, #btn-safe-area span, #slide-toolbar [data-act="preview"] span { display: none; }
  #slide-toolbar [data-act="ai-menu"], #btn-safe-area, #slide-toolbar [data-act="preview"] { width: 36px; padding: 0; }
  #canvas-stage { padding: 14px; }
  #canvas-scroll { touch-action: pan-y; }
  #empty-state { padding: 0 8px; } #empty-state h2 { font-size: 20px; } #empty-state .grid { grid-template-columns: 1fr; }
  #empty-state .mt-6 { flex-direction: column; } #empty-state .mt-6 button { width: 100%; justify-content: center; }
  #filmstrip { padding: 8px 10px; gap: 8px; }
  #ai-menu { position: fixed; left: 10px; right: 10px; top: auto; bottom: calc(var(--m-nav) + 12px); width: auto; max-height: 50vh; overflow: auto; }

  /* slide counter pill over the canvas */
  #m-counter { display: block; position: absolute; top: 52px; left: 50%; transform: translateX(-50%); background: color-mix(in srgb, var(--fg) 85%, transparent); color: var(--bg); font-size: 11px; font-weight: 700; padding: 4px 10px; border-radius: 999px; z-index: 5; pointer-events: none; opacity: 0; transition: opacity .2s; backdrop-filter: blur(6px); }
  #m-counter.on { opacity: 1; }

  /* ---- sheets (left panel + inspector) ---- */
  #left-panel, #inspector {
    display: block !important; position: fixed; left: 0; right: 0; bottom: var(--m-nav); top: auto; width: auto !important; height: calc(100dvh - var(--m-nav) - var(--m-sheet-top));
    max-height: calc(100dvh - var(--m-nav) - var(--m-sheet-top)); border: 0; border-top: 1px solid var(--line); border-radius: 22px 22px 0 0; box-shadow: 0 -20px 60px rgba(0,0,0,.25);
    transform: translateY(calc(100% + 20px)); transition: transform .32s cubic-bezier(.2,.8,.2,1); z-index: 30; overflow: hidden; display: flex !important; flex-direction: column;
    padding-top: 0; background: var(--panel);
  }
  #left-panel.m-open, #inspector.m-open { transform: translateY(0); }
  #left-panel.m-dragging, #inspector.m-dragging { transition: none; }
  #left-panel.m-half, #inspector.m-half { height: 46dvh; }
  .m-grab { flex: 0 0 auto; height: 28px; display: grid; place-items: center; cursor: grab; touch-action: none; position: relative; }
  .m-grab::before { content: ''; width: 44px; height: 5px; border-radius: 3px; background: var(--line); }
  .m-grab .m-close { position: absolute; right: 8px; top: 2px; width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; color: var(--muted); }
  .m-sheet-body { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
  #left-panel .tab-pane { padding: 12px 16px calc(16px + env(safe-area-inset-bottom)); }
  #inspector-empty { margin-top: 40px; } #inspector-body { padding: 12px 16px calc(16px + env(safe-area-inset-bottom)); }
  #left-panel.m-open .m-sheet-body > .tab-pane:not(.active) { display: none; }
  #m-scrim { display: block; position: fixed; inset: 0 0 var(--m-nav) 0; background: rgba(0,0,0,.35); z-index: 29; opacity: 0; pointer-events: none; transition: opacity .25s; }
  #m-scrim.on { opacity: 1; pointer-events: auto; }

  /* sticky generate button inside the create sheet */
  #btn-generate { position: sticky; bottom: 0; z-index: 2; box-shadow: 0 -8px 20px var(--panel), 0 6px 18px rgba(0,0,0,.18); }

  /* ---- bottom tab bar ---- */
  #m-nav { display: grid; position: fixed; left: 0; right: 0; bottom: 0; height: var(--m-nav); grid-template-columns: repeat(6, 1fr); background: var(--panel); border-top: 1px solid var(--line); z-index: 31; padding-bottom: env(safe-area-inset-bottom); }
  #m-nav button { appearance: none; border: 0; background: none; color: var(--muted); font: inherit; font-size: 10px; font-weight: 600; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; padding: 0; min-width: 0; -webkit-tap-highlight-color: transparent; }
  #m-nav button i { font-size: 17px; }
  #m-nav button.active { color: var(--brand); }
  #m-nav button.active i { transform: translateY(-1px) rotate(-6deg); transition: transform .15s; }
  #m-nav button:disabled { opacity: .35; }
  #m-nav button .dot { position: absolute; }

  /* ---- modals → bottom sheets ---- */
  .modal-backdrop { align-items: flex-end; padding: 0; }
  .modal { max-width: none !important; width: 100%; max-height: 92dvh; border-radius: 22px 22px 0 0; animation: sheetUp .28s cubic-bezier(.2,.8,.2,1); padding-bottom: env(safe-area-inset-bottom); }
  .modal-head { padding: 14px 16px; } .modal-body { padding: 16px; }
  @keyframes sheetUp { from { transform: translateY(40px); opacity: .6; } }
  .modal .phone { transform: scale(.82); transform-origin: top center; margin-bottom: -18%; }
  #toast-root { bottom: calc(var(--m-nav) + 14px); width: calc(100% - 24px); }
  .toast { font-size: 12px; }

  /* ---- misc density ---- */
  .field, .seg button { min-height: 40px; font-size: 14px; }
  .lbl { font-size: 13px; }
  .pf-chip { min-height: 40px; }
  #template-gallery { grid-template-columns: repeat(3, 1fr); gap: 10px; }
  .tpl-card .meta { flex-direction: column; align-items: flex-start; gap: 1px; font-size: 11px; line-height: 1.2; } .tpl-card .meta small { font-size: 9px; }
  .tpl-card .badge { font-size: 9px; padding: 2px 6px; }
  body:has(#modal-bd) #toast-root { bottom: auto; top: 64px; }
  .chip { min-height: 32px; }
  #legal-links { padding-bottom: 20px; }
}
@media (min-width: 769px) { #m-nav, #m-scrim, #m-counter, #btn-m-more, #m-title, .m-grab { display: none !important; } }

/* desktop-only dark/light theme contrast for the mobile nav follows panel tokens automatically */
.m-more-item { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 14px 6px; border: 1px solid var(--line); border-radius: 14px; background: var(--bg); color: var(--fg); font: inherit; font-size: 12px; font-weight: 600; }
.m-more-item i { font-size: 18px; color: var(--brand); } .m-more-item:disabled { opacity: .35; }
