/* responsive.css — consolidated responsive overrides */
/* ---------- responsive ---------- */
.only-mobile { display: none !important; }
@media (max-width: 1000px) {
  .search { width: 130px; }
  .pb-prog { width: 90px; }
}
/* ---------- mobile bottom navigation ---------- */
.mobile-nav { display: none; }

@media (max-width: 820px) {
  :root {
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
    --safe-right: env(safe-area-inset-right, 0px);
    --top: calc(52px + var(--safe-top));
    --player: 54px;
  }
  .only-desktop { display: none !important; }
  .only-mobile { display: inline-flex !important; }

  /* Mobile Slide-Over Sidebar Drawer */
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; width: 280px; max-width: 85vw;
    padding-top: var(--safe-top);
    padding-bottom: max(16px, var(--safe-bottom));
    transform: translateX(-100%);
    box-shadow: 0 10px 40px rgba(0,0,0,0.65); z-index: 150;
    transition: transform .26s cubic-bezier(0.16, 1, 0.3, 1);
    background: var(--bg2);
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }
  body.nav-open .sidebar { transform: translateX(0); }
  body.nav-open .scrim {
    display: block; position: fixed; inset: 0; background: rgba(0,0,0,.68);
    backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px); z-index: 140;
  }
  body.nav-collapsed .sidebar { width: 280px; }

  /* Mobile Topbar & Safe Areas */
  .topbar {
    padding-top: var(--safe-top);
    padding-left: max(8px, var(--safe-left));
    padding-right: max(8px, var(--safe-right));
    height: var(--top);
    gap: 6px;
  }
  .search, .search-box { display: none !important; }
  #btn-install, #btn-lock { display: none !important; }
  
  /* Touch target expansion (Fitts' Law: min 44px hit area) */
  .topbar-row .icon-btn {
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
  }
  .topbar-sync-btn {
    height: 36px;
    min-height: 44px;
    padding: 0 10px;
    gap: 0;
    touch-action: manipulation;
  }
  .topbar-sync-btn #sync-badge { display: none !important; }
  .pastebar { min-height: 38px; padding: 0 4px 0 8px; }

  /* Mobile App Bottom Navigation Bar (Thumb Zone) */
  .mobile-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(54px + var(--safe-bottom));
    padding-bottom: max(var(--safe-bottom), 4px);
    background: color-mix(in srgb, var(--panel) 96%, transparent);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--line);
    z-index: 100;
    align-items: center;
    justify-content: space-around;
  }
  .mobile-nav-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    flex: 1;
    height: 100%;
    min-height: 48px;
    min-width: 48px;
    background: transparent;
    border: none;
    color: var(--tx3);
    cursor: pointer;
    transition: color .15s ease, transform .1s ease;
    padding: 4px 0;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
  }
  .mobile-nav-btn:hover { color: var(--tx); }
  .mobile-nav-btn.active { color: var(--accent-text, color-mix(in srgb, var(--accent) 70%, #fff 30%)); }
  .mobile-nav-btn:active { transform: scale(0.92); }
  .mobile-nav-ico { font-size: 19px; line-height: 1; }
  .mobile-nav-lbl { font-size: 11px; font-weight: 600; letter-spacing: .02em; }

  /* Layout adjustments for mobile bottom bar */
  .statusbar { display: none !important; }
  .playerbar {
    bottom: calc(54px + var(--safe-bottom)) !important;
  }
  .main {
    padding-bottom: calc(var(--player) + 74px + var(--safe-bottom)) !important;
  }
  .toasts {
    bottom: calc(66px + var(--player) + var(--safe-bottom)) !important;
  }

  /* Sync Dropdown Popover on Mobile */
  .sync-popover {
    left: 8px !important;
    right: 8px !important;
    width: auto !important;
    max-width: none !important;
    top: calc(var(--top) + 6px) !important;
  }

  /* Settings on Mobile */
  .settings-nav {
    padding: 4px;
    gap: 4px;
    border-radius: 12px;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    overscroll-behavior-x: contain;
  }
  .settings-tab-btn {
    padding: 9px 14px;
    font-size: 12.5px;
    gap: 6px;
    min-height: 44px;
    touch-action: manipulation;
  }
  .settings-tab-icon { font-size: 14px; }
  .settings-card { padding: 14px 12px; gap: 12px; }
  .sync-hero-card { padding: 14px 12px; }
  .storage-kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .storage-kpi-val { font-size: 17px; }

  .page { padding: 10px 10px 24px; }
  .vgrid { grid-template-columns: repeat(auto-fill, minmax(158px, 1fr)); gap: 8px; }
  .vrow {
    grid-auto-columns: 178px;
    touch-action: pan-y;
    overscroll-behavior-x: contain;
  }
  .vcard-title { font-size: 12.2px; }
  .hero { gap: 8px; }
  .kpi-v { font-size: 1.15rem; }
  .chart-grid, .set-grid-cards, .focus-grid { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .set-grid { grid-template-columns: 1fr; }
  .page-h { flex-wrap: wrap; padding: 10px 12px; }
  .toolbar { gap: 8px; padding: 6px 8px; }
  .tb-pills {
    width: 100%;
    overflow-x: auto;
    padding-bottom: 2px;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    overscroll-behavior-x: contain;
  }
  .tb-search-wrap { flex: 1 1 140px; }
  .tb-search-input { width: 100%; font-size: 16px !important; }
  .tb-search-input:focus { width: 100%; }
  .tb-control { flex: 1 1 120px; }
  .tb-control .tb-select { width: 100%; font-size: 16px !important; }
  .tb-right { width: 100%; margin-left: 0; justify-content: flex-end; }
  
  /* Playerbar Touch Ergonomics */
  .playerbar { padding: 0 7px; gap: 6px; }
  .pb-thumb { width: 54px; }
  .pb-b {
    position: relative;
    width: 32px;
    height: 32px;
    font-size: 14px;
    touch-action: manipulation;
  }
  .pb-b::after {
    content: '';
    position: absolute;
    inset: -6px;
    min-width: 44px;
    min-height: 44px;
  }
  .pb-b.play {
    width: 36px;
    height: 36px;
  }
  .pb-b.play::after {
    inset: -4px;
    min-width: 44px;
    min-height: 44px;
  }
  .pb-prog, .pb-time { display: none; }
  .selbar { bottom: calc(var(--player) + 60px); padding: 5px 8px; gap: 5px; justify-content: flex-start; max-width: calc(100vw - 16px); }
  .selbar .btn { padding: 0 8px; font-size: 11.5px; min-height: 36px; }
  .shelves-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
  .pl-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
  .pomo-ring { width: 160px; height: 160px; }
  .pomo-time { font-size: 2.1rem; }
}

@media (max-width: 680px) {
  .pb-secondary:not(.speed-btn) { display: none !important; }
  .pb-time { font-size: 11px; }
  .pb-thumb { width: 48px; }
  .shelf-select-wrap, #btn-sync { display: none !important; }
  .speed-popover {
    width: calc(100vw - 20px) !important;
    left: 10px !important;
    bottom: calc(var(--player) + 8px) !important;
  }

  /* Native Mobile Bottom Sheet Dialogs */
  .backdrop {
    display: flex !important;
    align-items: flex-end !important;
    justify-content: center !important;
    padding: 0 !important;
  }
  .modal {
    width: 100% !important;
    max-width: 100% !important;
    max-height: 88dvh !important;
    border-radius: 20px 20px 0 0 !important;
    border-bottom: none !important;
    padding-bottom: max(16px, env(safe-area-inset-bottom, 0px)) !important;
    transform: translateY(100%) !important;
    transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s ease !important;
    will-change: transform;
  }
  .backdrop.in .modal {
    transform: translateY(0) !important;
  }
  .modal::before {
    content: '';
    display: block;
    width: 38px;
    height: 4px;
    border-radius: 999px;
    background: var(--line2);
    margin: 10px auto 4px auto;
    flex: none;
  }
  .modal-h { padding: 8px 15px 12px; }
  .modal-b { padding: 12px 15px; }
  .modal-f { padding: 12px 15px; }
}

@media (max-width: 480px) {
  .q-thumb-wrap { width: 72px; height: 41px; }
  .q-title { font-size: 12px; }
  .speed-grid { grid-template-columns: repeat(4, 1fr); }
  .vgrid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
  .vcard-body { padding: 6px 7px 8px; }
  .vcard-title { font-size: 11.6px; -webkit-line-clamp: 2; line-clamp: 2; }
  .vcard-meta { font-size: 10.2px; }
  .pastebar { min-height: 36px; max-height: 132px; padding: 0 4px 0 8px; }
  .paste-input { font-size: 16px !important; padding: 7px 0; }
  .paste-ico { display: none; }
  .page { padding: 8px 8px 20px; }
  .ph-thumb { width: 62px; }
  .goal-wrap { gap: 10px; }
}

@media (hover: none) {
  .vcard-play { opacity: .92; width: 36px; height: 36px; }
  .vcard-sel, .vcard-menu { opacity: .9; }
  .sec-a { opacity: 1; }
  .vcard:active, .btn:active, .card:active, .q-row:active {
    transform: scale(0.98);
    transition: transform 0.05s ease;
  }
  .icon-btn:active {
    transform: scale(0.90);
  }
}

@media print {
  .sidebar, .topbar, .playerbar, .statusbar, .mobile-nav { display: none !important; }
}
