/*
 * thumbnail-maker-mobile.css — Canva-style Mobile UX v3
 * Pure bottom-bar contextual approach — no panels covering canvas
 * Loads AFTER thumbnail-maker.css · Only affects ≤768px
 */

/* ═══════════════════════════════════════════════════════════════
   0. RESET OLD CONFLICTING MOBILE STUFF
═══════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  /* Hide old panels / sheets / quick action bar — replaced below */
  body.app-mode .left-panel,
  body.app-mode .right-panel,
  #canvaCtxPanel,
  .mobile-quick-actions-bar { display: none !important; }

  /* Hide old bottom nav — we replace it */
  body.app-mode .app-bottom-nav { display: none !important; }
}

/* ═══════════════════════════════════════════════════════════════
   1. LAYOUT — top bar + canvas + contextual bar + bottom tab bar
═══════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {

  /* Overall page in app mode */
  body.app-mode {
    overflow: hidden;
    height: 100dvh;
  }

  /* Top bar: Undo | Redo | Format | spacer | Zoom- | % | Zoom+ | Fit | Export */
  body.app-mode .app-top-bar {
    display: flex !important;
    align-items: center;
    gap: 4px;
    height: 48px;
    padding: 0 10px;
    background: var(--bg2);
    border-bottom: 1px solid rgba(212,175,55,0.12);
    flex-shrink: 0;
    overflow-x: auto;
    scrollbar-width: none;
    z-index: 100;
  }
  body.app-mode .app-top-bar::-webkit-scrollbar { display: none; }

  body.app-mode .app-top-btn {
    flex-shrink: 0;
    background: var(--bg3);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 8px;
    padding: 6px 10px;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
    font-family: 'Syne', sans-serif;
    display: flex;
    align-items: center;
    gap: 4px;
    height: 32px;
    -webkit-tap-highlight-color: transparent;
  }
  body.app-mode .app-top-btn:active { background: var(--bg4); border-color: var(--gold); }
  body.app-mode .app-top-btn svg { width: 14px; height: 14px; }
  body.app-mode .app-top-spacer { flex: 1; min-width: 4px; }
  body.app-mode .app-top-zoom {
    font-size: 11px; font-weight: 800; color: var(--text);
    min-width: 38px; text-align: center; flex-shrink: 0;
    font-family: 'DM Mono', monospace;
  }
  body.app-mode .app-format-btn { gap: 5px; }
  body.app-mode .app-format-btn #appFormatLabel { color: var(--gold); font-size: 10px; }

  /* Export btn in top bar — gold */
  body.app-mode #appExportTopBtn {
    background: var(--gold) !important;
    color: #111 !important;
    border-color: var(--gold) !important;
    font-weight: 900;
    letter-spacing: 0.3px;
  }
  body.app-mode #appExportTopBtn:active { opacity: 0.85; }

  /* Main area — fills between top bar and ctx bar + tab bar */
  body.app-mode .main {
    height: calc(100dvh - 48px - 54px) !important;
    flex-direction: column !important;
    overflow: hidden !important;
    transition: height 0.22s cubic-bezier(0.4,0,0.2,1);
  }

  /* When ctx bar is tall (sheet open), canvas shrinks more */
  body.app-mode.ctx-sheet-open .main {
    height: calc(100dvh - 48px - 54px - var(--ctx-sheet-h, 0px)) !important;
  }

  /* Canvas area fills main */
  body.app-mode .canvas-area {
    order: 1 !important;
    width: 100% !important;
    height: 100% !important;
    padding: 8px !important;
    background: #040407 !important;
    overflow: hidden !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
  }
  body.app-mode .canvas-wrapper { max-width: 100% !important; max-height: 100% !important; }
  body.app-mode .zoom-bar { display: none !important; }

  /* Hide desktop elements */
  body.app-mode .hero-section,
  body.app-mode .sticky-toolbar,
  body.app-mode .page-sections,
  body.app-mode footer,
  body.app-mode .mobile-tool-strip { display: none !important; }
  body.app-mode .sticky-top { position: relative; }
  body.app-mode .nav { height: 0 !important; overflow: hidden !important; padding: 0 !important; border: none !important; }
  body.app-mode .right-panel-toggle { display: none !important; }

  /* Toast */
  body.app-mode .toast {
    bottom: calc(54px + max(env(safe-area-inset-bottom),0px) + 8px) !important;
    z-index: 9999;
  }
}

/* ═══════════════════════════════════════════════════════════════
   2. CONTEXTUAL ACTION BAR — the scrollable bar above tab bar
      Changes based on what's selected — Canva style
═══════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {

  #mobCtxBar {
    position: fixed;
    bottom: max(env(safe-area-inset-bottom), 0px);
    left: 0; right: 0;
    height: 54px;
    background: rgba(14,14,20,0.98);
    border-top: 1px solid rgba(212,175,55,0.15);
    display: flex;
    align-items: center;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
    z-index: 300;
    padding: 0 6px;
    gap: 2px;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
  }
  #mobCtxBar::-webkit-scrollbar { display: none; }

  /* Each button in ctx bar */
  .ctx-btn {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-width: 52px;
    height: 42px;
    padding: 4px 6px;
    border-radius: 10px;
    background: transparent;
    border: none;
    color: var(--text2);
    font-size: 8px;
    font-weight: 800;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    cursor: pointer;
    font-family: 'Syne', sans-serif;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
    position: relative;
  }
  .ctx-btn svg { width: 18px; height: 18px; stroke: var(--text2); transition: stroke 0.15s; flex-shrink: 0; }
  .ctx-btn:active, .ctx-btn.active {
    background: rgba(212,175,55,0.12);
    color: var(--gold);
  }
  .ctx-btn:active svg, .ctx-btn.active svg { stroke: var(--gold); }

  /* Danger ctx button */
  .ctx-btn.danger { color: #f87171; }
  .ctx-btn.danger svg { stroke: #f87171; }
  .ctx-btn.danger:active { background: rgba(239,68,68,0.12); }

  /* Gold accent ctx button (e.g. Export) */
  .ctx-btn.gold {
    background: rgba(212,175,55,0.12);
    color: var(--gold);
    border: 1px solid rgba(212,175,55,0.25);
  }
  .ctx-btn.gold svg { stroke: var(--gold); }
  .ctx-btn.gold:active { background: rgba(212,175,55,0.22); }

  /* Divider between ctx groups */
  .ctx-sep {
    flex-shrink: 0;
    width: 1px;
    height: 28px;
    background: rgba(255,255,255,0.07);
    margin: 0 3px;
  }

  /* Emoji icon in ctx-btn (sticker/badge) */
  .ctx-btn .ctx-emoji {
    font-size: 18px;
    line-height: 1;
    display: block;
  }
}

/* ═══════════════════════════════════════════════════════════════
   3. BOTTOM TAB BAR — always visible, 5 static tabs
═══════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {

  #mobTabBar {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: calc(58px + max(env(safe-area-inset-bottom), 0px));
    background: rgba(10,10,16,0.98);
    border-top: 1px solid rgba(212,175,55,0.12);
    display: flex;
    align-items: flex-start;
    padding-top: 4px;
    z-index: 301;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
  }

  .mob-tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    height: 50px;
    background: none;
    border: none;
    color: var(--text3);
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.3px;
    text-transform: uppercase;
    cursor: pointer;
    font-family: 'Syne', sans-serif;
    -webkit-tap-highlight-color: transparent;
    transition: color 0.2s;
    padding: 0;
    position: relative;
  }
  .mob-tab svg { width: 22px; height: 22px; stroke: var(--text3); transition: stroke 0.2s, transform 0.2s; }
  .mob-tab.active { color: var(--gold); }
  .mob-tab.active svg { stroke: var(--gold); }

  /* Center ADD tab — raised gold */
  #mobTabAdd { position: relative; }
  #mobTabAdd .mob-tab-icon {
    width: 46px; height: 46px;
    background: var(--gold);
    border-radius: 14px;
    display: flex; align-items: center; justify-content: center;
    transform: translateY(-10px);
    box-shadow: 0 4px 20px rgba(212,175,55,0.5);
    transition: transform 0.15s, box-shadow 0.15s;
    margin-bottom: 2px;
  }
  #mobTabAdd .mob-tab-icon svg { stroke: #111; width: 22px; height: 22px; }
  #mobTabAdd:active .mob-tab-icon {
    transform: translateY(-6px);
    box-shadow: 0 2px 8px rgba(212,175,55,0.3);
  }
  #mobTabAdd span { margin-top: -6px; }
}

/* ═══════════════════════════════════════════════════════════════
   4. BOTTOM SHEETS — slide up from above tab bar
═══════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {

  .mob-sheet-backdrop {
    position: fixed; inset: 0; z-index: 490;
    background: transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s;
  }
  .mob-sheet-backdrop.show { opacity: 1; pointer-events: auto; }

  .mob-sheet {
    position: fixed;
    bottom: calc(54px + max(env(safe-area-inset-bottom),0px));
    left: 0; right: 0;
    z-index: 500;
    background: rgba(13,13,20,0.99);
    border: 1px solid rgba(212,175,55,0.2);
    border-bottom: none;
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -8px 40px rgba(0,0,0,0.7);
    transform: translateY(200%);
    transition: transform 0.28s cubic-bezier(0.4,0,0.2,1);
    pointer-events: none;
    max-height: 45dvh;
    display: flex;
    flex-direction: column;
  }

  /* Hide desktop backdrop on mobile — causes blur on shape select */
  body.app-mode #appSheetBackdrop { display: none !important; }
  .mob-sheet.show {
    transform: translateY(0);
    pointer-events: auto;
  }

  .mob-sheet-handle {
    width: 40px; height: 4px;
    background: rgba(212,175,55,0.25);
    border-radius: 99px;
    margin: 12px auto 0;
    flex-shrink: 0;
  }

  .mob-sheet-title {
    font-size: 10px; font-weight: 800; letter-spacing: 1.2px;
    text-transform: uppercase; color: var(--text2);
    text-align: center; padding: 8px 16px 4px;
    flex-shrink: 0;
  }

  .mob-sheet-body {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding: 8px 14px 20px;
    flex: 1;
  }
  .mob-sheet-body::-webkit-scrollbar { width: 3px; }
  .mob-sheet-body::-webkit-scrollbar-thumb { background: rgba(212,175,55,0.2); border-radius: 99px; }
}

/* ═══════════════════════════════════════════════════════════════
   5. ADD SHEET — grid of add options
═══════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {

  .mob-add-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
    margin-bottom: 10px;
  }

  .mob-add-tile {
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 5px; aspect-ratio: 1;
    border-radius: 12px;
    background: var(--bg3);
    border: 1px solid var(--border);
    color: var(--text); font-size: 9px; font-weight: 700;
    letter-spacing: 0.3px; text-transform: uppercase;
    cursor: pointer; padding: 6px 4px;
    -webkit-tap-highlight-color: transparent;
    transition: border-color 0.15s, transform 0.1s, background 0.15s;
  }
  .mob-add-tile:active { transform: scale(0.91); border-color: var(--gold); background: var(--bg4); }
  .mob-add-icon { font-size: 22px; line-height: 1; display: block; }

  /* Section title in add sheet */
  .mob-add-section {
    font-size: 9px; font-weight: 800; letter-spacing: 1px;
    text-transform: uppercase; color: var(--text3);
    margin: 14px 0 8px;
  }

  /* Export button inside add sheet */
  .mob-add-export-btn {
    width: 100%; height: 46px; border-radius: 12px;
    background: rgba(212,175,55,0.1);
    border: 1px solid rgba(212,175,55,0.3);
    color: var(--gold); font-size: 13px; font-weight: 800;
    font-family: 'Syne', sans-serif;
    display: flex; align-items: center; justify-content: center; gap: 8px;
    cursor: pointer; margin-top: 8px;
    -webkit-tap-highlight-color: transparent;
    transition: opacity 0.15s, transform 0.1s;
  }
  .mob-add-export-btn svg { stroke: var(--gold); }
  .mob-add-export-btn:active { opacity: 0.8; transform: scale(0.98); }
}

/* ═══════════════════════════════════════════════════════════════
   6. SHEET PANELS — font, color, filter, effects, position, etc.
      These are the sheets that open from ctx bar buttons
═══════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {

  /* ── Generic label ── */
  .sp-label {
    font-size: 9px; font-weight: 800; letter-spacing: 1px;
    text-transform: uppercase; color: var(--text2);
    margin: 12px 0 6px;
    display: flex; justify-content: space-between; align-items: center;
  }
  .sp-label span { color: var(--gold); font-size: 10px; font-weight: 700; font-family: 'DM Mono', monospace; }

  /* ── Slider row ── */
  .sp-slider {
    display: flex; align-items: center; gap: 10px; margin-bottom: 14px;
  }
  .sp-slider label {
    font-size: 9px; font-weight: 800; letter-spacing: 0.5px;
    text-transform: uppercase; color: var(--text3);
    min-width: 60px; flex-shrink: 0;
  }
  .sp-slider input[type="range"] {
    flex: 1; -webkit-appearance: none; appearance: none;
    height: 4px; background: var(--bg3); border-radius: 99px;
    accent-color: var(--gold); cursor: pointer;
  }
  .sp-slider input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 22px; height: 22px; border-radius: 50%;
    background: var(--gold); border: 2px solid var(--bg);
    box-shadow: 0 1px 6px rgba(0,0,0,0.4); cursor: pointer;
  }
  .sp-val {
    font-size: 11px; font-weight: 800; color: var(--text);
    font-family: 'DM Mono', monospace;
    min-width: 38px; text-align: right; flex-shrink: 0;
  }

  /* ── Color row ── */
  .sp-color-row {
    display: flex; align-items: center; gap: 8px; margin-bottom: 10px;
  }
  .sp-color-row label {
    font-size: 9px; font-weight: 800; text-transform: uppercase;
    color: var(--text3); min-width: 50px; flex-shrink: 0; letter-spacing: 0.4px;
  }
  .sp-color-row input[type="color"] {
    width: 38px; height: 38px; border-radius: 8px;
    border: 1px solid var(--border); padding: 2px;
    background: var(--bg3); cursor: pointer; flex-shrink: 0;
  }
  .sp-color-row input[type="text"] {
    flex: 1; height: 38px; background: var(--bg3);
    border: 1px solid var(--border); border-radius: 8px;
    color: var(--text); font-size: 12px; font-family: 'DM Mono', monospace;
    padding: 0 10px;
  }
  .sp-color-row input[type="text"]:focus { outline: none; border-color: var(--gold); }

  /* ── Palette swatches ── */
  .sp-palette {
    display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px;
  }
  .sp-swatch {
    width: 28px; height: 28px; border-radius: 6px; cursor: pointer;
    border: 2px solid transparent; transition: transform 0.12s, border-color 0.12s;
    flex-shrink: 0;
  }
  .sp-swatch:active { transform: scale(0.84); }
  .sp-swatch.on { border-color: var(--gold) !important; }

  /* ── Style toggle buttons (B, I, U, etc.) ── */
  .sp-style-row { display: flex; gap: 6px; margin-bottom: 10px; flex-wrap: wrap; }
  .sp-style-btn {
    flex: 1; min-width: 36px; height: 38px; border-radius: 8px;
    background: var(--bg3); border: 1px solid var(--border);
    color: var(--text); font-size: 14px; font-weight: 800;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    -webkit-tap-highlight-color: transparent; font-family: 'Syne', sans-serif;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
  }
  .sp-style-btn:active { background: var(--bg4); }
  .sp-style-btn.on { border-color: var(--gold); color: var(--gold); background: rgba(212,175,55,0.1); }

  /* ── Grid buttons (filter pills, fx options, shapes) ── */
  .sp-pill-row { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
  .sp-pill {
    padding: 7px 13px; border-radius: 99px;
    background: var(--bg3); border: 1px solid var(--border);
    color: var(--text2); font-size: 10px; font-weight: 700; letter-spacing: 0.3px;
    text-transform: uppercase; cursor: pointer; font-family: 'Syne', sans-serif;
    -webkit-tap-highlight-color: transparent;
    transition: border-color 0.15s, color 0.15s;
  }
  .sp-pill.on { border-color: var(--gold); color: var(--gold); background: rgba(212,175,55,0.08); }
  .sp-pill:active { background: var(--bg4); }

  /* ── Grid of action buttons 3-col ── */
  .sp-btn-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 7px; margin-bottom: 10px; }
  .sp-btn-grid-2 { display: grid; grid-template-columns: repeat(2,1fr); gap: 7px; margin-bottom: 10px; }
  .sp-action-btn {
    height: 42px; border-radius: 10px;
    background: var(--bg3); border: 1px solid var(--border);
    color: var(--text); font-size: 10px; font-weight: 700; letter-spacing: 0.3px;
    text-transform: uppercase; cursor: pointer; font-family: 'Syne', sans-serif;
    display: flex; align-items: center; justify-content: center; gap: 5px;
    -webkit-tap-highlight-color: transparent; transition: background 0.15s, border-color 0.15s;
  }
  .sp-action-btn:active { background: var(--bg4); border-color: var(--gold); }
  .sp-action-btn.danger { border-color: rgba(239,68,68,0.3); color: #f87171; }
  .sp-action-btn.danger:active { background: rgba(239,68,68,0.1); }
  .sp-action-btn.full { grid-column: 1 / -1; }
  .sp-action-btn svg { width: 14px; height: 14px; }

  /* ── X Y W H number inputs ── */
  .sp-xywh { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
  .sp-field { display: flex; flex-direction: column; gap: 3px; }
  .sp-field label { font-size: 9px; font-weight: 800; letter-spacing: 0.5px; text-transform: uppercase; color: var(--text3); }
  .sp-field input[type="number"] {
    height: 38px; background: var(--bg3); border: 1px solid var(--border);
    border-radius: 8px; color: var(--text); font-size: 13px; font-weight: 700;
    font-family: 'DM Mono', monospace; text-align: center; padding: 0 6px;
    -webkit-appearance: none;
  }
  .sp-field input[type="number"]:focus { outline: none; border-color: var(--gold); }

  /* ── Font size stepper ── */
  .sp-stepper {
    display: flex; align-items: center; border: 1px solid var(--border);
    border-radius: 10px; overflow: hidden; background: var(--bg3);
    margin-bottom: 10px;
  }
  .sp-step-btn {
    width: 44px; height: 42px; background: none; border: none;
    color: var(--gold); font-size: 20px; font-weight: 700; cursor: pointer;
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
  }
  .sp-step-btn:active { background: var(--bg4); }
  .sp-step-val {
    flex: 1; text-align: center; font-size: 16px; font-weight: 800;
    color: var(--text); font-family: 'DM Mono', monospace;
    border-left: 1px solid var(--border); border-right: 1px solid var(--border);
    height: 42px; display: flex; align-items: center; justify-content: center;
  }

  /* ── Font pills horizontal scroll ── */
  .sp-font-scroll {
    display: flex; gap: 7px; overflow-x: auto; scrollbar-width: none;
    margin-bottom: 12px; padding-bottom: 2px;
  }
  .sp-font-scroll::-webkit-scrollbar { display: none; }
  .sp-font-pill {
    flex-shrink: 0; padding: 9px 14px; border-radius: 10px;
    background: var(--bg3); border: 1px solid var(--border);
    color: var(--text); font-size: 14px; cursor: pointer; white-space: nowrap;
    -webkit-tap-highlight-color: transparent; transition: border-color 0.15s;
  }
  .sp-font-pill.on { border-color: var(--gold); color: var(--gold); background: rgba(212,175,55,0.08); }
  .sp-font-pill:active { background: var(--bg4); }

  /* ── Toggle switch ── */
  .sp-toggle-row {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 12px;
  }
  .sp-toggle-row label { font-size: 10px; font-weight: 700; color: var(--text2); letter-spacing: 0.3px; }
  .sp-toggle {
    width: 42px; height: 24px; border-radius: 99px;
    background: var(--bg3); border: 1px solid var(--border);
    position: relative; cursor: pointer; transition: background 0.2s;
  }
  .sp-toggle.on { background: var(--gold); border-color: var(--gold); }
  .sp-toggle::after {
    content: ''; position: absolute; width: 18px; height: 18px; border-radius: 50%;
    background: var(--text3); top: 2px; left: 2px; transition: left 0.2s, background 0.2s;
  }
  .sp-toggle.on::after { left: 20px; background: #111; }

  /* ── Select dropdown ── */
  .sp-select {
    width: 100%; height: 40px; border-radius: 8px;
    background: var(--bg3); border: 1px solid var(--border);
    color: var(--text); font-size: 12px; font-weight: 700;
    font-family: 'Syne', sans-serif; padding: 0 10px;
    -webkit-appearance: none; margin-bottom: 10px; cursor: pointer;
  }

  /* ── Gradient mini grid ── */
  .sp-grad-grid { display: grid; grid-template-columns: repeat(6,1fr); gap: 6px; margin-bottom: 12px; }
  .sp-grad-swatch {
    aspect-ratio: 1; border-radius: 8px; cursor: pointer;
    border: 2px solid transparent; transition: transform 0.12s, border-color 0.12s;
  }
  .sp-grad-swatch:active { transform: scale(0.88); }
  .sp-grad-swatch.on { border-color: var(--gold) !important; }

  /* ── Brush type grid ── */
  .sp-brush-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 7px; margin-bottom: 12px; }
  .sp-brush-btn {
    height: 44px; border-radius: 10px; background: var(--bg3);
    border: 1px solid var(--border); color: var(--text2);
    font-size: 10px; font-weight: 700; letter-spacing: 0.3px; text-transform: uppercase;
    cursor: pointer; font-family: 'Syne', sans-serif;
    display: flex; align-items: center; justify-content: center; gap: 4px;
    -webkit-tap-highlight-color: transparent;
  }
  .sp-brush-btn.on { border-color: var(--gold); color: var(--gold); background: rgba(212,175,55,0.08); }
  .sp-brush-btn:active { background: var(--bg4); }

  /* ── Full-width primary sheet button ── */
  .sp-primary-btn {
    width: 100%; height: 46px; border-radius: 12px;
    background: var(--gold); color: #111;
    border: none; font-size: 13px; font-weight: 900;
    font-family: 'Syne', sans-serif; letter-spacing: 0.3px;
    display: flex; align-items: center; justify-content: center; gap: 6px;
    cursor: pointer; margin-top: 8px;
    -webkit-tap-highlight-color: transparent;
    transition: opacity 0.15s, transform 0.1s;
  }
  .sp-primary-btn:active { opacity: 0.85; transform: scale(0.98); }

  /* ── More popup (long-press / "More" btn) ── */
  #mobMorePopup {
    position: fixed;
    z-index: 600;
    background: rgba(13,13,20,0.99);
    border: 1px solid rgba(212,175,55,0.2);
    border-radius: 14px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.7);
    padding: 6px;
    min-width: 200px;
    transform-origin: bottom center;
    animation: popIn 0.18s cubic-bezier(0.4,0,0.2,1);
  }
  @keyframes popIn {
    from { opacity:0; transform: scale(0.88) translateY(8px); }
    to   { opacity:1; transform: scale(1) translateY(0); }
  }
  .mob-more-item {
    display: flex; align-items: center; gap: 12px;
    padding: 11px 14px; border-radius: 8px;
    color: var(--text); font-size: 13px; font-weight: 600;
    cursor: pointer; -webkit-tap-highlight-color: transparent;
    transition: background 0.12s;
    font-family: 'Syne', sans-serif;
  }
  .mob-more-item:active { background: rgba(255,255,255,0.06); }
  .mob-more-item svg { width: 16px; height: 16px; stroke: var(--text2); flex-shrink: 0; }
  .mob-more-item.danger { color: #f87171; }
  .mob-more-item.danger svg { stroke: #f87171; }
  .mob-more-divider { height: 1px; background: rgba(255,255,255,0.06); margin: 3px 6px; }

  /* ── Existing modals as bottom sheets on mobile ── */
  body.app-mode .modal-overlay { align-items: flex-end !important; padding: 0 !important; }
  body.app-mode .modal-box {
    width: 100% !important; max-width: 100% !important;
    border-radius: 20px 20px 0 0 !important; margin: 0 !important;
    max-height: 82dvh; overflow-y: auto;
    padding: 20px 16px calc(20px + max(env(safe-area-inset-bottom),0px)) !important;
    animation: mobSheetUp 0.26s cubic-bezier(0.4,0,0.2,1);
  }
  @keyframes mobSheetUp {
    from { transform: translateY(40px); opacity: 0; }
    to   { transform: translateY(0); opacity: 1; }
  }
  body.app-mode .modal-box.wide { width: 100% !important; }
  body.app-mode .template-grid { grid-template-columns: repeat(2,1fr) !important; }
}

/* ═══════════════════════════════════════════════════════════════
   7. SMALL PHONES (< 375px)
═══════════════════════════════════════════════════════════════ */
@media (max-width: 374px) {
  .mob-add-grid { grid-template-columns: repeat(4,1fr) !important; }
  .ctx-btn { min-width: 46px; font-size: 7.5px; }
  .sp-btn-grid { grid-template-columns: repeat(2,1fr) !important; }
}
