:root{
  --ink: #262626;
  --gray: #8e8e8e;
  --border: #dbdbdb;
  --bg: #fafafa;
  --blue: #0095f6;
  --blue-hover: #1877f2;
  --red: #ed4956;
  --grad: linear-gradient(45deg, #833ab4, #fd1d1d 60%, #fcb045);
  --radius: 8px;
}

*{ margin:0; padding:0; box-sizing:border-box; -webkit-tap-highlight-color:transparent; }

body{
  font-family:'Inter', -apple-system, 'Helvetica Neue', Arial, sans-serif;
  color:var(--ink);
  background:var(--bg);
  line-height:1.35;
}

a{ text-decoration:none; color:inherit; }
button{ font-family:inherit; cursor:pointer; border:none; background:none; color:inherit; }
input{ font-family:inherit; border:none; outline:none; background:none; color:inherit; }
img{ display:block; width:100%; height:100%; object-fit:cover; }
ul{ list-style:none; }

/* ============ TOPBAR (mobile only) ============ */
.topbar{
  display:none;
  position:sticky; top:0; z-index:150;
  background:#fff; border-bottom:1px solid var(--border);
}
.topbar-inner{ display:flex; align-items:center; justify-content:space-between; padding:10px 16px; }
.logo-text{ font-family:'Poppins', cursive; font-weight:700; font-size:22px; }
.topbar-icons{ display:flex; gap:18px; }
.icon-btn svg{ width:24px; height:24px; }

/* ============ APP SHELL ============ */
.app-shell{ display:flex; max-width:1400px; margin:0 auto; min-height:100vh; }

/* ============ SIDEBAR ============ */
.sidebar{
  width:245px; flex-shrink:0;
  border-right:1px solid var(--border);
  background:#fff;
  position:sticky; top:0; height:100vh;
}
.sidebar-inner{ display:flex; flex-direction:column; height:100%; padding:8px 12px; }

.brand{ display:flex; align-items:center; gap:12px; padding:22px 12px 28px 12px; }
.brand-icon{ width:28px; height:28px; }
.brand-name{ font-family:'Poppins', sans-serif; font-weight:700; font-size:22px; }

.nav-list{ display:flex; flex-direction:column; gap:2px; flex:1; }
.nav-link{
  display:flex; align-items:center; gap:16px;
  padding:12px; border-radius:8px;
  font-size:16px; font-weight:500;
  transition:background .15s ease;
}
.nav-link svg{ width:24px; height:24px; flex-shrink:0; }
.nav-link:hover{ background:#f5f5f5; }
.nav-link.active{ font-weight:800; }
.nav-link.active svg path{ fill:var(--ink); }

.nav-avatar{ width:24px; height:24px; border-radius:50%; overflow:hidden; flex-shrink:0; border:1px solid var(--border); }
.nav-avatar.small{ width:26px; height:26px; }

.more-link{ margin-top:auto; margin-bottom:14px; }

/* Badge dot for notifications */
.has-badge{ position:relative; }
.has-badge::after{
  content:''; position:absolute; top:8px; left:26px;
  width:8px; height:8px; border-radius:50%; background:var(--red);
  border:2px solid #fff;
}

/* ============ MAIN ============ */
.main{ flex:1; display:flex; gap:28px; padding:28px 20px; min-width:0; }
.feed-wrap{ width:470px; max-width:100%; margin:0 auto; }

/* ============ STORIES ============ */
.stories-rail{
  display:flex; gap:16px; overflow-x:auto;
  background:#fff; border:1px solid var(--border); border-radius:var(--radius);
  padding:16px 12px; margin-bottom:24px;
  scrollbar-width:none;
}
.stories-rail::-webkit-scrollbar{ display:none; }
.story-item{ display:flex; flex-direction:column; align-items:center; gap:6px; cursor:pointer; flex-shrink:0; width:66px; }
.story-ring{
  width:60px; height:60px; border-radius:50%;
  padding:2.5px; background:var(--grad);
  transition:transform .15s ease;
}
.story-item:hover .story-ring{ transform:scale(1.05); }
.story-item.seen .story-ring{ background:#c7c7c7; }
.story-ring-inner{ width:100%; height:100%; border-radius:50%; border:2.5px solid #fff; overflow:hidden; }
.story-username{ font-size:12px; color:var(--ink); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; max-width:66px; }

/* ============ POSTS ============ */
.post{
  background:#fff; border:1px solid var(--border); border-radius:var(--radius);
  margin-bottom:24px;
  opacity:0; transform:translateY(14px);
  animation:postIn .5s ease forwards;
}
@keyframes postIn{ to{ opacity:1; transform:translateY(0); } }

.post-header{ display:flex; align-items:center; gap:12px; padding:14px; }
.post-avatar{ width:32px; height:32px; border-radius:50%; overflow:hidden; border:1px solid var(--border); flex-shrink:0; cursor:pointer; }
.post-avatar.story-avail{ padding:2px; background:var(--grad); }
.post-avatar.story-avail img{ border-radius:50%; border:2px solid #fff; }
.post-user-info{ display:flex; flex-direction:column; flex:1; min-width:0; }
.post-username{ font-size:14px; font-weight:600; cursor:pointer; }
.post-username:hover{ text-decoration:underline; }
.post-location{ font-size:12px; color:var(--gray); }
.post-more-btn svg{ width:20px; height:20px; }

.post-img-wrap{ position:relative; aspect-ratio:1/1; background:#000; overflow:hidden; user-select:none; }
.post-img-wrap img{ width:100%; height:100%; }

.like-burst{
  position:absolute; top:50%; left:50%;
  width:100px; height:100px;
  transform:translate(-50%,-50%) scale(0);
  color:#fff;
  filter:drop-shadow(0 2px 8px rgba(0,0,0,0.3));
  pointer-events:none;
  opacity:0;
}
.like-burst.animate{ animation:burst .9s cubic-bezier(.2,1.4,.4,1); }
@keyframes burst{
  0%{ transform:translate(-50%,-50%) scale(0); opacity:1; }
  30%{ transform:translate(-50%,-50%) scale(1.15); opacity:1; }
  45%{ transform:translate(-50%,-50%) scale(1); opacity:1; }
  80%{ opacity:1; }
  100%{ transform:translate(-50%,-50%) scale(1); opacity:0; }
}

.post-actions{ display:flex; align-items:center; padding:8px 14px 4px 14px; }
.action-btn{ padding:6px; margin-right:2px; transition:transform .15s ease, opacity .15s ease; }
.action-btn:hover{ opacity:.6; }
.action-btn:active{ transform:scale(0.85); }
.action-btn svg{ width:24px; height:24px; }
.action-btn.like-btn svg{ transition:transform .2s ease; }
.action-btn.like-btn.liked svg{ fill:var(--red); stroke:var(--red); }
.action-btn.like-btn.liked{ animation:likePop .3s ease; }
@keyframes likePop{ 0%{ transform:scale(1);} 40%{ transform:scale(1.3);} 100%{ transform:scale(1);} }
.action-btn.save-btn{ margin-left:auto; margin-right:0; }
.action-btn.save-btn.saved svg{ fill:var(--ink); }

.post-likes{ padding:0 14px; font-size:14px; font-weight:600; margin-bottom:4px; }
.post-caption{ padding:0 14px; font-size:14px; margin-bottom:6px; }
.post-caption .cap-username{ font-weight:600; margin-right:6px; }
.post-comments-link{ padding:0 14px; font-size:14px; color:var(--gray); margin-bottom:6px; display:block; cursor:pointer; }
.post-comments-link:hover{ color:var(--ink); }
.post-timestamp{ padding:0 14px 14px 14px; font-size:11px; color:var(--gray); text-transform:uppercase; letter-spacing:.2px; }

.post-add-comment{ display:flex; align-items:center; gap:10px; border-top:1px solid var(--border); padding:12px 14px; }
.post-add-comment svg{ width:22px; height:22px; color:var(--gray); flex-shrink:0; }
.post-add-comment input{ flex:1; font-size:14px; }
.post-add-comment input::placeholder{ color:var(--gray); }
.post-comment-submit{ font-size:14px; font-weight:700; color:var(--blue); opacity:.4; transition:opacity .15s ease; }
.post-comment-submit.active{ opacity:1; }

.feed-end{ text-align:center; padding:40px 0 60px 0; color:var(--gray); }
.feed-end p{ font-size:18px; font-weight:600; color:var(--ink); margin-bottom:6px; }
.feed-end span{ font-size:13px; }

/* ============ RIGHT PANEL ============ */
.suggestions-panel{ width:320px; flex-shrink:0; padding-top:6px; }
.mini-profile{ display:flex; align-items:center; gap:12px; margin-bottom:20px; }
.mini-avatar{ width:44px; height:44px; border-radius:50%; overflow:hidden; }
.mini-info{ display:flex; flex-direction:column; flex:1; min-width:0; }
.mini-info strong{ font-size:14px; }
.mini-info span{ font-size:13px; color:var(--gray); }
.switch-btn{ font-size:12px; font-weight:700; color:var(--blue); }
.switch-btn:hover{ color:var(--blue-hover); }

.suggestions-header{ display:flex; justify-content:space-between; align-items:center; margin-bottom:14px; }
.suggestions-header span{ font-size:14px; font-weight:600; color:var(--gray); }
.see-all-btn{ font-size:12px; font-weight:600; }
.see-all-btn:hover{ color:var(--gray); }

.suggestions-list{ display:flex; flex-direction:column; gap:12px; margin-bottom:28px; }
.suggestion-item{ display:flex; align-items:center; gap:12px; }
.suggestion-avatar{ width:36px; height:36px; border-radius:50%; overflow:hidden; flex-shrink:0; }
.suggestion-info{ flex:1; min-width:0; }
.suggestion-info strong{ font-size:13px; display:block; cursor:pointer; }
.suggestion-info span{ font-size:12px; color:var(--gray); }
.follow-btn{ font-size:12px; font-weight:700; color:var(--blue); flex-shrink:0; }
.follow-btn.following{ color:var(--ink); }
.follow-btn:hover{ color:var(--blue-hover); }

.mini-footer p{ font-size:11px; color:#c7c7c7; line-height:1.6; }
.copyright{ margin-top:12px; text-transform:uppercase; }

/* ============ BOTTOM NAV (mobile) ============ */
.bottom-nav{
  display:none;
  position:fixed; bottom:0; left:0; right:0; z-index:150;
  background:#fff; border-top:1px solid var(--border);
  padding:10px 20px;
  align-items:center; justify-content:space-between;
}
.bn-item svg{ width:26px; height:26px; }

/* ============ SEARCH OVERLAY ============ */
.search-overlay{
  position:fixed; top:0; left:245px; bottom:0; width:400px;
  background:#fff; border-right:1px solid var(--border);
  box-shadow:8px 0 24px rgba(0,0,0,0.08);
  transform:translateX(-120%);
  transition:transform .25s ease;
  z-index:180;
  padding:24px;
}
.search-overlay.open{ transform:translateX(0); }
.search-panel h3{ font-size:24px; margin-bottom:24px; }
.search-input-wrap{ display:flex; align-items:center; gap:8px; background:var(--bg); border-radius:8px; padding:10px 12px; margin-bottom:20px; }
.search-input-wrap svg{ width:16px; height:16px; color:var(--gray); flex-shrink:0; }
.search-input-wrap input{ flex:1; font-size:14px; }
.search-results{ display:flex; flex-direction:column; gap:16px; overflow-y:auto; }
.search-result-item{ display:flex; align-items:center; gap:12px; cursor:pointer; }
.search-result-item .suggestion-avatar{ width:44px; height:44px; }

/* ============ TOAST ============ */
.toast{
  position:fixed; bottom:28px; left:50%; transform:translateX(-50%) translateY(20px);
  background:var(--ink); color:#fff; font-weight:600; font-size:14px;
  padding:12px 22px; border-radius:8px;
  box-shadow:0 8px 24px rgba(0,0,0,0.3);
  opacity:0; pointer-events:none; z-index:1000;
  transition:opacity .25s ease, transform .25s ease;
}
.toast.show{ opacity:1; transform:translateX(-50%) translateY(0); }

/* ============ STORY VIEWER ============ */
.story-viewer{
  position:fixed; inset:0; background:rgba(0,0,0,0.9);
  display:flex; align-items:center; justify-content:center;
  opacity:0; pointer-events:none; z-index:400;
  transition:opacity .2s ease;
}
.story-viewer.open{ opacity:1; pointer-events:auto; }
.story-viewer-inner{
  position:relative; width:400px; max-width:92vw; height:80vh; max-height:720px;
  background:#000; border-radius:12px; overflow:hidden;
}
.story-progress-row{ position:absolute; top:10px; left:10px; right:10px; display:flex; gap:4px; z-index:3; }
.story-progress-track{ flex:1; height:2px; background:rgba(255,255,255,0.35); border-radius:2px; overflow:hidden; }
.story-progress-fill{ height:100%; width:0%; background:#fff; }
.story-progress-track.done .story-progress-fill{ width:100%; }

.story-header{ position:absolute; top:22px; left:14px; right:14px; display:flex; justify-content:space-between; align-items:center; z-index:3; }
.story-header-user{ display:flex; align-items:center; gap:8px; color:#fff; font-size:13px; font-weight:600; }
.story-avatar-sm{ width:30px; height:30px; border-radius:50%; overflow:hidden; border:1px solid rgba(255,255,255,0.5); }
.story-time{ color:rgba(255,255,255,0.7); font-weight:400; }
.story-close{ color:#fff; font-size:28px; line-height:1; }

.story-image{ width:100%; height:100%; object-fit:cover; }
.story-nav-btn{
  position:absolute; top:0; bottom:0; width:35%;
  color:#fff; font-size:36px; opacity:0;
  display:flex; align-items:center;
  transition:opacity .15s ease;
  background:transparent;
}
.story-nav-btn.prev{ left:0; justify-content:flex-start; padding-left:8px; }
.story-nav-btn.next{ right:0; justify-content:flex-end; padding-right:8px; }
.story-viewer-inner:hover .story-nav-btn{ opacity:.7; }

/* ============ POST MODAL ============ */
.modal-overlay{
  position:fixed; inset:0; background:rgba(0,0,0,0.85);
  display:flex; align-items:center; justify-content:center;
  opacity:0; pointer-events:none; z-index:400; padding:24px;
  transition:opacity .2s ease;
}
.modal-overlay.open{ opacity:1; pointer-events:auto; }
.post-modal{
  display:flex; background:#fff; border-radius:12px; overflow:hidden;
  max-width:900px; width:100%; max-height:85vh;
  transform:scale(0.94); transition:transform .2s ease;
}
.modal-overlay.open .post-modal{ transform:scale(1); }
.pm-img{ flex:1.3; background:#000; min-width:0; }
.pm-img img{ width:100%; height:100%; object-fit:contain; }
.pm-side{ flex:1; display:flex; flex-direction:column; min-width:280px; max-width:340px; }
.pm-header{ display:flex; align-items:center; gap:10px; padding:14px; border-bottom:1px solid var(--border); }
.pm-comments{ flex:1; overflow-y:auto; padding:14px; display:flex; flex-direction:column; gap:14px; }
.pm-comment{ display:flex; gap:10px; font-size:14px; }
.pm-comment .c-avatar{ width:28px; height:28px; border-radius:50%; overflow:hidden; flex-shrink:0; }
.pm-comment b{ margin-right:6px; }
.pm-actions{ padding:10px 14px; border-top:1px solid var(--border); }
.pm-likes{ padding:0 14px; font-size:14px; font-weight:600; }
.pm-add-comment{ display:flex; align-items:center; gap:8px; padding:14px; border-top:1px solid var(--border); }
.pm-add-comment input{ flex:1; font-size:14px; }
.pm-close-modal{ position:absolute; top:20px; right:20px; color:#fff; font-size:32px; z-index:5; }

/* ============ RESPONSIVE ============ */
@media (max-width: 1100px){
  .suggestions-panel{ display:none; }
  .main{ justify-content:center; }
}

@media (max-width: 900px){
  .sidebar{ width:72px; }
  .brand-name, .nav-link span{ display:none; }
  .brand{ justify-content:center; padding:22px 0 28px 0; }
  .nav-link{ justify-content:center; }
  .search-overlay{ left:72px; }
}

@media (max-width: 700px){
  .topbar{ display:block; }
  .sidebar{ display:none; }
  .bottom-nav{ display:flex; }
  .search-overlay{ left:0; width:100%; top:52px; }
  .main{ padding:16px 0 70px 0; }
  .feed-wrap{ width:100%; }
  .post{ border-left:none; border-right:none; border-radius:0; }
  .stories-rail{ border-left:none; border-right:none; border-radius:0; margin:0 0 16px 0; }
  .post-modal{ flex-direction:column; max-height:90vh; }
  .pm-img{ flex:none; height:50vh; }
  .pm-side{ max-width:none; }
}

@media (prefers-reduced-motion: reduce){
  *{ animation-duration:0.01ms !important; transition-duration:0.01ms !important; }
}

:focus-visible{ outline:2px solid var(--blue); outline-offset:2px; }