:root {
  --bg: #000000;
  --surface: #16181c;
  --surface-hover: rgba(255, 255, 255, 0.04);
  --sticky-bg: rgba(0, 0, 0, 0.72);
  --text: #e7e9ea;
  --muted: #71767b;
  --border: #2f3336;
  --accent: #1d9bf0;
  --accent-hover: #1a8cd8;
  --accent-soft: rgba(29, 155, 240, 0.14);
  --danger: #f4212e;
  --success: #00ba7c;
}

[data-bg="dim"] {
  --bg: #15202b;
  --surface: #1e2732;
  --surface-hover: rgba(255, 255, 255, 0.05);
  --sticky-bg: rgba(21, 32, 43, 0.78);
  --border: #38444d;
  --muted: #8b98a5;
}

[data-bg="light"] {
  --bg: #ffffff;
  --surface: #f7f9f9;
  --surface-hover: rgba(15, 20, 25, 0.04);
  --sticky-bg: rgba(255, 255, 255, 0.85);
  --text: #0f1419;
  --muted: #536471;
  --border: #eff3f4;
}

[data-bg="space"] {
  --bg: #070b18;
  --surface: rgba(17, 24, 46, 0.85);
  --surface-hover: rgba(120, 160, 255, 0.08);
  --sticky-bg: rgba(7, 11, 24, 0.78);
  --text: #eef2ff;
  --muted: #8e9cc4;
  --border: #222d4d;
}

.space-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
}

[data-accent="blue"]   { --accent: #1d9bf0; --accent-hover: #1a8cd8; --accent-soft: rgba(29, 155, 240, 0.14); }
[data-accent="gold"]   { --accent: #ffd400; --accent-hover: #e6bf00; --accent-soft: rgba(255, 212, 0, 0.15); }
[data-accent="pink"]   { --accent: #f91880; --accent-hover: #e01473; --accent-soft: rgba(249, 24, 128, 0.14); }
[data-accent="purple"] { --accent: #7856ff; --accent-hover: #6745ec; --accent-soft: rgba(120, 86, 255, 0.15); }
[data-accent="green"]  { --accent: #00ba7c; --accent-hover: #00a36d; --accent-soft: rgba(0, 186, 124, 0.14); }

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.45;
}

a { color: inherit; text-decoration: none; }

.hidden { display: none !important; }

.x-shell {
  position: relative;
  z-index: 1;
  max-width: 1265px;
  margin: 0 auto;
  display: flex;
  min-height: 100vh;
}

/* Left Sidebar */
.left-sidebar {
  width: 260px;
  flex-shrink: 0;
  padding: 0 12px;
}

.left-inner {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 10px 0 16px;
}

.brand-logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 999px;
  width: fit-content;
  transition: background 0.15s;
}
.brand-logo:hover { background: var(--surface-hover); }
.brand-name { font-size: 20px; font-weight: 800; letter-spacing: -0.02em; }

.nav-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 6px;
}

.nav-item {
  display: inline-flex;
  align-items: center;
  gap: 16px;
  padding: 11px 16px;
  border-radius: 999px;
  font-size: 19px;
  font-weight: 400;
  width: fit-content;
  transition: background 0.15s;
  color: var(--text);
}
.nav-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  font-family: inherit;
}
.nav-item:hover { background: var(--surface-hover); }
.nav-item.active { font-weight: 700; }
.nav-ico { font-size: 21px; width: 26px; text-align: center; }

.badge {
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
}

.btn-post-big {
  margin-top: 14px;
  width: 90%;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 14px 20px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-post-big:hover { background: var(--accent-hover); }

.account-pill {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s;
}
.account-pill:hover { background: var(--surface-hover); }

/* Center Column */
.center-col {
  width: 600px;
  min-width: 0;
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
  min-height: 100vh;
}

.sticky-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--sticky-bg);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.tabs-row {
  display: flex;
}

.tab-btn {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 15px;
  font-weight: 600;
  padding: 15px 12px;
  cursor: pointer;
  position: relative;
  transition: background 0.15s;
}
.tab-btn:hover { background: var(--surface-hover); }
.tab-btn.active { color: var(--text); font-weight: 700; }
.tab-btn.active::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 64px;
  height: 4px;
  border-radius: 999px;
  background: var(--accent);
}

.page-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
}
.page-header h2 { margin: 0; font-size: 20px; font-weight: 800; }
.back-btn {
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 18px;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  cursor: pointer;
}
.back-btn:hover { background: var(--surface-hover); }

/* Composer */
.composer {
  display: flex;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
  object-fit: cover;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }

.composer-body { flex: 1; min-width: 0; }

.composer-textarea {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 19px;
  font-family: inherit;
  resize: none;
  min-height: 54px;
  padding: 6px 0;
}
.composer-textarea::placeholder { color: var(--muted); }

.composer-preview-img {
  position: relative;
  margin: 8px 0;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.composer-preview-img img { width: 100%; max-height: 320px; object-fit: cover; display: block; }
.preview-remove {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(15, 20, 25, 0.78);
  color: #fff;
  border: none;
  border-radius: 999px;
  width: 30px;
  height: 30px;
  cursor: pointer;
}

.poll-builder {
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 12px;
  margin: 8px 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.poll-builder input {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 14px;
  outline: none;
}
.poll-builder input:focus { border-color: var(--accent); }

.composer-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  margin-top: 6px;
}
.composer-tools { display: flex; align-items: center; gap: 4px; position: relative; }
.tool-btn {
  background: transparent;
  border: none;
  color: var(--accent);
  font-size: 18px;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.tool-btn:hover { background: var(--accent-soft); }

.btn-pill {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 8px 18px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}
.btn-pill:hover { background: var(--accent-hover); }
.btn-pill:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-outline {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 7px 16px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}
.btn-outline:hover { background: var(--surface-hover); }

.btn-white-pill {
  background: var(--text);
  color: var(--bg);
  border: none;
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}
.btn-white-pill:hover { opacity: 0.9; }

/* Post Card */
.post-card {
  display: flex;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  transition: background 0.12s;
  cursor: pointer;
}
.post-card:hover { background: var(--surface-hover); }

.post-main { flex: 1; min-width: 0; }
.post-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.post-author {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
  min-width: 0;
}
.post-name { font-weight: 700; font-size: 15px; }
.post-name:hover { text-decoration: underline; }
.verified-badge { color: var(--accent); font-size: 14px; }
.post-handle, .post-time { color: var(--muted); font-size: 14px; }

.post-text {
  font-size: 15px;
  white-space: pre-wrap;
  word-break: break-word;
  margin-top: 3px;
}
.hashtag, .mention { color: var(--accent); cursor: pointer; }
.hashtag:hover, .mention:hover { text-decoration: underline; }

.post-img {
  margin-top: 10px;
  border-radius: 16px;
  border: 1px solid var(--border);
  max-width: 100%;
  max-height: 420px;
  object-fit: cover;
  display: block;
}

.poll-box {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.poll-opt {
  position: relative;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 12px;
  overflow: hidden;
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  cursor: pointer;
  background: transparent;
  color: var(--text);
  text-align: left;
}
.poll-opt:hover { border-color: var(--accent); }
.poll-opt.voted { border-color: var(--accent); font-weight: 700; }
.poll-bar {
  position: absolute;
  inset: 0 auto 0 0;
  background: var(--accent-soft);
  z-index: 0;
  pointer-events: none;
}
.poll-opt span { position: relative; z-index: 1; }

.post-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 460px;
  margin-top: 10px;
}

.act-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  padding: 5px 8px;
  border-radius: 999px;
  cursor: pointer;
  transition: color 0.12s, background 0.12s;
}
.act-btn:hover { background: var(--accent-soft); color: var(--accent); }
.act-btn.liked { color: #f91880; }
.act-btn.liked:hover { background: rgba(249, 24, 128, 0.14); color: #f91880; }
.act-btn.reposted { color: var(--success); }
.act-btn.reposted:hover { background: rgba(0, 186, 124, 0.14); color: var(--success); }
.act-btn.bookmarked { color: var(--accent); }

/* Right Sidebar */
.right-sidebar {
  width: 350px;
  flex-shrink: 0;
  padding: 10px 0 24px 28px;
}
.right-inner {
  position: sticky;
  top: 10px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 10px 16px;
}
.search-box:focus-within {
  border-color: var(--accent);
  background: var(--bg);
}
.search-box input {
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 14px;
  width: 100%;
}

.side-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px 16px;
}
.side-card h3 { margin: 0 0 10px; font-size: 18px; font-weight: 800; }
.side-card p { margin: 0 0 12px; font-size: 14px; color: var(--muted); }

.trends-list, .follow-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.trend-item {
  display: flex;
  flex-direction: column;
  cursor: pointer;
}
.trend-item:hover .trend-tag { color: var(--accent); }
.trend-meta { font-size: 12px; color: var(--muted); }
.trend-tag { font-weight: 700; font-size: 15px; }

.follow-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.follow-user { display: flex; align-items: center; gap: 10px; min-width: 0; cursor: pointer; }

/* Profile */
.profile-banner {
  height: 170px;
  background: var(--accent);
}
.profile-top {
  padding: 0 16px 14px;
  border-bottom: 1px solid var(--border);
}
.profile-avatar-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-top: -46px;
  margin-bottom: 10px;
}
.profile-avatar {
  width: 96px;
  height: 96px;
  border-radius: 999px;
  border: 4px solid var(--bg);
  font-size: 34px;
}

/* Modals & Lightbox */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(91, 112, 131, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}
.modal-box {
  width: 100%;
  max-width: 520px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 20px;
  max-height: 90vh;
  overflow-y: auto;
}
.form-field {
  width: 100%;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--text);
  font-size: 15px;
  outline: none;
  margin-bottom: 10px;
  font-family: inherit;
}
.form-field:focus { border-color: var(--accent); }

.emoji-popover {
  position: absolute;
  top: 40px;
  left: 0;
  z-index: 30;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  width: 240px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 20px;
}
.lightbox img { max-width: 95vw; max-height: 90vh; border-radius: 12px; }
.lightbox-close {
  position: fixed;
  top: 16px;
  right: 16px;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  border: none;
  border-radius: 999px;
  width: 38px;
  height: 38px;
  font-size: 18px;
  cursor: pointer;
}

.mobile-nav, .fab-post { display: none; }

@media (max-width: 1120px) {
  .right-sidebar { display: none; }
  .x-shell { justify-content: center; }
}

@media (max-width: 760px) {
  .left-sidebar { display: none; }
  .center-col { width: 100%; border-left: none; border-right: none; padding-bottom: 70px; }
  .mobile-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg);
    border-top: 1px solid var(--border);
    justify-content: space-around;
    padding: 10px 0;
    font-size: 22px;
    z-index: 50;
  }
  .fab-post {
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    right: 18px;
    bottom: 68px;
    width: 54px;
    height: 54px;
    border-radius: 999px;
    background: var(--accent);
    color: #fff;
    border: none;
    font-size: 28px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
    z-index: 50;
  }
}
