:root,
[data-theme="dark"] {
  --bg: #000000;
  --surface: #16181C;
  --surface-hover: rgba(255, 255, 255, 0.035);
  --input-bg: #202327;
  --text: #E7E9EA;
  --text-secondary: #A9AEB3;
  --text-muted: #71767B;
  --border: #2F3336;
  --accent: #1D9BF0;
  --accent-soft: rgba(29, 155, 240, 0.14);
  --pill-bg: #EFF3F4;
  --pill-text: #0F1419;
  --pill-hover: #D7DBDC;
  --code-bg: #202327;
  --code-block-bg: #0D1014;
  --code-block-text: #E7E9EA;
  --sticky-bg: rgba(0, 0, 0, 0.72);
}

html[data-theme="light"] {
  --bg: #FFFFFF;
  --surface: #F7F9F9;
  --surface-hover: rgba(15, 20, 25, 0.03);
  --input-bg: #EFF3F4;
  --text: #0F1419;
  --text-secondary: #3B4650;
  --text-muted: #536471;
  --border: #EFF3F4;
  --accent: #1D9BF0;
  --accent-soft: rgba(29, 155, 240, 0.10);
  --pill-bg: #0F1419;
  --pill-text: #FFFFFF;
  --pill-hover: #272C30;
  --code-bg: #EFF3F4;
  --code-block-bg: #0F1419;
  --code-block-text: #EFF3F4;
  --sticky-bg: rgba(255, 255, 255, 0.85);
}

*, *::before, *::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  background-color: var(--bg);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Noto Sans CJK SC", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  
}

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

/* Reading progress */
.reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  width: 0%;
  height: 2px;
  background: var(--accent);
  z-index: 1000;
  transition: width 0.08s linear;
}

/* 3-Column X / Grok Shell */
.layout-shell {
  width: 100%;
  max-width: 1220px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 230px minmax(0, 640px) 320px;
  justify-content: center;
  min-height: 100vh;
}

/* Left Rail */
.left-rail {
  padding: 12px 16px 24px;
}

.left-rail-inner {
  position: sticky;
  top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.brand-logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 9999px;
  width: fit-content;
  transition: background-color 0.16s ease;
}

.brand-logo:hover {
  background: var(--surface-hover);
}

.bird-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
}

.brand-text {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.rail-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 6px 0 14px;
}

.rail-link {
  display: inline-flex;
  align-items: center;
  gap: 16px;
  padding: 11px 16px;
  border-radius: 9999px;
  font-size: 17px;
  font-weight: 400;
  color: var(--text);
  width: fit-content;
  background: transparent;
  border: none;
  cursor: pointer;
  font-family: inherit;
  transition: background-color 0.16s ease;
}

.rail-link:hover {
  background: var(--surface-hover);
}

.rail-link.active {
  font-weight: 700;
}

[data-theme="dark"] .icon-moon { display: none; }
[data-theme="light"] .icon-sun { display: none; }

.compose-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  max-width: 190px;
  height: 46px;
  border-radius: 9999px;
  background: var(--pill-bg);
  color: var(--pill-text);
  font-size: 15px;
  font-weight: 700;
  transition: background-color 0.16s ease, transform 0.12s ease;
}

.compose-pill:hover {
  background: var(--pill-hover);
}

/* Center Feed Column with Signature X 1px Vertical Hairlines */
.center-column {
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
  min-height: 100vh;
  padding-bottom: 72px;
}

.mobile-header {
  display: none;
}

.mobile-bottom-nav {
  display: none;
}

/* Sticky X Tab Header */
.feed-sticky-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--sticky-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.feed-title-bar {
  padding: 14px 18px 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.feed-title-bar h1 {
  margin: 0;
  font-size: 19px;
  font-weight: 800;
  letter-spacing: -0.015em;
}

.feed-subtitle-badge {
  font-size: 12px;
  color: var(--text-muted);
}

.x-tabs {
  display: flex;
  overflow-x: auto;
  scrollbar-width: none;
}

.x-tabs::-webkit-scrollbar {
  display: none;
}

.x-tab {
  flex: 1;
  min-width: 78px;
  padding: 12px 14px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  position: relative;
  white-space: nowrap;
  font-family: inherit;
  transition: background-color 0.16s ease, color 0.16s ease;
}

.x-tab:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.x-tab.active {
  color: var(--text);
  font-weight: 700;
}

.x-tab.active::after {
  content: "";
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: 48px;
  height: 3.5px;
  border-radius: 9999px;
  background: var(--accent);
}

/* Grok Prompt Banner at Top of Feed */
.grok-banner {
  padding: 18px 18px 16px;
  border-bottom: 1px solid var(--border);
  background: radial-gradient(circle at 88% 0%, var(--accent-soft), transparent 55%);
}

.grok-banner-eyebrow {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--accent);
  text-transform: uppercase;
  margin-bottom: 4px;
}

.grok-banner-text {
  margin: 0;
  font-size: 14.5px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.mobile-search-wrap {
  display: none;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
}

/* X-Style Stream Post Items */
.post-stream {
  display: flex;
  flex-direction: column;
}

.post-item {
  display: flex;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  transition: background-color 0.15s ease;
}

.post-item:hover {
  background: var(--surface-hover);
}

.post-avatar {
  width: 40px;
  height: 40px;
  border-radius: 9999px;
  background: var(--surface);
  border: 1px solid var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 15px;
  color: var(--text);
  flex-shrink: 0;
}

.post-main {
  flex: 1;
  min-width: 0;
}

.post-meta-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 13.5px;
  margin-bottom: 4px;
}

.post-author-name {
  font-weight: 700;
  color: var(--text);
}

.verified-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 15px;
  height: 15px;
  border-radius: 9999px;
  background: var(--accent);
  color: #FFFFFF;
  font-size: 10px;
  font-weight: 800;
}

.post-handle,
.post-date {
  color: var(--text-muted);
}

.post-cat-pill {
  margin-left: auto;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 2px 9px;
  border-radius: 9999px;
}

.post-title {
  margin: 4px 0 6px;
  font-size: 17.5px;
  font-weight: 700;
  line-height: 1.38;
  color: var(--text);
}

.post-summary {
  margin: 0 0 12px;
  font-size: 14.5px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.post-media {
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--border);
  margin-bottom: 12px;
  background: var(--surface);
}

.post-media img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  display: block;
}

.post-footer-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12.5px;
  color: var(--text-muted);
}

.post-tags-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.hash-tag {
  color: var(--accent);
  font-weight: 500;
}

/* Article Detail */
.detail-top-bar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--sticky-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 12px 18px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.back-circle {
  width: 34px;
  height: 34px;
  border-radius: 9999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.15s ease;
}

.back-circle:hover {
  background: var(--surface-hover);
}

.detail-body {
  padding: 20px 22px 36px;
}

.article-title {
  margin: 10px 0 14px;
  font-size: clamp(23px, 4vw, 30px);
  line-height: 1.3;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.article-hero-cover {
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--border);
  margin: 18px 0 24px;
}

.article-hero-cover img {
  width: 100%;
  max-height: 380px;
  object-fit: cover;
  display: block;
}

.article-toc {
  margin-bottom: 24px;
  padding: 14px 16px;
  border-radius: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
}

.article-toc-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
}

.article-toc ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.article-toc a {
  font-size: 13.5px;
  color: var(--text-secondary);
}

.article-toc a:hover {
  color: var(--accent);
}

.article-toc li.toc-h3 {
  padding-left: 14px;
}

/* Markdown Prose */
.prose {
  font-size: 15.5px;
  line-height: 1.82;
  color: var(--text);
}

.prose h1,
.prose h2,
.prose h3 {
  line-height: 1.35;
  margin-top: 1.8em;
  margin-bottom: 0.6em;
  font-weight: 700;
  scroll-margin-top: 70px;
}

.prose h2 {
  font-size: 20px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

.prose h3 {
  font-size: 17px;
}

.prose p {
  margin: 0 0 1.2em;
}

.prose a {
  color: var(--accent);
}

.prose a:hover {
  text-decoration: underline;
}

.prose blockquote {
  margin: 1.4em 0;
  padding: 12px 16px;
  border-left: 3px solid var(--accent);
  background: var(--surface);
  border-radius: 0 12px 12px 0;
  color: var(--text-secondary);
}

.prose blockquote p:last-child {
  margin-bottom: 0;
}

.prose ul,
.prose ol {
  margin: 0 0 1.2em;
  padding-left: 1.4em;
}

.prose li {
  margin-bottom: 0.4em;
}

.prose code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.88em;
  background: var(--code-bg);
  padding: 2px 6px;
  border-radius: 6px;
}

.code-block-wrap {
  position: relative;
  margin: 1.4em 0;
}

.code-copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 3px 10px;
  border-radius: 9999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
}

.code-copy-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.prose pre {
  margin: 0;
  padding: 16px 18px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--code-block-bg);
  color: var(--code-block-text);
  overflow-x: auto;
  line-height: 1.55;
}

.prose pre code {
  background: transparent;
  padding: 0;
  color: inherit;
  font-size: 13px;
}

.prose hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.8em 0;
}

.prose img {
  max-width: 100%;
  height: auto;
  border-radius: 14px;
  border: 1px solid var(--border);
  display: block;
  margin: 1.4em auto;
}

.article-nav {
  margin-top: 32px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.article-nav-card {
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface);
  transition: border-color 0.15s ease;
}

.article-nav-card:hover {
  border-color: var(--accent);
}

.article-nav-card.next {
  text-align: right;
}

.article-nav-label {
  font-size: 12px;
  color: var(--accent);
  font-weight: 600;
  margin-bottom: 4px;
}

.article-nav-title {
  font-size: 14px;
  font-weight: 700;
}

/* Archive & About */
.archive-year-head {
  padding: 12px 18px;
  font-size: 15px;
  font-weight: 800;
  color: var(--accent);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.archive-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 15px 18px;
  border-bottom: 1px solid var(--border);
  transition: background-color 0.15s ease;
}

.archive-row:hover {
  background: var(--surface-hover);
}

.archive-row-title {
  font-weight: 600;
  font-size: 15px;
}

.archive-row-date {
  font-size: 13px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

/* Right Sidebar (Grok / X Trends Style) */
.right-rail {
  padding: 12px 0 24px 24px;
}

.right-rail-inner {
  position: sticky;
  top: 12px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.grok-search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-radius: 9999px;
  background: var(--input-bg);
  border: 1px solid transparent;
  transition: border-color 0.16s ease, background-color 0.16s ease;
}

.grok-search-box:focus-within {
  border-color: var(--accent);
  background: var(--bg);
}

.search-svg {
  color: var(--text-muted);
  flex-shrink: 0;
}

.grok-search-box input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
}

.search-results {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.search-results:empty {
  display: none;
}

.search-item {
  display: block;
  padding: 10px 14px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  transition: border-color 0.15s ease;
}

.search-item:hover {
  border-color: var(--accent);
}

.search-item-title {
  font-size: 13.5px;
  font-weight: 700;
}

.search-item-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.rail-card {
  padding: 16px;
  border-radius: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
}

.rail-card-title {
  margin: 0 0 10px;
  font-size: 16px;
  font-weight: 800;
}

.rail-profile-bio {
  margin: 0 0 12px;
  font-size: 13.5px;
  color: var(--text-secondary);
  line-height: 1.55;
}

.rail-stats {
  display: flex;
  gap: 16px;
  font-size: 13px;
  color: var(--text-muted);
}

.rail-stats strong {
  color: var(--text);
}

.trend-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.trend-btn {
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border-radius: 10px;
  border: none;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: inherit;
  transition: background-color 0.15s ease;
}

.trend-btn:hover,
.trend-btn.active {
  background: var(--surface-hover);
}

.trend-tag {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}

.trend-btn.active .trend-tag {
  color: var(--accent);
}

.trend-count {
  font-size: 12px;
  color: var(--text-muted);
}

.rail-footer {
  padding: 0 6px;
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.rail-footer a:hover {
  color: var(--accent);
}

.empty-state {
  padding: 48px 20px;
  text-align: center;
  color: var(--text-muted);
}

/* Back to Top */
.back-to-top {
  position: fixed;
  right: 20px;
  bottom: 24px;
  width: 40px;
  height: 40px;
  border-radius: 9999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: all 0.2s ease;
}

.back-to-top.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

/* Responsive Breakpoints */
@media (max-width: 1120px) {
  .layout-shell {
    grid-template-columns: 76px minmax(0, 640px) 280px;
  }
  .brand-text,
  .rail-link span,
  .compose-pill span {
    display: none;
  }
  .compose-pill {
    width: 46px;
    padding: 0;
  }
  .left-rail {
    padding: 12px 10px;
    display: flex;
    justify-content: center;
  }
}

@media (max-width: 960px) {
  .layout-shell {
    grid-template-columns: 72px minmax(0, 1fr);
  }
  .right-rail {
    display: none;
  }
  .mobile-search-wrap {
    display: block;
  }
}

@media (max-width: 640px) {
  .layout-shell {
    display: block;
  }
  .left-rail,
  .right-rail {
    display: none;
  }
  .center-column {
    border-left: none;
    border-right: none;
    padding-bottom: 74px;
  }
  .mobile-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
  }
  .mobile-brand {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 18px;
    font-weight: 800;
  }
  .mobile-actions {
    display: flex;
    align-items: center;
    gap: 10px;
  }
  .mobile-compose {
    padding: 6px 14px;
    border-radius: 9999px;
    background: var(--pill-bg);
    color: var(--pill-text);
    font-size: 13px;
    font-weight: 700;
  }
  .icon-circle-btn {
    width: 34px;
    height: 34px;
    border-radius: 9999px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
  }
  .mobile-bottom-nav {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 90;
    background: var(--sticky-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid var(--border);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .mobile-tab {
    flex: 1;
    text-align: center;
    padding: 13px 0;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-muted);
  }
  .mobile-tab.active {
    color: var(--text);
    font-weight: 800;
  }
  .article-nav {
    grid-template-columns: 1fr;
  }
  .article-nav-card.next {
    text-align: left;
  }
  .back-to-top {
    bottom: 68px;
  }
}
