/* Friends hub — orb beside Dynamic Island + social modal */

/* Cluster is ONLY as wide as the island so the pill stays truly centered.
   Friends orb is absolutely parked beside it and does not shift the center. */
.island-top-cluster {
  position: fixed;
  top: calc(14px + var(--safe-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 1200;
  width: max-content;
  max-width: calc(100vw - 28px);
  pointer-events: none;
}

.island-top-cluster .dynamic-island-capsule,
.island-top-cluster .friends-orb-btn,
.island-top-cluster .mobile-nav-back-btn {
  pointer-events: auto;
}

/* Phone-only back orb (mirrors friends orb on the other side of the island) */
.mobile-nav-back-btn {
  display: none;
}

@media (max-width: 768px) {
  .mobile-nav-back-btn {
    position: absolute;
    top: 0;
    left: calc(100% + 8px);
    right: auto;
    width: 48px;
    height: 48px;
    flex: none;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.16);
    background: rgba(16, 16, 20, 0.94);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    color: #e4e4e7;
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.55);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    transition: transform 0.2s ease, background 0.2s ease, border-color 0.2s ease;
  }

  .mobile-nav-back-btn.hidden {
    display: none !important;
  }

  .mobile-nav-back-btn:active {
    transform: scale(0.96);
  }

  .island-top-cluster .dynamic-island-capsule {
    width: min(200px, calc(100vw - 28px - 112px));
    max-width: 220px;
  }

  .island-top-cluster .dynamic-island-capsule.expanded {
    width: min(260px, calc(100vw - 24px - 112px));
    max-width: 280px;
  }
}

/* Island was fixed+centered; now lives inside the cluster */
.island-top-cluster .dynamic-island-capsule {
  position: relative;
  top: auto;
  left: auto;
  transform: none;
  flex: none;
  /* Compact centered pill — never span the full top bar */
  width: min(220px, calc(100vw - 28px - 112px));
  max-width: 240px;
}

.island-top-cluster .dynamic-island-capsule.expanded {
  width: min(280px, calc(100vw - 24px - 112px));
  max-width: 300px;
}

.friends-orb-btn {
  position: absolute;
  top: 0;
  /* Physical left of the centered island (does not affect translate centering) */
  right: calc(100% + 8px);
  left: auto;
  width: 48px;
  height: 48px;
  flex: none;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(16, 16, 20, 0.94);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  color: #e4e4e7;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.55);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  transition: transform 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

.friends-orb-btn:hover {
  transform: scale(1.06);
  background: rgba(28, 28, 34, 0.98);
  border-color: rgba(255, 255, 255, 0.28);
}

.friends-orb-badge {
  position: absolute;
  top: -2px;
  left: -2px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: #fafafa;
  color: #111;
  font-size: 0.65rem;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.friends-orb-badge.hidden {
  display: none !important;
}

#friends-modal.modal-backdrop {
  z-index: 1400;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

#friends-modal.hidden {
  display: none !important;
}

.friends-hub-card {
  position: relative;
  width: min(720px, 100%);
  max-height: min(88vh, 820px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: rgba(12, 12, 16, 0.97);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 22px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.55);
}

.friends-hub-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 20px 10px;
  padding-left: 52px;
}

.friends-hub-title-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.friends-hub-icon {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #e4e4e7;
  flex-shrink: 0;
}

.friends-hub-header h2 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 800;
}

.friends-hub-sub {
  margin: 4px 0 0;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.friends-code-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  font-size: 0.78rem;
}

.friends-code-label {
  color: var(--text-muted);
  font-weight: 600;
}

.friends-code-copy {
  border: none;
  background: transparent;
  color: #d4d4d8;
  cursor: pointer;
  padding: 2px;
}

.friends-tabs {
  display: flex;
  gap: 6px;
  padding: 8px 16px 0;
  overflow-x: auto;
}

.friends-tab {
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.03);
  color: #a1a1aa;
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  font-family: inherit;
}

.friends-tab.active {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.22);
}

.friends-panels {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px 20px;
}

.friends-panel {
  display: none;
}

.friends-panel.active {
  display: block;
}

.friends-section {
  margin-bottom: 18px;
}

.friends-section h3 {
  margin: 0 0 10px;
  font-size: 0.88rem;
  font-weight: 800;
  color: #e4e4e7;
  display: flex;
  align-items: center;
  gap: 8px;
}

.friends-hint {
  margin: 0 0 10px;
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.6;
}

.friends-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.friends-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.friends-row img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.friends-row-meta {
  flex: 1;
  min-width: 0;
}

.friends-row-meta strong {
  display: block;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.friends-row-meta span {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  direction: ltr;
  text-align: right;
}

.friends-row-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.friends-btn {
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.08);
  color: #f4f4f5;
  border-radius: 12px;
  padding: 8px 12px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.friends-btn:hover {
  background: rgba(255, 255, 255, 0.14);
}

.friends-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.friends-btn-ghost {
  background: transparent;
}

.friends-btn-danger {
  border-color: rgba(239, 68, 68, 0.35);
  color: #f87171;
  background: rgba(239, 68, 68, 0.08);
}

.friends-btn-ok {
  border-color: rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.14);
}

.friends-empty {
  padding: 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  border: 1px dashed rgba(255, 255, 255, 0.1);
  border-radius: 14px;
}

.friends-search-box {
  position: relative;
  margin-bottom: 12px;
}

.friends-search-box i {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 0.85rem;
}

.friends-search-box input {
  width: 100%;
  padding: 12px 40px 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  color: #fff;
  font-family: inherit;
  font-size: 0.9rem;
}

.friends-stories-rail {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.friends-story-chip {
  flex: 0 0 auto;
  width: 86px;
  text-align: center;
  cursor: pointer;
}

.friends-story-chip img {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.35);
  padding: 2px;
  background: #111;
}

.friends-story-chip span {
  display: block;
  margin-top: 6px;
  font-size: 0.68rem;
  color: #d4d4d8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.friends-action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.friends-mini-track {
  min-height: 0;
}

.friends-mini-track .friends-row {
  cursor: pointer;
}

.friends-profile-view {
  margin-top: 14px;
  padding: 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.friends-profile-view.hidden {
  display: none !important;
}

.friends-profile-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.friends-profile-head img {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  object-fit: cover;
}

.friends-chat-layout {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 10px;
  min-height: 320px;
}

.friends-chat-people {
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
  max-height: 420px;
}

.friends-chat-person {
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
  border-radius: 12px;
  padding: 8px;
  cursor: pointer;
  text-align: center;
  color: #d4d4d8;
  font-size: 0.72rem;
}

.friends-chat-person.active {
  border-color: rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.1);
}

.friends-chat-person img {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
  margin: 0 auto 6px;
}

.friends-chat-thread-wrap {
  display: flex;
  flex-direction: column;
  min-width: 0;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.2);
}

.friends-chat-header {
  padding: 10px 12px;
  font-size: 0.82rem;
  font-weight: 700;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.friends-chat-thread {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  min-height: 180px;
  max-height: 280px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.friends-dm {
  max-width: 92%;
  padding: 8px 10px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  align-self: flex-start;
}

.friends-dm.mine {
  align-self: flex-end;
  background: rgba(255, 255, 255, 0.12);
}

.friends-dm-track {
  display: flex;
  gap: 8px;
  align-items: center;
  cursor: pointer;
}

.friends-dm-track img {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  object-fit: cover;
}

.friends-dm-note {
  margin-top: 6px;
  font-size: 0.78rem;
  color: #d4d4d8;
}

.friends-chat-compose {
  padding: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.friends-chat-compose input {
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  color: #fff;
  padding: 10px 12px;
  font-family: inherit;
}

.friends-share-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.friends-share-form select {
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: #18181b;
  color: #fff;
  padding: 10px;
  font-family: inherit;
}

.friends-coming-soon {
  text-align: center;
  padding: 48px 20px;
}

.friends-coming-soon-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 14px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  font-size: 1.4rem;
  color: #e4e4e7;
}

.friends-coming-soon h3 {
  margin: 0 0 8px;
  font-size: 1.2rem;
}

.friends-coming-soon p {
  margin: 0 auto 16px;
  max-width: 360px;
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.7;
}

.friends-coming-badge {
  display: inline-flex;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  font-size: 0.78rem;
  font-weight: 800;
  color: #f4f4f5;
}

/* Tiny friend avatars under likes / on cards */
.friend-likes-strip {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 6px;
  min-height: 18px;
}

.friend-likes-strip img {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid rgba(255, 255, 255, 0.25);
  margin-inline-start: -4px;
}

.friend-likes-strip img:first-child {
  margin-inline-start: 0;
}

.friend-likes-strip .friend-likes-label {
  font-size: 0.65rem;
  color: var(--text-muted);
  margin-inline-start: 4px;
}

.track-card .friend-likes-strip {
  justify-content: flex-start;
  padding: 0 2px;
}

@media (max-width: 640px) {
  .island-top-cluster {
    max-width: calc(100vw - 20px);
  }

  .island-top-cluster .dynamic-island-capsule {
    width: min(240px, calc(100vw - 20px - 112px));
  }

  .island-top-cluster .dynamic-island-capsule.expanded {
    width: min(280px, calc(100vw - 20px - 112px));
  }

  .friends-orb-btn {
    width: 44px;
    height: 44px;
    right: calc(100% + 6px);
  }

  .friends-chat-layout {
    grid-template-columns: 1fr;
  }

  .friends-chat-people {
    flex-direction: row;
    overflow-x: auto;
    max-height: none;
  }

  .friends-chat-person {
    min-width: 72px;
  }

  .friends-hub-header {
    flex-direction: column;
    padding-left: 20px;
  }
}

/* ========== Simplified Friends hub (v139) ========== */
.friends-hub-simple {
  position: relative;
  min-height: min(72vh, 680px);
  height: min(88vh, 820px);
  max-height: min(88vh, 820px);
}

.friends-main-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 8px 16px 20px;
  min-height: 0;
}

.friends-main-scroll.hidden {
  display: none !important;
}

.friends-add-block {
  margin-bottom: 14px;
  padding: 12px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.friends-search-results:empty {
  display: none;
}

.friends-search-results {
  margin-top: 10px;
}

.friends-empty-cta {
  margin-top: 8px;
  font-size: 0.8rem;
  color: #a1a1aa;
  line-height: 1.55;
}

.friends-section.hidden {
  display: none !important;
}

.friends-story-note-wrap {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  align-items: center;
}

.friends-story-note-wrap.hidden {
  display: none !important;
}

.friends-story-note-wrap input {
  flex: 1;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  color: #fff;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 0.85rem;
}

.friends-more-details {
  margin: 8px 0 4px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.02);
  padding: 0 12px 4px;
}

.friends-more-details summary {
  cursor: pointer;
  list-style: none;
  padding: 12px 4px;
  font-size: 0.88rem;
  font-weight: 800;
  color: #e4e4e7;
  display: flex;
  align-items: center;
  gap: 8px;
}

.friends-more-details summary::-webkit-details-marker {
  display: none;
}

.friends-more-details[open] summary {
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 4px;
}

/* Chat fills the whole hub card (not absolute-crushed) */
.friends-hub-simple.is-chat-open .friends-hub-header,
.friends-hub-simple.is-chat-open .btn-modal-close {
  display: none !important;
}

.friends-hub-simple.is-chat-open .friends-main-scroll {
  display: none !important;
}

.friends-chat-sheet {
  display: none;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  width: 100%;
  background: rgba(12, 12, 16, 0.99);
  border-radius: 22px;
  overflow: hidden;
}

.friends-hub-simple.is-chat-open .friends-chat-sheet {
  display: flex !important;
}

.friends-chat-sheet.hidden {
  display: none !important;
}

.friends-chat-sheet-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 14px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  flex-shrink: 0;
}

.friends-chat-sheet .friends-chat-header {
  flex: 1;
  border: none;
  padding: 0;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 0.92rem;
  font-weight: 800;
}

.friends-chat-sheet .friends-chat-thread {
  flex: 1 1 auto;
  min-height: 220px;
  max-height: none !important;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.friends-chat-sheet .friends-chat-compose {
  flex-shrink: 0;
  padding: 12px 14px calc(14px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(10, 10, 14, 0.98);
}

.friends-hub-simple .friends-hub-header {
  flex-shrink: 0;
}

@media (max-width: 640px) {
  .friends-hub-simple {
    min-height: min(78vh, 720px);
    height: min(90vh, 860px);
    max-height: min(90vh, 860px);
    width: min(100%, 100vw - 16px);
  }

  .friends-chat-sheet .friends-chat-thread {
    min-height: 260px;
  }
}

/* One-tap send song */
#send-song-modal.modal-backdrop {
  z-index: 1450;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
#send-song-modal.hidden { display: none !important; }
.send-song-card {
  width: min(420px, 100%);
  max-height: min(70vh, 560px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: rgba(12, 12, 16, 0.98);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 20px;
  padding: 18px 16px 16px;
  position: relative;
}
.send-song-card h3 {
  margin: 0 0 8px;
  font-size: 1.05rem;
  display: flex;
  align-items: center;
  gap: 8px;
}
.send-song-note {
  width: 100%;
  margin: 8px 0 12px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  color: #fff;
  font-family: inherit;
}
#send-song-friends-list {
  overflow-y: auto;
  flex: 1;
}

/* Public profile */
.public-profile-page {
  max-width: 640px;
  margin: 88px auto 120px;
  padding: 0 16px;
}
.public-profile-card {
  background: rgba(16, 16, 20, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 22px;
  padding: 22px 18px;
}
.public-profile-hero {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-bottom: 20px;
}
.public-profile-avatar {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.18);
}
.public-profile-meta h1 {
  margin: 0;
  font-size: 1.35rem;
}
.public-profile-handle {
  margin: 6px 0;
  color: var(--text-muted);
  font-size: 0.88rem;
}
.public-profile-hint {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.8rem;
}
.public-profile-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  font-size: 0.78rem;
  font-weight: 700;
}
.public-profile-section {
  margin-top: 18px;
}
.public-profile-section h2 {
  margin: 0 0 10px;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  gap: 8px;
}
.public-profile-empty {
  color: var(--text-muted);
  font-size: 0.85rem;
  padding: 12px;
  border: 1px dashed rgba(255, 255, 255, 0.12);
  border-radius: 12px;
}
.public-track-row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
  color: inherit;
  cursor: pointer;
  text-align: right;
  font-family: inherit;
}
.public-track-row img {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  object-fit: cover;
}
.public-track-row strong {
  display: block;
  font-size: 0.92rem;
}
.public-track-row span {
  display: block;
  font-size: 0.78rem;
  color: var(--text-muted);
}
.public-track-row > div { flex: 1; min-width: 0; }
.public-profile-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 22px;
}
