:root {
    --bg-primary: #ffffff;
    --bg-secondary: #f8f8f8;
    --bg-hover: #ececec;
    --bg-code: #f2f2f2;
    --text-normal: #2e3338;
    --text-muted: #6e6e6e;
    --text-faint: #999999;
    --border: #e3e3e3;
    --link: #6c4fd6;
    --link-hover: #5238b8;
    --sidebar-width: 260px;
    --font-text: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg-primary: #1e1e1e;
        --bg-secondary: #181818;
        --bg-hover: #2a2a2a;
        --bg-code: #292929;
        --text-normal: #dcddde;
        --text-muted: #a0a0a0;
        --text-faint: #6e6e6e;
        --border: #333333;
        --link: #a58cff;
        --link-hover: #bfa9ff;
    }
}

:root[data-theme="dark"] {
    --bg-primary: #1e1e1e;
    --bg-secondary: #181818;
    --bg-hover: #2a2a2a;
    --bg-code: #292929;
    --text-normal: #dcddde;
    --text-muted: #a0a0a0;
    --text-faint: #6e6e6e;
    --border: #333333;
    --link: #a58cff;
    --link-hover: #bfa9ff;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
}

body {
    background: var(--bg-primary);
    color: var(--text-normal);
    font-family: var(--font-text);
    font-size: 16px;
    line-height: 1.6;
}

.notes-layout {
    display: flex;
    min-height: 100vh;
}

.notes-sidebar {
    width: var(--sidebar-width);
    flex-shrink: 0;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    padding: 20px 14px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.notes-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
    padding: 0 6px;
}

.notes-sidebar-header a {
    font-weight: 700;
    font-size: 15px;
    color: var(--text-normal);
    text-decoration: none;
}

.theme-toggle {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 16px;
    padding: 4px;
    line-height: 1;
}

.theme-toggle:hover {
    color: var(--text-normal);
}

.notes-sidebar-byline {
    padding: 0 6px;
    margin: -8px 0 12px;
    font-size: 12px;
    color: var(--text-faint);
}

.notes-sidebar-byline a {
    color: var(--text-faint);
}

.notes-sidebar-byline a:hover {
    color: var(--link);
}

.notes-search {
    width: 100%;
    padding: 6px 10px;
    margin-bottom: 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-primary);
    color: var(--text-normal);
    font-size: 13px;
}

.notes-search:focus {
    outline: none;
    border-color: var(--link);
}

.notes-nav {
    list-style: none;
    margin: 0;
    padding: 0;
}

.notes-nav li a {
    display: block;
    padding: 5px 8px;
    border-radius: 6px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 13.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.notes-nav li a:hover {
    background: var(--bg-hover);
    color: var(--text-normal);
}

.notes-nav li a.active {
    background: var(--bg-hover);
    color: var(--link);
    font-weight: 600;
}

.notes-tags-link {
    display: block;
    padding: 6px 8px;
    margin-bottom: 12px;
    border-radius: 6px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 13px;
}

.notes-tags-link:hover {
    background: var(--bg-hover);
    color: var(--text-normal);
}

.notes-sidebar-footer {
    margin-top: 16px;
    padding: 0 6px;
    font-size: 12px;
}

.notes-sidebar-footer a {
    color: var(--text-faint);
}

.notes-main {
    flex: 1;
    min-width: 0;
    padding: 48px 40px 80px;
}

.notes-content {
    max-width: 720px;
    margin: 0 auto;
}

.notes-content h1 {
    font-size: 32px;
    margin: 0 0 8px;
}

.notes-content h2 {
    font-size: 24px;
    margin: 36px 0 12px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
}

.notes-content h3 {
    font-size: 19px;
    margin: 28px 0 10px;
}

.notes-content p {
    margin: 14px 0;
}

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

.notes-content a:hover {
    color: var(--link-hover);
}

.notes-content ul, .notes-content ol {
    padding-left: 24px;
}

.notes-content blockquote {
    margin: 16px 0;
    padding: 4px 16px;
    border-left: 3px solid var(--link);
    color: var(--text-muted);
    background: var(--bg-secondary);
}

.notes-content code {
    font-family: var(--font-mono);
    background: var(--bg-code);
    padding: 2px 5px;
    border-radius: 4px;
    font-size: 0.88em;
}

.notes-content pre {
    background: var(--bg-code);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px 16px;
    overflow-x: auto;
    margin: 18px 0;
}

.notes-content pre code {
    background: none;
    padding: 0;
    font-size: 0.85em;
    line-height: 1.5;
}

.notes-content table {
    border-collapse: collapse;
    width: 100%;
    margin: 16px 0;
    font-size: 0.92em;
}

.notes-content th, .notes-content td {
    border: 1px solid var(--border);
    padding: 6px 10px;
    text-align: left;
}

.notes-content th {
    background: var(--bg-secondary);
}

.notes-content img {
    max-width: 100%;
}

.note-tag {
    display: inline-flex;
    align-items: baseline;
    gap: 4px;
    color: var(--link);
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 1px 9px;
    font-size: 0.85em;
    text-decoration: none !important;
    white-space: nowrap;
}

.note-tag:hover {
    background: var(--bg-hover);
    color: var(--link-hover);
}

.notes-tag-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 24px 0;
}

.notes-tag-cloud-item {
    font-size: 1em;
    padding: 5px 14px;
}

.notes-tag-count {
    color: var(--text-faint);
    font-size: 0.85em;
}

.notes-backlinks {
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

.notes-backlinks h2 {
    font-size: 15px;
    color: var(--text-muted);
    margin: 0 0 10px;
    border-bottom: none;
    padding-bottom: 0;
}

.notes-backlinks ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.notes-backlinks li {
    padding: 4px 0;
}

.notes-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    color: var(--text-faint);
    font-size: 13px;
    margin-bottom: 32px;
}

.share-x {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--text-normal) !important;
    text-decoration: none !important;
    font-size: 13px;
}

.share-x:hover {
    background: var(--bg-hover);
    border-color: var(--text-faint);
}

.notes-footer {
    margin-top: 60px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
    color: var(--text-faint);
    font-size: 13px;
}

.notes-footer a {
    color: var(--text-faint);
}

.notes-index-list {
    list-style: none;
    padding: 0;
    margin: 24px 0;
}

.notes-index-list li {
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    gap: 16px;
}

.notes-index-list a {
    color: var(--text-normal);
    text-decoration: none;
    font-size: 15px;
}

.notes-index-list a:hover {
    color: var(--link);
}

.notes-index-list time {
    color: var(--text-faint);
    font-size: 13px;
    white-space: nowrap;
}

.notes-sidebar-toggle {
    display: none;
}

@media (max-width: 760px) {
    .notes-layout {
        display: block;
    }
    .notes-sidebar {
        position: static;
        width: auto;
        height: auto;
    }
    .notes-sidebar-toggle {
        display: block;
        width: 100%;
        margin: 4px 0 0;
        padding: 8px 10px;
        border: 1px solid var(--border);
        border-radius: 6px;
        background: var(--bg-primary);
        color: var(--text-normal);
        font-size: 13px;
        text-align: left;
        cursor: pointer;
    }
    .notes-sidebar-body {
        display: none;
        margin-top: 12px;
    }
    .notes-sidebar.open .notes-sidebar-body {
        display: block;
    }
    .notes-main {
        padding: 32px 20px 60px;
    }
}

/* mermaid diagrams (client-side rendering; see note.tt) */
div.mermaid {
    display: flex;
    justify-content: center;
    overflow-x: auto;
    margin: 1.2em 0;
}

/* KaTeX math (client-side rendering; see note.tt) */
div.math-display {
    overflow-x: auto;
    margin: 1.2em 0;
}
