/* ================================================
   知识百科 - knowledge_encyclopedia.css
   布局参考 online_chinese_dictionary，风格偏书卷学术感
   ================================================ */

/* ---------- 根容器 ---------- */
.ke-container {
    display: flex;
    flex-direction: column;
    height: 600px;
    border: 1px solid #d4c9b0;
    border-radius: 10px;
    overflow: hidden;
    background: #faf8f3;
    font-family: 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    box-shadow: 0 2px 16px rgba(120,100,60,0.10);
    transition: height 0.3s;
}

.ke-container.fullscreen {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 9000;
    width: 100vw;
    height: 100vh;
    border-radius: 0;
    border: none;
}

/* ---------- 工具栏 ---------- */
.ke-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 14px;
    height: 48px;
    flex-shrink: 0;
    background: linear-gradient(135deg, #4a6741 0%, #5c7a52 60%, #6b8f5e 100%);
    border-bottom: 2px solid #3a5232;
}

.toolbar-title {
    font-size: 14px;
    font-weight: 700;
    color: #e8f5e2;
    letter-spacing: 0.5px;
    margin-right: 4px;
    white-space: nowrap;
}

.toolbar-group {
    display: flex;
    align-items: center;
    gap: 6px;
}

.toolbar-group:not(:last-child) {
    padding-right: 10px;
    border-right: 1px solid rgba(255,255,255,0.2);
    margin-right: 2px;
}

.toolbar-btn {
    height: 30px;
    padding: 0 10px;
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 5px;
    background: rgba(255,255,255,0.12);
    color: #e8f5e2;
    font-size: 12px;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.18s;
}

.toolbar-btn:hover {
    background: rgba(255,255,255,0.25);
    border-color: rgba(255,255,255,0.5);
    color: #fff;
}

.toolbar-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

.toolbar-btn-primary {
    background: rgba(255,255,255,0.22);
    border-color: rgba(255,255,255,0.55);
    font-weight: 600;
}

.toolbar-btn-primary:hover {
    background: rgba(255,255,255,0.38);
}

.toolbar-btn-primary:disabled {
    background: rgba(255,255,255,0.10);
    opacity: 0.5;
}

/* ---------- 三栏主体 ---------- */
.ke-main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
    min-height: 0;
}

/* ======= 左栏：历史记录 ======= */
.ke-history-panel {
    width: 200px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    border-right: 1px solid #d4c9b0;
    background: #f5f1e8;
    overflow: hidden;
}

.history-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px 8px;
    border-bottom: 1px solid #d4c9b0;
    background: linear-gradient(to bottom, #f5f1e8 0%, #ede8da 100%);
    flex-shrink: 0;
}

.history-panel-header h3 {
    margin: 0;
    font-size: 12px;
    font-weight: 600;
    color: #5a4a2e;
    background: none;
    border: none;
    padding: 0;
}

.history-count {
    font-size: 11px;
    color: #8a7a5a;
    font-weight: normal;
}

.history-clear-btn {
    background: #fff5e6;
    border: 1px solid #e0c896;
    color: #b07030;
    font-size: 11px;
    cursor: pointer;
    padding: 2px 7px;
    border-radius: 3px;
    transition: all 0.2s;
    white-space: nowrap;
}

.history-clear-btn:hover {
    background: #ffe0b0;
    border-color: #c08020;
}

.history-search {
    padding: 8px 10px;
    border-bottom: 1px solid #d4c9b0;
    flex-shrink: 0;
}

.history-search input {
    width: 100%;
    height: 26px;
    padding: 0 8px;
    border: 1px solid #c8b888;
    border-radius: 4px;
    font-size: 11px;
    background: #fffdf5;
    color: #4a3a20;
    outline: none;
    box-sizing: border-box;
    transition: border-color 0.2s;
}

.history-search input:focus {
    border-color: #5c7a52;
}

.history-list {
    flex: 1;
    overflow-y: auto;
}

.history-list::-webkit-scrollbar { width: 5px; }
.history-list::-webkit-scrollbar-track { background: #f0ece0; }
.history-list::-webkit-scrollbar-thumb { background: #c0ab80; border-radius: 3px; }

.history-empty {
    padding: 20px 12px;
    text-align: center;
    font-size: 12px;
    color: #94a3b8;
    line-height: 1.7;
}

.history-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    cursor: pointer;
    border-bottom: 1px solid #e8e2d0;
    transition: background 0.15s;
    gap: 6px;
}

.history-item:hover {
    background: #ede4cc;
}

.history-item.active {
    background: #dff0d8;
    border-left: 3px solid #5c7a52;
}

.history-item-main {
    flex: 1;
    min-width: 0;
}

.history-item-topic {
    font-size: 12px;
    font-weight: 600;
    color: #3a2e18;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-item-meta {
    display: flex;
    gap: 4px;
    align-items: center;
    margin-top: 2px;
    flex-wrap: wrap;
}

.history-item-type {
    font-size: 10px;
    padding: 1px 5px;
    background: #e2f0d9;
    color: #4a6741;
    border-radius: 3px;
    border: 1px solid #b8d4a8;
    white-space: nowrap;
}

.history-item-cat {
    font-size: 10px;
    padding: 1px 5px;
    background: #fdf0e0;
    color: #906040;
    border-radius: 3px;
    border: 1px solid #e0c08a;
    white-space: nowrap;
}

.history-item-meta span {
    font-size: 10px;
    color: #8a7a5a;
}

.history-item-del {
    flex-shrink: 0;
    background: none;
    border: none;
    color: #c0956a;
    font-size: 12px;
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 3px;
    opacity: 0;
    transition: opacity 0.15s, color 0.15s;
    line-height: 1;
}

.history-item:hover .history-item-del {
    opacity: 1;
}

.history-item-del:hover {
    color: #c0392b;
}

/* ======= 中栏：输入区 ======= */
.ke-input-panel {
    width: 290px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    border-right: 1px solid #d4c9b0;
    background: #faf8f3;
    overflow: hidden;
}

.panel-header {
    padding: 10px 14px 8px;
    border-bottom: 1px solid #d4c9b0;
    background: linear-gradient(to bottom, #faf8f3, #f2eddf);
    flex-shrink: 0;
}

.panel-header h3 {
    margin: 0 0 2px;
    font-size: 13px;
    font-weight: 600;
    color: #3a2e18;
    background: none;
    border: none;
    padding: 0;
}

.panel-tip {
    font-size: 11px;
    color: #8a7a5a;
}

.ke-input-body {
    flex: 1;
    overflow-y: auto;
    padding: 12px 14px 20px;
}

.ke-input-body::-webkit-scrollbar { width: 5px; }
.ke-input-body::-webkit-scrollbar-track { background: #f0ece0; }
.ke-input-body::-webkit-scrollbar-thumb { background: #c0ab80; border-radius: 3px; }

/* 搜索框 */
.ke-search-box {
    display: flex;
    align-items: stretch;
    border: 1.5px solid #c8b888;
    border-radius: 7px;
    overflow: hidden;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: #fff;
}

.ke-search-box:focus-within {
    border-color: #5c7a52;
    box-shadow: 0 0 0 2px rgba(92,122,82,0.15);
}

.ke-search-input {
    flex: 1;
    padding: 8px 10px;
    border: none;
    background: transparent;
    font-size: 13px;
    color: #3a2e18;
    outline: none;
    min-width: 0;
}

.ke-search-input::placeholder { color: #b0a078; }

.ke-search-btn {
    width: 38px;
    background: #5c7a52;
    border: none;
    color: #fff;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.18s;
    flex-shrink: 0;
}

.ke-search-btn:hover { background: #4a6741; }
.ke-search-btn:disabled { background: #a0b090; cursor: not-allowed; }

/* 字数统计 */
.ke-char-counter {
    text-align: right;
    font-size: 11px;
    color: #b0a078;
    margin-top: 3px;
    margin-bottom: 10px;
}

.ke-char-counter.warning { color: #c0840a; }
.ke-char-counter.limit { color: #c0392b; }

/* 类别选择 */
.ke-category-label,
.ke-depth-label,
.ke-quick-label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: #5a4a2e;
    margin-bottom: 6px;
    letter-spacing: 0.3px;
}

.ke-category-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 5px;
    margin-bottom: 12px;
}

.ke-category-option {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 5px 8px;
    border: 1px solid #d4c9b0;
    border-radius: 6px;
    font-size: 11px;
    color: #5a4a2e;
    cursor: pointer;
    background: #fff;
    transition: all 0.18s;
    user-select: none;
}

.ke-category-option:hover {
    background: #ede8da;
    border-color: #b0a078;
}

.ke-category-option.selected {
    background: #e2f0d9;
    border-color: #5c7a52;
    color: #3a5232;
    font-weight: 600;
    box-shadow: 0 1px 4px rgba(92,122,82,0.18);
}

.ke-category-option span {
    font-size: 13px;
}

/* 查询深度 */
.ke-depth-group { margin-bottom: 6px; }

.ke-depth-options {
    display: flex;
    gap: 6px;
    margin-bottom: 4px;
}

.ke-depth-option {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 6px 4px;
    border: 1px solid #d4c9b0;
    border-radius: 6px;
    font-size: 11px;
    color: #5a4a2e;
    cursor: pointer;
    background: #fff;
    transition: all 0.18s;
    user-select: none;
    text-align: center;
}

.ke-depth-option:hover {
    background: #ede8da;
    border-color: #b0a078;
}

.ke-depth-option.selected {
    background: #e2f0d9;
    border-color: #5c7a52;
    color: #3a5232;
    font-weight: 600;
    box-shadow: 0 1px 4px rgba(92,122,82,0.18);
}

.ke-depth-option span {
    font-size: 16px;
}

.ke-depth-hint {
    display: block;
    font-size: 11px;
    color: #5c7a52;
    min-height: 16px;
    margin-bottom: 10px;
    opacity: 0;
    transition: opacity 0.3s;
}

.ke-depth-hint.visible { opacity: 1; }

/* 热门词条标签 */
.ke-quick-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-bottom: 12px;
}

.ke-quick-tag {
    display: inline-block;
    padding: 3px 9px;
    border: 1px solid #c8b888;
    border-radius: 12px;
    font-size: 11px;
    color: #5a4a2e;
    background: #faf5e8;
    cursor: pointer;
    transition: all 0.18s;
    user-select: none;
}

.ke-quick-tag:hover {
    background: #e2f0d9;
    border-color: #5c7a52;
    color: #3a5232;
}

/* 提示框 */
.ke-tips-box {
    background: #fdf8ec;
    border: 1px solid #e2d89a;
    border-radius: 7px;
    padding: 10px 12px;
    margin-top: 2px;
}

.ke-tips-box p {
    margin: 0 0 6px;
    font-size: 11px;
    font-weight: 600;
    color: #7a6030;
}

.ke-tips-box ul {
    margin: 0;
    padding-left: 14px;
}

.ke-tips-box li {
    font-size: 11px;
    color: #6a5428;
    line-height: 1.8;
}

/* ======= 右栏：结果区 ======= */
.ke-result-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
    background: #fff;
}

.ke-result-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px 8px;
    border-bottom: 1px solid #d4c9b0;
    background: linear-gradient(to bottom, #faf8f3, #f2eddf);
    flex-shrink: 0;
    flex-wrap: wrap;
    gap: 6px;
}

.ke-result-header h3 {
    margin: 0;
    font-size: 13px;
    font-weight: 600;
    color: #3a2e18;
    background: none;
    border: none;
    padding: 0;
}

.result-meta-info {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.result-meta-topic {
    font-size: 13px;
    font-weight: 700;
    color: #3a5232;
    padding: 1px 8px;
    background: #e2f0d9;
    border-radius: 10px;
    border: 1px solid #b8d4a8;
}

.result-depth-badge {
    font-size: 11px;
    padding: 1px 7px;
    border-radius: 10px;
    background: #edf7ff;
    color: #2563a0;
    border: 1px solid #bcd8f0;
}

.result-cat-badge {
    font-size: 11px;
    padding: 1px 7px;
    border-radius: 10px;
    background: #fff8e8;
    color: #906020;
    border: 1px solid #e8cc80;
}

.ke-result-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 18px;
    display: flex;
    flex-direction: column;
}

.ke-result-body::-webkit-scrollbar { width: 6px; }
.ke-result-body::-webkit-scrollbar-track { background: #f8f5ed; }
.ke-result-body::-webkit-scrollbar-thumb { background: #c0ab80; border-radius: 3px; }

/* 占位符 */
.result-placeholder {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    gap: 8px;
}

@keyframes kePlaceholderFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}

.placeholder-icon {
    font-size: 52px;
    opacity: 0.6;
    animation: kePlaceholderFloat 3s ease-in-out infinite;
}

.placeholder-title {
    font-size: 16px;
    font-weight: 600;
    color: #8a7a5a;
    margin: 0;
}

.placeholder-desc {
    font-size: 12px;
    color: #94a3b8;
    margin: 0;
}

/* 加载中 */
.result-loading {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    gap: 14px;
}

.loading-dots {
    display: flex;
    gap: 8px;
    align-items: center;
}

.loading-dots span {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #5c7a52;
    animation: keDotBounce 1.2s infinite ease-in-out;
    display: inline-block;
}

.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes keDotBounce {
    0%, 80%, 100% { transform: translateY(0); opacity: 0.5; }
    40% { transform: translateY(-10px); opacity: 1; }
}

.loading-text {
    font-size: 13px;
    color: #8a7a5a;
    margin: 0;
}

/* 结果内容（AI HTML样式） */
.result-content {
    animation: keResultEnter 0.35s ease;
}

@keyframes keResultEnter {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.result-content .ke-article {
    line-height: 1.75;
}

.result-content .ke-article-head {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 14px;
    padding-bottom: 12px;
    border-bottom: 2px solid #e2d8c0;
}

.result-content .ke-article-title {
    font-size: 22px;
    font-weight: 800;
    color: #2a2210;
    letter-spacing: 1px;
}

.result-content .ke-article-cat {
    font-size: 12px;
    padding: 2px 8px;
    background: #e2f0d9;
    border-radius: 10px;
    color: #3a5232;
    border: 1px solid #b8d4a8;
    font-weight: 600;
}

.result-content .ke-article-summary {
    font-size: 14px;
    color: #5a4a2e;
    background: #fdf8ec;
    border-left: 3px solid #c8a840;
    padding: 10px 14px;
    border-radius: 0 6px 6px 0;
    margin-bottom: 16px;
    line-height: 1.7;
}

.result-content .ke-section {
    margin-bottom: 16px;
}

.result-content .ke-section h4 {
    font-size: 14px;
    font-weight: 700;
    color: #3a2e18;
    margin: 0 0 8px;
    padding: 0 0 4px 10px;
    border-bottom: 1px solid #e2d8c0;
    border-left: 3px solid #5c7a52;
    display: flex;
    align-items: center;
    gap: 6px;
}

.result-content .ke-section p,
.result-content .ke-section li {
    font-size: 13px;
    color: #4a3a20;
    line-height: 1.8;
}

.result-content .ke-section ul,
.result-content .ke-section ol {
    padding-left: 18px;
    margin: 6px 0;
}

.result-content .ke-section li {
    margin-bottom: 4px;
}

.result-content .ke-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
}

.result-content .ke-related-tag {
    display: inline-block;
    padding: 3px 10px;
    border: 1px solid #c8b888;
    border-radius: 12px;
    font-size: 12px;
    color: #5a4a2e;
    background: #faf5e8;
    cursor: pointer;
    transition: all 0.18s;
}

.result-content .ke-related-tag:hover {
    background: #e2f0d9;
    border-color: #5c7a52;
    color: #3a5232;
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(92,122,82,0.18);
}

.result-content .ke-ref-cite {
    font-size: 12px;
    color: #8a7a5a;
    border-top: 1px solid #e2d8c0;
    padding-top: 10px;
    margin-top: 10px;
    font-style: italic;
}

/* 错误 */
#keResultError {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.result-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    gap: 10px;
}

.error-icon { font-size: 36px; }
.error-msg { font-size: 14px; color: #b03020; margin: 0; }
.error-tip { font-size: 12px; color: #94a3b8; margin: 0; }

/* ======= 模态框 ======= */
.ke-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 9100;
}

.ke-modal {
    display: none;
    position: fixed;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    z-index: 9200;
    background: #faf8f3;
    border: 1px solid #d4c9b0;
    border-radius: 12px;
    width: min(620px, 92vw);
    max-height: 80vh;
    flex-direction: column;
    box-shadow: 0 8px 40px rgba(60,40,10,0.22);
    overflow: hidden;
}

.ke-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid #d4c9b0;
    background: linear-gradient(135deg, #4a6741, #6b8f5e);
}

.ke-modal-header h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    color: #fff;
}

.ke-modal-close {
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.3);
    color: #fff;
    width: 28px; height: 28px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.18s;
}

.ke-modal-close:hover { background: rgba(255,255,255,0.3); }

.ke-modal-body {
    overflow-y: auto;
    padding: 16px;
}

.example-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 10px;
}

.example-card {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 12px;
    border: 1px solid #d4c9b0;
    border-radius: 8px;
    background: #fff;
    cursor: pointer;
    transition: all 0.18s;
}

.example-card:hover {
    border-color: #5c7a52;
    background: #e2f0d9;
    box-shadow: 0 2px 8px rgba(92,122,82,0.15);
    transform: translateY(-2px);
}

.example-icon {
    font-size: 24px;
    text-align: center;
}

.example-info {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.example-topic {
    font-size: 13px;
    font-weight: 700;
    color: #3a2e18;
    text-align: center;
}

.example-cat-badge {
    font-size: 10px;
    padding: 1px 6px;
    background: #e2f0d9;
    color: #3a5232;
    border-radius: 8px;
    border: 1px solid #b8d4a8;
    text-align: center;
    align-self: center;
}

.example-card-desc {
    font-size: 11px;
    color: #8a7a5a;
    text-align: center;
    line-height: 1.5;
}

.ke-retry-btn {
    margin-top: 10px;
    padding: 6px 18px;
    background: #5c7a52;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.18s;
}

.ke-retry-btn:hover { background: #4a6741; }

/* shake */
@keyframes keShake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-4px); }
    40% { transform: translateX(4px); }
    60% { transform: translateX(-4px); }
    80% { transform: translateX(2px); }
}

.ke-search-box.shake {
    animation: keShake 0.4s ease;
    border-color: #e05050 !important;
}

/* ================================================
   暗黑模式
   ================================================ */
body.dark .ke-container {
    background: #1a2020;
    border-color: #3a4a40;
    box-shadow: 0 2px 16px rgba(0,0,0,0.4);
}

body.dark .ke-toolbar {
    background: linear-gradient(135deg, #2a3a28 0%, #344e30 60%, #3d5c38 100%);
    border-bottom-color: #253024;
}

body.dark .toolbar-btn { color: #b8d4b0; border-color: rgba(255,255,255,0.15); }
body.dark .toolbar-btn:hover { background: rgba(255,255,255,0.12); color: #d8f0d0; }
body.dark .toolbar-btn:disabled { opacity: 0.35; }
body.dark .toolbar-btn-primary:disabled { background: rgba(255,255,255,0.06); opacity: 0.4; }

/* 左栏 */
body.dark .ke-history-panel { background: #1c2a20; border-right-color: #3a4a40; }
body.dark .history-panel-header { background: linear-gradient(to bottom, #1c2a20, #182418); border-bottom-color: #3a4a40; }
body.dark .history-panel-header h3 { color: #b8d4b0; }
body.dark .history-count { color: #6a8a62; }
body.dark .history-clear-btn { background: #2a2420; border-color: #5a4a30; color: #d0946a; }
body.dark .history-clear-btn:hover { background: #3a2810; border-color: #80602a; }
body.dark .history-search { border-bottom-color: #3a4a40; }
body.dark .history-search input { background: #243028; border-color: #3a5040; color: #c8d8c0; }
body.dark .history-search input:focus { border-color: #5c9852; }
body.dark .history-list::-webkit-scrollbar-track { background: #1c2a20; }
body.dark .history-list::-webkit-scrollbar-thumb { background: #4a6842; }
body.dark .history-empty { color: #94a3b8; }
body.dark .history-item { border-bottom-color: #2a3a30; }
body.dark .history-item:hover { background: #253228; }
body.dark .history-item.active { background: #1e3422; border-left-color: #5c9852; }
body.dark .history-item-topic { color: #c8e0c0; }
body.dark .history-item-type { background: #1e3422; color: #7ab870; border-color: #3a6032; }
body.dark .history-item-meta span { color: #6a8a62; }
body.dark .history-item-del { color: #8a6a42; }
body.dark .history-item-del:hover { color: #e05050; }
body.dark .history-item-cat { background: #2a2010; color: #d0946a; border-color: #5a4010; }

/* 中栏 */
body.dark .ke-input-panel { background: #1a2020; border-right-color: #3a4a40; }
body.dark .panel-header { background: linear-gradient(to bottom, #1a2020, #162018); border-bottom-color: #3a4a40; }
body.dark .panel-header h3 { color: #b8d4b0; }
body.dark .panel-tip { color: #6a8a62; }
body.dark .ke-input-body::-webkit-scrollbar-track { background: #1a2020; }
body.dark .ke-input-body::-webkit-scrollbar-thumb { background: #4a6842; }
body.dark .ke-search-box { background: #243028; border-color: #3a5040; }
body.dark .ke-search-box:focus-within { border-color: #5c9852; box-shadow: 0 0 0 2px rgba(92,152,82,0.18); }
body.dark .ke-search-box.shake { border-color: #e07060 !important; }
body.dark .ke-search-input { color: #c8e0c0; }
body.dark .ke-search-input::placeholder { color: #6a9060; }
body.dark .ke-search-btn { background: #3a6032; }
body.dark .ke-search-btn:hover { background: #2e5028; }
body.dark .ke-search-btn:disabled { background: #2a4028; }
body.dark .ke-char-counter { color: #6a9060; }
body.dark .ke-char-counter.warning { color: #c09040; }
body.dark .ke-char-counter.limit { color: #c05040; }
body.dark .ke-category-label,
body.dark .ke-depth-label,
body.dark .ke-quick-label { color: #8ab880; }
body.dark .ke-category-option { background: #243028; border-color: #3a5040; color: #a8c8a0; }
body.dark .ke-category-option:hover { background: #2a3a30; border-color: #5a8050; }
body.dark .ke-category-option.selected { background: #1e3422; border-color: #5c9852; color: #8ad878; box-shadow: 0 1px 4px rgba(92,152,82,0.25); }
body.dark .ke-depth-option { background: #243028; border-color: #3a5040; color: #a8c8a0; }
body.dark .ke-depth-option:hover { background: #2a3a30; border-color: #5a8050; }
body.dark .ke-depth-option.selected { background: #1e3422; border-color: #5c9852; color: #8ad878; box-shadow: 0 1px 4px rgba(92,152,82,0.25); }
body.dark .ke-depth-hint { color: #5c9852; }
body.dark .ke-quick-tag { background: #243028; border-color: #3a5040; color: #a8c8a0; }
body.dark .ke-quick-tag:hover { background: #1e3422; border-color: #5c9852; color: #8ad878; }
body.dark .ke-tips-box { background: #1e2a1e; border-color: #3a5030; }
body.dark .ke-tips-box p { color: #7a9870; }
body.dark .ke-tips-box li { color: #6a8860; }

body.dark .ke-retry-btn { background: #3a6032; }
body.dark .ke-retry-btn:hover { background: #2e5028; }

/* 右栏 */
body.dark .ke-result-panel { background: #1c2620; }
body.dark .ke-result-header { background: linear-gradient(to bottom, #1a2020, #162018); border-bottom-color: #3a4a40; }
body.dark .ke-result-header h3 { color: #b8d4b0; }
body.dark .result-meta-topic { background: #1e3422; color: #7ab870; border-color: #3a6032; }
body.dark .result-depth-badge { background: #1a2a3a; color: #6aa0d8; border-color: #2a4a60; }
body.dark .result-cat-badge { background: #2a2010; color: #d8a040; border-color: #5a4010; }
body.dark .ke-result-body::-webkit-scrollbar-track { background: #1c2620; }
body.dark .ke-result-body::-webkit-scrollbar-thumb { background: #4a6842; }
body.dark .placeholder-title { color: #6a8a62; }
body.dark .placeholder-desc { color: #94a3b8; }
body.dark .loading-dots span { background: #5c9852; }
body.dark .loading-text { color: #6a8a62; }

/* 结果内容暗黑 */
body.dark .result-content .ke-article-head { border-bottom-color: #3a4a38; }
body.dark .result-content .ke-article-title { color: #c8e0c0; }
body.dark .result-content .ke-article-cat { background: #1e3422; color: #7ab870; border-color: #3a6032; }
body.dark .result-content .ke-article-summary { background: #1e2818; border-left-color: #8a7030; color: #b0c8a0; }
body.dark .result-content .ke-section h4 { color: #b8d4b0; border-bottom-color: #3a4a38; border-left-color: #5c9852; }
body.dark .result-content .ke-section p,
body.dark .result-content .ke-section li { color: #9ab890; }
body.dark .result-content .ke-related-tag { background: #243028; border-color: #3a5040; color: #a8c8a0; }
body.dark .result-content .ke-related-tag:hover { background: #1e3422; border-color: #5c9852; color: #8ad878; }
body.dark .result-content .ke-ref-cite { color: #6a8a62; border-top-color: #3a4a38; }
body.dark .error-msg { color: #e07060; }
body.dark .error-tip { color: #94a3b8; }

/* 模态框暗黑 */
body.dark .ke-modal { background: #1a2020; border-color: #3a4a40; }
body.dark .ke-modal-header { background: linear-gradient(135deg, #1e3028, #253c28); }
body.dark .ke-modal-body { background: #1a2020; }
body.dark .example-card { background: #243028; border-color: #3a5040; }
body.dark .example-card:hover { background: #1e3422; border-color: #5c9852; }
body.dark .example-topic { color: #c8e0c0; }
body.dark .example-cat-badge { background: #1e3422; color: #7ab870; border-color: #3a6032; }
body.dark .example-card-desc { color: #94a3b8; }

/* ================================================
   响应式
   ================================================ */
@media (max-width: 768px) {
    .ke-container { height: 100vh; min-height: 500px; border-radius: 0; }

    .ke-main-content { flex-direction: column; }

    .ke-history-panel {
        width: 100%;
        height: 140px;
        border-right: none;
        border-bottom: 1px solid #d4c9b0;
        flex-direction: column;
    }

    body.dark .ke-history-panel { border-bottom-color: #3a4a40; }
    body.dark .ke-input-panel { border-bottom-color: #3a4a40; }

    .ke-input-panel {
        width: 100%;
        height: auto;
        max-height: 260px;
        border-right: none;
        border-bottom: 1px solid #d4c9b0;
    }

    .ke-result-panel {
        flex: 1;
        min-height: 240px;
    }

    .ke-toolbar {
        overflow-x: auto;
        flex-wrap: nowrap;
        padding: 0 8px;
    }

    .toolbar-title { display: none; }

    .history-item-del {
        opacity: 1 !important;
    }
}

@media (max-width: 480px) {
    .ke-category-options { grid-template-columns: 1fr 1fr 1fr; }
    .toolbar-btn { padding: 0 7px; font-size: 11px; }
}
