/* GitBook Style - 响应式设计 */
:root {
  --sidebar-width: 300px;
  --sidebar-collapsed-width: 0px;
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-mono: "SF Mono", Monaco, "Cascadia Code", "Roboto Mono", Consolas, "Courier New", monospace;
  --color-primary: #1976d2;
  --color-text: #333;
  --color-text-secondary: #666;
  --color-border: #e0e0e0;
  --color-bg: #fff;
  --color-sidebar-bg: #fafafa;
  --color-link: #1976d2;
  --color-link-hover: #1565c0;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.8;
  color: var(--color-text);
  background: var(--color-bg);
}

/* 布局 */
.book-container {
  display: flex;
  min-height: 100vh;
}

/* 侧边栏 */
.book-sidebar {
  width: var(--sidebar-width);
  background: var(--color-sidebar-bg);
  border-right: 1px solid var(--color-border);
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 100;
  transition: transform 0.3s ease;
}

.book-sidebar-header {
  padding: 20px;
  border-bottom: 1px solid var(--color-border);
}

.book-sidebar-header h1 {
  font-size: 18px;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 8px;
}

.book-sidebar-header p {
  font-size: 13px;
  color: var(--color-text-secondary);
}

/* 目录导航 */
.book-summary {
  padding: 16px 0;
}

.book-summary ul {
  list-style: none;
}

.book-summary li {
  margin: 0;
}

.book-summary a {
  display: block;
  padding: 8px 20px;
  color: var(--color-text);
  text-decoration: none;
  font-size: 14px;
  transition: all 0.2s;
}

.book-summary a:hover {
  background: rgba(0,0,0,0.04);
  color: var(--color-link);
}

.book-summary a.active {
  color: var(--color-link);
  font-weight: 500;
  background: rgba(25,118,210,0.08);
}

.book-summary .chapter {
  font-weight: 600;
  font-size: 15px;
  padding: 12px 20px 8px;
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.book-summary .subchapter {
  padding-left: 32px;
  font-size: 13px;
}

/* 主体内容 */
.book-body {
  flex: 1;
  margin-left: var(--sidebar-width);
  max-width: calc(100% - var(--sidebar-width));
}

.book-content {
  max-width: 900px;
  margin: 0 auto;
  padding: 40px 48px;
}

/* 移动端菜单按钮 */
.book-header {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 56px;
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
  z-index: 99;
  align-items: center;
  padding: 0 16px;
}

.menu-toggle {
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.menu-toggle svg {
  width: 24px;
  height: 24px;
  fill: var(--color-text);
}

.book-header-title {
  flex: 1;
  text-align: center;
  font-size: 16px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 0 16px;
}

/* 内容样式 */
.book-content h1 {
  font-size: 32px;
  font-weight: 700;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 2px solid var(--color-border);
  line-height: 1.3;
}

.book-content h2 {
  font-size: 26px;
  font-weight: 600;
  margin: 48px 0 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--color-border);
  line-height: 1.4;
}

.book-content h3 {
  font-size: 20px;
  font-weight: 600;
  margin: 32px 0 16px;
  line-height: 1.4;
}

.book-content h4 {
  font-size: 17px;
  font-weight: 600;
  margin: 24px 0 12px;
}

.book-content p {
  margin-bottom: 16px;
}

.book-content a {
  color: var(--color-link);
  text-decoration: none;
}

.book-content a:hover {
  text-decoration: underline;
}

.book-content ul, .book-content ol {
  margin: 16px 0;
  padding-left: 32px;
}

.book-content li {
  margin: 8px 0;
}

.book-content blockquote {
  margin: 24px 0;
  padding: 16px 20px;
  border-left: 4px solid var(--color-primary);
  background: #f5f5f5;
  font-style: italic;
  color: var(--color-text-secondary);
}

.book-content blockquote p:last-child {
  margin-bottom: 0;
}

/* 表格样式 */
.book-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 24px 0;
  font-size: 14px;
  overflow-x: auto;
  display: block;
}

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

.book-content th {
  background: var(--color-sidebar-bg);
  font-weight: 600;
}

.book-content tr:nth-child(even) {
  background: #fafafa;
}

/* 代码样式 */
.book-content code {
  font-family: var(--font-mono);
  background: #f5f5f5;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 14px;
}

.book-content pre {
  background: #263238;
  color: #aed581;
  padding: 16px 20px;
  border-radius: 6px;
  overflow-x: auto;
  margin: 20px 0;
}

.book-content pre code {
  background: none;
  padding: 0;
  color: inherit;
}

/* 强调 */
.book-content strong {
  font-weight: 600;
}

.book-content em {
  font-style: italic;
}

/* 分割线 */
.book-content hr {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: 40px 0;
}

/* 导航按钮 */
.book-navigation {
  display: flex;
  justify-content: space-between;
  margin-top: 64px;
  padding-top: 32px;
  border-top: 1px solid var(--color-border);
}

.book-navigation a {
  display: flex;
  flex-direction: column;
  padding: 16px 20px;
  border-radius: 6px;
  background: var(--color-sidebar-bg);
  text-decoration: none;
  color: var(--color-text);
  transition: all 0.2s;
  max-width: 45%;
}

.book-navigation a:hover {
  background: #e3f2fd;
  color: var(--color-link);
}

.book-navigation a.next {
  text-align: right;
  margin-left: auto;
}

.book-navigation .label {
  font-size: 12px;
  color: var(--color-text-secondary);
  margin-bottom: 4px;
  text-transform: uppercase;
}

.book-navigation .title {
  font-weight: 600;
  font-size: 15px;
}

/* 页脚 */
.book-footer {
  margin-top: 64px;
  padding: 32px 0;
  border-top: 1px solid var(--color-border);
  text-align: center;
  color: var(--color-text-secondary);
  font-size: 13px;
}

/* ===== 移动端响应式 ===== */
@media (max-width: 768px) {
  :root {
    --sidebar-width: 280px;
  }
  
  .book-header {
    display: flex;
  }
  
  .book-sidebar {
    transform: translateX(-100%);
  }
  
  .book-sidebar.open {
    transform: translateX(0);
    box-shadow: 2px 0 8px rgba(0,0,0,0.15);
  }
  
  .book-body {
    margin-left: 0;
    max-width: 100%;
    padding-top: 56px;
  }
  
  .book-content {
    padding: 24px 20px;
  }
  
  .book-content h1 {
    font-size: 26px;
  }
  
  .book-content h2 {
    font-size: 22px;
    margin-top: 36px;
  }
  
  .book-content h3 {
    font-size: 18px;
  }
  
  .book-content table {
    font-size: 13px;
  }
  
  .book-content th, .book-content td {
    padding: 8px 12px;
  }
  
  .book-navigation {
    flex-direction: column;
    gap: 12px;
  }
  
  .book-navigation a {
    max-width: 100%;
  }
  
  .book-navigation a.next {
    margin-left: 0;
  }
}

/* 遮罩层 */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 99;
}

.sidebar-overlay.show {
  display: block;
}

@media (min-width: 769px) {
  .sidebar-overlay {
    display: none !important;
  }
}