/* app.8kk.im 专用移动端 App 壳；只作用于 data-app="1" 的页面 */
.app-tabbar { display: none; }

@media (max-width: 900px) {
  html[data-app="1"] body {
    padding-bottom: calc(62px + env(safe-area-inset-bottom));
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
  }

  html[data-app="1"] .topbar {
    position: sticky;
    top: 0;
    z-index: 90;
    background: rgba(255, 255, 255, 0.88);
    -webkit-backdrop-filter: saturate(180%) blur(16px);
    backdrop-filter: saturate(180%) blur(16px);
    border-bottom: 1px solid var(--border-color, #e6e7f3);
  }
  html[data-theme="dark"][data-app="1"] .topbar {
    background: rgba(15, 18, 34, 0.88);
  }

  html[data-app="1"] .nav-toggle,
  html[data-app="1"] .top-nav,
  html[data-app="1"] .menu-toggle { display: none !important; }

  html[data-app="1"] .main-area { padding-bottom: calc(84px + env(safe-area-inset-bottom)) !important; }

  html[data-app="1"] .app-tabbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 95;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 2px;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    background: rgba(255, 255, 255, 0.94);
    -webkit-backdrop-filter: saturate(180%) blur(18px);
    backdrop-filter: saturate(180%) blur(18px);
    border-top: 1px solid var(--border-color, #e6e7f3);
    box-shadow: 0 -8px 24px rgba(30, 27, 75, 0.06);
  }
  html[data-theme="dark"][data-app="1"] .app-tabbar {
    background: rgba(15, 18, 34, 0.94);
    border-top-color: rgba(255, 255, 255, 0.08);
  }
  html[data-app="1"] .app-tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-height: 48px;
    padding: 4px 0 2px;
    border-radius: 14px;
    color: var(--text-light, #6b7194);
    font-size: 10px;
    font-weight: 600;
    line-height: 1;
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    transition: color 0.15s ease, transform 0.12s ease;
  }
  html[data-app="1"] .app-tab svg { width: 22px; height: 22px; }
  html[data-app="1"] .app-tab.active { color: var(--primary-color, #2F6BFF); }
  html[data-app="1"] .app-tab.active svg { transform: translateY(-1px); }
  html[data-app="1"] .app-tab:active { transform: scale(0.92); }

  /* 触摸反馈 */
  html[data-app="1"] a,
  html[data-app="1"] button { touch-action: manipulation; }
  html[data-app="1"] .stat-card,
  html[data-app="1"] .tool-card,
  html[data-app="1"] .nav-tab,
  html[data-app="1"] .btn-auth,
  html[data-app="1"] .btn-save,
  html[data-app="1"] .stat-card-action { transition: transform 0.12s ease; }
  html[data-app="1"] .stat-card:active,
  html[data-app="1"] .tool-card:active,
  html[data-app="1"] .nav-tab:active,
  html[data-app="1"] .btn-auth:active,
  html[data-app="1"] .btn-save:active,
  html[data-app="1"] .stat-card-action:active { transform: scale(0.97); }

  /* 手机端弹窗改为底部抽屉 */
  html[data-app="1"] .modal-overlay { align-items: flex-end; }
  html[data-app="1"] .modal {
    width: 100% !important;
    max-width: none !important;
    max-height: 88vh;
    overflow-y: auto;
    border-radius: 22px 22px 0 0 !important;
    padding-bottom: env(safe-area-inset-bottom);
    animation: appSheetIn 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
  }

  html[data-app="1"] .app-install {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: calc(70px + env(safe-area-inset-bottom));
    z-index: 94;
    display: none;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 16px;
    background: #14162e;
    color: #fff;
    box-shadow: 0 12px 30px rgba(15, 18, 34, 0.28);
    font-size: 13px;
  }
  html[data-app="1"] .app-install.show { display: flex; }
  html[data-app="1"] .app-install button {
    margin-left: auto;
    border: 0;
    border-radius: 10px;
    padding: 8px 12px;
    background: #2F6BFF;
    color: #fff;
    font-size: 13px;
    font-weight: 700;
  }
  html[data-app="1"] .app-install .close {
    background: transparent;
    color: rgba(255, 255, 255, 0.7);
    padding: 4px 6px;
    font-size: 16px;
  }
}

@keyframes appSheetIn {
  from { transform: translateY(24px); opacity: 0.5; }
  to { transform: translateY(0); opacity: 1; }
}

/* 页面切换过渡（支持的浏览器自动生效） */
@view-transition { navigation: auto; }
::view-transition-old(root) { animation: appPageOut 0.14s ease both; }
::view-transition-new(root) { animation: appPageIn 0.2s ease both; }
@keyframes appPageOut { to { opacity: 0; transform: translateY(-4px); } }
@keyframes appPageIn { from { opacity: 0; transform: translateY(6px); } }
