:root {
    --bg: #fafafa;
    --bg-card: #ffffff;
    --sidebar-bg: #f3f4f6;
    --text: #1a1a1a;
    --text-dim: #6b7280;
    --accent: #6366f1;
    --accent-dim: #818cf8;
    --border: #e5e7eb;
    --code-bg: #1f2937;
    --code-text: #f3f4f6;
    --highlight: #fef3c7;
    --shadow: 0 1px 3px rgba(0,0,0,0.06);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
    color: var(--text);
    background: var(--bg);
    line-height: 1.6;
    font-size: 15px;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 24px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 10;
}

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

header h1 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    background: linear-gradient(135deg, var(--accent), #8b5cf6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.logo { font-size: 24px; }

header .meta {
    font-size: 12px;
    color: var(--text-dim);
}

.layout {
    display: grid;
    grid-template-columns: 320px 1fr;
    min-height: calc(100vh - 53px);
}

#sidebar {
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    padding: 16px;
    overflow-y: auto;
    max-height: calc(100vh - 53px);
    position: sticky;
    top: 53px;
}

#search {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
    margin-bottom: 16px;
    background: var(--bg-card);
}

#search:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

#tree {
    font-size: 14px;
}

#tree details {
    margin-bottom: 4px;
}

#tree summary {
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    font-weight: 600;
    color: var(--text);
    user-select: none;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 4px;
}

#tree summary::-webkit-details-marker { display: none; }
#tree summary::before {
    content: "▶";
    font-size: 10px;
    transition: transform 0.15s;
    color: var(--text-dim);
}

#tree details[open] > summary::before {
    transform: rotate(90deg);
}

#tree summary:hover {
    background: rgba(99, 102, 241, 0.08);
}

#tree ul {
    list-style: none;
    padding-left: 18px;
    margin: 4px 0;
}

#tree li {
    margin: 1px 0;
}

#tree a {
    display: block;
    padding: 4px 8px;
    border-radius: 4px;
    color: var(--text);
    text-decoration: none;
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#tree a:hover {
    background: rgba(99, 102, 241, 0.08);
    color: var(--accent);
}

#tree a.active {
    background: var(--accent);
    color: white;
    font-weight: 500;
}

#content {
    padding: 32px 48px;
    max-width: 920px;
    margin: 0 auto;
    width: 100%;
}

.placeholder {
    text-align: center;
    color: var(--text-dim);
    padding: 80px 20px;
}

.placeholder h2 {
    color: var(--text);
    font-weight: 500;
    margin-bottom: 16px;
}

.placeholder p {
    max-width: 480px;
    margin: 12px auto;
}

.placeholder .hint {
    font-size: 13px;
    opacity: 0.7;
    margin-top: 24px;
}

code {
    font-family: "SF Mono", Menlo, Consolas, monospace;
    font-size: 0.9em;
    background: rgba(99, 102, 241, 0.08);
    padding: 2px 6px;
    border-radius: 3px;
    color: var(--accent);
}

.placeholder code {
    background: rgba(99, 102, 241, 0.12);
}

#content h1, #content h2, #content h3, #content h4 {
    margin-top: 32px;
    margin-bottom: 12px;
    font-weight: 600;
    line-height: 1.3;
}

#content h1 {
    font-size: 32px;
    border-bottom: 2px solid var(--border);
    padding-bottom: 8px;
    background: linear-gradient(135deg, var(--accent), #8b5cf6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

#content h2 {
    font-size: 24px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 6px;
}

#content h3 {
    font-size: 19px;
    color: var(--text);
}

#content p {
    margin: 12px 0;
    line-height: 1.7;
}

#content ul, #content ol {
    padding-left: 24px;
    margin: 12px 0;
}

#content li {
    margin: 4px 0;
}

#content a {
    color: var(--accent);
    text-decoration: none;
    border-bottom: 1px solid transparent;
}

#content a:hover {
    border-bottom-color: var(--accent);
}

#content blockquote {
    border-left: 3px solid var(--accent);
    margin: 16px 0;
    padding: 8px 16px;
    background: rgba(99, 102, 241, 0.04);
    color: var(--text-dim);
    border-radius: 0 4px 4px 0;
}

#content code {
    background: rgba(99, 102, 241, 0.08);
    border: 1px solid rgba(99, 102, 241, 0.15);
}

#content pre {
    background: var(--code-bg);
    color: var(--code-text);
    padding: 16px 20px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 16px 0;
    line-height: 1.5;
    font-size: 13px;
}

#content pre code {
    background: none;
    border: none;
    color: inherit;
    padding: 0;
    font-size: inherit;
}

#content table {
    border-collapse: collapse;
    width: 100%;
    margin: 16px 0;
    background: var(--bg-card);
    box-shadow: var(--shadow);
    border-radius: 6px;
    overflow: hidden;
}

#content th, #content td {
    padding: 10px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

#content th {
    background: var(--sidebar-bg);
    font-weight: 600;
    font-size: 13px;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

#content tr:last-child td {
    border-bottom: none;
}

#content tr:hover {
    background: rgba(99, 102, 241, 0.03);
}

#content img {
    max-width: 100%;
    height: auto;
    border-radius: 6px;
    box-shadow: var(--shadow);
    margin: 16px 0;
    display: block;
}

#content hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 32px 0;
}

#content mark {
    background: var(--highlight);
    padding: 2px 4px;
    border-radius: 2px;
}

#content del {
    color: var(--text-dim);
}

#content input[type="checkbox"] {
    margin-right: 8px;
}

#content .task-list-item {
    list-style: none;
    margin-left: -20px;
}

.doc-header {
    border-bottom: 1px solid var(--border);
    padding-bottom: 16px;
    margin-bottom: 24px;
    color: var(--text-dim);
    font-size: 13px;
}

.doc-header .path {
    font-family: "SF Mono", Menlo, Consolas, monospace;
    color: var(--accent);
}

.doc-header .size {
    margin-left: 12px;
    color: var(--text-dim);
    opacity: 0.7;
}

.error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
    padding: 16px 20px;
    border-radius: 8px;
}

.error h3 {
    margin-top: 0;
    color: #7f1d1d;
}

.error pre {
    background: #fef2f2;
    color: #7f1d1d;
    border: 1px solid #fecaca;
}

@media (max-width: 768px) {
    .layout { grid-template-columns: 1fr; }
    #sidebar { position: relative; max-height: none; top: 0; }
    #content { padding: 20px; }
}