/* GitBook 样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f8f9fa;
    padding-top: 60px; /* 为顶部菜单栏留出空间 */
}

/* 顶部菜单栏样式 */
.top-navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background-color: #2c3e50;
    color: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    z-index: 1000;
}

.navbar-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.navbar-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
    color: white;
}

.navbar-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.search-container {
    display: flex;
    align-items: center;
    gap: 8px;
    position: relative;
}

.search-results {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    width: min(420px, 80vw);
    max-height: 70vh;
    overflow-y: auto;
    background: white;
    color: #1f2933;
    border-radius: 10px;
    box-shadow: 0 16px 36px rgba(15, 23, 42, 0.24);
    border: 1px solid rgba(148, 163, 184, 0.25);
    padding: 8px;
    display: none;
    z-index: 1100;
}

.search-results.visible {
    display: block;
}

.search-loading-state,
.search-empty-state {
    padding: 12px 14px;
}

.search-loading-state {
    font-size: 0.9rem;
    color: #52606d;
}

.search-empty-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: #102a43;
}

.search-empty-subtitle {
    margin-top: 4px;
    font-size: 0.85rem;
    color: #52606d;
    line-height: 1.5;
}

.search-result-item {
    display: block;
    padding: 12px 14px;
    border-radius: 8px;
    text-decoration: none;
    color: inherit;
    transition: background-color 0.2s ease, transform 0.2s ease;
}

.search-result-item + .search-result-item {
    margin-top: 6px;
}

.search-result-item:hover,
.search-result-item.active {
    background: #f0f4f8;
    transform: translateY(-1px);
}

.search-result-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
}

.search-result-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: #102a43;
}

.search-result-url,
.search-result-heading {
    margin-top: 4px;
    font-size: 0.82rem;
    color: #486581;
}

.search-result-url {
    flex-shrink: 0;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.search-result-snippet {
    margin-top: 8px;
    font-size: 0.86rem;
    line-height: 1.5;
    color: #334e68;
    word-break: break-word;
}

.search-icon {
    font-size: 16px;
    color: #95a5a6;
    pointer-events: none;
    position: absolute;
    left: 12px;
    z-index: 1;
}

.search-input {
    padding: 8px 12px 8px 36px;
    border: 1px solid #34495e;
    border-radius: 4px;
    background-color: #34495e;
    color: white;
    font-size: 0.9rem;
    width: 200px;
    transition: all 0.3s ease;
}

.search-input::placeholder {
    color: #95a5a6;
}

.search-input:focus {
    outline: none;
    border-color: #3498db;
    background-color: #34495e;
    width: 250px;
}

.search-input:focus + .search-icon,
.search-container:focus-within .search-icon {
    color: #3498db;
}

.navbar-nav {
    display: flex;
    align-items: center;
    gap: 10px;
}

.nav-link {
    color: white;
    text-decoration: none;
    padding: 0 0 4px 0;
    border-bottom: 2px solid #3498db;
    transition: color 0.3s ease, border-color 0.3s ease;
    font-size: 0.9rem;
}

.nav-link:hover {
    color: #3498db;
    border-bottom-color: #3498db;
}

.nav-link.active {
    color: white;
    border-bottom: 2px solid #3498db;
}

body.ai-chat-open {
    overflow: hidden;
}

.ai-entry-button {
    height: 36px;
    padding: 0 14px;
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.12);
    color: white;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: background-color 0.2s ease, transform 0.2s ease, border-color 0.2s ease;
}

.ai-entry-button:hover {
    background: rgba(52, 152, 219, 0.22);
    border-color: rgba(52, 152, 219, 0.7);
    transform: translateY(-1px);
}

.ai-entry-button:active {
    transform: translateY(0);
}

.ai-chat-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.42);
    z-index: 1090;
}

.ai-chat-panel {
    position: fixed;
    top: 76px;
    right: 20px;
    width: min(440px, calc(100vw - 24px));
    max-height: calc(100vh - 96px);
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 18px;
    border-radius: 16px;
    background: #ffffff;
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.22);
    border: 1px solid rgba(148, 163, 184, 0.24);
    z-index: 1100;
    opacity: 0;
    pointer-events: none;
    transform: translateY(-8px) scale(0.98);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.ai-chat-panel.open {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0) scale(1);
}

.ai-chat-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.ai-chat-title {
    margin: 0;
    font-size: 1.05rem;
    color: #102a43;
}

.ai-chat-subtitle {
    margin-top: 4px;
    font-size: 0.84rem;
    color: #52606d;
}

.ai-chat-close {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: #eef2f6;
    color: #243b53;
    cursor: pointer;
    font-size: 24px;
    line-height: 1;
}

.ai-chat-config {
    padding: 14px;
    border-radius: 12px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
}

.ai-chat-config-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.ai-chat-config-header h3 {
    margin: 0;
    font-size: 0.95rem;
    color: #102a43;
}

.ai-chat-config-tip {
    font-size: 0.78rem;
    color: #64748b;
}

.ai-chat-config-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.ai-chat-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 0.84rem;
    color: #334e68;
}

.ai-chat-field-full {
    grid-column: 1 / -1;
}

.ai-chat-input,
.ai-chat-textarea {
    width: 100%;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    background: white;
    color: #102a43;
    font-size: 0.92rem;
    padding: 10px 12px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.ai-chat-input:focus,
.ai-chat-textarea:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.14);
}

.ai-chat-textarea {
    resize: vertical;
    min-height: 96px;
    line-height: 1.5;
}

.ai-chat-config-actions,
.ai-chat-composer-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.ai-chat-config-actions {
    margin-top: 12px;
}

.ai-chat-primary-button,
.ai-chat-secondary-button {
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    padding: 10px 14px;
    transition: transform 0.2s ease, opacity 0.2s ease, background-color 0.2s ease;
}

.ai-chat-primary-button {
    background: #2563eb;
    color: white;
}

.ai-chat-secondary-button {
    background: #e2e8f0;
    color: #102a43;
}

.ai-chat-primary-button:hover,
.ai-chat-secondary-button:hover {
    transform: translateY(-1px);
}

.ai-chat-primary-button:disabled,
.ai-chat-secondary-button:disabled,
.ai-chat-input:disabled,
.ai-chat-textarea:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.ai-chat-status {
    flex: 1;
    min-height: 20px;
    font-size: 0.82rem;
    text-align: right;
    color: #52606d;
}

.ai-chat-status[data-state="success"] {
    color: #15803d;
}

.ai-chat-status[data-state="error"] {
    color: #b91c1c;
}

.ai-chat-messages {
    flex: 1;
    min-height: 220px;
    max-height: 40vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 4px;
}

.ai-chat-message {
    max-width: 92%;
    padding: 12px 14px;
    border-radius: 14px;
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.06);
}

.ai-chat-message-role {
    margin-bottom: 6px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.04em;
}

.ai-chat-message-content {
    color: #102a43;
    font-size: 0.92rem;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
}

.ai-chat-message-user {
    margin-left: auto;
    background: #dbeafe;
}

.ai-chat-message-user .ai-chat-message-role {
    color: #1d4ed8;
}

.ai-chat-message-assistant {
    margin-right: auto;
    background: #f8fafc;
}

.ai-chat-message-assistant .ai-chat-message-role {
    color: #475569;
}

.ai-chat-message.is-pending .ai-chat-message-content {
    color: #64748b;
}

.ai-chat-composer {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.ai-chat-context-tip {
    font-size: 0.8rem;
    color: #64748b;
}

.container {
    display: flex;
    min-height: calc(100vh - 60px);
}

.sidebar {
    width: 300px;
    background-color: #2c3e50;
    color: white;
    overflow-y: auto;
    position: fixed;
    height: calc(100vh - 60px);
    left: 0;
    top: 60px;
    transition: transform 0.3s ease-in-out;
    z-index: 100;
}

.sidebar.hidden {
    transform: translateX(-100%);
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid #34495e;
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 60px;
}

.sidebar-header:empty {
    display: none;
}

.sidebar-header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    margin: 0;
    flex: 1;
    padding-left: 50px;
}

.sidebar-nav {
    padding: 20px 0;
}

.sidebar-item {
    margin-bottom: 5px;
}

.sidebar-link {
    display: block;
    padding: 10px 20px;
    color: #ecf0f1;
    text-decoration: none;
    transition: background-color 0.3s;
}

.sidebar-link:hover {
    background-color: #34495e;
}

.sidebar-children {
    margin-left: 20px;
}

.level-1 .sidebar-link { padding-left: 20px; }
.level-2 .sidebar-link { padding-left: 40px; }
.level-3 .sidebar-link { padding-left: 60px; }

.main-content {
    flex: 1;
    width: 100%;
    padding-left: 310px;
    padding-right: 10px;
    padding-top: 40px;
    padding-bottom: 40px;
    transition: padding-left 0.3s ease-in-out;
}

.sidebar.hidden ~ .main-content {
    padding-left: 0;
}

.content-wrapper {
    width: 100%;
    margin: 0 auto;
    display: flex;
    gap: 20px;
}

.content-body {
    flex: 1;
    min-width: 0;
    background: white;
    padding: 40px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.content-body img {
    max-width: 100%;
}

.toc {
    flex: 0 0 250px; /* grow=0, shrink=0, basis=250px */
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    height: fit-content;
    position: sticky;
    top: 20px;
    transition: all 0.3s ease-in-out;
}

.toc-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 15px;
}

.toc-header h3 {
    margin: 0;
    color: #2c3e50;
    flex: 1;
}

.toc-toggle {
    background: rgba(44, 62, 80, 0.1);
    color: #2c3e50;
    border: none;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    width: 28px;
    height: 28px;
}

.toc-toggle:hover {
    background: rgba(44, 62, 80, 0.2);
}

.toc-toggle:active {
    transform: scale(0.95);
}

.toc-toggle-icon {
    display: inline-block;
    transition: transform 0.3s ease;
}

.toc-content {
    transition: opacity 0.3s ease-in-out;
}

.toc.hidden {
    width: 50px;
    padding: 20px 10px;
    flex: 0 0 50px;  /* 宽度变成 50px */
}

.toc.hidden .toc-content {
    display: none;
}

.toc.hidden .toc-header {
    margin-bottom: 0;
    justify-content: center;
}

.toc.hidden .toc-header h3 {
    display: none;
}

.toc.hidden .toc-toggle {
    width: 32px;
    height: 32px;
    font-size: 24px;
}

.toc.hidden .toc-toggle-icon {
    transform: rotate(45deg);
}

.toc-list {
    list-style: none;
}

.toc-item {
    margin-bottom: 5px;
}

.toc-link {
    display: block;
    padding: 5px 0;
    color: #666;
    text-decoration: none;
    font-size: 0.9rem;
    transition: color 0.3s;
}

.toc-link:hover {
    color: #2c3e50;
}

.level-1 .toc-link { padding-left: 0; }
.level-2 .toc-link { padding-left: 15px; }
.level-3 .toc-link { padding-left: 30px; }

/* Markdown 内容样式 */
.content-body h1, .content-body h2, .content-body h3, .content-body h4, .content-body h5, .content-body h6 {
    margin-top: 30px;
    margin-bottom: 15px;
    color: #2c3e50;
}

.content-body h1 { font-size: 2rem; }
.content-body h2 { font-size: 1.5rem; }
.content-body h3 { font-size: 1.25rem; }

.content-body p {
    margin-bottom: 15px;
}

.content-body ul, .content-body ol {
    margin-bottom: 15px;
    padding-left: 30px;
}

.content-body li {
    margin-bottom: 5px;
}

.content-body code {
    background-color: #f1f2f6;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Monaco', 'Consolas', monospace;
}

.content-body pre {
    color: #464d4e;
    padding: 20px;
    border-radius: 5px;
    overflow-x: auto;
    margin-bottom: 20px;
}

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

.content-body blockquote {
    border-left: 4px solid #3498db;
    padding-left: 20px;
    margin: 20px 0;
    color: #666;
    font-style: italic;
}

.content-body table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
}

.content-body th, .content-body td {
    border: 1px solid #ddd;
    padding: 12px;
    text-align: left;
}

.content-body th {
    background-color: #f8f9fa;
    font-weight: 600;
}

/* 侧边栏切换按钮 */
.sidebar-toggle {
    background: transparent;
    color: white;
    border: none;
    padding: 8px;
    border-radius: 4px;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
}

.sidebar-toggle:hover {
    background: rgba(255, 255, 255, 0.1);
}

.sidebar-toggle:active {
    transform: scale(0.95);
}

.toggle-icon {
    display: inline-block;
    transition: transform 0.3s ease;
}
/* gitbook 样式 */
.gb-hint {
    padding: 12px;
    border-left: 4px solid #448aff;
    border-radius: 4px;
    margin-bottom: 16px;
  }
/* 提示框 */
.gb-note {
    border-left: 4px solid #448aff;
    background: #ecf5ff;
}

.gb-success {
    border-left: 4px solid #4caf50;
    background: #e8f5e9;
}

.gb-info {
    border-color: #2196f3;
    background: #e3f2fd;
}

.gb-warning {
    border-left: 4px solid #ff9800;
    background: #fff3e0;
}

.gb-danger {
    border-left: 4px solid #f44336;
    background: #ffebee;
}

.gb-tabs {
    border: 1px solid #e5e5e5;
    border-radius: 12px;
    background: #fff;
    overflow: hidden;
  }
  
  /* tab 顶部区域 */
  .tabs-header {
    display: flex;
    align-items: center;
    background: #f7f7f7;
    /* padding: 6px;
    border-bottom: 1px solid #e5e5e5; */
  }
  
  /* 单个 tab */
  .tab {
    appearance: none;
    border: none;
    background: transparent;
    padding: 8px 16px;
    margin-right: 4px;
    font-size: 15px;
    color: #666;
    cursor: pointer;
    /* border-radius: 8px; */
    position: relative;
  }
  
  /* tab 分隔线（非第一个） */
  .tab:not(:first-child)::before {
    content: "";
    position: absolute;
    left: -2px;
    top: 25%;
    bottom: 25%;
    width: 1px;
    background: #ddd;
  }
  
  /* 选中 tab */
  .tab.active {
    background: #fff;
    color: #111;
    /* font-weight: 500; */
    /* box-shadow: 0 1px 2px rgba(0,0,0,0.05); */
  }
  
  /* 内容区域 */
  .tabs-body {
    padding: 24px;
  }
  
  /* 面板 */
  .tab-panel {
    display: none;
    font-size: 16px;
    line-height: 1.6;
    color: #111;
  }
  
  .tab-panel.active {
    display: block;
  }

  /* stepper 样式 */
  .gb-stepper {
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 0;
    margin: 24px 0;
  }
  
  .step {
    display: flex;
    align-items: flex-start;
    position: relative;
    padding-bottom: 24px;
  }
  
  .step:last-child {
    padding-bottom: 0;
  }
  
  /* 左侧标记区域 */
  .step-marker {
    position: relative;
    width: 48px;
    min-width: 48px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    flex-shrink: 0;
  }
  
  /* 圆形数字 */
  .step-number {
    width: 36px;
    height: 36px;
    background: #ff6a21;
    color: #fff;
    border-radius: 50%;
    font-weight: 600;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 2;
    flex-shrink: 0;
  }
  
  /* 竖向连线 */
  .step-line {
    position: absolute;
    left: 50%;
    top: 36px;
    transform: translateX(-50%);
    width: 2px;
    height: calc(100% + 12px);
    background: rgba(255, 106, 33, 0.35);
    z-index: 1;
  }
  
  /* 右侧内容 */
  .step-content {
    flex: 1;
    padding-left: 16px;
    padding-top: 0;
    min-width: 0;
  }
  
  .step-content > *:first-child {
    margin-top: 0;
  }
  
  .step-content > *:last-child {
    margin-bottom: 0;
  }
  
  
/* 响应式设计 - 中等屏幕：TOC显示在内容上方 */
@media (max-width: 1024px) {
    .content-wrapper {
        flex-direction: column;
    }
    
    .content-body {
        order: 2;
    }
    
    .toc {
        width: 100%;
        position: static;
        order: 1;
        margin-bottom: 20px;
    }
}

/* 响应式设计 - 小屏幕 */
@media (max-width: 768px) {
    body {
        padding-top: 60px;
    }
    
    .top-navbar {
        height: 60px;
        padding: 0 10px;
    }

    .navbar-right {
        gap: 10px;
    }
    
    .navbar-title {
        font-size: 1rem;
    }
    
    .search-input {
        width: 150px;
    }
    
    .search-input:focus {
        width: 180px;
    }

    .search-results {
        width: min(320px, calc(100vw - 20px));
        right: 0;
        left: auto;
    }

    .ai-entry-button {
        padding: 0 12px;
    }

    .ai-chat-panel {
        top: 70px;
        right: 12px;
        left: 12px;
        width: auto;
        max-height: calc(100vh - 82px);
        padding: 14px;
    }

    .ai-chat-config-grid {
        grid-template-columns: 1fr;
    }

    .ai-chat-config-header,
    .ai-chat-config-actions,
    .ai-chat-composer-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .ai-chat-status {
        text-align: left;
    }

    .ai-chat-messages {
        max-height: 34vh;
    }
    
    .sidebar {
        top: 60px;
        height: calc(100vh - 60px);
        transform: translateX(-100%);
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .sidebar.hidden {
        transform: translateX(-100%);
    }
    
    .main-content {
        margin-left: 0;
        padding: 20px;
    }
    
    .toc.hidden {
        width: 50px;
        position: fixed;
        right: 20px;
        top: 80px;
        z-index: 999;
        padding: 10px;
    }
    
    .toc.hidden .toc-toggle {
        width: 36px;
        height: 36px;
        font-size: 24px;
    }
    
    .sidebar-toggle {
        display: flex;
    }
}

/* 回到顶部按钮 */
.back-to-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 50px;
    height: 50px;
    background-color: #2c3e50;
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
    z-index: 999;
    font-size: 24px;
    opacity: 0;
    transform: translateY(20px);
}

.back-to-top.show {
    display: flex;
    opacity: 1;
    transform: translateY(0);
}

.back-to-top:hover {
    background-color: #3498db;
    transform: translateY(-3px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.back-to-top:active {
    transform: translateY(-1px);
}

.back-to-top-icon {
    display: inline-block;
    line-height: 1;
}

/* 响应式设计 - 小屏幕：调整回到顶部按钮位置 */
@media (max-width: 768px) {
    .back-to-top {
        bottom: 20px;
        right: 20px;
        width: 44px;
        height: 44px;
        font-size: 20px;
    }
}