/* static/style.css */
/* v1.0.1 让左右边栏宽度固定，中间内容区域固定800px */
:root {
    --bg-color: #ffffff;
    --text-color: #333333;
    --sidebar-bg: #f8f9fa;
    --link-color: #07c160;
    --border-color: #ddd;
    --header-bg: #ffffff;
    --footer-bg: #f5f5f5;
}
.dark-theme {
    --bg-color: #1e1e1e;
    --text-color: #e0e0e0;
    --sidebar-bg: #2d2d2d;
    --link-color: #6ec1e4;
    --border-color: #444;
    --header-bg: #252525;
    --footer-bg: #202020;
}
.blue-theme {
    --bg-color: #f0f8ff;
    --text-color: #2c3e50;
    --sidebar-bg: #e6f2ff;
    --link-color: #2980b9;
    --border-color: #b3d9ff;
    --header-bg: #d0e7ff;
    --footer-bg: #c5e8c5;
}
.green-theme {
    --bg-color: #f8fff8;
    --text-color: #2c502c;
    --sidebar-bg: #e8f5e8;
    --link-color: #27ae60;
    --border-color: #c0e0c0;
    --header-bg: #d5f0d5;
    --footer-bg: #c5e8c5;
}
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}
body {
    font-family: "Microsoft YaHei", "Segoe UI", sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    padding-top: 50px;
    padding-bottom: 50px;
    line-height: 1.6;
}
header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 50px;
    background-color: var(--header-bg);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 1rem;
    z-index: 1000;
}
header h1 {
    font-size: 1.1rem;
    font-weight: bold;
}
/* 响应式表格 */
table {
  width: 100%;
  overflow-x: auto;
  display: block;
}
/* 代码块响应式 */
pre, code {
  overflow-x: auto;
  white-space: pre-wrap;
  word-wrap: break-word;
}
/* 移动端字体优化和标题遮挡修复 */
@media (max-width: 768px) {
  h1 { font-size: 1.5rem; }
  h2 { font-size: 1.25rem; }
  body { 
    padding: 1rem;
    font-size: 0.9rem;
    padding-top: 60px !important;
  }
  
  /* 目录导航优化 */
  .toc {
    font-size: 0.85rem;
    position: static !important;
    margin-top: 20px;
    margin-bottom: 20px;
    border: 1px solid #eee;
    padding: 10px;
    background: #f9f9f9;
  }
  
  /* 主标题样式优化 */
  h1:first-of-type {
    margin-top: 0 !important;
    padding-top: 20px !important;
  }
  
  /* 防止其他固定元素遮挡 */
  [style*="fixed"] {
    position: relative !important;
  }
  
  /* 移动端隐藏header h1 标题 */
  header h1 {
    display: none !important;
    margin: 0 !important;
    padding: 0 !important;
    height: 0 !important;
    visibility: hidden !important;
  }

  footer {
    display: none !important;
    margin: 0 !important;
    padding: 0 !important;
    height: 0 !important;
    visibility: hidden !important;
  }
}
/* 如果存在sticky导航，添加额外处理 */
.sticky, [class*="sticky"] {
  position: relative !important;
}
.controls {
    display: flex;
    gap: 0.6rem;
    align-items: center;
}
select, button {
    padding: 0.25rem 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background-color: white;
    color: var(--text-color);
    font-size: 0.9rem;
}
.homepage-btn {
    background-color: #07c160;
    color: white;
    border: none;
}
.container {
    display: grid;
    grid-template-columns: 220px minmax(0, 800px) 220px;
    justify-content: center;
    gap: 1.5rem;
    padding: 0 1rem;
    max-width: 1400px;
    margin: 0 auto;
}
/* 让左右边栏宽度固定，中间内容区域固定800px */
.toc-local,
.toc-global {
    width: 220px;
    position: sticky;
    top: 60px;
    height: calc(100vh - 120px);
    overflow-y: auto;
    background-color: var(--sidebar-bg);
    padding: 1rem;
    border-radius: 6px;
    border: 1px solid var(--border-color);
}
.toc-global {
    display: none;
}

/* 目录层级视觉样式 */
.toc-local .toc-root {
    list-style: none;
    padding-left: 0;
    margin: 0.5rem 0;
}

.toc-local .toc-root > li {
    font-weight: 600;
    margin: 0.3rem 0;
}

.toc-local .toc-root > li > a {
    color: #1e293b;
    text-decoration: none;
    border-left: 3px solid #3b82f6;
    padding-left: 0.5rem;
    display: inline-block;
}

.toc-local .toc-root > li > a:hover {
    color: #1d4ed8;
    border-left-color: #1d4ed8;
}

/* 二级目录 */
.toc-local .toc-level-2 {
    list-style: none;
    padding-left: 1.5rem;
    margin: 0.2rem 0;
    border-left: 2px dashed #cbd5e1;
}

.toc-local .toc-level-2 > li {
    font-weight: 500;
    margin: 0.2rem 0;
    padding-left: 0.5rem;
    position: relative;
}

.toc-local .toc-level-2 > li::before {
    content: "▸";
    color: #64748b;
    font-size: 0.75rem;
    margin-right: 0.4rem;
    display: inline-block;
}

.toc-local .toc-level-2 > li > a {
    color: #334155;
    text-decoration: none;
}

.toc-local .toc-level-2 > li > a:hover {
    color: #0f172a;
    text-decoration: underline;
}

/* 三级目录 */
.toc-local .toc-level-3 {
    list-style: none;
    padding-left: 1.5rem;
    margin: 0.1rem 0;
    border-left: 2px dotted #e2e8f0;
}

.toc-local .toc-level-3 > li {
    font-weight: 400;
    margin: 0.15rem 0;
    padding-left: 0.3rem;
}

.toc-local .toc-level-3 > li::before {
    content: "◦";
    color: #94a3b8;
    font-size: 1rem;
    margin-right: 0.4rem;
    display: inline-block;
}

.toc-local .toc-level-3 > li > a {
    color: #475569;
    text-decoration: none;
    font-size: 0.95em;
}

.toc-local .toc-level-3 > li > a:hover {
    color: #1e293b;
    text-decoration: underline wavy #94a3b8 1px;
}

/* 四级目录（如有） */
.toc-local .toc-level-4 {
    list-style: none;
    padding-left: 1.5rem;
    margin: 0.1rem 0;
    border-left: 1px solid #f1f5f9;
}

.toc-local .toc-level-4 > li {
    font-weight: 300;
    margin: 0.1rem 0;
    padding-left: 0.3rem;
}

.toc-local .toc-level-4 > li::before {
    content: "▪";
    color: #b9c7d9;
    font-size: 0.7rem;
    margin-right: 0.5rem;
    display: inline-block;
}

.toc-local .toc-level-4 > li > a {
    color: #64748b;
    text-decoration: none;
    font-size: 0.92em;
}

.toc-local .toc-level-4 > li > a:hover {
    color: #334155;
    text-decoration: underline dotted #94a3b8;
}

/* 悬浮效果 */
.toc-local li:hover {
    background-color: #f8fafc;
    border-radius: 4px;
    transition: background 0.15s;
}

.main-content {
    max-width: 800px;
    width: 100%;
}
.toc-local h3, .toc-global h3 {
    margin-bottom: 0.8rem;
    font-size: 1rem;
    color: var(--text-color);
}
.toc-local ul, .toc-global ul {
    list-style: none;
    padding-left: 0;
}
.toc-local li, .toc-global li {
    margin: 0.4rem 0;
}
.toc-local a, .toc-global a {
    color: var(--link-color);
    text-decoration: none;
    font-size: 0.95rem;
}
.toc-local a:hover, .toc-global a:hover {
    text-decoration: underline;
}
.toggle-toc-btn {
    position: fixed;
    bottom: 70px;
    right: 20px;
    background-color: #07c160;
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
    z-index: 900;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}
@media (max-width: 1200px) {
    .container {
        grid-template-columns: 200px minmax(0, 800px);
    }
    .toc-global {
        display: none !important;
    }
    .toggle-toc-btn {
        display: none;
    }
}
@media (max-width: 768px) {
    .container {
        grid-template-columns: 1fr;
    }
    .toc-local {
        display: none;
    }
    .main-content {
        max-width: min(720px, 100vw - 32px);
        width: 100%;
        padding: 0 24px;
    }
}

@media print {
  body {
    font-size: 10pt;
    line-height: 1.2;
    margin: 0.2in;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
  }
  header {
    position: static !important;
    break-after: avoid;
  } 
  /* 主内容区：大幅压缩间距 */
  .main-content h1,
  .main-content h2,
  .main-content h3,
  .main-content h4 {
    margin-top: 0.6em !important;
    margin-bottom: 0.3em !important;
    break-after: avoid;
  }
  .main-content p,
  .main-content ul,
  .main-content ol,
  .main-content pre,
  .main-content blockquote,
  .main-content table {
    margin-bottom: 0.4em !important;
    margin-top: 0 !important;
  }
  /* 段落 */
  p,pre {
    margin: 0 0 0.3em 0;
    margin-bottom: 0.1em;
  }
  .no-print,
  .no-print * {
    display: none !important;
  }
}
.main-content p {
    text-indent: 2em;
    margin-bottom: 1.4rem;
}
.main-content ul,
.main-content ol,
.main-content pre,
.main-content blockquote,
.main-content table {
    margin-bottom: 1.4rem;
}
.main-content h1,
.main-content h2,
.main-content h3,
.main-content h4 {
    margin-top: 2.2rem;
    margin-bottom: 1.1rem;
    font-weight: bold;
    line-height: 1.4;
    text-indent: 0;
}
.main-content h1 { font-size: 1.9rem; }
.main-content h2 { font-size: 1.6rem; }
.main-content h3 { font-size: 1.35rem; }
.main-content ul, .main-content ol {
    padding-left: 2rem;
    text-indent: 0;
}
.main-content li {
    margin-bottom: 0.6rem;
    text-indent: 0;
}
.main-content pre {
    background-color: #f5f5f5;
    padding: 1.1rem;
    border-radius: 6px;
    overflow-x: auto;
    font-size: 0.95rem;
    line-height: 1.6;
    text-indent: 0;
}
.dark-theme .main-content pre {
    background-color: #2d2d2d;
}
.main-content code {
    font-family: "Consolas", "Courier New", monospace;
    background-color: #f0f0f0;
    padding: 0.2em 0.4em;
    border-radius: 3px;
    font-size: 0.95em;
}
.dark-theme .main-content code {
    background-color: #444;
}
.main-content table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1.4rem;
}
.main-content th, .main-content td {
    border: 1px solid var(--border-color);
    padding: 0.7rem;
    text-align: left;
}
.main-content th {
    background-color: var(--sidebar-bg);
}
.main-content blockquote {
    border-left: 4px solid var(--link-color);
    padding-left: 1.2rem;
    color: #555;
    font-style: italic;
    margin-left: 10;
    text-indent: 0;
}
.main-content img {
    max-width: 100%;
    height: auto;
    margin: 1.2rem 0;
    border-radius: 4px;
    display: block;
}
.main-content h1, .main-content h2, .main-content h3 {
    scroll-margin-top: 70px;
}
footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 50px;
    background-color: var(--footer-bg);
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    color: var(--text-color);
    z-index: 1000;
    padding: 0 1rem;
    text-align: center;
}
   
footer a {
    color: var(--link-color);
    text-decoration: none;
}
footer a:hover {
    text-decoration: underline;
}
#qr-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.7);
    z-index: 9999;
    justify-content: center;
    align-items: center;
}
#qr-modal > div {
    background: white;
    padding: 1.5rem;
    border-radius: 10px;
    text-align: center;
    max-width: 90%;
    max-height: 90%;
}
#qr-modal img {
    max-width: 300px;
    max-height: 300px;
    margin: 1rem 0;
}