:root {
    --bg: #f4f7fb;
    --panel: #ffffff;
    --ink: #182235;
    --muted: #69758a;
    --line: #e5ebf3;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --accent: #14b8a6;
    --sidebar: #111827;
    --sidebar-soft: #1f2937;
}

* {
    letter-spacing: 0;
}

body {
    background: var(--bg);
    color: var(--ink);
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    overflow-x: hidden;
}

.app-shell {
    min-height: 100vh;
}

.sidebar {
    background: var(--sidebar);
    color: #fff;
    height: 100vh;
    left: 0;
    padding: 22px 18px;
    position: fixed;
    top: 0;
    width: 280px;
    z-index: 10;
}

.brand {
    align-items: center;
    display: flex;
    gap: 12px;
}

.brand-mark {
    align-items: center;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-radius: 8px;
    display: grid;
    flex: 0 0 44px;
    height: 44px;
    place-items: center;
    width: 44px;
}

.brand strong {
    display: block;
    font-size: 17px;
}

.brand span {
    color: #aab4c3;
    display: block;
    font-size: 12px;
}

.sidebar-nav {
    display: grid;
    gap: 8px;
    margin-top: 32px;
}

.sidebar-nav a {
    align-items: center;
    border-radius: 8px;
    color: #cbd5e1;
    display: flex;
    gap: 10px;
    padding: 12px 14px;
    text-decoration: none;
    transition: background .15s ease, color .15s ease;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
    background: var(--sidebar-soft);
    color: #fff;
}

.sidebar-footer {
    align-items: flex-start;
    background: rgba(255, 255, 255, .06);
    border: 1px solid rgba(255, 255, 255, .08);
    border-radius: 8px;
    bottom: 18px;
    color: #cbd5e1;
    display: flex;
    font-size: 12px;
    gap: 10px;
    left: 18px;
    padding: 12px;
    position: absolute;
    right: 18px;
}

.main-panel {
    margin-left: 280px;
    max-width: calc(100vw - 280px);
    min-height: 100vh;
    overflow-x: hidden;
}

.topbar {
    align-items: center;
    background: rgba(244, 247, 251, .86);
    backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--line);
    display: flex;
    justify-content: space-between;
    min-height: 86px;
    padding: 18px 32px;
    position: sticky;
    top: 0;
    z-index: 5;
}

.topbar h1 {
    font-size: 25px;
    font-weight: 750;
    margin: 0;
}

.topbar-user {
    align-items: center;
    display: flex;
    gap: 14px;
}

.content-wrap {
    min-width: 0;
    padding: 28px 32px 44px;
}

.panel,
.article-card,
.stat-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 14px 32px rgba(24, 34, 53, .06);
}

.panel {
    padding: 22px;
}

.panel-header {
    align-items: center;
    display: flex;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 18px;
}

.panel-header.compact {
    align-items: flex-start;
}

.panel-header h2 {
    font-size: 19px;
    font-weight: 750;
    margin: 0;
}

.panel-header p {
    color: var(--muted);
    margin: 4px 0 0;
}

.btn {
    border-radius: 8px;
    font-weight: 650;
}

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
}

.btn-primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
}

.form-control,
.form-select,
.input-group-text {
    border-color: var(--line);
    border-radius: 8px;
}

.input-group .form-control,
.input-group .input-group-text {
    border-radius: 0;
}

.input-group .input-group-text:first-child {
    border-bottom-left-radius: 8px;
    border-top-left-radius: 8px;
}

.input-group .form-control:last-child {
    border-bottom-right-radius: 8px;
    border-top-right-radius: 8px;
}

.stats-grid {
    display: grid;
    gap: 18px;
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.stat-card {
    padding: 20px;
}

.stat-card span {
    align-items: center;
    background: #eaf2ff;
    border-radius: 8px;
    color: var(--primary);
    display: grid;
    height: 42px;
    place-items: center;
    width: 42px;
}

.stat-card strong {
    display: block;
    font-size: 30px;
    margin-top: 18px;
}

.stat-card small {
    color: var(--muted);
}

.list-stack {
    display: grid;
    gap: 10px;
}

.knowledge-row,
.favorite-row {
    align-items: center;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--ink);
    display: flex;
    justify-content: space-between;
    gap: 14px;
    padding: 14px;
    text-decoration: none;
}

.knowledge-row:hover,
.favorite-row:hover {
    border-color: #b9c8dd;
}

.knowledge-row strong,
.knowledge-row span {
    display: block;
}

.knowledge-row span {
    color: var(--muted);
    font-size: 14px;
    margin-top: 3px;
}

.knowledge-row small {
    color: var(--primary);
    flex: 0 0 auto;
}

.favorite-row {
    justify-content: flex-start;
}

.favorite-row i,
.favorite-icon {
    color: #f59e0b;
}

.article-card-badges {
    align-items: center;
    display: flex;
    gap: 8px;
}

.note-count-pill {
    align-items: center;
    background: #eef2ff;
    border: 1px solid #c7d2fe;
    border-radius: 999px;
    color: #4338ca;
    display: inline-flex;
    font-size: 12px;
    font-weight: 750;
    gap: 5px;
    padding: 5px 9px;
}

.article-grid {
    display: grid;
    gap: 18px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.article-card {
    display: flex;
    flex-direction: column;
    min-height: 260px;
    padding: 20px;
}

.article-card-top,
.detail-header,
.detail-actions,
.meta-line,
.article-actions,
.code-toolbar {
    align-items: center;
    display: flex;
    gap: 12px;
}

.article-card-top,
.detail-header,
.code-toolbar {
    justify-content: space-between;
}

.category-pill {
    background: #e8f8f6;
    border: 1px solid #b7ebe4;
    border-radius: 999px;
    color: #0f766e;
    display: inline-flex;
    font-size: 12px;
    font-weight: 750;
    padding: 5px 10px;
}

.article-card h2,
.detail-header h2 {
    font-size: 21px;
    font-weight: 800;
    margin: 16px 0 8px;
}

.article-card p,
.detail-header p {
    color: var(--muted);
}

.article-card p {
    flex: 1;
}

.tags {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
}

.tags span {
    background: #f1f5f9;
    border-radius: 999px;
    color: #475569;
    font-size: 12px;
    padding: 5px 9px;
}

.article-actions {
    margin-top: 18px;
}

.article-detail {
    display: grid;
    gap: 20px;
    min-width: 0;
}

.detail-actions {
    flex: 0 0 auto;
}

.meta-line {
    border-bottom: 1px solid var(--line);
    border-top: 1px solid var(--line);
    color: var(--muted);
    flex-wrap: wrap;
    font-size: 14px;
    margin: 20px 0;
    padding: 12px 0;
}

.content-body {
    font-size: 16px;
    line-height: 1.75;
    white-space: normal;
}

.code-panel {
    background: #111827;
    border-color: #111827;
    color: #fff;
    min-width: 0;
    overflow: hidden;
    padding: 14px 22px;
}

.code-panel .code-toolbar {
    align-items: center;
}

.code-panel .code-toolbar strong {
    align-items: center;
    display: inline-flex;
    line-height: 32px;
}

.code-toolbar-actions {
    align-items: center;
    display: flex;
    gap: 8px;
}

.code-toolbar-actions .btn {
    align-items: center;
    display: inline-flex;
    gap: 5px;
    height: 30px;
    justify-content: center;
    line-height: 1;
    padding-bottom: 0;
    padding-top: 0;
}

.code-panel .code-content {
    max-width: 100%;
    min-width: 0;
    overflow: hidden;
}

.code-panel .code-content pre {
    border-radius: 0 0 8px 8px;
    margin: 14px -22px -14px;
    max-height: 560px;
    max-width: calc(100% + 44px);
    overflow-x: auto;
    overflow-y: auto;
}

.code-panel .code-content code {
    white-space: pre;
}

.editor-area {
    min-height: 260px;
}

.code-area {
    background: #101827;
    color: #e5edf8;
    font-family: "Cascadia Code", Consolas, monospace;
    min-height: 220px;
}

.empty-state {
    color: var(--muted);
    display: grid;
    justify-items: center;
    padding: 36px 18px;
    text-align: center;
}

.empty-state i {
    color: #94a3b8;
    font-size: 38px;
    margin-bottom: 10px;
}

.empty-state.small {
    padding: 22px 12px;
}

.user-list {
    display: grid;
    gap: 16px;
}

.user-card {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 18px;
}

.permission-box {
    background: #f8fafc;
    border: 1px solid var(--line);
    border-radius: 8px;
    display: grid;
    gap: 8px;
    padding: 14px;
}

.permission-box strong {
    font-size: 14px;
}

.permission-box .form-check {
    margin-bottom: 0;
}

.user-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 16px;
}

.delete-confirm-modal .modal-content {
    border: 0;
    border-radius: 8px;
    box-shadow: 0 30px 90px rgba(15, 23, 42, .28);
}

.delete-confirm-modal .modal-body {
    padding: 28px;
}

.delete-modal-icon {
    align-items: center;
    background: #fee2e2;
    border: 1px solid #fecaca;
    border-radius: 8px;
    color: #dc2626;
    display: grid;
    font-size: 26px;
    height: 56px;
    margin-bottom: 18px;
    place-items: center;
    width: 56px;
}

.delete-modal-copy h2 {
    font-size: 22px;
    font-weight: 800;
    margin: 0 0 8px;
}

.delete-modal-copy p {
    color: var(--ink);
    font-size: 16px;
    margin: 0 0 6px;
}

.delete-modal-copy span {
    color: var(--muted);
    display: block;
    font-size: 14px;
}

.delete-modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 24px;
}

.notes-panel {
    overflow: hidden;
}

.note-create-form {
    background: #f8fafc;
    border: 1px solid var(--line);
    border-radius: 8px;
    margin-bottom: 24px;
    padding: 16px;
}

.note-search-box {
    margin-bottom: 16px;
}

.note-form-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 12px;
}

.note-timeline {
    display: grid;
    gap: 16px;
    position: relative;
}

.note-timeline::before {
    background: var(--line);
    bottom: 8px;
    content: "";
    left: 10px;
    position: absolute;
    top: 8px;
    width: 2px;
}

.note-item {
    display: grid;
    gap: 14px;
    grid-template-columns: 22px minmax(0, 1fr);
    position: relative;
}

.note-marker {
    background: var(--primary);
    border: 4px solid #eaf2ff;
    border-radius: 999px;
    height: 22px;
    position: relative;
    width: 22px;
    z-index: 1;
}

.note-card {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 16px;
}

.note-head {
    align-items: flex-start;
    display: flex;
    gap: 14px;
    justify-content: space-between;
}

.note-head strong,
.note-head span,
.note-head small {
    display: block;
}

.note-head span,
.note-head small {
    color: var(--muted);
    font-size: 13px;
    margin-top: 2px;
}

.note-actions {
    align-items: center;
    display: flex;
    flex: 0 0 auto;
    gap: 8px;
}

.note-body {
    line-height: 1.65;
    margin-top: 12px;
    white-space: normal;
}

.note-edit-form {
    background: #f8fafc;
    border-radius: 8px;
    margin-top: 14px;
    padding: 12px;
}

.login-shell {
    align-items: center;
    background:
        radial-gradient(circle at top left, rgba(37, 99, 235, .16), transparent 34%),
        linear-gradient(135deg, #f8fbff, #eef6f5);
    display: flex;
    justify-content: center;
    min-height: 100vh;
    padding: 24px;
}

.login-card {
    background: rgba(255, 255, 255, .94);
    border: 1px solid rgba(229, 235, 243, .9);
    border-radius: 8px;
    box-shadow: 0 30px 80px rgba(24, 34, 53, .12);
    max-width: 430px;
    padding: 34px;
    width: 100%;
}

.login-card h1 {
    font-size: 28px;
    font-weight: 800;
}

.error-card {
    max-width: 680px;
}

.error-card code {
    background: #f1f5f9;
    border-radius: 8px;
    color: #b91c1c;
    display: block;
    padding: 14px;
    white-space: pre-wrap;
}

@media (max-width: 1180px) {
    .article-grid,
    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 860px) {
    .sidebar {
        height: auto;
        position: static;
        width: 100%;
    }

    .sidebar-footer {
        display: none;
    }

    .main-panel {
        margin-left: 0;
        max-width: 100vw;
    }

    .topbar {
        align-items: flex-start;
        flex-direction: column;
        padding: 18px;
    }

    .content-wrap {
        padding: 18px;
    }

    .article-grid,
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .detail-header {
        align-items: flex-start;
        flex-direction: column;
    }
}
