/* ============================================
   Layout, Sidebar & Main Content
   ============================================ */

/* --- Layout Container --- */
.layout {
  display: flex;
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px 20px 40px;
  gap: 24px;
  align-items: flex-start;
}

/* --- Sidebar --- */
.sidebar {
  position: sticky;
  top: 20px;
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 20px 0;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  transition: box-shadow var(--transition-normal), background var(--transition-normal);
}

.sidebar:hover {
  box-shadow: var(--shadow-card-hover);
}

.sidebar::-webkit-scrollbar {
  width: 4px;
}

.sidebar::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 4px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
  background: #bbb;
}

html[data-theme="dark"] .sidebar::-webkit-scrollbar-thumb {
  background: #59483b;
}

html[data-theme="dark"] .sidebar::-webkit-scrollbar-thumb:hover {
  background: var(--accent-gold);
}

.sidebar-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 0 20px 16px;
  border-bottom: 1px solid var(--border-light);
  margin-bottom: 8px;
}

.sidebar-header h3 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.sidebar-header span {
  font-size: 12px;
  color: var(--text-secondary);
}

/* --- TOC List --- */
.toc-list,
.toc-sublist {
  list-style: none;
  padding: 0;
}

.toc-sublist {
  padding-left: 0;
  display: none;
}

.toc-section.open > .toc-sublist,
.toc-list.searching .toc-sublist {
  display: block;
}

.toc-item {
  position: relative;
}

.toc-link {
  display: block;
  padding: 8px 20px 8px 24px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  transition: all var(--transition-fast);
  border-left: 3px solid transparent;
  line-height: 1.5;
  cursor: pointer;
}

.toc-section.has-children > .toc-link::after {
  content: '›';
  float: right;
  color: var(--text-secondary);
  transition: transform var(--transition-fast), color var(--transition-fast);
}

.toc-section.open > .toc-link::after,
.toc-list.searching .toc-section.has-children > .toc-link::after {
  transform: rotate(90deg);
  color: var(--accent-fire);
}

.toc-link:hover {
  color: var(--accent-fire);
  background: var(--accent-fire-bg);
}

.toc-link.active {
  color: var(--accent-fire);
  font-weight: 600;
  background: var(--accent-fire-bg);
  border-left-color: var(--accent-fire);
}

/* 二级标题（h3）：更小、更淡，作为子项 */
.toc-link.h3 {
  padding-left: 36px;
  font-size: 13px;
  font-weight: 400;
  color: var(--text-secondary);
}

.toc-link.h3:hover {
  color: var(--accent-fire);
}

.toc-link.h3.active {
  color: var(--accent-fire);
  font-weight: 500;
}

/* --- Main Content --- */
.main-content {
  flex: 1;
  min-width: 0;
}

.content-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 40px 48px;
  transition: box-shadow var(--transition-normal), background var(--transition-normal);
}

/* --- Footer --- */
.footer {
  text-align: center;
  padding: 32px 20px;
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 2;
}

.footer a {
  color: var(--accent-fire);
  font-weight: 500;
}

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

.footer-divider {
  width: 60px;
  height: 3px;
  background: var(--accent-fire);
  margin: 0 auto 16px;
  border-radius: 2px;
  opacity: 0.5;
}

/* --- Noscript --- */
noscript .noscript-warning {
  background: var(--color-warning-bg);
  border-left: 4px solid var(--color-warning);
  padding: 16px 20px;
  margin: 20px auto;
  max-width: 1400px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text-primary);
}
