/* ==========================================================================
   SALAM — Dedicated Mobile-App Experience (< 1024px)
   100% scoped to @media (max-width: 1023px) so Desktop (>= 1024px) is untouched.
   ========================================================================== */

@media (max-width: 1023px) {
  :root {
    --mob-top-bar-h: 56px;
    --mob-bottom-nav-h: 64px;
  }

  body {
    -webkit-tap-highlight-color: transparent;
    overscroll-behavior-y: contain;
  }

  /* Respect notch & status bar */
  .app-header {
    height: calc(var(--mob-top-bar-h) + env(safe-area-inset-top, 0px));
    padding: env(safe-area-inset-top, 0px) 0.9rem 0;
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border-bottom: 1px solid var(--border-subtle);
  }

  [data-theme="dark"] .app-header {
    background: rgba(5, 24, 19, 0.88);
  }

  .mobile-logo {
    width: 34px;
    height: 34px;
    border-radius: 10px;
  }

  .mobile-brand-name {
    font-size: 0.95rem;
    letter-spacing: 0.04em;
  }

  .mobile-brand-trigger {
    min-width: 0;
    flex: 1;
    overflow: hidden;
  }

  .mobile-brand-trigger > div:last-child {
    min-width: 0;
    flex: 1;
    overflow: hidden;
  }

  .mobile-hijri-sub {
    font-size: 0.66rem;
    display: block;
    width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Ensure embedded desktop auth/settings cards never overflow 360-390px mobile screens */
  .mob-screen .card,
  .mob-screen form {
    max-width: 100%;
    min-width: 0;
  }

  .mob-screen .seg-tabs,
  .mob-screen .auth-mode-tabs,
  .mob-screen [role="tablist"] {
    flex-wrap: wrap;
    max-width: 100%;
  }

  /* Compact icon buttons in mobile top bar (Profile lives in Bottom Nav!) */
  #header-btn-profile,
  #header-btn-install {
    display: none;
  }

  .location-pill-btn {
    padding: 0.34rem 0.65rem;
    font-size: 0.72rem;
    border-radius: 999px;
  }

  .icon-action-btn {
    width: 36px;
    height: 36px;
    border-radius: 12px;
  }

  /* Main content spacing for bottom nav + safe area */
  .app-main-wrapper {
    padding-bottom: calc(var(--mob-bottom-nav-h) + env(safe-area-inset-bottom, 0px) + 1.25rem);
  }

  .app-content {
    padding: 0.85rem 0.9rem 1.5rem;
  }

  /* Persistent 5-Tab Native Bottom Navigation */
  .mobile-bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 45;
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--border-subtle);
    padding: 0.35rem 0.5rem calc(0.35rem + env(safe-area-inset-bottom, 0px));
    box-shadow: 0 -6px 24px rgba(0, 0, 0, 0.06);
  }

  [data-theme="dark"] .mobile-bottom-nav {
    background: rgba(5, 24, 19, 0.94);
    box-shadow: 0 -6px 24px rgba(0, 0, 0, 0.35);
  }

  .mobile-nav-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0.15rem;
    max-width: 560px;
    margin: 0 auto;
  }

  .mobile-nav-btn {
    min-height: 48px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.2rem;
    padding: 0.25rem 0.15rem;
    border-radius: 14px;
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--text-muted);
    transition: transform 0.12s ease, color 0.15s ease;
    touch-action: manipulation;
  }

  .mobile-nav-btn:active {
    transform: scale(0.93);
  }

  .mobile-nav-btn.active {
    color: var(--emerald-700);
    font-weight: 700;
  }

  [data-theme="dark"] .mobile-nav-btn.active {
    color: var(--gold-300);
  }

  .mobile-nav-icon-pill {
    width: 44px;
    height: 28px;
    border-radius: 999px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.18s ease;
  }

  .mobile-nav-icon-pill svg {
    width: 19px;
    height: 19px;
  }

  .mobile-nav-btn.active .mobile-nav-icon-pill {
    background: rgba(16, 185, 129, 0.15);
    color: var(--emerald-700);
  }

  [data-theme="dark"] .mobile-nav-btn.active .mobile-nav-icon-pill {
    background: rgba(212, 175, 55, 0.2);
    color: var(--gold-300);
  }

  /* Compact Floating Mini Audio Player above Bottom Nav */
  .audio-player-dock {
    bottom: calc(var(--mob-bottom-nav-h) + env(safe-area-inset-bottom, 0px) + 0.5rem);
    width: calc(100% - 1rem);
    border-radius: 18px;
    padding: 0.6rem 0.85rem 0.55rem;
    z-index: 44;
  }

  /* Smooth Native Screen Entrance */
  @keyframes mobScreenEnter {
    from {
      opacity: 0;
      transform: translateY(8px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }

  .mob-screen {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    animation: mobScreenEnter 0.22s cubic-bezier(0.22, 1, 0.36, 1);
  }

  /* Mobile Greeting & Header */
  .mob-greeting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
  }

  .mob-greeting-title {
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: -0.01em;
    line-height: 1.2;
  }

  .mob-greeting-date {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 2px;
  }

  /* Next Prayer Hero Card */
  .mob-hero-prayer {
    border-radius: 22px;
    padding: 1.15rem 1.2rem;
    background: linear-gradient(145deg, #064e3b 0%, #0f766e 72%, #b89225 160%);
    color: #ffffff;
    box-shadow: 0 14px 30px rgba(6, 78, 59, 0.22);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
  }

  .mob-hero-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
  }

  .mob-hero-eyebrow {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--gold-200);
  }

  .mob-hero-prayer-name {
    font-size: 1.6rem;
    font-weight: 800;
    line-height: 1.15;
    margin-top: 0.15rem;
  }

  .mob-hero-countdown {
    font-family: var(--font-mono);
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--gold-300);
    text-align: right;
  }

  .mob-hero-time {
    font-size: 0.78rem;
    color: rgba(255, 255, 255, 0.85);
    text-align: right;
  }

  .mob-progress-track {
    width: 100%;
    height: 6px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.2);
    overflow: hidden;
  }

  .mob-progress-fill {
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--gold-300), #ffffff);
    transition: width 0.5s ease;
  }

  /* Today's 5 Prayer Pills Strip */
  .mob-prayer-strip {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0.4rem;
  }

  .mob-prayer-pill {
    padding: 0.55rem 0.25rem;
    border-radius: 14px;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.18rem;
    min-height: 62px;
    justify-content: center;
    transition: transform 0.12s ease, border-color 0.15s ease;
  }

  .mob-prayer-pill:active {
    transform: scale(0.95);
  }

  .mob-prayer-pill.is-next {
    border-color: var(--gold-400);
    background: rgba(212, 175, 55, 0.12);
  }

  .mob-prayer-pill.is-prayed {
    border-color: #10b981;
    background: rgba(16, 185, 129, 0.1);
  }

  .mob-prayer-pill-name {
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--text-muted);
  }

  .mob-prayer-pill-time {
    font-size: 0.72rem;
    font-weight: 800;
    color: var(--text-primary);
  }

  .mob-prayer-pill-check {
    font-size: 0.66rem;
    font-weight: 700;
    color: #10b981;
  }

  /* Native Mobile Cards & List Rows */
  .mob-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 18px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.03);
  }

  .mob-section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
  }

  .mob-section-title {
    font-size: 0.96rem;
    font-weight: 800;
  }

  .mob-link-btn {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text-gold);
    padding: 0.25rem 0.45rem;
  }

  .mob-list-group {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 18px;
    overflow: hidden;
  }

  .mob-list-row {
    width: 100%;
    min-height: 54px;
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border-subtle);
    transition: background 0.14s ease;
  }

  .mob-list-row:last-child {
    border-bottom: none;
  }

  .mob-list-row:active {
    background: var(--bg-surface-alt);
  }

  .mob-row-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
  }

  .mob-row-icon {
    width: 36px;
    height: 36px;
    border-radius: 11px;
    background: var(--bg-surface-alt);
    color: var(--text-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
  }

  /* Segmented Control Pills */
  .mob-segmented {
    display: flex;
    gap: 0.4rem;
    overflow-x: auto;
    padding-bottom: 0.15rem;
    scrollbar-width: none;
  }

  .mob-segmented::-webkit-scrollbar {
    display: none;
  }

  .mob-seg-btn {
    flex-shrink: 0;
    min-height: 38px;
    padding: 0.4rem 0.9rem;
    border-radius: 999px;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-secondary);
  }

  .mob-seg-btn.active {
    background: var(--emerald-700);
    border-color: var(--emerald-700);
    color: #ffffff;
  }

  /* Dedicated Mobile Quran Toolbar */
  .mob-quran-toolbar {
    position: sticky;
    top: calc(var(--mob-top-bar-h) + env(safe-area-inset-top, 0px) + 0.35rem);
    z-index: 25;
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid var(--border-subtle);
    border-radius: 16px;
    padding: 0.55rem 0.7rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.06);
  }

  [data-theme="dark"] .mob-quran-toolbar {
    background: rgba(9, 32, 26, 0.94);
  }

  .mob-ayah-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 18px;
    padding: 1rem 1rem 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
  }

  /* Native Bottom Sheet Modal */
  .mob-sheet-backdrop {
    position: fixed;
    inset: 0;
    z-index: 70;
    background: rgba(2, 18, 14, 0.6);
    backdrop-filter: blur(3px);
    display: flex;
    align-items: flex-end;
    justify-content: center;
  }

  .mob-sheet-backdrop.hidden {
    display: none;
  }

  .mob-bottom-sheet {
    width: 100%;
    max-width: 560px;
    max-height: 82vh;
    background: var(--bg-surface);
    border-top-left-radius: 24px;
    border-top-right-radius: 24px;
    padding: 0.75rem 1rem calc(1.25rem + env(safe-area-inset-bottom, 0px));
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    overflow-y: auto;
    animation: mobSheetUp 0.22s ease;
  }

  @keyframes mobSheetUp {
    from {
      transform: translateY(28px);
      opacity: 0.7;
    }
    to {
      transform: translateY(0);
      opacity: 1;
    }
  }

  .mob-sheet-handle {
    width: 40px;
    height: 4px;
    border-radius: 999px;
    background: var(--border-strong);
    margin: 0 auto 0.25rem;
  }
}
