/* SoundNation Community v1 */
.sn-community-page{max-width:1120px;margin:0 auto;padding-bottom:80px}
.sn-community-hero{display:flex;align-items:flex-end;justify-content:space-between;gap:24px;padding:30px;border:1px solid var(--border);border-radius:26px;background:linear-gradient(135deg,rgba(29,185,84,.18),rgba(255,255,255,.025));margin-bottom:20px}
.sn-community-hero h2{font-size:clamp(28px,4vw,44px);margin:5px 0 8px}
.sn-community-hero p{color:var(--muted);max-width:650px;line-height:1.55}
.sn-community-kicker{display:inline-flex;align-items:center;gap:8px;color:var(--accent);font-weight:800;font-size:12px;letter-spacing:.08em;text-transform:uppercase}
.sn-community-create{white-space:nowrap;border:0;border-radius:999px;padding:13px 18px;background:var(--accent);color:#07120a;font-weight:800;cursor:pointer;display:inline-flex;align-items:center;gap:8px}
.sn-community-create:hover{filter:brightness(1.08)}
.sn-community-toolbar{display:flex;align-items:center;gap:10px;overflow:auto;padding:2px 0 14px;scrollbar-width:none}
.sn-community-toolbar::-webkit-scrollbar{display:none}
.sn-community-filter{border:1px solid var(--border);background:var(--panel);color:#d8dbe2;border-radius:999px;padding:9px 14px;white-space:nowrap;cursor:pointer}
.sn-community-filter.active{background:var(--accent);border-color:var(--accent);color:#07120a;font-weight:800}
.sn-community-feed{display:grid;gap:12px}
.sn-community-card{border:1px solid var(--border);border-radius:20px;background:var(--panel);padding:18px;cursor:pointer;transition:transform .16s ease,border-color .16s ease,background .16s ease}
.sn-community-card:hover{transform:translateY(-2px);border-color:rgba(29,185,84,.35);background:#181a1f}
.sn-community-card.is-hidden{opacity:.58;border-style:dashed}
.sn-community-card-head,.sn-community-author{display:flex;align-items:center;gap:10px}
.sn-community-card-head{justify-content:space-between;margin-bottom:12px}
.sn-community-author{min-width:0}
.sn-community-avatar{width:42px;height:42px;border-radius:50%;object-fit:cover;background:#202329;flex:0 0 auto}
.sn-community-author-copy{min-width:0}
.sn-community-author-name{font-weight:800;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.sn-community-meta{font-size:12px;color:var(--muted);margin-top:2px;display:flex;gap:7px;flex-wrap:wrap;align-items:center}
.sn-community-badge{display:inline-flex;align-items:center;gap:5px;padding:4px 8px;border-radius:999px;background:rgba(29,185,84,.11);color:#7ee6a1;font-size:11px;font-weight:800}
.sn-community-badge.admin{background:rgba(255,190,61,.12);color:#ffd36d}
.sn-community-badge.locked{background:rgba(255,255,255,.07);color:#c7cbd3}
.sn-community-badge.hidden{background:rgba(255,91,91,.12);color:#ff9494}
.sn-community-card h3{font-size:20px;line-height:1.25;margin:0 0 8px}
.sn-community-excerpt{color:#cbd0d8;line-height:1.55;display:-webkit-box;-webkit-line-clamp:3;-webkit-box-orient:vertical;overflow:hidden;white-space:pre-wrap}
.sn-community-footer{display:flex;align-items:center;gap:16px;margin-top:14px;color:var(--muted);font-size:13px}
.sn-community-footer span{display:inline-flex;align-items:center;gap:6px}
.sn-community-pin{color:#ffd36d}
.sn-community-song{display:flex;align-items:center;gap:12px;border:1px solid rgba(255,255,255,.07);background:rgba(0,0,0,.18);border-radius:14px;padding:10px;margin-top:13px}
.sn-community-song img{width:50px;height:50px;border-radius:10px;object-fit:cover;background:#17191f}
.sn-community-song-copy{min-width:0;flex:1}
.sn-community-song-copy strong,.sn-community-song-copy small{display:block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.sn-community-song-copy small{color:var(--muted);margin-top:3px}
.sn-community-song-play{width:38px;height:38px;border:0;border-radius:50%;background:#fff;color:#000;cursor:pointer;flex:0 0 auto}
.sn-community-empty,.sn-community-loading{border:1px dashed var(--border);border-radius:18px;padding:35px;text-align:center;color:var(--muted)}
.sn-community-modal{position:fixed;inset:0;z-index:10020;display:none;align-items:center;justify-content:center;padding:18px}
.sn-community-modal.open{display:flex}
.sn-community-modal-backdrop{position:absolute;inset:0;background:rgba(0,0,0,.72);backdrop-filter:blur(8px)}
.sn-community-modal-panel{position:relative;width:min(760px,100%);max-height:min(90vh,900px);overflow:auto;background:#121419;border:1px solid var(--border);border-radius:24px;box-shadow:0 30px 100px rgba(0,0,0,.5);padding:22px}
.sn-community-topic-panel{width:min(880px,100%)}
.sn-community-modal-head{display:flex;align-items:center;justify-content:space-between;gap:16px;margin-bottom:18px}
.sn-community-modal-head h3{margin:0;font-size:23px}
.sn-community-close{width:40px;height:40px;border:0;border-radius:50%;background:rgba(255,255,255,.07);color:#fff;cursor:pointer}
.sn-community-form{display:grid;gap:14px}
.sn-community-form label{display:grid;gap:7px;font-size:13px;font-weight:700;color:#d9dde4}
.sn-community-form input,.sn-community-form select,.sn-community-form textarea,.sn-community-reply-box textarea{width:100%;border:1px solid var(--border);border-radius:13px;background:#1a1d23;color:#fff;padding:12px 13px;outline:none}
.sn-community-form textarea{min-height:160px;resize:vertical;line-height:1.5}
.sn-community-form input:focus,.sn-community-form select:focus,.sn-community-form textarea:focus,.sn-community-reply-box textarea:focus{border-color:rgba(29,185,84,.7);box-shadow:0 0 0 3px rgba(29,185,84,.1)}
.sn-community-form-actions{display:flex;justify-content:flex-end;gap:10px;margin-top:4px}
.sn-community-secondary,.sn-community-primary,.sn-community-action{border:0;border-radius:999px;padding:10px 15px;cursor:pointer;font-weight:750}
.sn-community-secondary{background:rgba(255,255,255,.07);color:#fff}
.sn-community-primary{background:var(--accent);color:#061108}
.sn-community-primary:disabled{opacity:.5;cursor:not-allowed}
.sn-community-topic-head{border-bottom:1px solid var(--border);padding-bottom:18px;margin-bottom:18px}
.sn-community-topic-title{font-size:clamp(24px,4vw,34px);line-height:1.2;margin:10px 0}
.sn-community-topic-body{white-space:pre-wrap;line-height:1.65;color:#e5e8ed;margin-top:16px;overflow-wrap:anywhere}
.sn-community-actions{display:flex;gap:8px;flex-wrap:wrap;margin-top:16px}
.sn-community-action{background:rgba(255,255,255,.06);color:#dce0e6;padding:8px 12px;font-size:12px}
.sn-community-action:hover{background:rgba(255,255,255,.1)}
.sn-community-action.liked{color:#7ee6a1;background:rgba(29,185,84,.12)}
.sn-community-action.danger{color:#ff9b9b}
.sn-community-replies{display:grid;gap:10px}
.sn-community-reply{border:1px solid var(--border);border-radius:16px;background:rgba(255,255,255,.025);padding:14px}
.sn-community-reply.is-hidden{opacity:.55;border-style:dashed}
.sn-community-reply-body{white-space:pre-wrap;line-height:1.55;margin-top:10px;color:#e2e5ea;overflow-wrap:anywhere}
.sn-community-reply-box{margin-top:18px;border-top:1px solid var(--border);padding-top:18px}
.sn-community-reply-box textarea{min-height:100px;resize:vertical;line-height:1.5}
.sn-community-reply-actions{display:flex;justify-content:flex-end;margin-top:10px}
.sn-community-locked{margin-top:18px;border:1px solid var(--border);border-radius:14px;padding:14px;color:var(--muted);display:flex;align-items:center;gap:9px}
.sn-community-note{font-size:12px;color:var(--muted);line-height:1.45}
.sn-community-toast{position:fixed;left:50%;bottom:110px;z-index:10100;transform:translate(-50%,20px);opacity:0;pointer-events:none;background:#202329;border:1px solid var(--border);color:#fff;padding:11px 16px;border-radius:999px;transition:.2s;max-width:min(90vw,520px);text-align:center;box-shadow:0 12px 35px rgba(0,0,0,.35)}
.sn-community-toast.show{opacity:1;transform:translate(-50%,0)}
@media(max-width:760px){
  .sn-community-hero{align-items:stretch;flex-direction:column;padding:20px;border-radius:20px}
  .sn-community-create{justify-content:center;width:100%}
  .sn-community-modal{align-items:flex-end;padding:0}
  .sn-community-modal-panel{width:100%;max-height:92vh;border-radius:24px 24px 0 0;padding:18px}
  .sn-community-card{padding:15px}
  .sn-community-card h3{font-size:18px}
  .sn-community-footer{gap:12px;flex-wrap:wrap}
}

/* ==========================================
   SoundNation Community v1.1 - Mobile polish
   Keeps cards, filters and modal sheets inside the viewport.
========================================== */
.sn-community-page,
.sn-community-page *{
  box-sizing:border-box;
}

.sn-community-page{
  width:100%;
  min-width:0;
}

.sn-community-card,
.sn-community-card-head,
.sn-community-author,
.sn-community-author-copy,
.sn-community-song,
.sn-community-song-copy,
.sn-community-topic-head,
.sn-community-reply{
  min-width:0;
  max-width:100%;
}

.sn-community-card h3,
.sn-community-author-name,
.sn-community-excerpt,
.sn-community-topic-title,
.sn-community-topic-body,
.sn-community-reply-body{
  overflow-wrap:anywhere;
  word-break:break-word;
}

@media(max-width:900px){
  #communityView{
    width:100%;
    max-width:100%;
    min-width:0;
    overflow:visible !important;
    padding-bottom:0 !important;
  }

  .sn-community-page{
    width:100%;
    max-width:100%;
    margin:0;
    padding:0 0 calc(190px + env(safe-area-inset-bottom));
    overflow:visible;
  }

  .sn-community-hero{
    width:100%;
    max-width:100%;
    margin:0 0 14px;
    padding:18px;
    border-radius:20px;
    gap:16px;
    align-items:stretch;
    flex-direction:column;
    overflow:hidden;
  }

  .sn-community-hero > div{
    min-width:0;
  }

  .sn-community-kicker{
    max-width:100%;
    white-space:normal;
    line-height:1.35;
    letter-spacing:.06em;
  }

  .sn-community-hero h2{
    font-size:32px;
    line-height:1.05;
    margin:8px 0 8px;
  }

  .sn-community-hero p{
    margin:0;
    font-size:14px;
    line-height:1.5;
    overflow-wrap:anywhere;
  }

  .sn-community-create{
    width:100%;
    min-height:46px;
    justify-content:center;
    padding:12px 16px;
    flex:0 0 auto;
  }

  .sn-community-toolbar{
    width:100%;
    max-width:100%;
    gap:8px;
    padding:2px 1px 12px;
    overflow-x:auto;
    overflow-y:hidden;
    -webkit-overflow-scrolling:touch;
    overscroll-behavior-x:contain;
    scroll-snap-type:x proximity;
  }

  .sn-community-filter{
    flex:0 0 auto;
    min-height:40px;
    padding:9px 13px;
    font-size:13px;
    scroll-snap-align:start;
  }

  .sn-community-feed{
    width:100%;
    min-width:0;
    gap:10px;
  }

  .sn-community-card{
    width:100%;
    max-width:100%;
    padding:14px;
    border-radius:17px;
    overflow:hidden;
    transform:none !important;
  }

  .sn-community-card-head{
    display:flex;
    align-items:flex-start;
    justify-content:flex-start;
    gap:9px;
    flex-wrap:wrap;
    margin-bottom:11px;
  }

  .sn-community-card-head > .sn-community-author{
    flex:1 1 100%;
    width:100%;
  }

  .sn-community-card-head > div:last-child:not(.sn-community-author){
    display:flex;
    flex-wrap:wrap;
    gap:6px;
    width:100%;
  }

  .sn-community-author{
    width:100%;
    align-items:flex-start;
  }

  .sn-community-avatar{
    width:40px;
    height:40px;
  }

  .sn-community-author-copy{
    flex:1 1 auto;
    width:0;
  }

  .sn-community-author-name{
    max-width:100%;
    font-size:14px;
  }

  .sn-community-meta{
    max-width:100%;
    gap:5px;
    font-size:11px;
    line-height:1.45;
  }

  .sn-community-badge{
    max-width:100%;
    padding:4px 7px;
    font-size:10px;
  }

  .sn-community-card h3{
    font-size:18px;
    line-height:1.25;
    margin:0 0 7px;
  }

  .sn-community-excerpt{
    font-size:14px;
    line-height:1.5;
    -webkit-line-clamp:4;
  }

  .sn-community-song{
    width:100%;
    gap:10px;
    padding:9px;
    border-radius:13px;
    margin-top:12px;
    overflow:hidden;
  }

  .sn-community-song img{
    width:44px;
    height:44px;
    border-radius:9px;
  }

  .sn-community-song-copy{
    width:0;
    flex:1 1 auto;
  }

  .sn-community-song-copy strong{
    font-size:13px;
  }

  .sn-community-song-copy small{
    font-size:11px;
  }

  .sn-community-song-play{
    width:40px;
    height:40px;
  }

  .sn-community-footer{
    width:100%;
    gap:14px;
    margin-top:12px;
    font-size:12px;
    flex-wrap:wrap;
  }

  .sn-community-empty,
  .sn-community-loading{
    width:100%;
    padding:26px 14px;
    border-radius:16px;
  }

  /* Community dialogs become proper mobile bottom sheets. */
  .sn-community-modal{
    inset:0;
    width:100vw;
    max-width:100vw;
    padding:0;
    align-items:flex-end;
    justify-content:center;
    overflow:hidden;
  }

  .sn-community-modal-backdrop{
    position:fixed;
    inset:0;
  }

  .sn-community-modal-panel,
  .sn-community-topic-panel{
    width:100%;
    max-width:100%;
    min-width:0;
    max-height:calc(100dvh - env(safe-area-inset-top));
    margin:0;
    padding:16px 16px calc(24px + env(safe-area-inset-bottom));
    border-left:0;
    border-right:0;
    border-bottom:0;
    border-radius:22px 22px 0 0;
    overflow-y:auto;
    overflow-x:hidden;
    -webkit-overflow-scrolling:touch;
    overscroll-behavior:contain;
  }

  .sn-community-modal-head{
    position:sticky;
    top:-16px;
    z-index:3;
    margin:-16px -16px 14px;
    padding:14px 16px 12px;
    background:rgba(18,20,25,.96);
    backdrop-filter:blur(12px);
    border-bottom:1px solid rgba(255,255,255,.07);
  }

  .sn-community-modal-head h3{
    min-width:0;
    font-size:20px;
    line-height:1.2;
  }

  .sn-community-close{
    width:44px;
    height:44px;
    flex:0 0 44px;
  }

  .sn-community-form{
    width:100%;
    min-width:0;
    gap:13px;
  }

  .sn-community-form label{
    width:100%;
    min-width:0;
  }

  .sn-community-form input,
  .sn-community-form select,
  .sn-community-form textarea,
  .sn-community-reply-box textarea{
    max-width:100%;
    min-width:0;
    font-size:16px; /* avoids iOS zoom */
  }

  .sn-community-form textarea{
    min-height:135px;
  }

  .sn-community-form-actions{
    position:sticky;
    bottom:calc(-24px - env(safe-area-inset-bottom));
    z-index:3;
    display:grid;
    grid-template-columns:1fr 1.35fr;
    gap:9px;
    margin:6px -16px calc(-24px - env(safe-area-inset-bottom));
    padding:12px 16px calc(16px + env(safe-area-inset-bottom));
    background:linear-gradient(to top,#121419 75%,rgba(18,20,25,.9));
    border-top:1px solid rgba(255,255,255,.07);
  }

  .sn-community-secondary,
  .sn-community-primary{
    width:100%;
    min-height:46px;
    padding:10px 12px;
  }

  .sn-community-topic-head{
    width:100%;
    padding-bottom:15px;
    margin-bottom:15px;
  }

  .sn-community-topic-title{
    font-size:25px;
    line-height:1.18;
    margin:10px 0;
  }

  .sn-community-topic-body,
  .sn-community-reply-body{
    font-size:14px;
    line-height:1.58;
  }

  .sn-community-actions{
    width:100%;
    gap:7px;
  }

  .sn-community-action{
    min-height:38px;
    display:inline-flex;
    align-items:center;
    justify-content:center;
    padding:8px 11px;
  }

  .sn-community-replies{
    width:100%;
    gap:9px;
  }

  .sn-community-reply{
    width:100%;
    padding:13px;
    border-radius:14px;
    overflow:hidden;
  }

  .sn-community-reply-box{
    width:100%;
    padding-bottom:10px;
  }

  .sn-community-reply-actions{
    width:100%;
  }

  .sn-community-reply-actions .sn-community-primary{
    width:100%;
  }

  .sn-community-locked{
    width:100%;
    align-items:flex-start;
  }

  .sn-community-toast{
    left:12px;
    right:12px;
    bottom:calc(18px + env(safe-area-inset-bottom));
    max-width:none;
    transform:translateY(20px);
    border-radius:14px;
  }

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

  body.sn-community-modal-open #content{
    overflow:hidden !important;
  }

  body.sn-community-modal-open #player,
  body.sn-community-modal-open .mobile-nav,
  body.sn-community-modal-open .mobile-menu-sheet{
    opacity:0 !important;
    visibility:hidden !important;
    pointer-events:none !important;
  }
}

@media(max-width:430px){
  .sn-community-hero{
    padding:16px;
  }

  .sn-community-hero h2{
    font-size:29px;
  }

  .sn-community-card{
    padding:13px;
  }

  .sn-community-footer{
    justify-content:space-between;
    gap:8px;
  }

  .sn-community-footer span{
    flex:0 0 auto;
  }

  .sn-community-actions .sn-community-action{
    flex:1 1 calc(50% - 7px);
  }

  .sn-community-form-actions{
    grid-template-columns:1fr;
  }
}

/* ==========================================
   SoundNation Community v1.2 - PWA width hard fix
   Fixes CSS-grid min-content expansion caused by horizontal category chips.
========================================== */
@media(max-width:900px){
  html,
  body{
    width:100% !important;
    max-width:100% !important;
    overflow-x:hidden !important;
  }

  .app{
    width:100% !important;
    max-width:100vw !important;
    min-width:0 !important;
    grid-template-columns:minmax(0,1fr) !important;
    overflow-x:hidden !important;
  }

  .main{
    width:100% !important;
    max-width:100% !important;
    min-width:0 !important;
    overflow-x:hidden !important;
  }

  #content{
    width:100% !important;
    max-width:100% !important;
    min-width:0 !important;
    overflow-x:hidden !important;
  }

  #communityView,
  #communityView.view,
  #communityView.view.active{
    box-sizing:border-box !important;
    width:100% !important;
    max-width:100% !important;
    min-width:0 !important;
    overflow-x:hidden !important;
  }

  .sn-community-page{
    box-sizing:border-box !important;
    width:100% !important;
    max-width:100% !important;
    min-width:0 !important;
    overflow-x:hidden !important;
    contain:inline-size;
  }

  .sn-community-hero,
  .sn-community-feed,
  .sn-community-card,
  .sn-community-empty,
  .sn-community-loading{
    width:100% !important;
    max-width:100% !important;
    min-width:0 !important;
  }

  .sn-community-feed{
    grid-template-columns:minmax(0,1fr) !important;
  }

  /* Only the category row may scroll sideways; it must never widen the page. */
  .sn-community-toolbar{
    display:flex !important;
    width:100% !important;
    max-width:100% !important;
    min-width:0 !important;
    overflow-x:auto !important;
    overflow-y:hidden !important;
    contain:inline-size;
  }

  .sn-community-filter{
    flex:0 0 auto !important;
  }

  .sn-community-card-head,
  .sn-community-author,
  .sn-community-author-copy,
  .sn-community-song,
  .sn-community-song-copy,
  .sn-community-footer,
  .sn-community-actions,
  .sn-community-reply,
  .sn-community-reply-box{
    min-width:0 !important;
    max-width:100% !important;
  }

  /* Topic header is created with an inline flex style in community.js. */
  .sn-community-topic-head > div:first-child{
    width:100% !important;
    max-width:100% !important;
    min-width:0 !important;
    flex-wrap:wrap !important;
  }

  .sn-community-topic-head > div:first-child > .sn-community-author{
    flex:1 1 210px !important;
    min-width:0 !important;
  }

  .sn-community-topic-head > div:first-child > div:last-child{
    max-width:100% !important;
    display:flex !important;
    flex-wrap:wrap !important;
    gap:6px !important;
  }

  .sn-community-modal{
    width:100% !important;
    max-width:100% !important;
    overflow-x:hidden !important;
  }

  .sn-community-modal-panel,
  .sn-community-topic-panel,
  #snCommunityTopicContent{
    box-sizing:border-box !important;
    width:100% !important;
    max-width:100% !important;
    min-width:0 !important;
    overflow-x:hidden !important;
  }
}
