/* concepedia — Wikipedia-inspired light theme */

:root {
    --bg-page: #f6f6f6;
    --bg-content: #ffffff;
    --bg-sidebar: #f6f6f6;
    --border: #a2a9b1;
    --border-light: #eaecf0;
    --text: #202122;
    --text-muted: #54595d;
    --text-sidebar: #202122;
    --link: #0645ad;
    --link-visited: #0b0080;
    --link-new: #ba0000;
    --accent: #3366cc;
    --accent-light: #eaf3ff;
    --green: #14866d;
    --yellow: #a66200;
    --red: #d73333;
    --heading-font: 'Linux Libertine', 'Georgia', 'Times', serif;
    --body-font: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Lato', 'Helvetica Neue', sans-serif;
    --radius: 2px;
}

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

body {
    font-family: var(--body-font);
    font-size: 0.875rem;
    line-height: 1.6;
    color: var(--text);
    background: var(--bg-page);
}

/* ===== Layout ===== */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* ===== Sidebar — Wikipedia style ===== */
.sidebar {
    width: 176px;
    background: var(--bg-sidebar);
    padding: 0;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 10;
    border-right: 1px solid var(--border-light);
    overflow-y: auto;
    font-size: 0.8125rem;
}

.sidebar-header {
    padding: 12px 12px 8px 12px;
}

.logo {
    display: block;
    width: 120px;
    height: 120px;
    margin: 0 auto;
    background: var(--bg-sidebar);
    text-align: center;
    line-height: 120px;
    font-family: var(--heading-font);
    font-size: 1.1rem;
    font-weight: 400;
    color: var(--text);
    text-decoration: none;
}

.kb-name {
    display: block;
    font-size: 0.6875rem;
    color: var(--text-muted);
    text-align: center;
    padding: 4px 8px 12px 8px;
    border-bottom: 1px solid var(--border-light);
    word-break: break-all;
}

.nav-links {
    list-style: none;
    padding: 8px 0;
    flex: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    color: var(--link);
    text-decoration: none;
    font-size: 0.8125rem;
    line-height: 1.25;
}

.nav-item:hover { background: #eaecf0; color: var(--link); }
.nav-item.active { background: #eaf3ff; color: var(--link); font-weight: 600; }

.nav-icon { font-size: 0.75rem; width: 16px; text-align: center; color: var(--text-muted); }

.sidebar-footer {
    padding: 8px 12px;
    border-top: 1px solid var(--border-light);
}

.version { font-size: 0.6875rem; color: var(--text-muted); }

/* ===== Main Content (fills available width) ===== */
.main-content {
    flex: 1;
    margin-left: 176px;
    background: var(--bg-content);
    min-height: 100vh;
    border-left: 1px solid var(--border);
    padding: 24px 32px 48px 32px;
}

/* ===== Page Header ===== */
.page-header {
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border-light);
    margin-bottom: 16px;
}

.page-header h1 {
    font-family: var(--heading-font);
    font-size: 1.8em;
    font-weight: 400;
    color: var(--text);
    line-height: 1.3;
    word-wrap: break-word;
}

.page-header p {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-top: 4px;
}

/* ===== Typography ===== */
h1, h2, h3, h4 {
    font-family: var(--heading-font);
    font-weight: 400;
    color: var(--text);
    line-height: 1.3;
    border-bottom: 1px solid var(--border-light);
    padding-bottom: 4px;
    margin-top: 24px;
    margin-bottom: 8px;
}

h2 { font-size: 1.5em; }
h3 { font-size: 1.25em; }

a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
a:visited { color: var(--link-visited); }

/* ===== Cards ===== */
.card {
    background: var(--bg-content);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: 16px 20px;
}

.card-title {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 8px;
}

.card-value {
    font-size: 1.4em;
    font-weight: 600;
    color: var(--text);
}

/* ===== Stats Grid (responsive, fills width) ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 10px;
    margin-bottom: 24px;
}

.stat-card {
    background: #f8f9fa;
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: 14px 16px;
    transition: background 0.15s;
}

.stat-card:hover { background: #eaecf0; }

.stat-card .stat-label {
    font-size: 0.6875rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.stat-card .stat-value {
    font-size: 1.6em;
    font-weight: 600;
    margin-top: 2px;
    color: var(--text);
    font-family: var(--heading-font);
}

.stat-card.accent .stat-value { color: var(--accent); }
.stat-card.green .stat-value { color: var(--green); }
.stat-card.yellow .stat-value { color: var(--yellow); }
.stat-card.purple .stat-value { color: #6b4ba1; }
.stat-card.red .stat-value { color: var(--red); }

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 5px 12px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: #f8f9fa;
    color: var(--text);
    cursor: pointer;
    font-size: 0.875rem;
    font-family: var(--body-font);
    font-weight: 400;
    text-decoration: none;
    white-space: nowrap;
    transition: background 0.1s, border-color 0.1s;
}

.btn:hover { background: #ffffff; border-color: #a2a9b1; text-decoration: none; color: var(--text); }

.btn-primary {
    background: #f8f9fa;
    border-color: var(--accent);
    color: var(--accent);
    font-weight: 600;
}
.btn-primary:hover { background: var(--accent-light); border-color: var(--accent); color: var(--accent); }

.btn-danger { background: #f8f9fa; border-color: var(--red); color: var(--red); }
.btn-danger:hover { background: #fee7e6; border-color: var(--red); color: var(--red); }

.btn-green { background: #f8f9fa; border-color: var(--green); color: var(--green); }
.btn-green:hover { background: #d5f5e3; border-color: var(--green); color: var(--green); }

/* ===== Forms ===== */
.form-group { margin-bottom: 12px; }

.form-label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.form-input, .form-select, .form-textarea {
    width: 100%;
    padding: 6px 10px;
    background: var(--bg-content);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 0.875rem;
    font-family: var(--body-font);
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: inset 0 0 0 1px var(--accent);
}

.form-textarea { min-height: 80px; resize: vertical; }

/* ===== Tables (wikitable style) ===== */
.table-container { overflow-x: auto; }

table {
    width: 100%;
    border-collapse: collapse;
    background: #f8f9fa;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

th {
    text-align: left;
    font-size: 0.8125rem;
    font-weight: 600;
    background: #eaecf0;
    color: var(--text);
    padding: 6px 10px;
    border: 1px solid var(--border-light);
}

td {
    padding: 6px 10px;
    border: 1px solid var(--border-light);
    font-size: 0.875rem;
    background: var(--bg-content);
}

tr:hover td { background: #f8f9fa; }

/* ===== Badges ===== */
.badge {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 9px;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    border: 1px solid;
}

.badge-document { background: #eaf3ff; color: var(--accent); border-color: var(--accent); }
.badge-concept { background: #f3e8ff; color: #6b4ba1; border-color: #6b4ba1; }
.badge-green { background: #d5f5e3; color: var(--green); border-color: var(--green); }
.badge-yellow { background: #fef6e7; color: var(--yellow); border-color: var(--yellow); }
.badge-red { background: #fee7e6; color: var(--red); border-color: var(--red); }
.badge-gray { background: #eaecf0; color: var(--text-muted); border-color: var(--border); }

/* ===== Graph Page ===== */
.graph-toolbar {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    align-items: center;
    flex-wrap: wrap;
}

.graph-search {
    flex: 1;
    max-width: 280px;
}

.graph-layout {
    display: flex;
    gap: 0;
    height: calc(100vh - 190px);
    min-height: 400px;
}
.graph-sidebar {
    width: 200px;
    flex-shrink: 0;
    overflow-y: auto;
    background: var(--bg-content);
    border: 1px solid var(--border);
    border-right: none;
    border-radius: var(--radius) 0 0 var(--radius);
    padding: 10px;
    font-size: 0.75rem;
}
.graph-sidebar .gs-section {
    margin-bottom: 14px;
}
.graph-sidebar .gs-section h4 {
    font-family: var(--heading-font);
    font-size: 0.75rem;
    font-weight: 600;
    margin: 0 0 6px 0;
    color: var(--text-primary);
}
.graph-container {
    flex: 1;
    background: #f8f9fa;
    border: 1px solid var(--border);
    border-radius: 0 var(--radius) var(--radius) 0;
    position: relative;
    overflow: hidden;
}

/* Legend */
.graph-legend {
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 0.6875rem;
    color: var(--text-secondary);
    padding: 1px 0;
}
.legend-line {
    display: inline-block;
    width: 16px;
    height: 3px;
    flex-shrink: 0;
    border-radius: 1px;
}
.legend-shape {
    display: inline-block;
    width: 10px;
    height: 10px;
    flex-shrink: 0;
    border: 2px solid #666;
}
.legend-shape.dia-doc { transform: rotate(45deg); border-radius: 2px; background: transparent; }
.legend-shape.dot-con { border-radius: 50%; }
.legend-label {
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.legend-sep {
    font-weight: 600;
    font-size: 0.6875rem;
    color: var(--text-muted);
    margin-top: 8px;
    padding-top: 6px;
    border-top: 1px solid var(--border-light);
}

/* Filter chips */
.filter-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    margin-top: 6px;
}
.filter-chip {
    font-size: 0.625rem;
    padding: 2px 6px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: var(--bg-content);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s;
    user-select: none;
}
.filter-chip.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}
.filter-chip:not(.active) {
    opacity: 0.55;
}
.filter-chip:hover {
    border-color: var(--accent);
    opacity: 1;
}

#graph-canvas {
    width: 100%;
    height: 100%;
}

.node-detail {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 260px;
    max-height: 65%;
    overflow-y: auto;
    background: var(--bg-content);
    border: 1px solid var(--border);
    box-shadow: 0 1px 4px rgba(0,0,0,0.1);
    border-radius: var(--radius);
    padding: 14px;
    display: none;
    z-index: 5;
    font-size: 0.8125rem;
}

.node-detail.visible { display: block; }

.node-detail h3 {
    font-family: var(--heading-font);
    font-size: 1.1em;
    font-weight: 400;
    margin-top: 0;
    margin-bottom: 8px;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--border-light);
}

.node-detail .detail-row {
    display: flex;
    justify-content: space-between;
    padding: 3px 0;
    font-size: 0.8125rem;
    border-bottom: 1px solid var(--border-light);
}

/* ===== Pipeline ===== */
.log-output {
    background: #f8f9fa;
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: 12px;
    max-height: 360px;
    overflow-y: auto;
    font-family: 'Menlo', 'Consolas', 'Liberation Mono', monospace;
    font-size: 0.75rem;
    line-height: 1.5;
    white-space: pre-wrap;
}

.progress-bar-container {
    margin: 10px 0;
    background: #eaecf0;
    border-radius: var(--radius);
    height: 6px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: var(--accent);
    border-radius: var(--radius);
    transition: width 0.3s;
    width: 0%;
}

/* ===== Query ===== */
.answer-box {
    background: var(--bg-content);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: 20px 24px;
    margin-top: 16px;
    min-height: 80px;
    line-height: 1.7;
    font-size: 0.875rem;
}

.answer-box h1, .answer-box h2, .answer-box h3 {
    font-family: var(--heading-font);
    font-weight: 400;
    border-bottom: 1px solid var(--border-light);
    margin-top: 16px;
    margin-bottom: 6px;
    padding-bottom: 3px;
}

.answer-box ul, .answer-box ol { padding-left: 22px; margin: 6px 0; }

.answer-box blockquote {
    border-left: 3px solid var(--border);
    padding-left: 12px;
    color: var(--text-muted);
    margin: 8px 0;
}

.answer-box a { color: var(--link); }

.answer-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--border-light);
}

/* ===== Wiki Page ===== */
.wiki-content {
    background: var(--bg-content);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: 24px 28px;
    line-height: 1.7;
    font-size: 0.875rem;
}

.wiki-content h1 {
    font-family: var(--heading-font);
    font-size: 1.8em;
    font-weight: 400;
    margin-top: 0;
    margin-bottom: 12px;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--border);
}

.wiki-content h2 {
    font-family: var(--heading-font);
    font-size: 1.4em;
    font-weight: 400;
    margin-top: 20px;
    margin-bottom: 8px;
    padding-bottom: 3px;
    border-bottom: 1px solid var(--border-light);
}

.wiki-content h3 {
    font-family: var(--heading-font);
    font-size: 1.15em;
    font-weight: 600;
    margin-top: 16px;
    margin-bottom: 6px;
}

.wiki-content table {
    margin: 10px 0;
    font-size: 0.8125rem;
}

.wiki-content th {
    background: #eaecf0;
    font-weight: 600;
}

.wiki-content a { color: var(--link); }
.wiki-content a:visited { color: var(--link-visited); }

.wiki-content ul, .wiki-content ol { padding-left: 22px; margin: 6px 0; }

.wiki-content blockquote {
    border-left: 3px solid var(--border-light);
    padding-left: 12px;
    color: var(--text-muted);
    margin: 8px 0;
}

.wiki-content p { margin: 8px 0; }

.wiki-frontmatter {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 6px;
    margin-bottom: 20px;
    padding: 12px 16px;
    background: #f8f9fa;
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
}

.wiki-fm-item { font-size: 0.8125rem; }

.wiki-fm-item .fm-key {
    color: var(--text-muted);
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.wiki-fm-item .fm-value {
    font-size: 0.8125rem;
    word-break: break-word;
}

/* ===== Alerts ===== */
.alert {
    padding: 10px 14px;
    border-radius: var(--radius);
    margin-bottom: 12px;
    font-size: 0.875rem;
    border: 1px solid;
}

.alert-info { background: #eaf3ff; border-color: var(--accent); color: #202122; }
.alert-success { background: #d5f5e3; border-color: var(--green); color: #202122; }
.alert-error { background: #fee7e6; border-color: var(--red); color: #202122; }
.alert-warning { background: #fef6e7; border-color: var(--yellow); color: #202122; }

/* ===== Query History ===== */
.history-list { display: flex; flex-direction: column; gap: 6px; }

.history-item {
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: 10px 14px;
    cursor: pointer;
    transition: background 0.1s;
    font-size: 0.8125rem;
}

.history-item:hover { background: #f8f9fa; }

.history-item .h-question { font-weight: 600; }
.history-item .h-meta { font-size: 0.6875rem; color: var(--text-muted); margin-top: 2px; }

/* ===== Settings ===== */
.settings-section {
    margin-bottom: 24px;
}

.settings-section h2 {
    font-family: var(--heading-font);
    font-size: 1.3em;
    font-weight: 400;
    margin-top: 0;
    margin-bottom: 12px;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--border-light);
}

.settings-section h3 {
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text-muted);
}

.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 10px;
}

/* ===== Loading spinner ===== */
.spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid var(--border-light);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Toast notification ===== */
.toast {
    position: fixed;
    bottom: 16px;
    right: 16px;
    padding: 10px 18px;
    border-radius: var(--radius);
    font-size: 0.8125rem;
    z-index: 100;
    animation: fadeIn 0.2s;
    border: 1px solid;
}

.toast-success { background: #d5f5e3; border-color: var(--green); color: #202122; }
.toast-error { background: #fee7e6; border-color: var(--red); color: #202122; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ===== Wiki Inline Editor ===== */
.editor-fm-card {
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    margin-bottom: 16px;
    overflow: hidden;
}

.editor-fm-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 14px;
    background: #f8f9fa;
    border-bottom: 1px solid var(--border-light);
    cursor: pointer;
    user-select: none;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text);
}

.editor-fm-header:hover { background: #eaecf0; }

.editor-fm-chevron {
    font-size: 0.625rem;
    color: var(--text-muted);
    transition: transform 0.15s;
}

.editor-fm-body {
    padding: 10px 14px;
    background: var(--bg-content);
}

.fm-edit-row {
    display: flex;
    gap: 8px;
    margin-bottom: 5px;
    align-items: center;
}

.fm-label {
    width: 120px;
    flex-shrink: 0;
    text-align: right;
    font-size: 0.75rem;
    font-family: monospace;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.fm-val-input {
    flex: 1;
    padding: 4px 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.8125rem;
    font-family: var(--body-font);
    color: var(--text);
    background: #fafafa;
}

.fm-val-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: inset 0 0 0 1px var(--accent);
    background: var(--bg-content);
}

.fm-remove-btn {
    background: none;
    border: none;
    color: var(--red);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 2px 6px;
    line-height: 1;
    flex-shrink: 0;
}

.fm-remove-btn:hover {
    background: #fee7e6;
    border-radius: var(--radius);
}

/* ---- Tab bar ---- */
.editor-tabs {
    display: flex;
    border-bottom: 1px solid var(--border-light);
    margin-bottom: 0;
}

.editor-tab {
    padding: 7px 18px;
    font-size: 0.8125rem;
    font-family: var(--body-font);
    font-weight: 600;
    color: var(--text-muted);
    background: none;
    border: 1px solid transparent;
    border-bottom: none;
    border-radius: var(--radius) var(--radius) 0 0;
    cursor: pointer;
    margin-bottom: -1px;
    transition: background 0.1s;
}

.editor-tab:hover { background: #f8f9fa; color: var(--text); }

.editor-tab.active {
    color: var(--text);
    background: var(--bg-content);
    border-color: var(--border-light);
    border-bottom-color: var(--bg-content);
}

/* ---- Toolbar ---- */
.editor-toolbar {
    display: flex;
    gap: 2px;
    align-items: center;
    padding: 6px 8px;
    background: #f8f9fa;
    border: 1px solid var(--border-light);
    border-top: none;
    flex-wrap: wrap;
}

.tb-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    background: none;
    border: 1px solid transparent;
    border-radius: 4px;
    font-size: 0.75rem;
    font-family: var(--body-font);
    color: var(--text);
    cursor: pointer;
    transition: background 0.1s, border-color 0.1s;
}

.tb-btn:hover {
    background: var(--bg-content);
    border-color: var(--border);
}

.tb-btn:active { background: #eaecf0; }

.tb-sep {
    display: inline-block;
    width: 1px;
    height: 18px;
    background: var(--border-light);
    margin: 0 4px;
}

.tb-help {
    margin-left: auto;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-decoration: none;
    padding: 2px 8px;
    border: 1px solid var(--border-light);
    border-radius: 10px;
    transition: background 0.1s;
}

.tb-help:hover {
    background: var(--bg-content);
    color: var(--text);
    text-decoration: none;
}

/* ---- Formatting help panel ---- */
.editor-help {
    padding: 10px 14px;
    background: #f8f9fa;
    border: 1px solid var(--border-light);
    border-top: none;
}

.help-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 4px 16px;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.help-grid code {
    font-size: 0.6875rem;
    background: var(--bg-content);
    padding: 1px 5px;
    border-radius: var(--radius);
    border: 1px solid var(--border-light);
    color: var(--text);
}

/* ---- Editor textarea ---- */
.editor-textarea {
    display: block;
    width: 100%;
    height: calc(100vh - 230px);
    min-height: 400px;
    padding: 14px 18px;
    border: 1px solid var(--border-light);
    border-top: none;
    border-radius: 0 0 var(--radius) var(--radius);
    font-size: 0.875rem;
    font-family: 'Menlo', 'Consolas', 'Liberation Mono', monospace;
    line-height: 1.6;
    color: var(--text);
    background: var(--bg-content);
    resize: none;
    tab-size: 4;
}

.editor-textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: inset 0 0 0 1px var(--accent);
}

/* ---- Action bar ---- */
.editor-actions {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ---- Wiki page footer ---- */
.wiki-footer {
    margin-top: 20px;
    padding-top: 12px;
    border-top: 1px solid var(--border-light);
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ---- Preview pane in editor ---- */
#pane-preview .wiki-content {
    border-radius: 0 0 var(--radius) var(--radius);
    border-top: none;
    height: calc(100vh - 230px);
    min-height: 400px;
    border-color: var(--border-light);
    overflow-y: auto;
}

/* ---- Button size variant ---- */
.btn-sm {
    padding: 3px 8px;
    font-size: 0.75rem;
}

/* ===== Responsive ===== */
@media (max-width: 1024px) {
    .main-content { padding: 20px 24px; }
}

@media (max-width: 768px) {
    .sidebar {
        width: 48px;
    }
    .sidebar .logo { font-size: 0.7rem; width: 40px; height: 40px; line-height: 40px; }
    .sidebar .nav-item span:not(.nav-icon) { display: none; }
    .sidebar .kb-name, .sidebar .version { display: none; }
    .main-content { margin-left: 48px; padding: 14px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .page-header h1 { font-size: 1.3em; }
    .graph-container { height: calc(100vh - 240px); }
    .settings-grid { grid-template-columns: 1fr; }
}

@media (min-width: 1600px) {
    .stats-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
}

/* ---- User area (sidebar footer) ---- */
.sidebar-footer .user-area {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 0;
    margin-bottom: 8px;
    border-bottom: 1px solid var(--border-light);
}
.user-area .user-name {
    font-size: 12px;
    color: var(--text-secondary);
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.user-area .sign-out-link {
    font-size: 11px;
    color: var(--text-tertiary);
    text-decoration: none;
}
.user-area .sign-out-link:hover {
    color: var(--text-primary);
}

/* ---- Login page ---- */
.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg-page);
}
.auth-card {
    background: var(--bg-content);
    border-radius: 8px;
    box-shadow: 0 2px 16px rgba(0,0,0,0.08);
    padding: 48px;
    text-align: center;
    max-width: 440px;
    width: 100%;
}

/* ===== Profile page (Wikipedia-inspired) ===== */
.profile-page {
    max-width: 720px;
    margin: 0 auto;
    padding: 8px 0 40px 0;
    font-family: var(--sans-font);
}
.profile-header {
    display: flex;
    align-items: center;
    gap: 20px;
    padding-bottom: 20px;
    margin-bottom: 24px;
    border-bottom: 1px solid var(--border);
}
.profile-avatar {
    flex-shrink: 0;
}
.profile-avatar .avatar-img {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border-light);
}
.avatar-placeholder {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    font-size: 28px;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--heading-font);
}
.profile-title h1 {
    font-family: var(--heading-font);
    font-size: 1.75rem;
    font-weight: 400;
    margin: 0 0 4px 0;
    color: var(--text-primary);
    border-bottom: none;
    padding-bottom: 0;
}
.profile-email {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin: 0;
}
.profile-section {
    margin-bottom: 28px;
}
.profile-section h2 {
    font-family: var(--heading-font);
    font-size: 1.25rem;
    font-weight: 400;
    margin: 0 0 10px 0;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-primary);
}
.profile-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}
.profile-table tr {
    border-bottom: 1px solid var(--border-light);
}
.profile-table td {
    padding: 6px 8px;
    vertical-align: top;
}
.profile-table td.label {
    width: 140px;
    color: var(--text-muted);
    font-size: 0.8125rem;
    padding-right: 16px;
}
.profile-table code {
    font-size: 0.8125rem;
    background: var(--bg-page);
    padding: 1px 5px;
    border-radius: 3px;
}
.top-list {
    padding-left: 20px;
    font-size: 0.875rem;
    line-height: 1.8;
}
.top-list li {
    padding: 2px 0;
}
.top-label {
    color: var(--text-primary);
}
.top-stat {
    color: var(--text-muted);
    font-size: 0.75rem;
    margin-left: 6px;
}
.profile-username {
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin: 2px 0 0 0;
    font-family: monospace;
}

/* ---- Project area (sidebar footer) ---- */
.project-area {
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid var(--border-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.project-label {
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.project-name {
    font-size: 0.6875rem;
    color: var(--text);
    font-weight: 500;
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
