:root{
  --bg: #000000;
  --card: #16181C;
  --card-2: #0F1113;
  --text: #E7E9EA;
  --text-dim: #8B98A5;
  --brand: #1D9BF0;
  --border: #2F3336;
  --success: #00BA7C;
  --danger: #F91880;
  --warn: #F5C451;
  --pill: #1E2732;
}

*{ box-sizing: border-box; }
html,body{ height:100%; }
body{
  margin:0;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", system-ui, -apple-system, Segoe UI, Roboto, Arial, "Noto Sans", sans-serif;
  overflow-x: hidden;
}

/* Shell */
.container{
  max-width: 1260px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 275px minmax(0, 600px) 350px;
  gap: 24px;
  padding: 0 16px;
}
.left, .main, .right{
  min-height: 100vh;
}

/* Left Sidebar */
.left{
  position: sticky;
  top: 0;
  align-self: start;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 8px 0;
}
.x-logo{
  width: 44px; height: 44px;
  display: grid; place-items: center;
  border-radius: 999px;
  color: var(--text);
  font-weight: 800;
  border: 1px solid var(--border);
}
.brand-logo{
  height: 44px; min-width: 44px;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0 14px; border-radius: 999px;
  color: #fff; font-weight: 900; letter-spacing: 0.2px;
  border: 1px solid var(--border);
  background: linear-gradient(135deg, #111827, #0b1220);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.04);
}
.brand-logo img{ max-height: 26px; width: auto; display: block; filter: drop-shadow(0 2px 4px rgba(0,0,0,.35)); }
.nav{
  display: flex; flex-direction: column; gap: 4px;
}
.nav a{
  display: flex; align-items: center; gap: 14px;
  color: var(--text);
  text-decoration: none;
  padding: 12px 14px;
  font-size: 18px;
  border-radius: 999px;
  width: fit-content;
}
.nav a i{ font-size: 20px; }
.nav a:hover{ background: #181C20; }
.nav a.active{ font-weight: 700; }

.tweet-btn{
  margin-top: 8px;
  background: var(--brand);
  color: #fff;
  border: none;
  padding: 14px 22px;
  border-radius: 999px;
  font-weight: 800;
  width: 75%;
  cursor: pointer;
}

.me-card{
  margin-top: auto;
  display: flex; align-items: center; gap: 10px;
  padding: 12px; border-radius: 12px;
  transition: background .15s ease;
  cursor: pointer;
}
.me-card:hover{ background: #0B0D0F; }
.avatar{
  width: 40px; height: 40px;
  border-radius: 999px;
  overflow: hidden; border: 1px solid var(--border);
  flex-shrink: 0;
}
.avatar img{ width:100%; height:100%; object-fit: cover; }
.me-info{ min-width: 0; }
.me-info .name{ font-weight: 700; font-size: 15px; }
.me-info .handle{ color: var(--text-dim); font-size: 14px; }

/* Main */
.main{
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
  min-height: 100vh;
  position: relative;
}
.main-header{
  position: sticky; top: 0; z-index: 5;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(8px);
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  font-weight: 800; font-size: 20px;
}
.mh-actions{ display:flex; align-items:center; gap: 8px; }
.hdr-btn{ position: relative; width: 36px; height: 36px; border-radius: 999px; border: none; background: transparent; color: var(--text); cursor: pointer; display: grid; place-items: center; }
.hdr-btn:hover{ background: #181C20; }
.notif-count{ position: absolute; top: -4px; right: -4px; background: var(--brand); color: #fff; border-radius: 999px; font-size: 11px; line-height: 1; padding: 3px 6px; border: 2px solid #000; }

/* Notifications dropdown */
.notif-dd{
  position: absolute; right: 16px; top: 52px; z-index: 10; width: min(420px, 92vw);
  background: var(--card); border: 1px solid var(--border); border-radius: 16px; overflow: hidden;
  box-shadow: 0 12px 24px rgba(0,0,0,0.45);
  display: none;
}
.notif-dd.open{ display: block !important; }
.notif-dd .head{ display:flex; align-items:center; justify-content: space-between; padding: 10px 12px; border-bottom: 1px solid var(--border); font-weight: 800; }
.notif-dd .mark{ background: transparent; color: var(--text); border:1px solid var(--border); border-radius: 999px; padding: 6px 10px; cursor: pointer; font-weight:700; font-size: 12px; }
.notif-dd .mark:hover{ background: #0B0D0F; }
.notif-list{ display: flex; flex-direction: column; max-height: 60vh; overflow: auto; }
.notif-item{ display:flex; gap: 10px; align-items: center; padding: 12px 12px; border-bottom: 1px solid var(--border); cursor: pointer; }
.notif-item:hover{ background: #0B0D0F; }
.notif-item .avatar{ width: 36px; height: 36px; }
.notif-msg{ display:flex; flex-direction:column; gap: 2px; min-width: 0; }
.notif-line{ font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.notif-meta{ color: var(--text-dim); font-size: 12px; }

/* Composer */
.composer{
  display: flex; gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.composer .avatar{ width: 48px; height: 48px; }
.composer .box{ flex:1; }
.what{
  width: 100%; resize: none; border: none; outline: none;
  background: transparent; color: var(--text);
  font-size: 18px; line-height: 1.4; min-height: 60px;
}
.toolbar{
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 8px;
}
.toolbar-left{
  display: flex; gap: 10px;
}
.tb-btn{
  color: var(--brand); background: transparent; border: none;
  width: 36px; height: 36px; border-radius: 999px; cursor: pointer;
}
.tb-btn:hover{ background: #031018; }
.char{
  color: var(--text-dim);
  font-size: 12px; margin-right: 10px;
}
.post-btn{
  background: var(--brand); color: #fff; border: none;
  padding: 10px 16px; border-radius: 999px; font-weight: 800; cursor: pointer;
}
.post-btn:disabled{ opacity: .5; cursor: not-allowed; }
.toolbar .post-btn{ min-width: 74px; }

/* Timeline */
.timeline{ display: flex; flex-direction: column; }
.post{
  display: flex; gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  transition: background .1s ease;
}
.post:hover{ background: #07090B; box-shadow: 0 8px 16px rgba(0,0,0,0.25) inset; }
.post.highlight{ background: linear-gradient(0deg, rgba(29,155,240,0.06), transparent); }
.post.skeleton .sk{ position: relative; overflow: hidden; background:#0B0D0F !important; border:1px solid var(--border); border-radius:8px; }
.post.skeleton .sk-ava{ border-radius:999px; }
.post.skeleton .sk::after{ content:""; position:absolute; inset:0; transform:translateX(-100%); background:linear-gradient(90deg, rgba(255,255,255,0), rgba(255,255,255,0.06), rgba(255,255,255,0)); animation: shimmer 1.25s linear infinite; }
@keyframes shimmer{ 100% { transform: translateX(100%); } }
.post .meta-line{
  display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap;
  font-size: 15px;
}
.post .name{ font-weight: 700; }
.post .handle{ color: var(--text-dim); }
.post .dot{ color: var(--text-dim); }
.post .time{ color: var(--text-dim); }
.post .text{
  white-space: pre-wrap; line-height: 1.5; font-size: 15px; margin-top: 4px;
  overflow-wrap: anywhere; word-break: break-word;
}
.post .text a{ color: var(--brand); text-decoration: none; word-break: break-all; }
.post .text a:hover{ text-decoration: underline; }
.media{
  margin-top: 10px;
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  position: relative;
}
.media img, .media video{ width: 100%; height: auto; display: block; }

/* Composer media controls */
.remove-attach{
  position: absolute; top: 8px; right: 8px;
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border-radius: 999px; border: 1px solid var(--border);
  background: rgba(0,0,0,0.6); color: var(--text);
  cursor: pointer;
}
.remove-attach:hover{ background: rgba(0,0,0,0.8); }
.uploading{ position: absolute; inset: 0; display: grid; place-items: center; background: rgba(0,0,0,0.25); }
.spinner{ width: 28px; height: 28px; border-radius: 999px; border: 3px solid rgba(255,255,255,0.25); border-top-color: var(--brand); animation: spin 1s linear infinite; }
@keyframes spin{ to { transform: rotate(360deg) } }

/* Link preview card */
.link-preview{
  display: flex; align-items: stretch; gap: 0;
  margin-top: 10px;
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  text-decoration: none;
  color: var(--text);
  background: var(--card);
  max-width: 100%;
}
.link-preview img{
  width: 112px; height: 112px; object-fit: cover; flex-shrink: 0; display: block; border-right: 1px solid var(--border);
}
.lp-info{ padding: 10px 12px; display:flex; flex-direction:column; gap:4px; min-width:0; }
.lp-title{ font-weight: 700; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lp-desc{ color: var(--text-dim); font-size: 13px; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* Prevent horizontal drift on small screens */
@media (max-width: 640px){
  .container{ overflow-x: hidden; }
}

.actions{
  display: flex; justify-content: space-between; max-width: 460px;
  margin-top: 8px; color: var(--text-dim);
}
.act{
  display: inline-flex; align-items: center; gap: 10px;
  padding: 8px; border-radius: 999px; cursor: pointer;
}
.act i{ width: 18px; text-align: center; }
.act:hover{ background: #0B0D0F; color: var(--text); }
.act.comment:hover{ color: var(--brand); background: #06141D; }
.act.repost:hover{ color: var(--success); background: #051B17; }
.act.like:hover{ color: var(--danger); background: #200914; }
.act.share:hover{ color: var(--brand); background: #06141D; }
.act .count{ font-size: 13px; }
.liked{ color: var(--danger); }
.reposted{ color: var(--success); }

/* Polls */
.poll{ margin-top:10px; background: var(--card); border:1px solid var(--border); border-radius:16px; padding:10px; }
.poll-list{ display:flex; flex-direction:column; gap:8px; }
.poll .poll-opt{ background:#0B0D0F; border:1px solid var(--border); border-radius:12px; padding:10px 12px; display:flex; align-items:center; gap:10px; }
.poll .poll-opt input{ accent-color: var(--brand); }
.poll .poll-opt:hover{ background:#0F1215; }
.poll .bar{ width:100%; height:8px; background:rgba(29,155,240,0.18); border-radius:999px; overflow:hidden; }
.poll .fill{ height:8px; background: var(--brand); }
.poll .lbl{ color: var(--text-dim); font-size:13px; margin-top:4px; }
.poll .poll-meta{ margin-top:6px; color:#8B98A5; font-size:12px; }

/* Breaking */
.badge-breaking{ color: var(--warn); font-weight: 800; display: inline-flex; align-items: center; gap: 6px; margin-right: 6px; }
.tb-btn.active{ background: #06141D; }

/* AI Posts */
.badge-ai{ color: #7C3AED; font-weight: 800; display: inline-flex; align-items: center; gap: 6px; }
.post.ai{ background: linear-gradient(0deg, rgba(124,58,237,0.06), transparent); }

/* Right Sidebar */
.right{
  position: sticky; top: 0; align-self: start;
  display: flex; flex-direction: column; gap: 12px;
  padding: 8px 0;
}
.srch{
  position: sticky; top: 8px; z-index: 4;
  background: var(--card-2);
  border: 1px solid var(--border);
  border-radius: 999px; padding: 10px 14px;
  display: flex; align-items: center; gap: 10px;
}
.srch input{
  flex: 1; background: transparent; border: none; outline: none;
  color: var(--text); font-size: 14px;
}
.srch-dd{
  position: sticky; top: 56px; z-index: 5;
  margin-top: 8px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 12px 24px rgba(0,0,0,0.45);
  overflow: hidden;
  display: none;
}
.srch-dd.open{ display: block !important; }
.srch-list{ display: flex; flex-direction: column; max-height: 60vh; overflow: auto; }
.srch-item{ display:flex; align-items:center; gap:10px; padding: 10px 12px; cursor: pointer; }
.srch-item:hover{ background: #0B0D0F; }
.srch-item.active{ background: #0B0D0F; }
.srch-item .avatar{ width: 36px; height: 36px; }
.srch-item .name{ font-weight: 700; font-size: 14px; }
.srch-item .handle{ color: var(--text-dim); font-size: 12px; }
.srch-empty{ padding: 12px; color: var(--text-dim); font-size: 13px; }
.card{
  background: linear-gradient(135deg, rgba(22,24,28,0.85), rgba(16,18,20,0.85));
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 16px; overflow: hidden;
  backdrop-filter: blur(8px);
  box-shadow: 0 10px 22px rgba(0,0,0,0.35);
}
.card h3{
  font-size: 20px; font-weight: 800; padding: 12px 16px; margin: 0; border-bottom: 1px solid var(--border);
}
.card .body{ padding: 12px 16px; }
.buy{
  background: var(--brand); color: #fff; border: none;
  padding: 10px 14px; border-radius: 999px; font-weight: 700; cursor: pointer;
}

/* Eyro Pro card (colorful) */
#proCard{
  background: linear-gradient(135deg, #0e1726 0%, #102033 55%, #1b2a41 100%);
  border-color: rgba(255,255,255,0.12);
  box-shadow: 0 12px 28px rgba(29,155,240,0.12), inset 0 0 0 1px rgba(255,255,255,0.02);
}
#proCard h3{
  border-bottom-color: rgba(255,255,255,0.12);
  background: transparent;
  display: flex; align-items: center; gap: 8px;
}
#proCard h3::before{
  content: "★";
  color: #ffd43b;
}
#proCard .body{
  color: #cbd5e1;
}
#proCard .buy{
  display: inline-block;
  background: linear-gradient(135deg, #1D9BF0, #7C3AED);
  color: #fff; text-decoration: none;
  padding: 10px 16px;
  border-radius: 999px; font-weight: 800; border: none;
  box-shadow: 0 8px 18px rgba(124,58,237,0.35), 0 0 0 1px rgba(255,255,255,0.08) inset;
  transition: transform .12s ease, filter .12s ease;
}
#proCard .buy:hover{ filter: brightness(1.06); transform: translateY(-1px); }
.trend{ display: flex; flex-direction: column; gap: 2px; padding: 12px 16px; cursor: pointer; }
.trend:hover{ background: #0B0D0F; }
.trend .meta{ color: var(--text-dim); font-size: 12px; }
.trend .tag{ font-weight: 700; }

.who{ display: flex; flex-direction: column; }
.who-item{
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; gap: 12px;
}
.who-item:hover{ background: #0B0D0F; }
.who .info{ min-width: 0; }
.follow{
  background: #fff; color: #000; border: none; padding: 8px 12px; border-radius: 999px; font-weight: 700; cursor: pointer;
}

/* Comment Modal */
.modal{
  position: fixed; inset: 0; z-index: 50;
  display: none; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.6);
}
.modal.open{ display: flex; }
.modal-card{
  width: min(600px, 92vw);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  display: grid; grid-template-rows: auto 1fr auto;
  max-height: 80vh;
}
.modal-head{
  display:flex; align-items:center; justify-content: space-between; gap: 12px;
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  font-weight: 800;
}
.modal-body{
  padding: 12px 16px; overflow: auto;
  display: flex; flex-direction: column; gap: 12px;
}
.comment-item{ display:flex; gap: 10px; }
.comment-text{ background: #0B0D0F; border:1px solid var(--border); padding: 10px; border-radius: 12px; }
.modal-foot{
  padding: 12px 16px; border-top: 1px solid var(--border);
  display:flex; gap: 8px; align-items: center;
}
.modal-foot textarea{
  flex:1; min-height: 46px; resize: vertical; background: #0B0D0F; border:1px solid var(--border); border-radius: 12px; color: var(--text); padding: 10px;
}
.send{ background: var(--brand); color:#fff; border:none; padding:10px 14px; border-radius: 12px; font-weight:700; cursor:pointer; }

/* Tabs */
.tabs{ display:flex; border-bottom:1px solid var(--border); }
.tabs .tab{ flex:1; text-align:center; padding:12px 10px; cursor:pointer; color:var(--text-dim); font-weight:700; }
.tabs .tab:hover{ background:#07090B; color:var(--text); }
.tabs .tab.active{ color:var(--text); border-bottom:3px solid var(--brand); }
.feed-tabs{ position:sticky; top:52px; z-index:4; background:rgba(0,0,0,0.6); backdrop-filter: blur(8px); }
/* Parallax-enhanced tabs (JS toggles .parallax and sets --par) */
.feed-tabs.parallax{ background: rgba(0,0,0, calc(0.4 + var(--par, 0))); }

/* Responsive */
@media (max-width: 1100px){
  .container{
    grid-template-columns: 88px minmax(0, 1fr) 0px;
  }
  .nav a span{ display: none; }
  .tweet-btn{ width: 44px; border-radius: 999px; text-indent: -9999px; position: relative; }
  .tweet-btn::after{ content: "+"; position: absolute; inset: 0; display: grid; place-items: center; text-indent: 0; font-size: 20px; }
  .right{ display: none; }
}
@media (max-width: 640px){
  .container{ grid-template-columns: minmax(0, 1fr); }
  .left{ display: none; }
  .main{ border-left: none; border-right: none; }
  .composer .what{ font-size: 16px; }
  .toolbar{ flex-wrap: wrap; row-gap: 8px; }
  .toolbar-left{ order: 2; width: 100%; }
  .toolbar > div:last-child{ order: 1; margin-left: auto; }
}

/* Floating Post button (all devices) */
.fab-post{
  position: fixed;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom));
  width: 56px; height: 56px;
  border-radius: 999px;
  border: none;
  display: grid; place-items: center;
  font-size: 22px; color: #fff;
  background: linear-gradient(135deg, var(--brand), #7C3AED);
  box-shadow: 0 10px 24px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,255,255,0.06) inset;
  z-index: 2000; cursor: pointer;
  transition: transform .12s ease, filter .12s ease;
}
.fab-post:hover{ filter: brightness(1.08); transform: translateY(-1px); }
body.has-fab .main{ padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
body.has-bottom-nav .main{ padding-bottom: calc(140px + env(safe-area-inset-bottom)); }
@media (max-width: 640px){
  .fab-post{ bottom: calc(88px + env(safe-area-inset-bottom)); }
}
@media (min-width: 641px){
  .bottom-nav{ display: none; }
  body.has-bottom-nav .main{ padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
  body.show-bottom-nav-desktop .bottom-nav{ display:flex; }
  body.show-bottom-nav-desktop.has-bottom-nav .main{ padding-bottom: calc(140px + env(safe-area-inset-bottom)); }
}

/* Bottom navigation (X-like) */
.bottom-nav{
  position: fixed; left:0; right:0; bottom:0;
  height: 64px; padding-bottom: env(safe-area-inset-bottom);
  background: rgba(16,18,20,0.72);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  display:flex; justify-content:space-around; align-items:center;
  z-index: 40;
}
.bottom-nav a{ display:flex; flex-direction:column; align-items:center; gap:4px; color:var(--text-dim); text-decoration:none; font-size:12px; }
.bottom-nav a i{ font-size: 20px; }
.bottom-nav a.active{ color:#fff; }
.bottom-nav a.active i{ color: var(--brand); }
@media (max-width: 380px){ .bottom-nav a span{ display:none; } }
.bn-count{ position:absolute; top:-2px; right:-10px; background:var(--brand); color:#fff; border-radius:999px; padding:2px 6px; font-size:10px; line-height:1; border:2px solid #000; }
.bn-dot{ position:absolute; top:2px; right:-2px; width:8px; height:8px; border-radius:999px; background: var(--brand); box-shadow: 0 0 0 2px #000; }

/* Pull-to-refresh indicator */
.ptr{
  position: fixed; top:0; left:0; right:0; height:64px;
  display:grid; place-items:center; z-index: 35; pointer-events:none;
  transition: transform .15s ease;
}
.ptr .spinner{ width:24px; height:24px; border-width:3px; }
.ptr.refreshing .spinner{ animation: spin 0.8s linear infinite; }

/* Header scrolled state */
.main-header.scrolled{ background: rgba(0,0,0,0.75); box-shadow: 0 6px 18px rgba(0,0,0,0.35); }

/* Micro-interactions */
.tap-anim{ transition: transform .12s ease; }
.pulse-once{ animation: pulse .18s ease; }
@keyframes pulse{ 0%{ transform: scale(1);} 50%{ transform: scale(0.96);} 100%{ transform: scale(1);} }

/* Back to Top FAB */
.fab-top{
  position: fixed; right: 16px; bottom: calc(88px + env(safe-area-inset-bottom));
  width: 48px; height: 48px; border-radius: 999px; border: none; display: grid; place-items: center;
  background: linear-gradient(135deg, #0ea5e9, #22d3ee); color: #001018;
  box-shadow: 0 10px 24px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,255,255,0.06) inset;
  z-index: 55; cursor: pointer; transition: transform .12s ease, filter .12s ease; opacity: .95;
}
.fab-top:hover{ filter: brightness(1.08); transform: translateY(-1px); }

/* AI headline link behavior */
.ai-headline{ font-weight: 700; color: #FFFFFF; }
.ai-headline, .ai-headline:link, .ai-headline:visited{ text-decoration: none; color: #FFFFFF; }
.ai-headline:hover, .ai-headline:focus{ text-decoration: underline; }

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce){
  .fab-post, .tap-anim{ transition: none !important; }
  .pulse-once{ animation: none !important; }
  .ptr .spinner{ animation: none !important; }
  .post.skeleton .sk::after{ animation: none !important; }
}
