:root {
    --bg: #ffffff;
    --panel: #ffffff;
    --text: #1f2329;
    --muted: #646a73;
    --line: #e5e6eb;
    --soft: #f7f8fa;
    --hover: #eff3ff;
    --brand: #3370ff;
    --danger: #d83931;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    color: var(--text);
    background: var(--bg);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
    font-size: 14px;
    line-height: 1.75;
    overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 16px;
    height: 56px;
    padding: 0 24px;
    background: rgba(255, 255, 255, .96);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(12px);
}
.brand {
    max-width: 220px;
    overflow: hidden;
    font-size: 16px;
    font-weight: 650;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.search {
    display: flex;
    align-items: center;
    flex: 1;
    max-width: 420px;
    min-width: 0;
    margin-left: auto;
    border: 1px solid transparent;
    border-radius: 6px;
    background: var(--soft);
}
.search:focus-within {
    border-color: #b7c7ff;
    background: #fff;
}
input, textarea, select {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 9px 11px;
    color: var(--text);
    background: #fff;
    font: inherit;
}
.search input {
    min-width: 0;
    height: 34px;
    border: 0;
    background: transparent;
    outline: none;
}
textarea { resize: vertical; }
button, .primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 34px;
    border: 0;
    border-radius: 6px;
    padding: 8px 14px;
    color: #fff;
    background: var(--brand);
    font: inherit;
    cursor: pointer;
}
.search button {
    flex: 0 0 52px;
    min-height: 30px;
    margin-right: 2px;
    padding: 5px 10px;
    color: var(--brand);
    background: transparent;
    white-space: nowrap;
}
button:hover, .primary:hover { filter: brightness(.96); }
.admin-link, .admin-nav a {
    padding: 7px 9px;
    border-radius: 6px;
    color: var(--muted);
}
.admin-link:hover, .admin-nav a:hover { background: var(--soft); color: var(--text); }
.admin-nav {
    display: flex;
    gap: 4px;
    margin-left: auto;
}
.admin-nav a.active {
    color: var(--brand);
    background: var(--hover);
}

main {
    width: 100%;
    max-width: 1240px;
    margin: 0 auto;
}
.home-shell, .reader {
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
    min-height: calc(100vh - 56px);
    min-width: 0;
}
.home-side, .sidebar {
    position: sticky;
    top: 56px;
    height: calc(100vh - 56px);
    overflow: auto;
    padding: 18px 12px;
    border-right: 1px solid var(--line);
    background: #fbfbfc;
    min-width: 0;
}
.side-title {
    margin: 0 10px 10px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 650;
}
.home-side a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 10px;
    border-radius: 6px;
    color: #333842;
}
.home-side a span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.home-side a:hover {
    background: var(--hover);
    color: var(--brand);
}
.home-side em {
    min-width: 22px;
    color: var(--muted);
    font-style: normal;
    text-align: right;
}

.doc-pane, .content-list, .panel {
    width: calc(100% - 48px);
    max-width: 920px;
    margin: 32px auto;
    padding: 0;
    background: var(--panel);
    min-width: 0;
}
.page-head {
    margin-bottom: 20px;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--line);
}
.page-head h1, .doc-pane > h1, .content-list h1, .panel h1 {
    margin: 0 0 8px;
    color: var(--text);
    font-size: 28px;
    line-height: 1.3;
    letter-spacing: 0;
}
.page-head p, .lead {
    margin: 0;
    color: var(--muted);
}

.projects {
    display: grid;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    border-top: 1px solid var(--line);
}
.project-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 16px;
    align-items: center;
    min-height: 86px;
    min-width: 0;
    max-width: 100%;
    padding: 16px 2px;
    border-bottom: 1px solid var(--line);
}
.project-card > a {
    min-width: 0;
    max-width: 100%;
}
.project-card h2 {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 4px;
    font-size: 16px;
    font-weight: 650;
    min-width: 0;
}
.project-card h2 span {
    padding: 1px 7px;
    border-radius: 999px;
    color: var(--muted);
    background: var(--soft);
    font-size: 12px;
    font-weight: 500;
}
.project-card p {
    max-width: 100%;
    margin: 0;
    color: var(--muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.first-doc {
    padding: 6px 10px;
    border-radius: 6px;
    color: var(--brand);
    white-space: nowrap;
}
.first-doc:hover { background: var(--hover); }

.sidebar h1 {
    margin: 0 10px 6px;
    font-size: 16px;
    line-height: 1.4;
}
.sidebar p {
    margin: 0 10px 14px;
    color: var(--muted);
    font-size: 13px;
}
.sidebar nav {
    display: grid;
    gap: 2px;
}
.sidebar nav a, .back {
    display: block;
    overflow: hidden;
    padding: 7px 10px;
    border-radius: 6px;
    color: #333842;
    font-size: 13px;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.sidebar nav a:hover, .sidebar nav a.active {
    color: var(--brand);
    background: var(--hover);
}
.back {
    margin: 0 0 10px;
    color: var(--brand);
    font-weight: 650;
}

.markdown {
    font-size: 15px;
}
.markdown h1 {
    padding-bottom: 18px;
    border-bottom: 1px solid var(--line);
    font-size: 30px;
    font-weight: 700;
}
.markdown h2, .markdown h3, .markdown h4 {
    margin: 30px 0 10px;
    line-height: 1.35;
}
.markdown h2 { font-size: 22px; }
.markdown h3 { font-size: 18px; }
.markdown p { margin: 12px 0; }
.markdown img {
    max-width: 100%;
    height: auto;
    border: 1px solid var(--line);
    border-radius: 4px;
    background: #fff;
}
.markdown figure { margin: 18px 0; }
.markdown code {
    padding: 2px 5px;
    border-radius: 4px;
    background: var(--soft);
    color: #c0252d;
}
.markdown pre {
    overflow: auto;
    padding: 14px 16px;
    border-radius: 6px;
    background: #f7f8fa;
    border: 1px solid var(--line);
    color: var(--text);
}
.markdown pre code {
    padding: 0;
    color: inherit;
    background: transparent;
}
.markdown a { color: var(--brand); }
.markdown mark { padding: 0 3px; background: #fff7d6; }

.content-list {
    display: grid;
    gap: 0;
}
.result {
    padding: 15px 0;
    border-bottom: 1px solid var(--line);
}
.result a {
    color: var(--text);
    font-weight: 650;
    font-size: 16px;
}
.result a:hover { color: var(--brand); }
.result small {
    margin-left: 8px;
    color: var(--muted);
}
.result p { margin: 5px 0 0; color: var(--muted); }
.empty {
    padding: 28px;
    border: 1px dashed var(--line);
    border-radius: 6px;
    color: var(--muted);
    background: var(--soft);
}

.login-box {
    width: calc(100% - 32px);
    max-width: 420px;
    margin: 80px auto;
    padding: 28px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
}
.login-box form, .editor-form {
    display: grid;
    gap: 14px;
}
label {
    display: grid;
    gap: 6px;
    color: #333842;
    font-weight: 650;
}
.admin-layout {
    display: grid;
    gap: 22px;
    width: calc(100% - 48px);
    max-width: 1080px;
    margin: 28px auto;
}
.admin-layout .panel {
    width: 100%;
    margin: 0;
    padding: 24px;
    border: 1px solid var(--line);
    border-radius: 8px;
}
.panel table {
    width: 100%;
    border-collapse: collapse;
}
th, td {
    padding: 10px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}
th { color: var(--muted); font-size: 13px; }
.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}
.actions a { color: var(--brand); font-weight: 650; }
.actions form { margin: 0; }
.actions button {
    min-height: 28px;
    padding: 4px 8px;
    background: var(--danger);
}
.notice {
    padding: 10px 12px;
    border-radius: 6px;
    color: #8f5400;
    background: #fff7d6;
}
.muted { color: var(--muted); }
.editor-label {
    display: block;
}
.edui-default {
    margin-top: 6px;
}
.edui-default .edui-editor {
    border-color: var(--line) !important;
    border-radius: 6px !important;
    overflow: hidden;
}
.edui-default .edui-editor-toolbarboxouter {
    border-bottom-color: var(--line) !important;
    background: #fbfbfc !important;
    box-shadow: none !important;
}
.edui-default .edui-toolbar .edui-button,
.edui-default .edui-toolbar .edui-splitbutton,
.edui-default .edui-toolbar .edui-menubutton {
    min-height: 0;
    background: transparent;
}
.edui-default .edui-editor-iframeholder {
    background: #fff;
}

@media (max-width: 820px) {
    .topbar {
        flex-wrap: wrap;
        height: auto;
        min-height: 56px;
        padding: 10px 14px;
    }
    .search {
        order: 3;
        width: 100%;
        max-width: none;
        margin-left: 0;
    }
    .home-shell, .reader { grid-template-columns: 1fr; }
    .home-side, .sidebar {
        position: static;
        height: auto;
        max-height: 260px;
        border-right: 0;
        border-bottom: 1px solid var(--line);
    }
    .doc-pane, .content-list, .panel {
        width: calc(100% - 32px);
        margin: 22px auto;
    }
    .project-card {
        grid-template-columns: 1fr;
        gap: 6px;
    }
}
