*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --primary: #ff5e3b;
  --primary-hover: #ff815e;
  --primary-light: #fff5f0;
  --text-primary: #222222;
  --text-secondary: #666666;
  --text-muted: #888888;
  --border: #d9d9d9;
  --bg-page: #f5f5f5;
  --bg-white: #ffffff;
  --sidebar-width: 200px;
  --sidebar-collapsed-width: 64px;
  --sidebar-drawer-breakpoint: 1280px;
  --right-sidebar-width: 300px;
  --content-max-width: 1400px;
  --header-height: 56px;
  --category-bar-height: 48px;
  --transition: 0.25s ease;
  /* 字体层级（对齐 CSDN 首页） */
  --font-xs: 12px;
  --font-sm: 13px;
  --font-md: 14px;
  --font-base: 16px;
  --font-lg: 18px;
  --font-xl: 20px;
}

html {
  font-size: 16px;
}

body {
  font-family: 'Noto Sans SC', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: var(--font-base);
  background: var(--bg-page);
  color: var(--text-primary);
  min-height: 100vh;
}

a {
  color: inherit;
  text-decoration: none;
}

ul {
  list-style: none;
}

/* ========== Top Header ========== */
.top-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: var(--bg-white);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 200;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  z-index: 1;
}

.sidebar-toggle-mobile {
  display: none;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 20px;
  color: var(--text-primary);
}

.logo-icon {
  height: 1em;
  width: auto;
  flex-shrink: 0;
  display: block;
  object-fit: contain;
  vertical-align: middle;
}

.header-center {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  gap: 28px;
  max-width: calc(100% - 400px);
  pointer-events: none;
}

.header-center > * {
  pointer-events: auto;
}

.header-search {
  width: 520px;
  flex-shrink: 1;
  min-width: 200px;
  display: flex;
  align-items: center;
  background: var(--bg-page);
  border-radius: 20px;
  padding: 0 4px 0 16px;
  border: 1px solid transparent;
  transition: border-color var(--transition);
}

.header-search:focus-within {
  border-color: var(--primary);
  background: var(--bg-white);
}

.header-search input {
  flex: 1;
  border: none;
  background: none;
  outline: none;
  font-size: var(--font-base);
  font-family: inherit;
  height: 36px;
  color: var(--text-primary);
}

.header-search input::placeholder {
  color: var(--text-muted);
}

.search-btn {
  width: 32px;
  height: 32px;
  border: none;
  background: var(--primary);
  color: #fff;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background var(--transition);
}

.search-btn:hover {
  background: var(--primary-hover);
}

.header-nav {
  display: flex;
  gap: 24px;
  flex-shrink: 0;
}

.nav-item {
  color: var(--text-secondary);
  font-size: var(--font-base);
  white-space: nowrap;
  transition: color var(--transition);
}

.nav-item:hover,
.nav-item.active {
  color: var(--primary);
}

.nav-vip {
  color: #c8a062;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  z-index: 1;
}

.btn-login,
.btn-register {
  font-size: var(--font-base);
  color: var(--text-secondary);
  transition: color var(--transition);
}

.btn-login:hover,
.btn-register:hover {
  color: var(--primary);
}

.btn-login[hidden],
.btn-register[hidden],
.header-auth-user[hidden] {
  display: none !important;
}

/* 登录后：头像 + 昵称 */
.header-auth-user {
  position: relative;
  flex-shrink: 0;
}

.header-user {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 160px;
  padding: 4px 8px 4px 4px;
  border: none;
  border-radius: 20px;
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: var(--font-sm);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}

.header-user:hover,
.header-auth-user.is-open .header-user {
  background: var(--bg-page);
  color: var(--text-primary);
}

.header-user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--bg-page);
}

.header-user-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}

.header-user-caret {
  flex-shrink: 0;
  color: var(--text-muted);
  transition: transform var(--transition);
}

.header-auth-user.is-open .header-user-caret {
  transform: rotate(180deg);
}

.header-user-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 140px;
  padding: 6px 0;
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
  z-index: 200;
}

.header-user-menu-item {
  display: block;
  width: 100%;
  padding: 10px 16px;
  border: none;
  background: none;
  text-align: left;
  font-size: var(--font-sm);
  font-family: inherit;
  color: var(--text-secondary);
  cursor: pointer;
  text-decoration: none;
}

.header-user-menu-item:hover {
  background: var(--bg-page);
  color: var(--primary);
}

.header-user-menu-item--btn {
  border-top: 1px solid var(--border);
  margin-top: 4px;
  padding-top: 12px;
}

.btn-create {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 16px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 18px;
  font-size: var(--font-base);
  font-family: inherit;
  cursor: pointer;
  transition: background var(--transition);
  text-decoration: none;
}

.btn-create:hover {
  background: var(--primary-hover);
  color: #fff;
}

/* ========== Layout ========== */
.layout {
  display: flex;
  padding-top: var(--header-height);
  min-height: 100vh;
}

/* ========== Sidebar ========== */
.sidebar {
  position: fixed;
  top: var(--header-height);
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--bg-white);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 150;
  transition: width var(--transition);
  overflow: hidden;
}

.sidebar.collapsed {
  width: var(--sidebar-collapsed-width);
}

.sidebar-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-scroll::-webkit-scrollbar {
  width: 4px;
}

.sidebar-scroll::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

.sidebar-nav {
  padding: 12px 0 8px;
}

.sidebar-nav--personal {
  padding: 8px 0 12px;
}

.sidebar-section-divider {
  height: 1px;
  margin: 4px 16px;
  background: var(--border);
}

.sidebar-footer {
  padding: 16px;
  margin-top: 8px;
  border-top: 1px solid var(--border);
}

.sidebar-footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  margin-bottom: 12px;
}

.sidebar-footer-links a {
  font-size: var(--font-xs);
  color: var(--text-muted);
  line-height: 1.5;
  transition: color var(--transition);
}

.sidebar-footer-links a:hover {
  color: var(--primary);
}

.sidebar-footer-line {
  font-size: var(--font-xs);
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 2px;
}

.sidebar-footer-copy {
  font-size: var(--font-xs);
  color: var(--text-muted);
  line-height: 1.6;
  margin-top: 8px;
}

.sidebar.collapsed .sidebar-footer {
  display: none;
}

.sidebar.collapsed .sidebar-section-divider {
  margin: 4px 8px;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  color: var(--text-secondary);
  font-size: var(--font-md);
  transition: all var(--transition);
  white-space: nowrap;
  position: relative;
}

.sidebar-item svg {
  flex-shrink: 0;
  opacity: 0.7;
}

.sidebar-item:hover {
  color: var(--primary);
  background: var(--primary-light);
}

.sidebar-item:hover svg {
  opacity: 1;
}

.sidebar-item.active {
  color: var(--primary);
  background: var(--primary-light);
  font-weight: 500;
}

.sidebar-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 20px;
  background: var(--primary);
  border-radius: 0 2px 2px 0;
}

.sidebar-item.active svg {
  opacity: 1;
}

.sidebar-label {
  overflow: hidden;
  text-overflow: ellipsis;
  transition: opacity var(--transition);
}

.sidebar.collapsed .sidebar-label {
  opacity: 0;
  width: 0;
}

.sidebar.collapsed .sidebar-item {
  justify-content: center;
  padding: 10px;
}

.sidebar.collapsed .sidebar-item.active::before {
  height: 100%;
  top: 0;
  transform: none;
}

/* Tooltip when collapsed */
.sidebar.collapsed .sidebar-item::after {
  content: attr(data-tooltip);
  position: absolute;
  left: calc(100% + 8px);
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0, 0, 0, 0.8);
  color: #fff;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: var(--font-sm);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
  z-index: 300;
}

.sidebar.collapsed .sidebar-item:hover::after {
  opacity: 1;
}

.sidebar-collapse-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 20px;
  border: none;
  border-top: 1px solid var(--border);
  background: none;
  color: var(--text-muted);
  font-size: var(--font-md);
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: color var(--transition);
  flex-shrink: 0;
}

.sidebar-collapse-btn:hover {
  color: var(--primary);
}

.sidebar-collapse-btn .icon-expand {
  display: none;
}

.sidebar.collapsed .sidebar-collapse-btn {
  justify-content: center;
  padding: 14px;
}

.sidebar.collapsed .sidebar-collapse-btn .icon-collapse {
  display: none;
}

.sidebar.collapsed .sidebar-collapse-btn .icon-expand {
  display: block;
}

.sidebar.collapsed .sidebar-collapse-btn .sidebar-label {
  display: none;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  top: var(--header-height);
  background: rgba(0, 0, 0, 0.4);
  z-index: 140;
}

/* ========== Main Content ========== */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  transition: margin-left var(--transition);
  min-width: 0;
  width: calc(100% - var(--sidebar-width));
}

.layout.sidebar-is-collapsed .main-content {
  margin-left: var(--sidebar-collapsed-width);
  width: calc(100% - var(--sidebar-collapsed-width));
}

/* Category bar */
.category-bar {
  display: flex;
  align-items: stretch;
  background: var(--bg-white);
  border-bottom: 1px solid var(--border);
  padding: 0;
  position: sticky;
  top: var(--header-height);
  z-index: 50;
}

.category-scroll-btn {
  display: none;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  width: 36px;
  background: var(--bg-white);
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  transition: color var(--transition), background var(--transition), opacity var(--transition);
}

.category-scroll-btn:hover:not(:disabled) {
  color: var(--primary);
  background: var(--primary-light);
}

.category-scroll-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.category-bar.is-scrollable .category-scroll-btn {
  display: flex;
}

.category-tabs-viewport {
  position: relative;
  flex: 1;
  min-width: 0;
  max-width: var(--content-max-width);
  margin: 0 auto;
}

.category-bar.is-scrollable:not(.is-at-start) .category-tabs-viewport::before,
.category-bar.is-scrollable:not(.is-at-end) .category-tabs-viewport::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  width: 20px;
  pointer-events: none;
  z-index: 1;
}

.category-bar.is-scrollable:not(.is-at-start) .category-tabs-viewport::before {
  left: 0;
  background: linear-gradient(to right, var(--bg-white), transparent);
}

.category-bar.is-scrollable:not(.is-at-end) .category-tabs-viewport::after {
  right: 0;
  background: linear-gradient(to left, var(--bg-white), transparent);
}

.category-tabs {
  display: flex;
  justify-content: center;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  scroll-behavior: smooth;
}

.category-bar.is-scrollable .category-tabs {
  justify-content: flex-start;
}

.category-tabs::-webkit-scrollbar {
  display: none;
}

.category-tab {
  flex-shrink: 0;
  padding: 14px 16px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  font-size: var(--font-base);
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.category-tab:hover {
  color: var(--primary);
}

.category-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 500;
}

/* Content wrapper：中间 feed + 右侧栏合计最大宽度，右侧栏固定贴右 */
.content-wrapper {
  display: flex;
  align-items: flex-start;
  gap: 20px;
  padding: 20px 24px;
  width: 100%;
  max-width: var(--content-max-width);
  margin-left: auto;
  margin-right: auto;
}

.feed-area {
  flex: 1 1 auto;
  min-width: 0;
}

/* ========== Promo Banner ========== */
.promo-banner {
  margin-bottom: 16px;
}

.promo-banner-slider {
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg-white);
}

.promo-banner-track {
  position: relative;
  height: 120px;
}

.promo-slide {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 48px 0 28px;
  background: var(--slide-bg);
  color: #fff;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.5s ease, visibility 0.5s ease;
  text-decoration: none;
}

.promo-slide.active {
  opacity: 1;
  visibility: visible;
}

.promo-slide-content {
  flex: 1;
  min-width: 0;
}

.promo-badge {
  display: inline-block;
  padding: 2px 8px;
  margin-bottom: 8px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 3px;
  font-size: var(--font-xs);
}

.promo-title {
  font-size: var(--font-lg);
  font-weight: 600;
  line-height: 1.4;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.promo-desc {
  font-size: var(--font-sm);
  color: rgba(255, 255, 255, 0.85);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.promo-cta {
  flex-shrink: 0;
  padding: 8px 20px;
  background: rgba(255, 255, 255, 0.95);
  color: var(--text-primary);
  border-radius: 20px;
  font-size: var(--font-sm);
  font-weight: 500;
  transition: transform var(--transition), box-shadow var(--transition);
}

.promo-slide:hover .promo-cta {
  transform: scale(1.04);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.promo-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.25);
  border: none;
  border-radius: 50%;
  color: #fff;
  cursor: pointer;
  opacity: 0;
  transition: opacity var(--transition), background var(--transition);
  z-index: 2;
}

.promo-banner-slider:hover .promo-nav {
  opacity: 1;
}

.promo-nav:hover {
  background: rgba(255, 255, 255, 0.4);
}

.promo-prev {
  left: 8px;
}

.promo-next {
  right: 8px;
}

.promo-dots {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
  z-index: 2;
}

.promo-dot {
  width: 6px;
  height: 6px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.45);
  cursor: pointer;
  transition: background var(--transition), width var(--transition);
}

.promo-dot.active {
  width: 16px;
  border-radius: 3px;
  background: #fff;
}

/* ========== Project Recommend ========== */
.project-recommend {
  background: var(--bg-white);
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 16px;
}

.project-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.project-card {
  display: flex;
  gap: 12px;
  padding: 14px;
  min-width: 0;
  background: var(--bg-page);
  border-radius: 8px;
  transition: background var(--transition), box-shadow var(--transition);
  text-decoration: none;
  color: inherit;
}

.project-card:hover {
  background: var(--primary-light);
  box-shadow: 0 2px 8px rgba(255, 94, 59, 0.1);
}

.project-icon {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  font-size: var(--font-sm);
  font-weight: 700;
  color: #fff;
}

.project-icon--blue { background: #3949ab; }
.project-icon--purple { background: #7b1fa2; }
.project-icon--green { background: #00897b; }
.project-icon--orange { background: #f57c00; }

.project-body {
  flex: 1;
  min-width: 0;
}

.project-name {
  font-size: var(--font-md);
  font-weight: 600;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.project-desc {
  font-size: var(--font-sm);
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 8px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.project-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.project-tag {
  padding: 1px 6px;
  background: var(--bg-white);
  border-radius: 3px;
  font-size: var(--font-xs);
  color: var(--text-muted);
}

.project-stat {
  font-size: var(--font-xs);
  color: var(--text-muted);
}

.project-stat::before {
  content: '★ ';
  color: #faad14;
}

.project-action {
  margin-left: auto;
  font-size: var(--font-xs);
  color: var(--primary);
}

/* News headline */
.news-headline {
  background: var(--bg-white);
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 16px;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.section-title {
  font-size: var(--font-lg);
  font-weight: 600;
}

.section-more {
  font-size: var(--font-md);
  color: var(--text-muted);
  transition: color var(--transition);
}

.section-more:hover {
  color: var(--primary);
}

.headline-banner {
  display: flex;
  gap: 20px;
}

.headline-main {
  flex: 1;
  min-width: 0;
  padding: 16px;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  border-radius: 8px;
  color: #fff;
}

.headline-tag {
  display: inline-block;
  padding: 2px 8px;
  background: var(--primary);
  border-radius: 3px;
  font-size: var(--font-xs);
  margin-bottom: 10px;
}

.headline-title {
  font-size: var(--font-lg);
  font-weight: 600;
  line-height: 1.5;
  margin-bottom: 8px;
}

.headline-desc {
  font-size: var(--font-md);
  color: rgba(255, 255, 255, 0.7);
  line-height: 1.6;
}

.headline-side {
  flex: 0 0 280px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.headline-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 12px;
  border-radius: 6px;
  transition: background var(--transition);
}

.headline-item:hover {
  background: var(--bg-page);
}

.item-tag {
  font-size: var(--font-xs);
  color: var(--primary);
}

.item-title {
  font-size: var(--font-md);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.item-meta {
  font-size: var(--font-sm);
  color: var(--text-muted);
}

/* Article feed */
.article-feed {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.feed-sentinel {
  height: 1px;
  pointer-events: none;
}

.feed-footer {
  display: none;
  padding: 20px 12px 8px;
  text-align: center;
}

.feed-footer.is-visible {
  display: block;
}

.feed-footer-status,
.feed-footer-retry {
  display: none;
  margin: 0;
  font-size: var(--font-sm);
  color: var(--text-muted);
}

.feed-footer.is-loading .feed-footer-loading {
  display: block;
}

.feed-footer.is-end .feed-footer-end {
  display: block;
}

.feed-footer.is-retry .feed-footer-retry {
  display: inline-block;
}

.feed-footer-loading {
  position: relative;
  padding-left: 22px;
}

.feed-footer-loading::before {
  content: '';
  position: absolute;
  left: calc(50% - 52px);
  top: 50%;
  width: 14px;
  height: 14px;
  margin-top: -7px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: feed-spin 0.8s linear infinite;
}

@keyframes feed-spin {
  to { transform: rotate(360deg); }
}

.feed-footer-retry {
  padding: 8px 18px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-white);
  color: var(--text-secondary);
  font-size: var(--font-sm);
  cursor: pointer;
  transition: color var(--transition), border-color var(--transition);
}

.feed-footer-retry:hover {
  color: var(--primary);
  border-color: var(--primary);
}

.feed-card {
  background: var(--bg-white);
  border-radius: 8px;
  padding: 20px;
  transition: box-shadow var(--transition);
}

.feed-card-layout {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.feed-card--has-cover .feed-card-body {
  flex: 1;
  min-width: 0;
}

.feed-cover {
  flex-shrink: 0;
  width: 132px;
  height: 88px;
  border-radius: 4px;
  overflow: hidden;
  display: block;
  background: var(--bg-page);
}

.feed-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform var(--transition);
}

.feed-card--has-cover:hover .feed-cover img {
  transform: scale(1.04);
}

.feed-card--has-cover .feed-title {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.feed-card--has-cover .feed-summary {
  -webkit-line-clamp: 2;
}

/* 多图模式（标题下方横排小图） */
.feed-card--multi .feed-summary {
  display: none;
}

.feed-media--multi {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  margin-bottom: 12px;
  max-width: 420px;
}

.feed-media--multi.feed-media--count-2 {
  grid-template-columns: repeat(2, 1fr);
  max-width: 280px;
}

.feed-media-item {
  aspect-ratio: 4 / 3;
  border-radius: 4px;
  overflow: hidden;
  display: block;
  background: var(--bg-page);
}

.feed-media-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform var(--transition);
}

.feed-card--multi:hover .feed-media-item img {
  transform: scale(1.03);
}

/* 大图 / 视频模式（标题下方宽幅封面） */
.feed-card--large .feed-summary,
.feed-card--video .feed-summary {
  display: none;
}

.feed-media--large {
  position: relative;
  display: block;
  margin-bottom: 12px;
  border-radius: 4px;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  max-height: 240px;
  background: var(--bg-page);
}

.feed-media--large img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform var(--transition);
}

.feed-card--large:hover .feed-media--large img,
.feed-card--video:hover .feed-media--large img {
  transform: scale(1.02);
}

.feed-media-play {
  position: absolute;
  left: 10px;
  bottom: 10px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
  border-radius: 50%;
  color: #fff;
  font-size: 14px;
  line-height: 1;
  pointer-events: none;
}

.feed-media-play svg {
  margin-left: 2px;
}

.feed-media-duration {
  position: absolute;
  right: 10px;
  bottom: 10px;
  padding: 2px 6px;
  background: rgba(0, 0, 0, 0.55);
  border-radius: 2px;
  color: #fff;
  font-size: var(--font-xs);
  line-height: 1.4;
  pointer-events: none;
}

.feed-card:hover {
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
}

.feed-card--ad {
  border: 1px dashed var(--border);
}

.ad-badge {
  display: inline-block;
  padding: 1px 6px;
  background: #f0f0f0;
  color: var(--text-muted);
  font-size: var(--font-xs);
  border-radius: 3px;
  margin-bottom: 8px;
}

.feed-title {
  font-size: var(--font-lg);
  font-weight: 600;
  line-height: 1.5;
  margin-bottom: 8px;
}

.feed-title a:hover {
  color: var(--primary);
}

.feed-summary {
  font-size: var(--font-md);
  color: var(--text-secondary);
  line-height: 1.7;
  margin-bottom: 12px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.feed-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: var(--font-sm);
  color: var(--text-muted);
  flex-wrap: wrap;
}

.feed-author {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
  max-width: 160px;
}

.feed-author:hover {
  color: var(--primary);
}

.feed-author-avatar {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--bg-page);
}

.feed-author-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 一篇文章可挂多个话题 */
.feed-topics {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.feed-topic {
  padding: 1px 8px;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: 3px;
  font-size: var(--font-xs);
  line-height: 1.4;
  white-space: nowrap;
  text-decoration: none;
}

.feed-topic:hover {
  color: var(--primary-hover);
}

/* ========== Right Sidebar ========== */
.right-sidebar {
  flex: 0 0 var(--right-sidebar-width);
  width: var(--right-sidebar-width);
  display: flex;
  flex-direction: column;
  gap: 16px;
  flex-shrink: 0;
  /* 与中间栏等高，便于话题推荐在滚动后 sticky 固定 */
  align-self: stretch;
}

/* 话题推荐：滚过上方卡片后固定在右侧（避开顶栏+分类栏，保证完整可见） */
.widget--sticky {
  position: sticky;
  top: calc(var(--header-height) + var(--category-bar-height) + 12px);
  z-index: 10;
  max-height: calc(100vh - var(--header-height) - var(--category-bar-height) - 24px);
  overflow-y: auto;
  overscroll-behavior: contain;
}

/* 右侧滚动广告（对齐 CSDN activity 轮播） */
.sidebar-ad {
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg-white);
}

.sidebar-ad.is-closed {
  display: none;
}

.sidebar-ad-close {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 3;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 2px;
  background: rgba(0, 0, 0, 0.25);
  color: #fff;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  transition: background var(--transition);
}

.sidebar-ad-close:hover {
  background: rgba(0, 0, 0, 0.45);
}

.sidebar-ad-slider {
  position: relative;
  width: 100%;
  aspect-ratio: 5 / 6;
}

.sidebar-ad-track {
  position: relative;
  width: 100%;
  height: 100%;
}

.sidebar-ad-slide {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: flex-start;
  gap: 8px;
  padding: 24px 16px 36px;
  background: var(--ad-bg);
  color: #fff;
  text-decoration: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.45s ease, visibility 0.45s ease;
}

.sidebar-ad-slide.active {
  opacity: 1;
  visibility: visible;
}

.sidebar-ad-tag {
  display: inline-block;
  padding: 1px 6px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 2px;
  font-size: var(--font-xs);
  line-height: 1.4;
}

.sidebar-ad-text {
  font-size: var(--font-lg);
  font-weight: 600;
  line-height: 1.45;
}

.sidebar-ad-sub {
  font-size: var(--font-sm);
  color: rgba(255, 255, 255, 0.85);
  line-height: 1.5;
}

.sidebar-ad-dots {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 5px;
  z-index: 2;
}

.sidebar-ad-dot {
  width: 6px;
  height: 6px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.45);
  cursor: pointer;
  transition: background var(--transition), width var(--transition);
}

.sidebar-ad-dot.active {
  width: 14px;
  border-radius: 3px;
  background: #fff;
}

.widget {
  background: var(--bg-white);
  border-radius: 8px;
  padding: 16px;
}

.widget-title {
  font-size: var(--font-lg);
  font-weight: 600;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.community-list li {
  margin-bottom: 8px;
}

.community-list a {
  font-size: var(--font-md);
  color: var(--text-secondary);
  transition: color var(--transition);
}

.community-list a:hover {
  color: var(--primary);
}

.live-list li {
  margin-bottom: 10px;
}

.live-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: var(--font-md);
  color: var(--text-secondary);
  line-height: 1.4;
  transition: color var(--transition);
}

.live-item:hover {
  color: var(--primary);
}

.live-dot {
  flex-shrink: 0;
  width: 6px;
  height: 6px;
  background: #ff4d4f;
  border-radius: 50%;
  margin-top: 6px;
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.event-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.event-item {
  display: flex;
  gap: 12px;
}

.event-date {
  flex-shrink: 0;
  width: 44px;
  text-align: center;
  background: var(--primary-light);
  border-radius: 6px;
  padding: 6px 4px;
}

.event-day {
  display: block;
  font-size: var(--font-lg);
  font-weight: 700;
  color: var(--primary);
  line-height: 1.2;
}

.event-month {
  display: block;
  font-size: var(--font-xs);
  color: var(--primary);
}

.event-info {
  flex: 1;
  min-width: 0;
}

.event-title {
  display: block;
  font-size: var(--font-md);
  color: var(--text-primary);
  line-height: 1.4;
  margin-bottom: 4px;
  transition: color var(--transition);
}

.event-title:hover {
  color: var(--primary);
}

.event-location {
  font-size: var(--font-sm);
  color: var(--text-muted);
}

.course-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.course-item {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.course-vip {
  flex-shrink: 0;
  padding: 2px 6px;
  background: linear-gradient(135deg, #c8a062, #e8c88a);
  color: #fff;
  font-size: var(--font-xs);
  font-weight: 600;
  border-radius: 3px;
}

.course-info {
  flex: 1;
  min-width: 0;
}

.course-name {
  display: block;
  font-size: var(--font-md);
  font-weight: 500;
  margin-bottom: 4px;
  transition: color var(--transition);
}

.course-item:hover .course-name {
  color: var(--primary);
}

.course-meta {
  font-size: var(--font-sm);
  color: var(--text-muted);
}

.blogger-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.blogger-item {
  display: flex;
  align-items: center;
  gap: 10px;
  transition: opacity var(--transition);
}

.blogger-item:hover {
  opacity: 0.85;
}

.blogger-item:hover .blogger-name {
  color: var(--primary);
}

.blogger-avatar {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
}

.blogger-info {
  flex: 1;
  min-width: 0;
}

.blogger-name {
  display: block;
  font-size: var(--font-md);
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 2px;
  transition: color var(--transition);
}

.blogger-desc {
  display: block;
  font-size: var(--font-sm);
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ========== 回到顶部 ========== */
.back-to-top {
  position: fixed;
  right: 28px;
  bottom: 36px;
  z-index: 180;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--bg-white);
  color: var(--text-secondary);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.1);
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity var(--transition), visibility var(--transition), transform var(--transition), color var(--transition), border-color var(--transition), background var(--transition);
}

.back-to-top.is-visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0);
}

.back-to-top:hover {
  color: var(--primary);
  border-color: var(--primary);
  background: var(--primary-light);
}

/* ========== Responsive ========== */
@media (max-width: 1200px) {
  .right-sidebar {
    display: none;
  }

  .back-to-top {
    right: 16px;
    bottom: 24px;
  }
}

/* 对齐 CSDN：视口宽度 < 1280px 时左侧栏改为抽屉，默认隐藏 */
@media (max-width: 1279px) {
  .sidebar-toggle-mobile {
    display: flex;
  }

  .sidebar-collapse-btn {
    display: none;
  }

  .sidebar {
    transform: translateX(-100%);
    width: var(--sidebar-width) !important;
    transition: transform var(--transition);
  }

  .sidebar.mobile-open {
    transform: translateX(0);
  }

  .sidebar.collapsed {
    transform: translateX(-100%);
  }

  .sidebar-overlay.active {
    display: block;
  }

  .main-content {
    margin-left: 0 !important;
    width: 100% !important;
  }
}

@media (max-width: 992px) {
  .header-center {
    max-width: calc(100% - 280px);
  }

  .header-search {
    width: 480px;
  }

  .header-nav {
    display: none;
  }

  .logo-text {
    display: none;
  }

  .headline-banner {
    flex-direction: column;
  }

  .headline-side {
    flex: none;
  }

  .promo-slide {
    padding: 0 36px 0 20px;
  }

  .promo-title {
    font-size: var(--font-md);
  }

  .promo-cta {
    display: none;
  }
}

@media (max-width: 768px) {
  .top-header {
    gap: 12px;
  }

  .header-center {
    position: static;
    transform: none;
    flex: 1;
    min-width: 0;
    max-width: none;
  }

  .header-search {
    width: 100%;
    min-width: 0;
  }

  .header-right .btn-login,
  .header-right .btn-register {
    display: none;
  }

  .header-user-name,
  .header-user-caret {
    display: none;
  }

  .header-user {
    max-width: none;
    padding: 2px;
  }

  .content-wrapper {
    padding: 12px;
  }

  .category-scroll-btn {
    width: 32px;
  }

  .category-tab {
    font-size: var(--font-md);
  }

  .promo-banner-track {
    height: 96px;
  }

  .promo-nav {
    display: none;
  }

  .project-grid {
    grid-template-columns: 1fr;
  }

  .feed-cover {
    width: 108px;
    height: 72px;
  }

  .feed-media--multi {
    max-width: 100%;
  }

  .feed-media--multi.feed-media--count-2 {
    max-width: 100%;
  }

  .feed-card {
    padding: 16px;
  }

  .feed-card--large .feed-card-body,
  .feed-card--video .feed-card-body {
    width: 100%;
    min-width: 0;
  }

  .feed-card--large .feed-media--large,
  .feed-card--video .feed-media--large {
    width: 100%;
    max-width: 100%;
    max-height: none;
    box-sizing: border-box;
  }
}

@media (max-width: 480px) {
  .top-header {
    padding: 0 12px;
    gap: 10px;
  }

  .btn-create span,
  .btn-create {
    font-size: 0;
    padding: 8px;
    border-radius: 50%;
  }
}
