@media (max-width: 980px) {
  #view-home {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  #view-home .left-panel { order: 2; }
  #view-home .center-panel { order: 1; }
  #view-home .right-panel { order: 3; }

  .view { padding-left: 56px; padding-top: 8px; padding-bottom: 96px; padding-right: 12px; }
  #view-profile, #view-friends, #view-music, #view-settings { padding-top: 16px; }

  .profile-bio-box, .friends-full-box, .music-full-box, .settings-box { width: 100%; }
  .friends-full-sections .friends-cards { grid-template-columns: 1fr 1fr; }

  .widget { padding: 12px 14px; }
  .widget h2 { font-size: 0.7rem; margin-bottom: 8px; }
  .widget .row { font-size: 0.8rem; padding: 4px 0; }
}

@media (max-width: 480px) {
  #main { padding: 12px 10px 100px; }
  .loading-ring { width: 92px; height: 92px; }
  #intro-name { font-size: 1.3rem; }
  .profile-avatar { width: 72px; height: 72px; }
  .music-full-box .cover { width: 120px; height: 120px; }
  .calendar-modal { padding-inline: 14px; }
  .widget { padding: 10px 12px; }
  .social-row a { width: 32px; height: 32px; }
}


/* Mobile: clock top-left; language pill fixed under it — same for FA & EN */
@media (max-width: 760px) {
  .corner-clock {
    top: 10px !important;
    left: 10px !important;
    right: auto !important;
    bottom: auto !important;
    z-index: 60;
    flex-direction: row;
    max-width: calc(100vw - 100px);
  }
  html[dir="ltr"] .corner-clock,
  body.ltr .corner-clock {
    left: 10px !important;
    right: auto !important;
  }

  /* Horizontal pill — no vertical writing-mode (that was jumping between FA/EN) */
  .lang-toggle {
    position: fixed !important;
    top: 56px !important;
    left: 10px !important;
    right: auto !important;
    bottom: auto !important;
    inset-inline-end: auto !important;
    inset-inline-start: 10px !important;
    z-index: 60;
    writing-mode: horizontal-tb !important;
    text-orientation: mixed;
    padding: 6px 12px !important;
    letter-spacing: 0.1em;
    border-radius: 999px !important;
    font-size: 0.68rem !important;
  }
  html[dir="ltr"] .lang-toggle,
  body.ltr .lang-toggle {
    left: 10px !important;
    right: auto !important;
  }

  .side-nav { z-index: 55; }
}

/* Performance on mobile */
@media (max-width: 760px) {
  .friend-card:hover {
    transform: none;
    box-shadow: none;
  }
  .friend-card-bg {
    opacity: 0.12;
  }
  .friends-cards {
    gap: 8px;
  }
  .friend-card {
    padding: 10px;
    min-height: 56px;
  }
  #rain, .rain-layer {
    opacity: 0.45;
  }
}


/* ===== Phase B: mobile smoothness (desktop unchanged) ===== */
@media (max-width: 760px) {
  .friend-card {
    content-visibility: auto;
    contain-intrinsic-size: 56px 120px;
    transition: border-color 0.15s ease;
  }
  .friend-card:hover {
    transform: none;
    box-shadow: none;
  }
  .friend-card-bg {
    opacity: 0.1;
    filter: none;
  }
  /* Keep star orbit but slower / cheaper */
  .friend-card.starred .avatar-wrap::before {
    animation-duration: 10s;
    box-shadow: none;
  }
  .friend-card.starred .friend-avatar,
  .friend-card.starred .avatar-fallback {
    box-shadow: 0 0 6px rgba(255, 220, 120, 0.3);
  }
  .avatar-wrap.ring-online .friend-ring-progress,
  .avatar-wrap.ring-playing .friend-ring-progress {
    filter: none;
  }
  .glass, .widget.glass {
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
  }
  #rain, .rain-layer {
    opacity: 0.35;
    pointer-events: none;
  }
  .friends-cards {
    gap: 8px;
  }
}

@media (max-width: 760px) and (prefers-reduced-motion: reduce) {
  .friend-card.starred .avatar-wrap::before,
  .friend-star,
  .apple-spin-ring,
  .avatar-wrap.ring-online .friend-ring-progress {
    animation: none !important;
  }
}
