/* ── KMS Styles ────────────────────────────────────────────────────────── */
/* Rule 36: simple, restrained, no distractions */

:root {
    --bg: #fafaf9;
    --surface: #ffffff;
    --border: #e5e5e4;
    --text: #1c1917;
    --text-muted: #78716c;
    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --tag-bg: #f1f5f9;
    --tag-color: #475569;
    --code-bg: #f8fafc;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

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

/* ── Navigation ──────────────────────────────────────────────────────────── */

.nav {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0.75rem 1rem;
    position: sticky;
    top: 0;
    z-index: 100;
}
.nav-inner {
    max-width: 960px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 1.5rem;
}
.nav-brand {
    font-weight: 700;
    font-size: 1.125rem;
    color: var(--text);
}
.nav-links {
    display: flex;
    gap: 1rem;
    font-size: 0.875rem;
}
.search-form {
    flex: 1;
    max-width: 400px;
    margin-left: auto;
}
.search-form input,
.search-input {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.875rem;
    background: var(--bg);
    outline: none;
    transition: border-color 0.15s;
}
.search-form input:focus,
.search-input:focus {
    border-color: var(--accent);
}

/* ── Content ─────────────────────────────────────────────────────────────── */

.content {
    max-width: 960px;
    margin: 2rem auto;
    padding: 0 1rem;
}

.hero {
    text-align: center;
    margin-bottom: 2.5rem;
}
.hero h1 {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}
.subtitle {
    color: var(--text-muted);
    font-size: 0.9375rem;
    margin-bottom: 1.5rem;
}
.hero-search {
    max-width: 500px;
    margin: 0 auto;
}

h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 1.25rem;
}
h2 {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
}
h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

/* ── Two column layout ───────────────────────────────────────────────────── */

.two-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}
@media (max-width: 640px) {
    .two-col {
        grid-template-columns: 1fr;
    }
}

/* ── Lists ───────────────────────────────────────────────────────────────── */

.page-list {
    list-style: none;
}
.page-list li {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
}
.page-list li:last-child {
    border-bottom: none;
}
.page-title {
    display: block;
    font-weight: 500;
}
.page-meta {
    font-size: 0.8125rem;
    color: var(--text-muted);
}
.result-count {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

/* ── Search results ──────────────────────────────────────────────────────── */

.search-results {
    list-style: none;
}
.result-item {
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
}
.result-title {
    font-weight: 600;
    font-size: 1rem;
}
.result-snippet {
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin: 0.25rem 0;
    line-height: 1.4;
}
.result-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ── Tags ────────────────────────────────────────────────────────────────── */

.tag-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}
.tag {
    font-size: 0.75rem;
    background: var(--tag-bg);
    color: var(--tag-color);
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    white-space: nowrap;
}
.tag:hover {
    background: #e2e8f0;
    text-decoration: none;
}
.tag-lg {
    font-size: 0.8125rem;
    padding: 0.25rem 0.6rem;
}

/* ── Badges ──────────────────────────────────────────────────────────────── */

.badge {
    font-size: 0.75rem;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    background: var(--tag-bg);
    color: var(--tag-color);
}
.badge-high {
    background: #dcfce7;
    color: #166534;
}
.badge-medium {
    background: #fef9c3;
    color: #854d0e;
}
.badge-low {
    background: #fee2e2;
    color: #991b1b;
}

/* ── Wiki page ───────────────────────────────────────────────────────────── */

.wiki-page {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 2rem;
}
.page-header {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}
.page-header h1 {
    margin-bottom: 0.5rem;
}
.page-tags {
    margin-top: 0.5rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}
.source-link {
    display: inline-block;
    margin-top: 0.75rem;
    font-size: 0.875rem;
}

.page-content h2 {
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
    padding-bottom: 0.25rem;
    border-bottom: 1px solid var(--border);
}
.page-content h3 {
    margin-top: 1.25rem;
}
.page-content p {
    margin-bottom: 1rem;
}
.page-content ul, .page-content ol {
    margin-bottom: 1rem;
    padding-left: 1.5rem;
}
.page-content li {
    margin-bottom: 0.25rem;
}
.page-content code {
    background: var(--code-bg);
    padding: 0.125rem 0.375rem;
    border-radius: 3px;
    font-size: 0.875em;
}
.page-content pre {
    background: var(--code-bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 1rem;
    overflow-x: auto;
    margin-bottom: 1rem;
}
.page-content pre code {
    background: none;
    padding: 0;
}
.page-content blockquote {
    border-left: 3px solid var(--accent);
    padding-left: 1rem;
    margin-bottom: 1rem;
    color: var(--text-muted);
}
.page-content table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1rem;
}
.page-content th,
.page-content td {
    border: 1px solid var(--border);
    padding: 0.5rem 0.75rem;
    text-align: left;
    font-size: 0.875rem;
}
.page-content th {
    background: var(--tag-bg);
    font-weight: 600;
}
.page-content .backlink {
    color: var(--accent);
    font-weight: 500;
}

/* ── Upload ──────────────────────────────────────────────────────────────── */

.upload-form {
    margin-bottom: 2rem;
}
.upload-area {
    border: 2px dashed var(--border);
    border-radius: 8px;
    padding: 2rem;
    text-align: center;
}
.upload-label {
    display: block;
    cursor: pointer;
    color: var(--text-muted);
    margin-bottom: 1rem;
}
.file-input {
    display: block;
    margin: 0 auto 1rem;
    font-size: 0.875rem;
}
.topic-select {
    display: block;
    margin: 0 auto 1rem;
    padding: 0.4rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.875rem;
    background: var(--surface);
}

.btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 0.875rem;
    cursor: pointer;
    text-decoration: none;
}
.btn:hover {
    background: var(--accent-hover);
    text-decoration: none;
    color: #fff;
}
.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ── File groups ─────────────────────────────────────────────────────────── */

.file-group {
    margin-bottom: 1.5rem;
}
.file-group-title {
    font-weight: 600;
    margin-bottom: 0.5rem;
    text-transform: capitalize;
}
.file-list {
    list-style: none;
}
.file-item {
    padding: 0.3rem 0;
    font-size: 0.875rem;
    display: flex;
    gap: 0.75rem;
    align-items: center;
}
.file-name {
    font-weight: 500;
}
.file-size {
    color: var(--text-muted);
    font-size: 0.75rem;
}
.download-link {
    font-size: 0.75rem;
}

/* ── Flash messages ──────────────────────────────────────────────────────── */

.flash {
    padding: 0.75rem 1rem;
    border-radius: 6px;
    margin-bottom: 1rem;
    font-size: 0.875rem;
}
.flash-success {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #bbf7d0;
}

/* ── Empty state ─────────────────────────────────────────────────────────── */

.empty {
    color: var(--text-muted);
    font-size: 0.875rem;
    font-style: italic;
}

/* ── Pagination ──────────────────────────────────────────────────────────── */

.pagination {
    display: flex;
    gap: 0.5rem;
    margin-top: 1.5rem;
}

/* ── Footer ──────────────────────────────────────────────────────────────── */

.footer {
    max-width: 960px;
    margin: 3rem auto 1rem;
    padding: 0 1rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: center;
}

/* ── Misc ────────────────────────────────────────────────────────────────── */

section {
    margin-bottom: 2rem;
}

/* ── Markdown table override for wiki content ────────────────────────────── */
.page-content .highlight {
    margin-bottom: 1rem;
}

/* ── Breadcrumb ─────────────────────────────────────────────────────────── */
.breadcrumb {
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}
.breadcrumb a {
    color: var(--text-muted);
}

/* ── Doc sections ───────────────────────────────────────────────────────── */
.doc-section {
    margin-bottom: 2rem;
}
