/* 主题变量 */
:root {
  --bg-main: #eaf6fb !important;
  --bg-content: #fafdff !important;
  --text-main: #23272e !important;
  --sidebar-bg: #23272e !important;
  --sidebar-text: #bfc7d5 !important;
  --primary: #4fd1c5 !important;
  --accent: #ffb300 !important;
  --table-header: #1976d2 !important;
  --table-row-even: #f4faff !important;
  --table-row-odd: #fff !important;
  --table-hover: #e3f2fd !important;
}
body.theme-dark {
  --bg-main: #23272e !important;
  --bg-content: #2d323c !important;
  --text-main: #e0e4ea !important;
  --sidebar-bg: #23272e !important;
  --sidebar-text: #bfc7d5 !important;
  --primary: #4fd1c5 !important;
  --accent: #ffb300 !important;
  --table-header: #2196f3 !important;
  --table-row-even: #23272e !important;
  --table-row-odd: #2d323c !important;
  --table-hover: #38404a !important;
}
body.theme-light {
  --bg-main: #eaf6fb !important;
  --bg-content: #f0f6fa !important;
  --text-main: #23272e !important;
  --sidebar-bg: #23272e !important;
  --sidebar-text: #bfc7d5 !important;
  --primary: #4fd1c5 !important;
  --accent: #ffb300 !important;
  --table-header: #1976d2 !important;
  --table-row-even: #f4faff !important;
  --table-row-odd: #fff !important;
  --table-hover: #e3f2fd !important;
}
html, body {
  height: 100%;
}
body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  margin: 0;
  font-family: 'JetBrains Mono', 'Fira Mono', 'Consolas', 'Menlo', 'PingFang SC', 'Microsoft YaHei', Arial, sans-serif;
  background: var(--bg-main);
  color: var(--text-main);
  transition: background 0.3s, color 0.3s;
}
.book-header {
  background: var(--sidebar-bg);
  color: #fff;
  padding: 0.7rem 0 0.7rem 2rem;
  font-size: 1.3rem;
  font-weight: bold;
  letter-spacing: 1px;
  box-shadow: 0 2px 8px rgba(35,39,46,0.08);
}
.book-logo {
  color: var(--accent);
  text-decoration: none;
  font-family: 'JetBrains Mono', 'Fira Mono', monospace;
  font-size: 1.2em;
}
.book-container {
  flex: 1 0 auto;
  min-height: 0;
  display: flex;
  background: var(--bg-main) !important;
  align-items: stretch;
  /* min-height: 100vh; */
}
.book-sidebar {
  width: 260px;
  background: var(--sidebar-bg);
  border-right: 1px solid #2d323c;
  padding: 2rem 1rem 1rem 1.5rem;
  box-sizing: border-box;
  color: var(--sidebar-text);
  transition: background 0.3s;
  display: flex;
  flex-direction: column;
  flex: none;
}
.book-sidebar h2 {
  font-size: 1.1rem;
  margin-top: 0;
  margin-bottom: 1.2rem;
  color: var(--primary);
  letter-spacing: 1px;
}
.book-sidebar ul {
  list-style: none;
  padding: 0;
  margin: 0;
}
.book-sidebar li {
  margin-bottom: 0.7rem;
}
.book-sidebar a {
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 1rem;
  padding: 0.3rem 0.7rem;
  border-radius: 5px;
  display: block;
  transition: background 0.2s, color 0.2s;
}
.book-sidebar a.active, .book-sidebar a:hover {
  background: var(--primary);
  color: var(--sidebar-bg);
  font-weight: bold;
}
.book-sidebar .nav-group {
  margin-bottom: 1.2rem;
}
.book-sidebar .nav-group > strong {
  display: block;
  font-size: 1.05rem;
  color: var(--accent);
  margin-bottom: 0.3rem;
  margin-top: 0.7rem;
  letter-spacing: 1px;
}
.book-sidebar .nav-group ul {
  margin-left: 0.5rem;
  padding-left: 0.5rem;
  border-left: 2px solid #38404a;
}
.book-sidebar .nav-group ul li {
  margin-bottom: 0.3rem;
}
.book-content {
  flex: 1;
  padding: 2.5rem 2.5rem 0 2.5rem;
  background: var(--bg-main);
  min-width: 0;
  transition: background 0.3s;
}
.book-content article {
  max-width: 900px;
  margin: 0 auto;
  background: var(--bg-content) !important;
  border-radius: 12px;
  box-shadow: 0 4px 24px rgba(35,39,46,0.08);
  padding: 2.5rem 2rem 2rem 2rem;
  line-height: 1.8;
  font-size: 1.08rem;
  word-break: break-word;
  border: 1px solid #e0e4ea;
  color: var(--text-main);
}
.book-content h1, .book-content h2, .book-content h3 {
  color: var(--sidebar-bg);
  margin-top: 1.5em;
  font-family: 'JetBrains Mono', 'Fira Mono', monospace;
}
.book-content h1 {
  border-left: 5px solid var(--primary);
  padding-left: 0.5em;
  font-size: 2em;
}
.book-content h2 {
  border-left: 4px solid var(--accent);
  padding-left: 0.5em;
  font-size: 1.4em;
}
.book-content h3 {
  border-left: 3px solid var(--table-header);
  padding-left: 0.5em;
  font-size: 1.15em;
}
.book-content pre, .book-content code {
  background: #282c34 !important;
  border-radius: 4px;
  font-family: 'JetBrains Mono', 'Fira Mono', 'Consolas', 'Menlo', monospace;
  font-size: 0.98em;
  /* 不设置 color，交给 highlight.js 控制 */
}
.book-content pre {
  padding: 1em;
  overflow-x: auto;
  box-shadow: 0 2px 8px rgba(35,39,46,0.08);
  border: 1px solid #2d323c;
}
.book-content code {
  padding: 0.2em 0.4em;
  font-size: 0.97em;
  background: #282c34 !important;
  /* 不设置 color，交给 highlight.js 控制 */
}
.book-content blockquote {
  border-left: 4px solid var(--primary);
  background: var(--table-hover);
  color: var(--table-header);
  margin: 1.5em 0;
  padding: 0.8em 1.2em;
  border-radius: 6px;
  font-style: italic;
}
.book-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5em 0;
  background: var(--bg-content) !important;
  box-shadow: 0 1px 4px rgba(35,39,46,0.04);
  font-size: 1.08em;
  line-height: 1.7;
}
.book-content th, .book-content td {
  border: 1.5px solid var(--table-header);
  padding: 0.7em 1.1em;
  text-align: left;
}
.book-content th {
  background: var(--sidebar-bg) !important;
  color: #fff !important;
  font-weight: bold;
  letter-spacing: 1px;
  border-bottom: 2.5px solid var(--primary);
  font-size: 1.08em;
  text-align: left;
}
body.theme-dark .book-content th {
  background: var(--sidebar-bg) !important;
  color: #fff !important;
  border-bottom: 2.5px solid var(--primary);
}
body.theme-light .book-content th {
  background: var(--sidebar-bg) !important;
  color: #fff !important;
  border-bottom: 2.5px solid var(--primary);
}
.book-content tr:nth-child(even) {
  background: var(--table-row-even);
}
.book-content tr:nth-child(odd) {
  background: var(--table-row-odd);
}
.book-content tr:hover {
  background: var(--table-hover);
}
.book-footer {
  flex-shrink: 0;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  text-align: center;
  padding: 1.2rem 0 1rem 0;
  font-size: 1rem;
  margin-top: 0;
  border-top: 1px solid #2d323c;
}
.toc {
  background: var(--bg-content) !important;
  border: 1px solid var(--primary);
  border-radius: 8px;
  padding: 1rem 1.2rem;
  margin-bottom: 2rem;
  font-size: 0.98rem;
  color: var(--table-header);
}
.toc h3 {
  margin-top: 0;
  color: var(--table-header);
  font-size: 1.1rem;
}
.toc-list, .toc-sublist {
  list-style: none;
  padding-left: 0.7em;
}
.toc-item a {
  color: var(--table-header);
  text-decoration: none;
  transition: color 0.2s;
}
.toc-item a:hover {
  color: var(--accent);
  text-decoration: underline;
}
#doc-search {
  width: 95%;
  padding: 0.7em 1.1em;
  margin-bottom: 1em;
  border: 2px solid var(--primary);
  border-radius: 8px;
  font-size: 1.13rem;
  outline: none;
  box-sizing: border-box;
  background: var(--bg-content);
  color: var(--sidebar-text);
  box-shadow: 0 2px 12px rgba(35,39,46,0.10);
  transition: border 0.2s, box-shadow 0.2s, background 0.2s;
}
#doc-search:focus, #doc-search:hover {
  border: 2.5px solid var(--accent);
  background: #fffbe7;
  box-shadow: 0 4px 18px rgba(35,39,46,0.16);
}
#doc-search::placeholder {
  color: var(--primary);
  opacity: 0.8;
  font-size: 1em;
  letter-spacing: 1px;
}
.search-results {
  background: var(--bg-content) !important;
  border: 1px solid var(--primary);
  border-radius: 6px;
  max-height: 300px;
  overflow-y: auto;
  margin-bottom: 1em;
  display: none;
  position: relative;
  z-index: 10;
  color: var(--sidebar-text);
}
.search-results ul {
  list-style: none;
  margin: 0;
  padding: 0.5em 0;
}
.search-results li {
  padding: 0.3em 1em;
  border-bottom: 1px solid #38404a;
}
.search-results li:last-child {
  border-bottom: none;
}
.search-results a {
  color: var(--primary);
  text-decoration: none;
  display: block;
}
.search-results a:hover {
  background: var(--table-header);
  color: var(--accent);
}
/* 主题切换按钮动效 */
#theme-toggle {
  transition: transform 0.15s cubic-bezier(.4,2,.6,1), background 0.18s;
  position: relative;
}
#theme-toggle:active {
  transform: scale(0.92);
  background: rgba(79,209,197,0.13);
}
#theme-toggle-icon {
  font-size: 1.5em !important;
  color: var(--accent) !important;
  filter: drop-shadow(0 0 4px var(--primary));
  transition: color 0.2s, filter 0.2s, transform 0.5s cubic-bezier(.4,2,.6,1);
}
#theme-toggle:hover #theme-toggle-icon {
  color: var(--primary) !important;
  filter: drop-shadow(0 0 8px var(--primary));
  transform: scale(1.18) rotate(-12deg);
}
body.theme-dark #theme-toggle-icon {
  color: #fff176 !important;
  filter: drop-shadow(0 0 6px #fff176);
}
body.theme-dark #theme-toggle:hover #theme-toggle-icon {
  color: #ff9800 !important;
  filter: drop-shadow(0 0 12px #ff9800);
}
body.theme-dark .book-content h1,
body.theme-dark .book-content h2,
body.theme-dark .book-content h3 {
  color: var(--primary) !important;
}
body.theme-dark .book-content a {
  color: var(--primary) !important;
}
body.theme-dark .book-content blockquote {
  color: var(--primary) !important;
}
body.theme-dark .toc,
body.theme-dark .toc-item a {
  color: var(--primary) !important;
}
body.theme-dark .book-content pre,
body.theme-dark .book-content code {
  background: #282c34 !important;
}
body.theme-light .book-content pre,
body.theme-light .book-content code {
  background: #fafdff !important;
}
body.theme-dark .mermaid svg path,
body.theme-dark .mermaid svg line,
body.theme-dark .mermaid svg polygon,
body.theme-dark .mermaid .edgePath path,
body.theme-dark .mermaid .flowchart-link {
  stroke: #e0e6f0 !important;
}
body.theme-dark .mermaid .edgeLabel,
body.theme-dark .mermaid .label {
  fill: #e0e6f0 !important;
  color: #e0e6f0 !important;
}
/* 移动端侧边栏收起与浮动按钮 */
@media (max-width: 900px) {
  .book-container { flex-direction: column; }
  .book-sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid #2d323c;
    padding: 0.7rem 0.5rem 0.7rem 0.5rem;
    font-size: 0.98rem;
    box-sizing: border-box;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    height: 100vh;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(.4,2,.6,1);
    background: var(--sidebar-bg);
    overflow-y: auto;
  }
  .book-sidebar.open {
    transform: translateX(0);
  }
  .sidebar-toggle-btn {
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 1100;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 2.6rem;
    height: 2.6rem;
    box-shadow: 0 2px 8px rgba(35,39,46,0.12);
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s, box-shadow 0.2s;
  }
  .sidebar-toggle-btn:active {
    background: var(--accent);
  }
  .book-content { padding: 0.7rem; margin-top: 3.2rem; }
  .book-header { padding-left: 0.7rem; font-size: 1.05rem; }
  .book-sidebar h2 { font-size: 1rem; }
  .book-sidebar a { font-size: 0.98rem; }
  #doc-search { font-size: 1rem; padding: 0.5em 0.7em; }
}
@media (max-width: 600px) {
  .book-content article { padding: 0.5rem 0.2rem; }
  .book-header { padding-left: 0.5rem; font-size: 0.95rem; }
  .book-sidebar { padding: 0.5rem 0.2rem; }
  .book-sidebar h2 { font-size: 0.95rem; }
  .book-sidebar a { font-size: 0.95rem; }
  #doc-search { font-size: 0.95rem; }
}
