/* === Hero === */
.hero {
  text-align: center;
  padding: 40px 0 28px;
}
.hero h1 {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 8px;
  letter-spacing: -0.02em;
}
.hero h1 span { color: var(--color-primary); }
.hero p {
  font-size: 1rem;
  color: var(--color-text-secondary);
  margin-bottom: 20px;
}
.hero-search {
  max-width: 440px;
  margin: 0 auto;
  position: relative;
}
.hero-search input {
  width: 100%;
  padding: 12px 20px 12px 44px;
  border: 1px solid var(--color-border);
  border-radius: 24px;
  font-size: 0.9375rem;
  outline: none;
  transition: all var(--transition);
  background: var(--color-bg);
}
.hero-search input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-bg);
}
.hero-search .search-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-text-muted);
}

/* === Layout === */
.home-page {
  display: flex;
  align-items: flex-start;
  min-height: calc(100vh - var(--header-height));
  padding-left: 220px;
}

/* === Sidebar === */
.home-sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--color-bg-secondary);
  border-right: 1px solid var(--color-border);
  position: fixed;
  top: var(--header-height);
  left: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  overscroll-behavior: contain;
}

/* Thin scrollbar */
.home-sidebar::-webkit-scrollbar { width: 4px; }
.home-sidebar::-webkit-scrollbar-track { background: transparent; }
.home-sidebar::-webkit-scrollbar-thumb { background: var(--color-border); border-radius: 4px; }
.home-sidebar::-webkit-scrollbar-thumb:hover { background: var(--color-text-muted); }

/* Sidebar header */
.sidebar-header {
  padding: 16px 16px 8px;
  border-bottom: 1px solid var(--color-border);
}
.sidebar-header-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-muted);
  margin-bottom: 10px;
}
.sidebar-search {
  position: relative;
}
.sidebar-search input {
  width: 100%;
  padding: 6px 10px 6px 30px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: 0.8125rem;
  outline: none;
  background: var(--color-bg);
  transition: border-color var(--transition);
}
.sidebar-search input:focus { border-color: var(--color-primary); }
.sidebar-search svg {
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-text-muted);
}

/* Tree nav */
.sidebar-nav { padding: 8px 0; flex: 1; overflow-y: auto; }

.tree-node {
  margin-bottom: 1px;
}

/* First-level node header */
.tree-node-header {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 7px 12px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--color-text);
  transition: all 0.15s;
  border-radius: 0;
  position: relative;
  text-align: left;
}
.tree-node-header:hover {
  background: var(--color-bg-hover);
}
.tree-node-header:hover .tree-node-link {
  color: var(--color-primary);
}

.tree-arrow {
  color: var(--color-text-muted);
  transition: transform 0.2s;
  flex-shrink: 0;
}
.tree-node[data-expanded="true"] .tree-arrow {
  transform: rotate(90deg);
}

.tree-node-icon {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  width: 16px;
  height: 16px;
}
.tree-node-icon img { border-radius: 2px; }

.tree-node-link {
  flex: 1;
  color: var(--color-text);
  text-decoration: none;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: color 0.15s;
}

.tree-node-count {
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--color-text-muted);
  background: var(--color-bg);
  padding: 1px 7px;
  border-radius: 10px;
  flex-shrink: 0;
  min-width: 20px;
  text-align: center;
}

/* Second-level body */
.tree-node-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}
.tree-node[data-expanded="true"] .tree-node-body {
  max-height: 5000px;
}

/* Second-level container (collapsible category) */
.tree-child {
  margin-bottom: 1px;
}

.tree-child-header {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px 12px 5px 28px;
  font-size: 0.8125rem;
  cursor: pointer;
  transition: background 0.15s;
  border-left: 2px solid transparent;
}
.tree-child-header:hover {
  background: var(--color-bg-hover);
  border-left-color: var(--color-primary);
}
.tree-child-header:hover .tree-child-link {
  color: var(--color-primary);
}
.tree-child-header:hover .tree-arrow-sm,
.tree-child-header:hover > svg {
  color: var(--color-primary);
}

.tree-arrow-sm {
  color: var(--color-text-muted);
  transition: transform 0.2s;
  flex-shrink: 0;
}
.tree-child[data-expanded="true"] .tree-arrow-sm {
  transform: rotate(90deg);
}

.tree-child-header > svg {
  color: var(--color-text-muted);
  flex-shrink: 0;
}

.tree-child-link {
  flex: 1;
  color: var(--color-text-secondary);
  text-decoration: none;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: color 0.15s;
}
.tree-child-link-static {
  color: var(--color-text-muted);
  font-style: italic;
  cursor: default;
}

.tree-child-count {
  font-size: 0.625rem;
  color: var(--color-text-muted);
  flex-shrink: 0;
}

/* Third-level body (articles list) */
.tree-child-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.25s ease;
}
.tree-child[data-expanded="true"] .tree-child-body {
  max-height: 800px;
}

/* Third-level article item */
.tree-leaf-item {
  display: block;
  padding: 4px 12px 4px 52px;
  font-size: 0.75rem;
  color: var(--color-text-muted);
  text-decoration: none;
  transition: all 0.15s;
  border-left: 2px solid transparent;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tree-leaf-item:hover {
  color: var(--color-primary);
  background: var(--color-primary-bg);
  border-left-color: var(--color-primary);
}

/* === Sidebar Card (二维码/图片+文字) === */
.card-show-pc { display: block; flex-shrink: 0; }
.card-show-pc .sidebar-card { margin-top: 0; }
.card-show-mobile { display: none; }
@media (max-width: 768px) {
  .card-show-pc { display: none; }
  .card-show-mobile { display: block; }
}
.sidebar-card {
  margin-top: 28px;
  padding: 20px;
  background: var(--color-bg-secondary, #f8f9fa);
  border: 1px solid var(--color-border, #e5e7eb);
  border-radius: var(--radius, 8px);
  text-align: center;
  transition: box-shadow 0.2s;
}
.sidebar-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}
.sidebar-card-img {
  max-width: 120px;
  width: 100%;
  height: auto;
  border-radius: var(--radius, 8px);
  margin-bottom: 8px;
  display: block;
  margin-left: auto;
  margin-right: auto;
}
.sidebar-card-text {
  font-size: 0.8125rem;
  color: var(--color-text-secondary, #6b7280);
  margin: 0;
  line-height: 1.5;
}
@media (max-width: 768px) {
  .sidebar-card {
    margin-top: 20px;
    padding: 16px;
  }
  .card-show-mobile .sidebar-card {
    margin-top: 0;
    margin-bottom: 16px;
  }
  .sidebar-card-img {
    max-width: 100px;
  }
}

/* Empty tree */
.tree-empty {
  padding: 20px 16px;
  text-align: center;
  font-size: 0.8125rem;
  color: var(--color-text-muted);
}

/* Mobile toggle */
.sidebar-mobile-toggle {
  display: none;
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--color-primary);
  color: #fff;
  border: none;
  cursor: pointer;
  z-index: 200;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
  align-items: center;
  justify-content: center;
}
.sidebar-mobile-toggle:active { transform: scale(0.92); }

/* Overlay */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  z-index: 149;
  backdrop-filter: blur(2px);
}
.sidebar-overlay.show { display: block; }

/* === Main Content === */
.home-content {
  flex: 1;
  min-width: 0;
  padding: 0 24px 40px;
  max-width: 1000px;
  margin: 0 auto;
}

/* Section title */
.section-title {
  font-size: 1.125rem;
  font-weight: 700;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.section-title::before {
  content: '';
  width: 3px;
  height: 16px;
  background: var(--color-primary);
  border-radius: 2px;
  flex-shrink: 0;
}

/* OS Cards */
.os-section { margin-bottom: 36px; }
.os-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}
.os-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  text-align: center;
  transition: all var(--transition);
  background: var(--color-bg);
  text-decoration: none;
  color: var(--color-text);
}
.os-card:hover {
  border-color: var(--color-primary);
  box-shadow: 0 2px 8px rgba(255,107,53,0.1);
  transform: translateY(-1px);
}
.os-card .os-icon {
  width: 36px;
  height: 36px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.os-card .os-name {
  font-weight: 600;
  font-size: 0.875rem;
  margin-bottom: 2px;
}
.os-card .os-count {
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

/* Featured */
.featured-articles { margin-bottom: 36px; }
.featured-group { margin-bottom: 24px; }
.featured-group:last-child { margin-bottom: 0; }
.group-title {
  font-size: 0.9375rem;
  font-weight: 600;
  margin-bottom: 10px;
  color: var(--color-text);
  padding-left: 10px;
  border-left: 2px solid var(--color-primary);
}

/* Hot */
.hot-articles { margin-bottom: 36px; }

/* Article list */
.article-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.article-list.cols-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.article-item {
  display: flex;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  transition: all var(--transition);
  background: var(--color-bg);
}
.article-item:hover {
  border-color: var(--color-primary);
  box-shadow: var(--shadow-sm);
}
.article-item .article-cover {
  width: 100px;
  height: 68px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--color-bg-secondary);
}
.article-item .article-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.article-item .article-title {
  font-weight: 600;
  font-size: 0.9375rem;
  margin-bottom: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.4;
}
.article-item .article-title a {
  color: var(--color-text);
  text-decoration: none;
}
.article-item .article-title a:hover {
  color: var(--color-primary);
}
.article-item .article-meta {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  display: flex;
  gap: 10px;
  align-items: center;
}
.article-item .article-summary {
  font-size: 0.8125rem;
  color: var(--color-text-secondary);
  margin-top: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* No-cover variant */
.article-item.no-cover {
  padding: 12px 14px;
}
.article-item.no-cover .article-info {
  justify-content: center;
}

/* === Responsive === */
@media (max-width: 1024px) {
  .home-sidebar { width: 190px; }
  .os-cards { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
}

@media (max-width: 768px) {
  .home-page { padding-left: 0; }
  .hero { padding: 28px 0 20px; }
  .hero h1 { font-size: 1.5rem; }
  .hero p { font-size: 0.875rem; margin-bottom: 16px; }

  .home-content { padding: 0 16px 32px; }
  .os-cards { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 10px; }
  .os-card { padding: 14px 8px; }
  .os-card .os-icon { width: 28px; height: 28px; }
  .os-card .os-name { font-size: 0.8125rem; }

  .article-list.cols-2 { grid-template-columns: 1fr; gap: 8px; }
  .article-item { padding: 10px 12px; gap: 10px; }
  .article-item .article-cover { width: 72px; height: 48px; }
  .article-item .article-title { font-size: 0.875rem; -webkit-line-clamp: 2; }
  .article-item .article-meta { font-size: 0.6875rem; gap: 8px; }
  .article-item .article-summary { -webkit-line-clamp: 1; }

  /* Mobile sidebar */
  .sidebar-mobile-toggle { display: flex; }
  .home-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: 260px;
    height: 100vh;
    height: 100dvh;
    z-index: 200;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    padding-top: env(safe-area-inset-top, 0px);
    box-shadow: 2px 0 12px rgba(0, 0, 0, 0.15);
  }
  .home-sidebar.show { transform: translateX(0); }
  .home-sidebar .sidebar-header { padding-top: 16px; }
}

@media (max-width: 480px) {
  .hero h1 { font-size: 1.25rem; }
  .article-item .article-cover { display: none; }
  .article-item .article-info { align-items: flex-start; }
  .article-item .article-title { font-size: 0.8125rem; -webkit-line-clamp: 2; text-align: left; }
  .article-item .article-summary { display: none; }
  .article-item .article-meta { font-size: 0.625rem; }
}
