/* =========================
   GitBook 风格主题
   ========================= */

:root {
  --primary: #1a1dc3;
  --primary-hover: #1416a8;
  --text-primary: #1a1a1a;
  --text-secondary: #6b7280;
  --text-muted: #9ca3af;
  --border-color: #e5e7eb;
  --bg-main: #ffffff;
  --bg-secondary: #fafafa;
  --hover-bg: #f3f4f6;
  --radius: 8px;
}

html { font-size: 16px; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--bg-main);
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* =========================
   顶部导航栏
   ========================= */
#site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: 64px;
  background: #fff;
  border-bottom: 1px solid var(--border-color);
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}

.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  height: 100%;
}

.header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  padding: 0 24px;
  gap: 24px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.site-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text-primary);
}

.site-emoji {
  font-size: 22px;
}

.site-title {
  font-size: 17px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-center {
  flex: 1;
  max-width: 400px;
  display: flex;
  justify-content: center;
}

.search-box {
  position: relative;
  width: 100%;
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 14px;
}

.search-input {
  width: 100%;
  padding: 10px 80px 10px 40px;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background: var(--bg-secondary);
  font-size: 14px;
  outline: none;
  transition: all 0.2s;
}

.search-input:focus {
  border-color: var(--primary);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(26, 29, 195, 0.1);
}

.search-shortcut {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 11px;
  padding: 3px 6px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background: #fff;
  color: var(--text-muted);
}

.header-right {
  display: flex;
  align-items: center;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 4px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  transition: all 0.2s;
}

.nav-link:hover {
  background: var(--hover-bg);
  color: var(--primary);
  text-decoration: none;
}

/* =========================
   主内容区
   ========================= */
.main-wrapper {
  min-height: calc(100vh - 64px);
  background: var(--bg-main);
}

@media (max-width: 900px) {
  .header-center { display: none; }
  .header-nav { gap: 2px; }
  .nav-link { padding: 8px 10px; }
  .nav-link span { display: none; }
}

/* =========================
   顶部导航栏
   ========================= */
#site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: 64px;
  background: #fff;
  border-bottom: 1px solid var(--border-color);
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}

.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  height: 100%;
}

.header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  padding: 0 24px;
  gap: 24px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.menu-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  padding: 8px;
  color: var(--text-secondary);
}

.site-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text-primary);
}

.site-emoji {
  font-size: 22px;
}

.site-title {
  font-size: 17px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-center {
  flex: 1;
  max-width: 400px;
  display: flex;
  justify-content: center;
}

.search-box {
  position: relative;
  width: 100%;
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 14px;
}

.search-input {
  width: 100%;
  padding: 10px 80px 10px 40px;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background: var(--bg-secondary);
  font-size: 14px;
  outline: none;
  transition: all 0.2s;
}

.search-input:focus {
  border-color: var(--primary);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(26, 29, 195, 0.1);
}

.search-shortcut {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 11px;
  padding: 3px 6px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background: #fff;
  color: var(--text-muted);
}

.header-right {
  display: flex;
  align-items: center;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 4px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  transition: all 0.2s;
}

.nav-link:hover {
  background: var(--hover-bg);
  color: var(--primary);
  text-decoration: none;
}

/* =========================
   主内容区 + 侧边栏布局
   ========================= */
.main-wrapper {
  min-height: calc(100vh - 64px);
  background: var(--bg-main);
}

.with-sidebar {
  display: flex;
  gap: 32px;
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 24px;
}

.sidebar-nav {
  width: 240px;
  flex: 0 0 240px;
  min-width: 240px;
  position: sticky;
  top: 96px;
  height: fit-content;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
}

.sidebar-section {
  margin-bottom: 20px;
}

.sidebar-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #9ca3af;
  padding: 8px 12px;
  margin-bottom: 4px;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 14px;
  color: #4b5563;
  text-decoration: none;
  transition: all 0.15s;
}

.sidebar-item:hover {
  background: var(--hover-bg);
  color: var(--primary);
  text-decoration: none;
}

.sidebar-item.active {
  background: rgba(26, 29, 195, 0.08);
  color: var(--primary);
  font-weight: 500;
}

.sidebar-emoji {
  font-size: 14px;
}

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

/* =========================
   文章页
   ========================= */
.article {
  max-width: 100%;
}

.article h1 {
  font-size: 28px;
  font-weight: 700;
  margin: 0 0 20px;
  line-height: 1.3;
}

.article h2 {
  font-size: 22px;
  font-weight: 600;
  margin: 1.4em 0 0.6em;
  padding-bottom: 0.3em;
  border-bottom: 1px solid var(--border-color);
}

.article h3 {
  font-size: 18px;
  font-weight: 600;
  margin: 1.2em 0 0.5em;
}

.article p {
  font-size: 16px;
  line-height: 1.8;
  margin: 1em 0;
}

.article li {
  font-size: 16px;
  line-height: 1.7;
  margin: 0.5em 0;
}

.article .meta {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

/* =========================
   表格
   ========================= */
.article table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  margin: 16px 0;
}

.article th,
.article td {
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  text-align: left;
}

.article th {
  background: var(--bg-secondary);
  font-weight: 600;
}

.article td {
  background: #fff;
}

.article th:not(:first-child),
.article td:not(:first-child) {
  text-align: right;
}

/* =========================
   图表
   ========================= */
.chart-wrap {
  max-width: 800px;
  margin: 24px auto;
}

.chart-wrap canvas {
  width: 100% !important;
  height: auto !important;
}

/* =========================
   响应式
   ========================= */
@media (max-width: 900px) {
  .header-center { display: none; }
  
  .header-nav { gap: 2px; }
  .nav-link { padding: 8px 10px; }
  .nav-link span { display: none; }
  
  .with-sidebar {
    flex-direction: column;
    padding: 20px 16px;
  }
  
  .sidebar-nav {
    width: 100%;
    flex: none;
    position: static;
    max-height: none;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 16px;
    margin-bottom: 16px;
    display: flex;
    gap: 16px;
    overflow-x: auto;
  }
  
  .sidebar-section {
    margin-bottom: 0;
    white-space: nowrap;
  }
}
