/* ═══════════════════════════════════════════════════
   TOQIBOX — mobile.css
   Подключается только на мобильных через media query
   ═══════════════════════════════════════════════════ */

@media (max-width: 768px) {

  /* ── Базовые touch-оптимизации ── */
  * {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
  }

  /* ── ШАПКА — компактная ── */
  .site-header {
    padding: 0 10px !important;
    gap: 6px !important;
    height: 48px !important;
  }

  /* Скрываем в шапке на мобиле */
  .eco-nav,
  #btn-transparent-mode,
  #fmt-btns,
  .hdr-sp,
  #btn-undo,
  #btn-redo {
    display: none !important;
  }

  /* Лого компактнее */
  .lw-wrap a span:first-child {
    font-size: 13px !important;
  }
  .lw-wrap a span:last-child {
    display: none !important;
  }
  .lw-wrap img {
    width: 28px !important;
    height: 28px !important;
  }

  /* Кнопка скачать — компактная */
  #btn-download {
    width: 90px !important;
    height: 34px !important;
    font-size: 10px !important;
  }

  /* ── APP LAYOUT — вертикальный ── */
  .app {
    flex-direction: column !important;
    padding-top: 48px !important;
    height: 100dvh !important;
    overflow: hidden !important;
  }

  /* ── ХОЛСТ — занимает верхнюю часть ── */
  .workspace {
    flex: 0 0 auto !important;
    width: 100% !important;
    height: calc(100dvh - 48px - 64px) !important;
    overflow: hidden !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 8px !important;
  }

  .canvas-shell {
    max-width: 100% !important;
    max-height: 100% !important;
  }

  /* ── SIDEBAR — скрываем десктопный ── */
  .sidebar {
    display: none !important;
  }

  /* ══════════════════════════════════════
     BOTTOM NAV BAR
  ══════════════════════════════════════ */
  #mob-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 64px;
    background: rgba(8, 8, 18, 0.97);
    border-top: 1px solid rgba(139,111,255,0.2);
    backdrop-filter: blur(20px);
    display: flex;
    align-items: center;
    justify-content: space-around;
    z-index: 1000;
    padding: 0 4px;
    padding-bottom: env(safe-area-inset-bottom);
  }

  .mob-nav-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 6px 10px;
    border: none;
    background: transparent;
    color: rgba(255,255,255,0.45);
    cursor: pointer;
    border-radius: 12px;
    transition: all 0.2s;
    min-width: 44px;
    min-height: 44px;
    position: relative;
  }

  .mob-nav-btn span {
    font-size: 9px;
    font-family: 'DM Sans', sans-serif;
    font-weight: 500;
    letter-spacing: 0.3px;
    white-space: nowrap;
  }

  .mob-nav-btn.active {
    color: #8b6fff;
  }

  .mob-nav-btn.active::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 24px;
    height: 2px;
    background: #8b6fff;
    border-radius: 0 0 3px 3px;
  }

  /* Центральная кнопка — добавить текст */
  .mob-nav-btn.mob-center {
    background: linear-gradient(135deg, #7c3aed, #6d28d9);
    color: #fff;
    width: 52px;
    height: 52px;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(124,58,237,0.5);
    margin-bottom: 8px;
  }

  .mob-nav-btn.mob-center span {
    display: none;
  }

  /* ══════════════════════════════════════
     DRAWER — панель снизу
  ══════════════════════════════════════ */
  #mob-drawer {
    position: fixed;
    bottom: 64px;
    left: 0;
    right: 0;
    height: 75dvh;
    background: rgba(10, 10, 20, 0.98);
    border-top: 1px solid rgba(139,111,255,0.25);
    border-radius: 20px 20px 0 0;
    backdrop-filter: blur(24px);
    z-index: 999;
    transform: translateY(110%);
    transition: transform 0.38s cubic-bezier(0.32, 0.72, 0, 1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  #mob-drawer.open {
    transform: translateY(0);
  }

  /* Ручка drawer */
  #mob-drawer-handle {
    width: 36px;
    height: 4px;
    background: rgba(255,255,255,0.2);
    border-radius: 2px;
    margin: 10px auto 0;
    flex-shrink: 0;
  }

  /* Заголовок drawer */
#mob-drawer-title {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: rgba(139,111,255,0.8);
    text-align: center;
    padding: 8px 0 6px;
    flex-shrink: 0;
    position: relative;   /* ← добавляем для позиционирования кнопки назад */
    min-height: 32px;
  }

  /* Контент drawer — скроллится */
  #mob-drawer-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 8px 14px 16px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  #mob-drawer-content::-webkit-scrollbar {
    display: none;
  }

  /* Перемещаем контент панелей в drawer */
  #mob-drawer-content .panel {
    display: block !important;
  }

  /* ── Форматы в drawer ── */
  #mob-fmt-row {
    display: flex;
    gap: 8px;
    margin-bottom: 14px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(255,255,255,0.07);
  }

  .mob-fmt-btn {
    flex: 1;
    padding: 8px 6px;
    border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.1);
    background: rgba(255,255,255,0.05);
    color: rgba(255,255,255,0.6);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s;
    font-family: 'DM Sans', sans-serif;
  }

  .mob-fmt-btn.active {
    background: rgba(139,111,255,0.3);
    border-color: rgba(139,111,255,0.6);
    color: #fff;
  }

  /* ── Undo/Redo в шапке на мобиле ── */
  #mob-undo-redo {
    display: flex;
    gap: 4px;
    margin-left: auto;
    margin-right: 6px;
  }

  .mob-ur-btn {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.1);
    background: rgba(255,255,255,0.06);
    color: rgba(255,255,255,0.6);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* ── Overlay drawer background ── */
  #mob-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 998;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
  }

  #mob-overlay.show {
    opacity: 1;
    pointer-events: all;
  }

  /* ── Touch активные состояния ── */
  .mob-nav-btn:active {
    transform: scale(0.92);
  }

  .mob-center:active {
    transform: scale(0.9) !important;
  }

  /* ── Увеличиваем кнопки в панели для touch ── */
  .stb, .pill, .preset-grid-btn {
    min-height: 38px !important;
  }

  .add-text-btn, #add-text {
    height: 48px !important;
    font-size: 14px !important;
  }
/* ── Текст вставляется по центру ── */
  .text-layer {
    left: 50% !important;
    top: 50% !important;
    transform: translate(-50%, -50%) !important;
  }
  /* Слайдеры шире */
  input[type="range"] {
    height: 20px !important;
  }

  /* ── Анимация появления drawer ── */
  @keyframes mobDrawerIn {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
  }
}

/* Скрываем mob элементы на десктопе */
@media (min-width: 769px) {
  #mob-nav,
  #mob-drawer,
  #mob-overlay,
  #mob-undo-redo {
    display: none !important;
  }
}
/* ── Кнопка слоёв сбоку ── */
#mob-layer-trigger {
  display: flex !important;
}

#mob-layer-panel {
  width: 148px !important;
  max-width: 148px !important;
  min-width: 148px !important;
  box-sizing: border-box !important;
  padding-bottom: calc(64px + env(safe-area-inset-bottom)) !important;
}

#mob-layer-list::-webkit-scrollbar {
  display: none;
}
/* Bazar иконка в nav — цветная при active */
  .mob-nav-btn[data-tab="bazar"] .bazar-nav-icon {
    filter: brightness(0.6);
    transition: filter 0.2s;
  }
  .mob-nav-btn[data-tab="bazar"]:active .bazar-nav-icon {
    filter: brightness(1.2);
  }