/* ============================================================
   FatakNews — Mobile UI layer
   Loaded on every page; active only at <=768px viewport.
   Desktop (>768px) is completely unaffected.
   ============================================================ */

:root {
  /* FatakNews design tokens — 70% light / 20% navy / 10% red */
  --m-bg:        #f1f5f9;  /* light gray page */
  --m-surface:   #ffffff;  /* cards, nav */
  --m-surface-2: #f1f5f9;  /* inputs, inactive chips, dividers zone */
  --m-elevated:  #ffffff;
  --m-text:      #0f172a;  /* primary navy — headlines, nav */
  --m-text-2:    #1e293b;  /* secondary navy — subheads, supporting */
  --m-text-3:    #64748b;  /* gray — metadata, timestamps, views */
  --m-border:    #e2e8f0;
  --m-accent:    #e41e26;  /* FatakNews red — accent only */
  --m-accent-ink:#ffffff;
  --m-accent-soft:#fef2f2;
  --m-success:   #16a34a;
  --m-warning:   #f59e0b;
  --m-error:     #dc2626;
  --m-shadow:    0 1px 2px rgba(15,23,42,.04), 0 6px 20px rgba(15,23,42,.06);
  --m-shadow-sm: 0 1px 3px rgba(15,23,42,.07);
  --m-radius:    14px;
  --m-radius-sm: 10px;
  --m-pad:       16px;
  --m-topbar-h:  56px;
  --m-bottomnav-h: 60px;
  --m-safe-b:    env(safe-area-inset-bottom, 0px);
  --m-font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

:root[data-theme="dark"] {
  --m-bg:        #0f172a;
  --m-surface:   #1e293b;
  --m-surface-2: #273449;
  --m-elevated:  #1e293b;
  --m-text:      #ffffff;
  --m-text-2:    #cbd5e1;
  --m-text-3:    #94a3b8;
  --m-border:    #334155;
  --m-accent:    #e41e26;
  --m-accent-ink:#ffffff;
  --m-accent-soft:#3a1e20;
  --m-shadow:    0 1px 2px rgba(0,0,0,.35), 0 6px 20px rgba(0,0,0,.4);
  --m-shadow-sm: 0 1px 3px rgba(0,0,0,.4);
}

@media (max-width: 768px) {

  /* ---------- reset / base ---------- */
  html, body { background: var(--m-bg); }
  body {
    font-family: var(--m-font);
    color: var(--m-text);
    -webkit-font-smoothing: antialiased;
    padding-bottom: calc(var(--m-bottomnav-h) + var(--m-safe-b));
  }
  body, .m-item-body h3, .news-card-title, .m-hero-body h3, .post-title, .m-topbar-title,
  .m-section-head h2, .m-menu-item, .m-settings-row, .team-card-name, h1, h2, h3, h4 {
    font-family: var(--m-font);
  }
  .page-wrapper { max-width: 100%; padding: 0; margin: 0; display: block; }

  /* ---------- Lucide outline icons (consistent stroke) ---------- */
  svg.lucide { stroke-width: 2; flex: 0 0 auto; }
  .m-iconbtn svg.lucide { width: 22px; height: 22px; }
  .m-bottomnav a svg.lucide { width: 23px; height: 23px; }
  .m-section-head h2 svg.lucide { width: 15px; height: 15px; }
  .m-meta svg.lucide { width: 13px; height: 13px; }
  .m-kicker svg.lucide { width: 12px; height: 12px; }
  .m-catrow > svg.lucide { width: 18px; height: 18px; color: var(--m-text-3); }
  .m-catrow-icon svg.lucide { width: 20px; height: 20px; }
  .m-menu-item svg.lucide, .m-settings-row svg.lucide { width: 19px; height: 19px; }
  .m-menu-item > svg.lucide:last-child, .m-settings-row > svg.lucide:last-child { width: 15px; height: 15px; color: var(--m-text-3); }
  .m-chip svg.lucide { width: 14px; height: 14px; vertical-align: -2px; }
  .post-actions-bar svg.lucide { width: 20px; height: 20px; }
  .m-profile-head svg.lucide { width: 22px; height: 22px; }
  .m-searchbar svg.lucide { width: 18px; height: 18px; color: var(--m-text-3); }

  /* hide desktop chrome */
  .navbar, .ticker-wrap, .site-footer, .sidebar-col, .mobile-nav, .mobile-nav-overlay,
  .home-latest-sidebar, aside.sidebar-col, .home-desktop-only, .mobile-section-bottomnav,
  .d-only, .post-related-shell .post-related-panel > .widget-title ~ * ~ .sidebar-widget {
    display: none !important;
  }
  .home-grid, .post-page { display: block; grid-template-columns: 1fr; gap: 0; padding: 0; margin: 0; }
  .feed-col, .post-main { width: 100%; max-width: 100%; padding: 0; }

  /* ---------- top bar ---------- */
  .m-topbar {
    position: sticky; top: 0; z-index: 900;
    height: var(--m-topbar-h);
    display: flex; align-items: center; gap: 12px;
    padding: 0 14px;
    background: var(--m-surface);
    border-bottom: 1px solid var(--m-border);
  }
  .m-topbar-logo { display: flex; align-items: center; gap: 8px; margin-right: auto; }
  .m-topbar-logo img { width: 30px; height: 30px; object-fit: contain; }
  .m-topbar-logo b { font-size: 17px; font-weight: 800; letter-spacing: -.02em; }
  .m-topbar-logo b span { color: var(--m-accent); }
  .m-topbar-logo small { display: block; font-size: 8px; letter-spacing: .18em; color: var(--m-text-3); text-transform: uppercase; margin-top: 1px; }
  .m-topbar-title { margin-right: auto; font-size: 17px; font-weight: 700; }
  .m-iconbtn {
    width: 38px; height: 38px; flex: 0 0 auto;
    display: flex; align-items: center; justify-content: center;
    border-radius: 50%; border: 0; background: transparent;
    color: var(--m-text); font-size: 17px; position: relative; cursor: pointer;
  }
  .m-iconbtn:active { background: var(--m-surface-2); }
  .m-iconbtn .m-dot {
    position: absolute; top: 6px; right: 6px;
    min-width: 15px; height: 15px; padding: 0 3px;
    border-radius: 999px; background: var(--m-accent); color: var(--m-accent-ink);
    font-size: 9px; font-weight: 700; display: flex; align-items: center; justify-content: center;
    border: 2px solid var(--m-surface);
  }

  /* ---------- bottom nav ---------- */
  .m-bottomnav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 950;
    height: calc(var(--m-bottomnav-h) + var(--m-safe-b));
    padding-bottom: var(--m-safe-b);
    display: flex; background: var(--m-surface);
    border-top: 1px solid var(--m-border);
  }
  .m-bottomnav a {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    color: var(--m-text-3); font-size: 10px; font-weight: 600; text-decoration: none;
  }
  .m-bottomnav a i { font-size: 18px; }
  .m-bottomnav a.active { color: var(--m-accent); }

  /* ---------- generic screen wrapper ---------- */
  .m-screen { padding: 16px; }
  .m-section-head {
    display: flex; align-items: center; justify-content: space-between;
    margin: 20px 16px 10px;
  }
  .m-section-head:first-child { margin-top: 6px; }
  .m-section-head h2 {
    font-size: 13px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase;
    color: var(--m-text-2); display: flex; align-items: center; gap: 7px; margin: 0;
  }
  .m-section-head h2 i { color: var(--m-accent); }
  .m-section-head a { font-size: 12px; font-weight: 600; color: var(--m-accent); text-decoration: none; }

  /* ---------- category chips (horizontal) ---------- */
  .m-chips {
    display: flex; flex-wrap: nowrap; align-items: center;
    gap: 8px; overflow-x: auto; -webkit-overflow-scrolling: touch;
    padding: 10px 16px;
    background: var(--m-surface); border-bottom: 1px solid var(--m-border);
    scrollbar-width: none; position: sticky; top: var(--m-topbar-h); z-index: 800;
  }
  .m-chips::-webkit-scrollbar { display: none; }
  .m-chip {
    flex: 0 0 auto; padding: 7px 14px; border-radius: 999px;
    font-size: 13px; font-weight: 600; line-height: 1; text-decoration: none; white-space: nowrap;
    color: var(--m-text-2); background: var(--m-surface-2); border: 1px solid transparent;
  }
  .m-chip.active { background: var(--m-accent); color: var(--m-accent-ink); }

  /* ---------- stories strip ---------- */
  .m-stories {
    display: flex; gap: 14px; overflow-x: auto; scrollbar-width: none;
    padding: 12px 16px; background: var(--m-surface); border-bottom: 1px solid var(--m-border);
  }
  .m-stories::-webkit-scrollbar { display: none; }
  .m-story { flex: 0 0 auto; width: 60px; display: flex; flex-direction: column; align-items: center; gap: 5px; text-decoration: none; }
  .m-story-ring {
    width: 58px; height: 58px; border-radius: 50%; padding: 2px;
    background: var(--m-border); display: flex; align-items: center; justify-content: center;
  }
  .m-story.is-unseen .m-story-ring { background: linear-gradient(135deg, var(--m-accent), #ff8a3d); }
  .m-story-ring img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; border: 2px solid var(--m-surface); }
  .m-story-name { font-size: 11px; color: var(--m-text-2); max-width: 60px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  /* ---------- hero card ---------- */
  .m-hero {
    display: block; margin: 16px; border-radius: var(--m-radius); overflow: hidden;
    background: var(--m-surface); box-shadow: var(--m-shadow); text-decoration: none; color: inherit;
  }
  .m-hero-media { position: relative; aspect-ratio: 16/10; background: var(--m-surface-2); }
  .m-hero-media img { width: 100%; height: 100%; object-fit: cover; display: block; }
  .m-badge {
    position: absolute; top: 12px; left: 12px;
    padding: 4px 10px; border-radius: 8px; background: var(--m-accent); color: var(--m-accent-ink);
    font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  }
  .m-hero-body { padding: 16px; }
  .m-hero-body h3 { font-size: 18px; line-height: 1.34; font-weight: 700; margin: 0 0 8px; color: var(--m-text); letter-spacing: -.01em; }
  .m-meta { display: flex; align-items: center; gap: 12px; font-size: 12px; color: var(--m-text-3); }
  .m-meta span { display: inline-flex; align-items: center; gap: 4px; }

  /* ---------- list item (restyles shared .news-card too) ---------- */
  .m-list { padding: 0 16px; }
  .m-item, .news-card {
    display: flex; gap: 12px; padding: 12px 0; align-items: flex-start;
    border-bottom: 1px solid var(--m-border); background: transparent; box-shadow: none; border-radius: 0;
    text-decoration: none; color: inherit;
  }
  .m-item:last-child, .news-card:last-child { border-bottom: 0; }
  .m-item-thumb, .news-card > a:first-child, .news-card-img {
    flex: 0 0 auto;
  }
  .m-item-thumb, .news-card-img {
    width: 104px; height: 78px; border-radius: var(--m-radius-sm); object-fit: cover;
    background: var(--m-surface-2);
  }
  .news-card > a:first-child { width: 104px; height: 78px; border-radius: var(--m-radius-sm); overflow: hidden; }
  .news-card > a:first-child .news-card-img { width: 100%; height: 100%; }
  .m-item-body, .news-card > div { flex: 1 1 auto; min-width: 0; }
  .m-kicker, .news-card-cat {
    font-size: 10.5px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase;
    color: var(--m-accent); text-decoration: none; display: block; margin-bottom: 3px;
  }
  .m-item-body h3, .news-card-title {
    font-size: 15px; line-height: 1.4; font-weight: 600; margin: 0 0 6px; color: var(--m-text);
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  }
  .m-item-body h3 a, .news-card-title a { color: var(--m-text); text-decoration: none; }
  .news-card-meta { font-size: 11.5px; color: var(--m-text-3); gap: 8px; }
  .news-card-meta img { display: none; }
  .news-card-actions { display: none; }

  /* rank list (explore) */
  .m-rankitem { display: flex; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--m-border); align-items: flex-start; text-decoration: none; color: inherit; }
  .m-rankitem:last-child { border-bottom: 0; }
  .m-rank-num { flex: 0 0 auto; width: 22px; font-size: 20px; font-weight: 800; color: var(--m-accent); line-height: 1.1; }
  .m-rankitem .m-item-thumb { width: 84px; height: 64px; }

  /* ---------- segmented tabs ---------- */
  .m-segtabs {
    display: flex; gap: 8px; overflow-x: auto; padding: 12px 14px 4px;
    scrollbar-width: none;
  }
  .m-segtabs::-webkit-scrollbar { display: none; }
  .m-segtab {
    flex: 0 0 auto; padding: 7px 15px; border-radius: 999px; font-size: 13px; font-weight: 600;
    color: var(--m-text-2); background: var(--m-surface-2); text-decoration: none; white-space: nowrap;
  }
  .m-segtab.active { background: var(--m-accent); color: var(--m-accent-ink); }

  /* ---------- categories list ---------- */
  .m-catlist { padding: 8px 16px; }
  .m-catrow {
    display: flex; align-items: center; gap: 14px; padding: 14px 12px; margin-bottom: 10px;
    background: var(--m-surface); border: 1px solid var(--m-border); border-radius: var(--m-radius);
    text-decoration: none; color: inherit; box-shadow: var(--m-shadow-sm);
  }
  .m-catrow-icon {
    flex: 0 0 auto; width: 44px; height: 44px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center; font-size: 18px;
    background: var(--m-accent-soft); color: var(--m-accent);
  }
  .m-catrow-body { flex: 1; min-width: 0; }
  .m-catrow-body strong { display: block; font-size: 15px; font-weight: 700; }
  .m-catrow-body span { display: block; font-size: 12px; color: var(--m-text-3); margin-top: 2px; }
  .m-catrow > i.fa-chevron-right, .m-catrow > i.fa-angle-right { color: var(--m-text-3); font-size: 14px; }

  /* ---------- article ---------- */
  .single-post-page .post-page { display: block; }

  /* reorder so the cover image sits at the very top (mockup order) */
  .single-post-page .post-main { display: flex; flex-direction: column; }
  .single-post-page .post-main > * { order: 5; }
  .single-post-page .post-cover,
  .single-post-page .post-cover-fallback { order: 1; }
  .single-post-page .post-header { order: 2; padding-top: 12px; }
  .single-post-page .post-actions-bar { order: 3; }
  .single-post-page .post-content { order: 4; }
  .single-post-page .comments-section { order: 8; }

  /* compact byline — hide the verbose desktop meta, show one clean line */
  .single-post-page .post-meta-bar { display: none; }
  .m-byline {
    display: flex; align-items: center; flex-wrap: wrap; gap: 6px;
    margin-top: 14px; font-size: 13px; color: var(--m-text-3);
  }
  .m-byline img { width: 26px; height: 26px; border-radius: 50%; object-fit: cover; }
  .m-byline a { color: var(--m-text-2); font-weight: 600; }
  .m-byline i { font-style: normal; color: var(--m-text-3); }

  /* action bar — icon + count + label, evenly spaced (mockup) */
  .post-actions-bar .post-action-big {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
    background: transparent; border: 0; padding: 4px 0; color: var(--m-text-2);
    font-size: 11px; font-weight: 600; text-decoration: none;
  }
  .post-actions-bar .post-action-big em { font-style: normal; color: var(--m-text-3); font-size: 11px; }
  .post-actions-bar .post-action-big .react-count,
  .post-actions-bar .post-action-big > span { font-size: 12px; font-weight: 700; color: var(--m-text); }
  .post-actions-bar .post-action-big.is-active { color: var(--m-accent); }
  .post-actions-bar .post-action-big.is-active .react-count { color: var(--m-accent); }
  .m-article-bar {
    position: sticky; top: 0; z-index: 900;
    display: flex; align-items: center; gap: 6px; padding: 0 8px; height: var(--m-topbar-h);
    background: var(--m-surface); border-bottom: 1px solid var(--m-border);
  }
  .m-article-bar .m-iconbtn:nth-child(2) { margin-right: auto; }
  .post-page .post-header { padding: 16px; }
  .post-page .post-cat-badge, .m-article .m-badge-inline {
    display: inline-block; padding: 4px 10px; border-radius: 8px;
    background: var(--m-accent); color: var(--m-accent-ink);
    font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  }
  .post-page .post-title { font-size: 25px; line-height: 1.28; font-weight: 800; margin: 12px 0 12px; color: var(--m-text); letter-spacing: -.02em; }
  .post-page .post-excerpt { font-size: 16px; line-height: 1.6; color: var(--m-text-2); }
  .post-page .post-cover { width: 100%; height: auto; border-radius: 0; margin: 0; }
  .post-page .post-content { padding: 16px; font-size: 16px; line-height: 1.75; }
  .post-page .post-content img { border-radius: var(--m-radius-sm); }
  .post-page .site-breadcrumb { display: none; }
  .post-page .post-meta-bar { flex-direction: column; align-items: flex-start; gap: 8px; margin-top: 12px; }
  .post-actions-bar {
    position: static; z-index: 700;
    display: flex; gap: 6px; padding: 12px; margin: 0;
    background: var(--m-surface);
    border-top: 1px solid var(--m-border); border-bottom: 1px solid var(--m-border);
  }
  .post-actions-bar .post-action-big {
    flex: 1; flex-direction: column; gap: 3px; font-size: 11px; padding: 4px 0;
    background: transparent; border: 0; color: var(--m-text-2);
  }
  .post-actions-bar .post-action-big i { font-size: 17px; }

  /* related grid -> horizontal scroll cards */
  .post-related-shell { padding: 8px 0 4px; }
  .post-related-panel { background: transparent; border: 0; box-shadow: none; padding: 0 14px; }
  .related-posts-grid { display: flex; gap: 12px; overflow-x: auto; scrollbar-width: none; }
  .related-posts-grid::-webkit-scrollbar { display: none; }
  .related-post-card { flex: 0 0 240px; background: var(--m-surface); border: 1px solid var(--m-border); border-radius: var(--m-radius); }

  /* author card */
  .author-card { margin: 14px; border-radius: var(--m-radius); background: var(--m-surface); border-color: var(--m-border); }

  /* ---------- shorts (vertical video feed) ---------- */
  body.shorts-page { padding-bottom: 0; background: #000; }
  .m-shorts { position: relative; background: #000; }
  .m-shorts-back {
    position: fixed; top: 12px; left: 12px; z-index: 20;
    width: 38px; height: 38px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
    background: rgba(0,0,0,.4); color: #fff;
  }
  .m-shorts-title {
    position: fixed; top: 20px; left: 0; right: 0; z-index: 20; text-align: center;
    color: #fff; font-weight: 700; font-size: 16px; pointer-events: none; text-shadow: 0 1px 4px rgba(0,0,0,.5);
  }
  .m-shorts-feed {
    height: calc(100dvh - var(--m-bottomnav-h)); overflow-y: scroll;
    scroll-snap-type: y mandatory; scrollbar-width: none;
  }
  .m-shorts-feed::-webkit-scrollbar { display: none; }
  .m-short {
    position: relative; height: calc(100dvh - var(--m-bottomnav-h));
    scroll-snap-align: start; scroll-snap-stop: always;
    display: flex; align-items: center; justify-content: center; overflow: hidden; background: #000;
  }
  video.m-short-media { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border: 0; display: block; }
  iframe.m-short-media { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
  .m-short-media.m-short-social { object-fit: contain; background: #000; overflow: auto; }
  .m-short-media.m-short-social blockquote { margin: 0 auto; }
  .m-short-link { display: flex; align-items: center; justify-content: center; }
  .m-short-link img { width: 100%; height: 100%; object-fit: cover; }
  .m-short-play {
    position: absolute; width: 64px; height: 64px; border-radius: 50%;
    background: rgba(255,255,255,.15); display: flex; align-items: center; justify-content: center; color: #fff;
  }
  .m-short-play svg.lucide { width: 30px; height: 30px; }
  .m-short-shade {
    position: absolute; inset: 0; pointer-events: none;
    background: linear-gradient(to top, rgba(0,0,0,.7) 0%, rgba(0,0,0,0) 32%, rgba(0,0,0,0) 78%, rgba(0,0,0,.35) 100%);
  }
  .m-short-overlay {
    position: absolute; left: 0; right: 70px; bottom: 16px;
    padding: 0 16px; color: #fff; z-index: 5;
  }
  .m-short-sound {
    position: absolute; top: 14px; right: 14px; z-index: 20;
    width: 40px; height: 40px; border-radius: 50%; border: 0;
    background: rgba(0,0,0,.45); color: #fff; display: flex; align-items: center; justify-content: center;
  }
  .m-short-sound svg.lucide { width: 20px; height: 20px; }
  .m-short-cat {
    display: inline-block; padding: 3px 9px; border-radius: 6px; background: var(--m-accent); color: #fff;
    font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; text-decoration: none; margin-bottom: 8px;
  }
  .m-short-headline { display: block; color: #fff; font-size: 16px; font-weight: 700; line-height: 1.35; text-decoration: none; text-shadow: 0 1px 6px rgba(0,0,0,.6); }
  .m-short-author { display: inline-flex; align-items: center; gap: 8px; margin-top: 10px; color: #fff; text-decoration: none; font-size: 13px; font-weight: 600; }
  .m-short-author img { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; border: 1px solid rgba(255,255,255,.5); }
  .m-short-author svg.lucide { width: 14px; height: 14px; color: #4da3ff; }
  .m-short-actions {
    position: absolute; right: 10px; bottom: 16px; z-index: 6;
    display: flex; flex-direction: column; gap: 14px;
  }
  .m-short-act {
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    background: transparent; border: 0; color: #fff; font-size: 10px; font-weight: 600; text-decoration: none;
    text-shadow: 0 1px 4px rgba(0,0,0,.6);
  }
  .m-short-act svg.lucide { width: 26px; height: 26px; }
  .m-short-act.is-active svg.lucide { color: var(--m-accent); fill: var(--m-accent); }
  .m-shorts-empty {
    height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center;
    color: #fff; text-align: center; padding: 24px;
  }
  .m-shorts-empty svg.lucide { width: 42px; height: 42px; margin-bottom: 14px; opacity: .8; }
  .m-shorts-empty h3 { font-size: 18px; margin-bottom: 6px; }
  .m-shorts-empty p { color: #a0a0ae; font-size: 14px; }

  /* community feed */
  .community-page .feed-col > .site-breadcrumb { display: none; }
  .community-stories-card { margin: 12px 16px !important; padding: 14px !important; }
  .community-create-cta { padding: 0 16px 12px; }
  .community-create-cta .btn-write { width: 100%; justify-content: center; border-radius: 12px; }
  .community-feed { padding: 0 16px; display: flex; flex-direction: column; gap: 14px; }
  .community-card {
    padding: 14px !important; border-radius: var(--m-radius) !important;
    background: var(--m-surface) !important; border: 1px solid var(--m-border) !important; box-shadow: var(--m-shadow-sm) !important;
  }
  .community-card-title a { color: var(--m-text); font-size: 16px; font-weight: 700; }
  .community-card-excerpt { color: var(--m-text-2); font-size: 14px; }
  .community-card-img { border-radius: var(--m-radius-sm); }

  /* explore (social embeds) feed */
  .explore-grid { display: block; padding: 12px 14px; }
  .explore-card {
    margin-bottom: 14px !important; padding: 14px !important; border-radius: var(--m-radius) !important;
    background: var(--m-surface) !important; border: 1px solid var(--m-border) !important; box-shadow: var(--m-shadow-sm) !important;
  }
  .explore-card h2 { font-size: 16px; line-height: 1.35; }
  .explore-card h2 a { color: var(--m-text); }
  .explore-embed img, .explore-embed iframe { border-radius: var(--m-radius-sm); }

  /* ---------- profile ---------- */
  .m-profile-head {
    background: #1c1c24; color: #fff; padding: 22px 18px 20px; border-radius: 0 0 22px 22px;
    display: flex; align-items: center; gap: 14px;
  }
  :root[data-theme="dark"] .m-profile-head { background: #24242e; }
  .m-profile-head img, .m-profile-head .m-avatar-fallback {
    width: 58px; height: 58px; border-radius: 50%; object-fit: cover; background: #33333f;
    display: flex; align-items: center; justify-content: center; font-size: 22px; color: #b8b8c4;
  }
  .m-profile-head .m-profile-id { flex: 1; min-width: 0; }
  .m-profile-head .m-profile-id b { font-size: 17px; font-weight: 700; display: block; }
  .m-profile-head .m-profile-id span { font-size: 12.5px; color: #a9a9b8; }
  .m-profile-head .m-iconbtn { color: #fff; }

  .m-menu { padding: 12px 16px; }
  .m-menu-item {
    display: flex; align-items: center; gap: 14px; padding: 15px 14px; margin-bottom: 8px;
    background: var(--m-surface); border: 1px solid var(--m-border); border-radius: 14px;
    text-decoration: none; color: var(--m-text); font-size: 14.5px; font-weight: 600;
  }
  .m-menu-item > i:first-child { width: 20px; text-align: center; color: var(--m-text-2); font-size: 16px; }
  .m-menu-item .m-menu-label { flex: 1; }
  .m-menu-item .m-menu-label small { display: block; font-size: 11.5px; font-weight: 500; color: var(--m-text-3); margin-top: 1px; }
  .m-menu-item .m-menu-value { font-size: 13px; color: var(--m-text-3); font-weight: 500; }
  .m-menu-item > i.fa-chevron-right { color: var(--m-text-3); font-size: 12px; }
  .m-menu-item .m-dot {
    min-width: 18px; height: 18px; border-radius: 999px; background: var(--m-accent); color: var(--m-accent-ink);
    font-size: 10px; font-weight: 700; display: flex; align-items: center; justify-content: center;
  }

  .m-btn-logout {
    display: block; width: calc(100% - 28px); margin: 12px 14px 20px;
    padding: 14px; border-radius: 14px; border: 0; background: var(--m-accent); color: var(--m-accent-ink);
    font-size: 15px; font-weight: 700; text-align: center; text-decoration: none;
  }

  /* ---------- settings ---------- */
  .m-settings { padding: 12px 16px; }
  .m-settings-group { margin-bottom: 22px; }
  .m-settings-group > h3 {
    font-size: 12px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase;
    color: var(--m-text-3); margin: 0 4px 10px;
  }
  .m-settings-card {
    background: var(--m-surface); border: 1px solid var(--m-border); border-radius: 14px; overflow: hidden;
  }
  .m-settings-row {
    display: flex; align-items: center; gap: 14px; padding: 14px;
    border-bottom: 1px solid var(--m-border); text-decoration: none; color: var(--m-text);
    font-size: 14.5px; font-weight: 600; background: transparent; width: 100%; border-left: 0; border-right: 0; border-top: 0;
  }
  .m-settings-row:last-child { border-bottom: 0; }
  .m-settings-row > i:first-child { width: 20px; text-align: center; color: var(--m-text-2); font-size: 16px; }
  .m-settings-row .m-menu-label { flex: 1; text-align: left; }
  .m-settings-row .m-menu-value { font-size: 13px; color: var(--m-text-3); font-weight: 500; }
  .m-settings-row > i.fa-chevron-right { color: var(--m-text-3); font-size: 12px; }

  /* iOS-style toggle */
  .m-switch { flex: 0 0 auto; width: 46px; height: 28px; position: relative; display: inline-block; }
  .m-switch input { opacity: 0; width: 0; height: 0; }
  .m-switch .m-slider {
    position: absolute; inset: 0; border-radius: 999px; background: var(--m-border);
    transition: background .2s;
  }
  .m-switch .m-slider::before {
    content: ""; position: absolute; width: 22px; height: 22px; left: 3px; top: 3px;
    background: #fff; border-radius: 50%; transition: transform .2s; box-shadow: 0 1px 3px rgba(0,0,0,.3);
  }
  .m-switch input:checked + .m-slider { background: var(--m-accent); }
  .m-switch input:checked + .m-slider::before { transform: translateX(18px); }

  /* ---------- misc shared ---------- */
  .empty-state { padding: 48px 20px; text-align: center; color: var(--m-text-3); }
  .empty-state i { font-size: 30px; margin-bottom: 10px; color: var(--m-text-3); }
  .sidebar-widget, .settings-page, .settings-card {
    background: var(--m-surface); border-color: var(--m-border); border-radius: var(--m-radius);
  }
  .feed-col > .sidebar-widget { margin: 12px 14px !important; padding: 16px !important; }
  .feed-col > .sidebar-widget h1,
  .category-page-title,
  .feed-col h1[style] { font-size: 22px !important; line-height: 1.25 !important; font-family: inherit !important; }
  .feed-col .news-feed, .feed-col .news-list { padding: 0 14px; }
  .category-page-hero, .page-hero { border-radius: var(--m-radius) !important; }
  .pagination { padding: 18px 14px calc(var(--m-bottomnav-h) + 24px); }
  .toast-container { bottom: calc(var(--m-bottomnav-h) + var(--m-safe-b) + 12px); }

  /* ---------- compose (community create) ---------- */
  .m-compose { max-width: 640px; margin: 0 auto; padding: 14px 16px 28px; display: block; }
  .m-compose-user { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
  .m-compose-user img { width: 42px; height: 42px; border-radius: 50%; object-fit: cover; }
  .m-compose-user strong { display: block; font-size: 14px; color: var(--m-text); }
  .m-compose-user span { font-size: 12px; color: var(--m-text-3); }
  .m-compose-title {
    width: 100%; border: 0; background: transparent; outline: none;
    font-family: var(--m-font); font-size: 19px; font-weight: 700; color: var(--m-text);
    padding: 6px 0; border-bottom: 1px solid var(--m-border);
  }
  .m-compose-title::placeholder { color: var(--m-text-3); font-weight: 600; }
  .m-compose-body {
    width: 100%; min-height: 120px; border: 0; background: transparent; outline: none; resize: none;
    font-family: var(--m-font); font-size: 16px; line-height: 1.55; color: var(--m-text); padding: 12px 0;
  }
  .m-compose-body::placeholder { color: var(--m-text-3); }
  .m-compose-panel {
    background: var(--m-surface-2); border: 1px solid var(--m-border); border-radius: 12px;
    padding: 12px; margin-bottom: 10px; display: flex; flex-direction: column; gap: 8px;
  }
  .m-compose-panel input[type="url"], .m-compose-panel input[type="text"] {
    width: 100%; padding: 11px 12px; border: 1px solid var(--m-border); border-radius: 10px;
    background: var(--m-surface); color: var(--m-text); font-size: 14px; font-family: var(--m-font);
  }
  .m-compose-panel input[type="file"] { font-size: 13px; color: var(--m-text-2); }
  .m-compose-check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--m-text-2); font-weight: 500; }
  .m-compose-check input { accent-color: var(--m-accent); }
  .m-compose-preview img { width: 100%; border-radius: 10px; display: block; }
  .m-compose-add {
    display: flex; align-items: center; justify-content: space-between;
    border: 1px solid var(--m-border); border-radius: 12px; padding: 10px 12px; margin: 4px 0 16px;
  }
  .m-compose-add > span { font-size: 13px; font-weight: 600; color: var(--m-text-2); }
  .m-compose-addbtns { display: flex; gap: 6px; }
  .m-compose-addbtns button {
    width: 38px; height: 38px; border-radius: 10px; border: 0; background: var(--m-surface-2);
    color: var(--m-text-2); display: flex; align-items: center; justify-content: center;
  }
  .m-compose-addbtns button.is-on { background: var(--m-accent-soft); color: var(--m-accent); }
  .m-compose-addbtns svg.lucide { width: 19px; height: 19px; }
  .m-compose-actions { display: flex; gap: 10px; }
  .m-compose-post {
    flex: 1; padding: 13px; border-radius: 12px; border: 0;
    background: var(--m-accent); color: var(--m-accent-ink); font-size: 15px; font-weight: 700; font-family: var(--m-font);
  }
  .m-compose-draft {
    padding: 13px 16px; border-radius: 12px; border: 1px solid var(--m-border);
    background: var(--m-surface); color: var(--m-text-2); font-size: 14px; font-weight: 600; font-family: var(--m-font);
  }

  /* ---------- search screen ---------- */
  .m-searchscreen { padding-top: 14px; }
  .m-searchbar {
    display: flex; align-items: center; gap: 10px; margin: 0 16px 4px;
    padding: 12px 14px; border-radius: 12px; background: var(--m-surface-2);
    border: 1px solid var(--m-border);
  }
  .m-searchbar i { color: var(--m-text-3); font-size: 15px; }
  .m-searchbar input {
    flex: 1; border: 0; background: transparent; outline: none;
    font-size: 15px; color: var(--m-text); font-family: var(--m-font);
  }
  .m-searchbar-clear { color: var(--m-text-3); }
  .m-searchtags { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 16px 8px; }
  .m-searchtags .m-chip { background: var(--m-surface); border: 1px solid var(--m-border); }

  /* ---------- auth pages (login / register / reset) ---------- */
  .auth-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; background: var(--m-bg); }
  .auth-card {
    width: 100%; max-width: 420px; background: var(--m-surface);
    border: 1px solid var(--m-border); border-radius: 20px; padding: 26px 20px;
    box-shadow: var(--m-shadow);
  }
  .auth-card h1 { color: var(--m-text); }
  .auth-card .form-control {
    width: 100%; padding: 13px 14px; border-radius: 12px;
    border: 1px solid var(--m-border); background: var(--m-surface-2); color: var(--m-text); font-size: 15px;
  }
  .auth-card .form-group { margin-bottom: 14px; }
  .auth-card label { color: var(--m-text-2); font-size: 13px; font-weight: 600; display: block; margin-bottom: 6px; }
  .auth-card .btn-block {
    width: 100%; padding: 14px; border-radius: 12px; border: 0; margin-top: 6px;
    background: var(--m-accent); color: var(--m-accent-ink); font-size: 15px; font-weight: 700;
  }
  .auth-card .btn-ghost { background: var(--m-surface-2); border: 1px solid var(--m-border); color: var(--m-text); border-radius: 12px; }
  .auth-divider { color: var(--m-text-3); font-size: 12px; text-align: center; margin: 16px 0; }
  .auth-footer { text-align: center; font-size: 14px; color: var(--m-text-2); margin-top: 16px; }
  .auth-footer a, .auth-card a { color: var(--m-accent); }

  /* mobile-only / desktop-only helpers
     NOTE: .m-only must NOT set `display` — components like .m-topbar / .m-bottomnav
     / .m-chips carry their own display:flex and we must not override it. They are
     visible by default at this breakpoint; the >=769px block hides them. */
  .d-only { display: none !important; }
  .m-screen-title { display: none; }
}

@media (min-width: 769px) {
  .m-only { display: none !important; }
  .m-topbar, .m-bottomnav, .m-chips { display: none !important; }

  /* community compose form still uses this markup on desktop */
  .m-compose { max-width: 620px; margin: 32px auto; padding: 24px; background: var(--m-surface); border: 1px solid var(--m-border); border-radius: 16px; }
  .m-compose-user { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
  .m-compose-user img { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; }
  .m-compose-user strong { display: block; font-size: 15px; }
  .m-compose-user span { font-size: 12px; color: var(--m-text-3); }
  .m-compose-title { width: 100%; border: 0; border-bottom: 1px solid var(--m-border); background: transparent; font-size: 20px; font-weight: 700; padding: 8px 0; outline: none; color: var(--m-text); }
  .m-compose-body { width: 100%; min-height: 140px; border: 0; background: transparent; resize: vertical; font-size: 16px; line-height: 1.6; padding: 12px 0; outline: none; color: var(--m-text); font-family: inherit; }
  .m-compose-panel { background: var(--m-surface-2); border: 1px solid var(--m-border); border-radius: 12px; padding: 12px; margin-bottom: 10px; display: flex; flex-direction: column; gap: 8px; }
  .m-compose-panel input { width: 100%; padding: 10px 12px; border: 1px solid var(--m-border); border-radius: 10px; background: var(--m-surface); color: var(--m-text); }
  .m-compose-check { display: flex; align-items: center; gap: 8px; font-size: 13px; }
  .m-compose-preview img { width: 100%; border-radius: 10px; }
  .m-compose-add { display: flex; align-items: center; justify-content: space-between; border: 1px solid var(--m-border); border-radius: 12px; padding: 10px 12px; margin: 6px 0 16px; }
  .m-compose-addbtns { display: flex; gap: 6px; }
  .m-compose-addbtns button { width: 40px; height: 40px; border-radius: 10px; border: 0; background: var(--m-surface-2); color: var(--m-text-2); cursor: pointer; }
  .m-compose-addbtns button.is-on { background: var(--m-accent-soft); color: var(--m-accent); }
  .m-compose-addbtns svg.lucide { width: 19px; height: 19px; }
  .m-compose-actions { display: flex; gap: 10px; }
  .m-compose-post { flex: 1; padding: 13px; border-radius: 12px; border: 0; background: var(--m-accent); color: #fff; font-size: 15px; font-weight: 700; cursor: pointer; }
  .m-compose-draft { padding: 13px 18px; border-radius: 12px; border: 1px solid var(--m-border); background: transparent; color: var(--m-text-2); font-weight: 600; cursor: pointer; }

  /* /categories renders the same markup on desktop — give it a sane grid */
  .m-catlist { max-width: 1000px; margin: 32px auto; padding: 0 20px; display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
  .m-catrow { display: flex; align-items: center; gap: 14px; padding: 16px; background: var(--m-surface); border: 1px solid var(--m-border); border-radius: 16px; text-decoration: none; color: var(--m-text); }
  .m-catrow-icon { width: 46px; height: 46px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 18px; background: var(--m-accent-soft); color: var(--m-accent); flex: 0 0 auto; }
  .m-catrow-body strong { display: block; font-size: 15px; font-weight: 700; }
  .m-catrow-body span { display: block; font-size: 12px; color: var(--m-text-3); margin-top: 2px; }
  .m-screen-title { max-width: 1000px; margin: 28px auto 0; padding: 0 20px; font-size: 26px; font-weight: 800; }
}

/* splash — outside media query so it can show before CSS matches, but sized for mobile */
.m-splash {
  position: fixed; inset: 0; z-index: 3000;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
  background: var(--m-surface, #fff);
  transition: opacity .45s ease, visibility .45s ease;
}
.m-splash.is-hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.m-splash img { width: 130px; height: 130px; object-fit: contain; }
.m-splash b { font-size: 22px; font-weight: 800; color: var(--m-text, #17171c); letter-spacing: -.02em; }
.m-splash b span { color: var(--m-accent, #e8232c); }
.m-splash small { font-size: 10px; letter-spacing: .22em; text-transform: uppercase; color: var(--m-text-3, #9a9aa6); }
.m-splash .m-splash-bar { width: 120px; height: 3px; border-radius: 999px; background: var(--m-surface-2, #eee); overflow: hidden; }
.m-splash .m-splash-bar i { display: block; height: 100%; width: 40%; background: var(--m-accent, #e8232c); animation: m-splash-load 1s ease-in-out infinite; }
@keyframes m-splash-load { 0% { transform: translateX(-100%); } 100% { transform: translateX(320%); } }
@media (min-width: 769px) { .m-splash { display: none !important; } }
