/* ===========================
   MOBILE STYLES — APP-LIKE
   Max-width: 899px
   =========================== */

@media (max-width: 899px) {

  /* ===== Show mobile elements ===== */
  .mobile-menu-trigger {
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: transparent;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    border-radius: 8px;
    flex-shrink: 0;
  }

  .mobile-menu-trigger svg {
    width: 22px;
    height: 22px;
  }

  .mobile-search-trigger {
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: transparent;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    border-radius: 8px;
    flex-shrink: 0;
  }

  .mobile-search-trigger svg {
    width: 20px;
    height: 20px;
  }

  .mobile-drawer {
    display: block !important;
  }

  .mobile-bottom-nav {
    display: flex !important;
  }

  /* ===== Hide desktop elements ===== */
  .sidebar,
  .toc,
  .header-nav,
  .search-trigger,
  .logo-separator,
  .logo-docs {
    display: none !important;
  }

  /* ===== Body ===== */
  body {
    font-size: 14px;
    padding-bottom: 80px; /* Bottom nav space */
  }

  /* ===== Layout ===== */
  .docs-layout,
  .docs-layout.no-toc {
    display: block;
    grid-template-columns: none;
  }

  /* ===== Header ===== */
  .header {
    position: sticky;
    top: 0;
    background: rgba(10, 10, 10, 0.85);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-bottom: 1px solid var(--border-subtle);
    z-index: 100;
    height: 56px;
  }

  [data-theme="light"] .header {
    background: rgba(255, 255, 255, 0.85);
  }

  .header-inner {
    height: 100%;
    padding: 0 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
  }

  .header-left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
  }

  .logo {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 1.125rem;
    letter-spacing: 0.04em;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-primary);
    white-space: nowrap;
  }

  .logo-mark-img {
    width: 24px;
    height: 24px;
  }

  .header-right {
    display: flex;
    align-items: center;
    gap: 0.25rem;
  }

  /* GitHub icon hide on small screens */
  .header-right a.btn-icon[href*="github"] {
    display: none;
  }

  /* ===== Mobile Drawer ===== */
  .mobile-drawer {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 85%;
    max-width: 320px;
    background: var(--bg-primary);
    z-index: 200;
    transform: translateX(-100%);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    overflow-y: auto;
    border-right: 1px solid var(--border-subtle);
    padding-bottom: 2rem;
  }

  .mobile-drawer.open {
    transform: translateX(0);
  }

  .mobile-drawer-header {
    position: sticky;
    top: 0;
    background: var(--bg-primary);
    padding: 1rem;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 1;
  }

  .mobile-drawer-content {
    padding: 1.5rem 1rem;
  }

  .mobile-drawer-section {
    margin-bottom: 1.5rem;
  }

  .mobile-drawer-section-title {
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 0.75rem;
    padding: 0 0.5rem;
  }

  .mobile-drawer-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    border-radius: 10px;
    color: var(--text-secondary);
    font-size: 0.9375rem;
    transition: background 0.2s ease;
  }

  .mobile-drawer-item:active {
    background: var(--bg-hover);
  }

  .mobile-drawer-item.active {
    background: var(--bg-hover);
    color: var(--text-primary);
    font-weight: 500;
  }

  .mobile-drawer-item svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
  }

  /* ===== Main Content ===== */
  .main-content {
    padding: 1.5rem 1rem 2rem;
    max-width: 100%;
  }

  /* ===== HERO SECTION FIXES ===== */
  .main-content h1 {
    font-size: 2.25rem !important;
    line-height: 1.1;
  }

  .main-content h2 {
    font-size: 1.75rem !important;
  }

  .main-content > section:first-child p {
    font-size: 1rem !important;
  }

  /* ===== Card Grid ===== */
  .card-grid {
    display: flex !important;
    flex-direction: column;
    gap: 0.875rem;
    margin-top: 1.5rem;
    grid-template-columns: none !important;
  }

  .card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: 14px;
    padding: 1.25rem;
    transition: transform 0.15s ease;
    -webkit-tap-highlight-color: transparent;
    display: block;
  }

  .card:active {
    transform: scale(0.98);
    background: var(--bg-tertiary);
  }

  .card-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.875rem;
    color: var(--text-secondary);
  }

  .card-icon svg {
    width: 18px;
    height: 18px;
  }

  .product-logo-card {
    width: 28px;
    height: 28px;
  }

  .card-title {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 1.25rem;
    color: var(--text-primary);
    margin-bottom: 0.375rem;
  }

  .card-description {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    line-height: 1.55;
    margin-bottom: 0.75rem;
  }

  .card-footer {
    display: flex;
    align-items: center;
    font-size: 0.75rem;
    color: var(--text-tertiary);
  }

  .card-arrow {
    margin-left: auto;
    width: 14px;
    height: 14px;
  }

  /* ===== STATS SECTION FIX ===== */
  .main-content section[style*="grid-template-columns"] {
    padding: 1.5rem !important;
  }

  .main-content section > div[style*="grid"] {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 1.25rem !important;
  }

  .main-content section > div[style*="grid"] > div > div:first-child {
    font-size: 1.875rem !important;
  }

  /* ===== Article Actions ===== */
  .article-actions {
    display: flex;
    gap: 0.5rem;
    padding: 0.875rem 0;
    border-top: 1px solid var(--border-subtle);
    border-bottom: 1px solid var(--border-subtle);
    margin: 1.5rem 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* ===== Pagination ===== */
  .pagination {
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
    margin: 2rem 0;
  }

  .pagination-link {
    display: flex;
    flex-direction: column;
    padding: 1rem 1.125rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
  }

  .pagination-label {
    font-size: 0.6875rem;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 0.25rem;
  }

  .pagination-title {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 1rem;
    color: var(--text-primary);
  }

  /* ===== Feedback ===== */
  .feedback {
    padding: 1.5rem 1.25rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: 14px;
    margin: 1.5rem 0;
    text-align: center;
  }

  .feedback-question {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 1.125rem;
    color: var(--text-primary);
    margin-bottom: 0.875rem;
  }

  .feedback-emojis {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    flex-wrap: wrap;
  }

  .emoji-btn {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    font-size: 1.5rem;
    cursor: pointer;
    transition: transform 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
  }

  .emoji-btn:active {
    transform: scale(0.9);
  }

  /* ===== Bottom Tab Navigation ===== */
  .mobile-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 64px;
    background: rgba(10, 10, 10, 0.92);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-top: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-around;
    z-index: 100;
    padding-bottom: env(safe-area-inset-bottom, 0);
  }

  [data-theme="light"] .mobile-bottom-nav {
    background: rgba(255, 255, 255, 0.92);
  }

  .bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    padding: 0.5rem 0.5rem;
    color: var(--text-tertiary);
    font-size: 0.6875rem;
    transition: color 0.2s ease;
    -webkit-tap-highlight-color: transparent;
    flex: 1;
    min-width: 0;
  }

  .bottom-nav-item span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
  }

  .bottom-nav-item svg {
    width: 22px;
    height: 22px;
    transition: transform 0.2s ease;
    flex-shrink: 0;
  }

  .bottom-nav-item.active {
    color: var(--text-primary);
  }

  .bottom-nav-item.active svg {
    transform: scale(1.1);
  }

  .bottom-nav-item:active svg {
    transform: scale(0.85);
  }

  /* ===== Modal Mobile ===== */
  .modal {
    max-width: calc(100% - 2rem);
    padding: 1.5rem;
    border-radius: 18px;
  }

  /* ===== Toast Mobile ===== */
  .toast {
    bottom: 5.5rem;
    left: 1rem;
    right: 1rem;
    transform: translateY(100px);
    max-width: none;
  }

  .toast.show {
    transform: translateY(0);
  }

  /* ===== Search Overlay Mobile ===== */
  .search-overlay {
    padding-top: 0;
    background: var(--bg-primary);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    align-items: stretch;
    flex-direction: column;
  }

  .search-overlay-header {
    max-width: none;
    border-radius: 0;
    border: none;
    border-bottom: 1px solid var(--border-subtle);
    box-shadow: none;
    background: var(--bg-primary);
    padding: 1rem;
    transform: none !important;
    opacity: 1 !important;
  }

  /* ===== Breadcrumbs Mobile ===== */
  .breadcrumbs {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.75rem;
    color: var(--text-tertiary);
    margin-bottom: 1rem;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
  }

  .breadcrumbs svg {
    width: 10px;
    height: 10px;
  }

  /* ===== Page Header Mobile ===== */
  .page-header {
    margin-bottom: 1.5rem;
  }

  .page-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 0.75rem;
    font-size: 0.75rem;
    color: var(--text-tertiary);
  }

  .page-meta-item {
    display: flex;
    align-items: center;
    gap: 0.25rem;
  }

  .page-meta-item svg {
    width: 12px;
    height: 12px;
  }
}

/* Extra small phones */
@media (max-width: 380px) {
  .main-content {
    padding: 1.25rem 0.875rem 2rem;
  }

  .main-content h1 {
    font-size: 1.875rem !important;
  }

  .bottom-nav-item {
    font-size: 0.625rem;
    padding: 0.5rem 0.25rem;
  }

  .bottom-nav-item svg {
    width: 20px;
    height: 20px;
  }

  .header-inner {
    gap: 0.25rem;
  }
}