/* 黄峥知识库 · Style (仿 learnbuffett.com / 红金配色) */
:root {
    --primary: #D62828;
    --primary-light: #E63946;
    --primary-dark: #9B1C1C;
    --accent: #FCBF49;
    --accent-dark: #F77F00;
    --bg: #FAF7F2;
    --surface: #FFFFFF;
    --text: #1F1F1F;
    --text-light: #555;
    --text-muted: #888;
    --border: #E5DFD2;
    --code-bg: #F5F1EA;
    --navy: #22223B;
    --sidebar-bg: #22223B;
    --sidebar-active: #FCBF49;
    --sidebar-w: 280px;
    --radius: 8px;
    --shadow: 0 2px 12px rgba(0,0,0,0.06);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; font-size: 15px; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.75;
}

/* ===== Sidebar ===== */
.sidebar {
    width: var(--sidebar-w);
    height: 100vh;
    position: fixed;
    left: 0; top: 0;
    background: linear-gradient(180deg, #22223B 0%, #3A1616 100%);
    color: #fff;
    overflow-y: auto;
    z-index: 100;
    box-shadow: 2px 0 16px rgba(0,0,0,0.12);
    display: flex;
    flex-direction: column;
}
.sidebar-header { padding: 24px 20px 18px; border-bottom: 1px solid rgba(255,255,255,0.1); }
.logo { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; }
.logo-icon { font-size: 28px; }
.logo-text { font-size: 17px; font-weight: 700; line-height: 1.3; }
.logo-text small { display: block; font-size: 11px; font-weight: 400; color: rgba(255,255,255,0.6); margin-top: 3px; letter-spacing: 1px; }
.sidebar-search { padding: 14px 16px; position: relative; }
.sidebar-search input {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid rgba(255,255,255,0.2);
    background: rgba(255,255,255,0.08);
    color: #fff;
    border-radius: 6px;
    font-size: 13px;
    outline: none;
}
.sidebar-search input::placeholder { color: rgba(255,255,255,0.45); }
.sidebar-search input:focus { border-color: var(--accent); background: rgba(255,255,255,0.15); }
.sidebar-nav { flex: 1; padding: 0 10px 20px; overflow-y: auto; }
.nav-section { margin-bottom: 6px; }
.nav-section-title {
    padding: 9px 14px;
    font-size: 13px;
    font-weight: 600;
    color: rgba(255,255,255,0.85);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 6px;
    user-select: none;
    transition: background 0.2s;
}
.nav-section-title:hover { background: rgba(255,255,255,0.08); }
.nav-section-title .count { background: rgba(255,255,255,0.15); padding: 2px 8px; border-radius: 10px; font-size: 11px; }
.nav-items { list-style: none; padding-left: 0; margin-top: 2px; display: none; }
.nav-section.active .nav-items { display: block; }
.nav-items li { padding: 0; }
.nav-items li a {
    display: block;
    padding: 7px 14px 7px 26px;
    color: rgba(255,255,255,0.75);
    text-decoration: none;
    font-size: 13px;
    border-left: 2px solid transparent;
    transition: all 0.15s;
}
.nav-items li a:hover { background: rgba(255,255,255,0.06); color: #fff; }
.nav-items li.active a { background: rgba(252,191,73,0.12); color: var(--accent); border-left-color: var(--accent); font-weight: 500; }
.sidebar-footer { padding: 12px 18px; border-top: 1px solid rgba(255,255,255,0.1); font-size: 11px; color: rgba(255,255,255,0.55); }
.sidebar-footer .stats span { margin-right: 8px; }
.visitor-counter { margin-top: 8px; padding-top: 8px; border-top: 1px dashed rgba(255,255,255,0.15); font-size: 11px; color: rgba(255,255,255,0.7); letter-spacing: 0.5px; }
.visitor-counter strong { color: var(--accent); font-weight: 700; }

/* ===== Content ===== */
.content { margin-left: var(--sidebar-w); min-height: 100vh; }
.content-inner { max-width: 860px; padding: 30px 50px 60px; }

/* Sidebar toggle (mobile) */
.sidebar-toggle { display: none; position: fixed; top: 18px; left: 18px; z-index: 101; background: var(--primary); color: #fff; border: none; padding: 9px 13px; border-radius: 6px; font-size: 16px; cursor: pointer; box-shadow: 0 2px 8px rgba(0,0,0,0.15); }

/* ===== Article ===== */
.article-header { margin-bottom: 30px; padding-bottom: 18px; border-bottom: 2px solid var(--border); }
.breadcrumb { font-size: 13px; color: var(--text-light); margin-bottom: 10px; }
.breadcrumb a { color: var(--primary); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }
.article-header h1 { font-size: 30px; font-weight: 700; color: var(--primary-dark); line-height: 1.3; }
.tags { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 6px; }
.tag { background: var(--accent); color: var(--text); padding: 3px 10px; border-radius: 12px; font-size: 12px; font-weight: 500; }
.meta { margin-top: 8px; color: var(--text-muted); font-size: 13px; }

/* ===== Article body ===== */
.article-body { font-size: 15px; line-height: 1.85; color: var(--text); }
.article-body h1 { font-size: 24px; color: var(--primary-dark); margin: 28px 0 14px; font-weight: 700; }
.article-body h2 { font-size: 22px; color: var(--primary); margin: 30px 0 14px; font-weight: 700; padding-left: 10px; border-left: 4px solid var(--accent); }
.article-body h3 { font-size: 18px; color: var(--primary-dark); margin: 22px 0 12px; font-weight: 600; }
.article-body h4 { font-size: 16px; margin: 18px 0 10px; font-weight: 600; }
.article-body p { margin-bottom: 14px; }
.article-body ul, .article-body ol { margin: 12px 0 16px 24px; }
.article-body li { margin-bottom: 6px; }
.article-body strong { color: var(--primary-dark); font-weight: 600; }
.article-body em { font-style: normal; color: #7A3E1F; }
.article-body code { background: var(--code-bg); color: var(--primary-dark); padding: 2px 6px; border-radius: 3px; font-family: "SF Mono", Consolas, monospace; font-size: 13px; border: 1px solid var(--border); }
.article-body pre { background: var(--code-bg); padding: 16px 20px; border-radius: 6px; border-left: 3px solid var(--accent); overflow-x: auto; font-size: 13px; line-height: 1.6; margin: 16px 0; }
.article-body pre code { background: none; border: none; padding: 0; color: #333; }
.article-body blockquote { border-left: 4px solid var(--accent); background: #FDF9EF; padding: 12px 18px; margin: 16px 0; color: #554; border-radius: 0 4px 4px 0; }
.article-body blockquote p:last-child { margin-bottom: 0; }
.article-body a.wikilink { color: var(--primary); text-decoration: none; border-bottom: 1px dotted var(--primary); padding-bottom: 1px; font-weight: 500; }
.article-body a.wikilink:hover { color: var(--accent-dark); border-bottom-style: solid; }
span.wikilink-broken, .article-body span.wikilink-broken { color: inherit !important; border-bottom: none !important; text-decoration: none !important; }
.article-body a { color: var(--primary); }
.article-body hr { border: 0; border-top: 1px solid var(--border); margin: 28px 0; }

/* Callouts (Obsidian) */
.callout { border-radius: var(--radius); padding: 14px 18px; margin: 16px 0; border-left: 4px solid var(--accent); }
.callout-title { font-weight: 700; margin-bottom: 6px; color: var(--primary-dark); font-size: 14px; }
.callout-quote { background: #FDF9EF; border-color: var(--accent); }
.callout-note { background: #F2F5FA; border-color: #3D6C9F; }
.callout-tip { background: #F0F9F3; border-color: #2E8B57; }
.callout-abstract { background: #FDF5E7; border-color: var(--accent-dark); }

/* Tables */
.article-body table { width: 100%; border-collapse: collapse; margin: 18px 0; font-size: 14px; background: #fff; border-radius: 6px; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,0.04); }
.article-body th { background: var(--primary); color: #fff; padding: 10px 14px; text-align: left; font-weight: 600; font-size: 13px; }
.article-body td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
.article-body tr:nth-child(even) td { background: #FDFAF3; }
.article-body tr:hover td { background: #F9F1DF; }

/* ===== Homepage ===== */
.homepage { padding: 32px 44px 60px; max-width: 1280px; margin: 0 auto; }
.hero {
  background: linear-gradient(135deg, #C82121 0%, #8C1616 100%);
  color: #fff;
  padding: 40px 44px;
  margin: 0 0 28px;
  border-radius: 14px;
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: 44px;
  align-items: center;
  box-shadow: 0 6px 24px rgba(156, 30, 30, 0.15);
}
.hero::before {
  content: '';
  position: absolute;
  right: -100px;
  top: -100px;
  width: 360px;
  height: 360px;
  background: radial-gradient(circle, rgba(252,191,73,0.28) 0%, transparent 70%);
  border-radius: 50%;
  pointer-events: none;
}
.hero::after {
  content: '';
  position: absolute;
  left: -60px;
  bottom: -80px;
  width: 220px;
  height: 220px;
  background: radial-gradient(circle, rgba(255,255,255,0.06) 0%, transparent 70%);
  border-radius: 50%;
  pointer-events: none;
}
.hero-content { position: relative; z-index: 1; min-width: 0; }
.hero h1 {
  font-size: 30px;
  margin: 0 0 6px;
  font-weight: 700;
  letter-spacing: -0.3px;
  line-height: 1.2;
}
.hero-subtitle {
  font-size: 13px;
  opacity: 0.78;
  margin: 0 0 16px;
  letter-spacing: 0.2px;
  font-weight: 400;
}
.hero-desc {
  font-size: 14px;
  opacity: 0.94;
  max-width: none;
  line-height: 1.85;
  margin: 0;
}
.hero-stats {
  position: relative;
  z-index: 1;
  margin-top: 0;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px 28px;
  padding: 8px 0 8px 32px;
  border-left: 1px solid rgba(255,255,255,0.18);
}
.stat { }
.stat-num {
  font-size: 28px;
  font-weight: 700;
  color: var(--accent);
  display: block;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.stat-label {
  font-size: 12px;
  opacity: 0.88;
  letter-spacing: 0.3px;
  margin-top: 6px;
  display: block;
}
@media (max-width: 980px) {
  .hero { grid-template-columns: 1fr; gap: 24px; padding: 32px 28px; }
  .hero-stats {
    border-left: none;
    border-top: 1px solid rgba(255,255,255,0.18);
    padding: 20px 0 0 0;
    grid-template-columns: repeat(4, 1fr);
    gap: 18px;
  }
  .homepage { padding: 24px 20px 40px; }
}
@media (max-width: 560px) {
  .hero-stats { grid-template-columns: repeat(2, 1fr); }
  .hero h1 { font-size: 24px; }
}

.section { margin-bottom: 24px; background: var(--surface); padding: 22px 26px 24px; border-radius: 12px; box-shadow: var(--shadow); }
.section h2 { font-size: 17px; color: var(--primary-dark); margin: 0 0 14px; font-weight: 700; display: flex; align-items: center; gap: 10px; padding-bottom: 12px; border-bottom: 1px solid rgba(0,0,0,0.06); }
.section-count { font-size: 11px; background: var(--accent); color: var(--primary-dark); padding: 2px 10px; border-radius: 10px; font-weight: 600; margin-left: 8px; letter-spacing: 0.3px; }
.section-desc { color: var(--text-light); font-size: 14px; margin-bottom: 18px; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.card { background: #FDFAF3; border: 1px solid var(--border); border-radius: 8px; padding: 14px 16px; text-decoration: none; color: var(--text); transition: all 0.18s ease; position: relative; display: flex; flex-direction: column; gap: 4px; }
.card:hover { transform: translateY(-1px); box-shadow: 0 3px 12px rgba(198,40,40,0.1); border-color: var(--primary-light); background: #fff; }
.card-title { font-weight: 600; color: var(--primary-dark); font-size: 14.5px; line-height: 1.45; margin: 0; }
.card-desc { color: var(--text-light); font-size: 12px; line-height: 1.5; }
.card-year { font-size: 11.5px; font-weight: 500; color: var(--accent-dark); letter-spacing: 0.3px; margin: 0; order: -1; }
.card-author, .card-tags { color: var(--text-light); font-size: 12px; }
.card-tags { margin-top: 4px; color: var(--accent-dark); }

/* ===== Search results ===== */
.search-results {
    position: absolute; top: calc(100% + 4px); left: 16px; right: 16px;
    background: #fff; border: 1px solid #ddd; border-radius: 6px;
    box-shadow: 0 6px 24px rgba(0,0,0,0.18); max-height: 70vh; overflow-y: auto;
    z-index: 1000; color: #222;
}
.search-meta { padding: 8px 12px; background: #F5F5F5; color: #666; font-size: 11px; letter-spacing: 0.5px; border-bottom: 1px solid #eee; position: sticky; top: 0; }
.search-result-item { display: block; padding: 10px 12px; border-bottom: 1px solid #f0f0f0; text-decoration: none; color: #222; cursor: pointer; }
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover, .search-result-item.active { background: #FDF3EC; border-left: 3px solid var(--accent); padding-left: 9px; }
.search-result-title { font-size: 13px; font-weight: 600; color: var(--primary-dark); margin-bottom: 4px; display: flex; align-items: center; gap: 6px; }
.search-icon { font-size: 14px; flex-shrink: 0; }
.search-cat { margin-left: auto; background: var(--accent); color: var(--text); padding: 2px 8px; border-radius: 10px; font-size: 10px; font-weight: 500; flex-shrink: 0; }
.search-result-snippet { font-size: 12px; color: #555; line-height: 1.5; margin-left: 20px; }
.search-result-snippet mark, .search-result-title mark { background: #FFF3A0; color: var(--primary-dark); padding: 0 2px; border-radius: 2px; font-weight: 600; }
.search-empty, .search-loading { padding: 16px; text-align: center; color: #888; font-size: 13px; }

/* ===== Responsive ===== */
@media (max-width: 900px) {
    .sidebar { transform: translateX(-100%); transition: transform 0.3s; }
    .sidebar.open { transform: translateX(0); }
    .content { margin-left: 0; }
    .content-inner { padding: 60px 20px 40px; }
    .homepage { padding: 60px 20px 40px; }
    .hero { padding: 40px 25px; }
    .hero h1 { font-size: 26px; }
    .sidebar-toggle { display: block; }
    .hero-stats { flex-wrap: wrap; gap: 20px; }
}
