@font-face {
    font-family: "Comic Sans MS";
    src: url("fonts/comic.ttf") format("truetype");
    font-weight: 400;
    font-style: normal;
}
@font-face {
    font-family: "Comic Sans MS";
    src: url("fonts/comicbd.ttf") format("truetype");
    font-weight: 700;
    font-style: normal;
}
@font-face {
    font-family: "Comic Sans MS";
    src: url("fonts/comici.ttf") format("truetype");
    font-weight: 400;
    font-style: italic;
}
@font-face {
    font-family: "Comic Sans MS";
    src: url("fonts/comicz.ttf") format("truetype");
    font-weight: 700;
    font-style: italic;
}

:root {
    --sidebar-width: 320px;
    --font: "Comic Sans MS", cursive;
    --font-mono: "Comic Sans MS", cursive;
    --line-width: 900px;
}

/* Catppuccin Latte (Light) */
[data-theme="light"] {
    --accent: #43704e;
    --text: #4c4f69;
    --subtext1: #5c5f77;
    --subtext0: #6c6f85;
    --overlay2: #7c7f93;
    --overlay1: #8c8fa1;
    --overlay0: #9ca0b0;
    --surface2: #acb0be;
    --surface1: #bcc0cc;
    --surface0: #ccd0da;
    --base: #eff1f5;
    --mantle: #e6e9ef;
    --crust: #dce0e8;
    --blue: #1e66f5;
    --lavender: #7287fd;
    --tag-bg: #ccd0da;
    --tag-text: #43704e;
    --code-bg: #e6e9ef;
}

/* Catppuccin Mocha (Dark) */
[data-theme="dark"] {
    --accent: #a6e3a1;
    --text: #a6adc8;
    --subtext1: #9399b2;
    --subtext0: #7f849c;
    --overlay2: #9399b2;
    --overlay1: #7f849c;
    --overlay0: #6c7086;
    --surface2: #585b70;
    --surface1: #45475a;
    --surface0: #313244;
    --base: #1e1e2e;
    --mantle: #181825;
    --crust: #11111b;
    --blue: #89b4fa;
    --lavender: #b4befe;
    --tag-bg: #313244;
    --tag-text: #a6e3a1;
    --code-bg: #181825;
}

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

::-webkit-scrollbar {
    width: 3px;
    height: 3px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--surface1);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--surface2);
}

html, body {
    height: 100%;
    font-family: var(--font);
    font-size: 14px;
    color: var(--text);
    background: var(--base);
}

.layout {
    display: flex;
    height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    min-width: 180px;
    max-width: 50vw;
    background: var(--mantle);
    border-right: none;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

.resize-handle {
    width: 1px;
    cursor: col-resize;
    background: var(--surface0);
    flex-shrink: 0;
    transition: background 0.15s;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
    margin: 0 -6px;
    background-clip: content-box;
}

.resize-handle:hover,
.resize-handle.active {
    background: var(--accent);
}

.expand-btn {
    display: none;
    position: absolute;
    left: -6px;
    width: 16px;
    height: 40px;
    background: var(--surface1);
    border: 1px solid var(--surface0);
    border-radius: 0 6px 6px 0;
    cursor: pointer;
    font-size: 14px;
    color: var(--overlay1);
    padding: 0;
    line-height: 40px;
    text-align: center;
}

.expand-btn:hover {
    background: var(--accent);
    color: var(--base);
}

.sidebar.collapsed + .resize-handle {
    cursor: pointer;
    width: 2px;
}

.sidebar.collapsed + .resize-handle .expand-btn {
    display: block;
}

.sidebar-header {
    padding: 10px 12px;
    border-bottom: 1px solid var(--surface0);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sidebar-header h1 {
    font-size: 16px;
    font-weight: 600;
    color: var(--accent);
    font-family: var(--font);
}

.sidebar-toggle {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 20px;
    color: var(--overlay1);
    padding: 0 4px;
    border-radius: 4px;
    line-height: 1;
}

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


.theme-toggle {
    background: var(--surface0);
    border: none;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    color: var(--text);
    transition: background 0.2s;
    flex-shrink: 0;
}

.theme-toggle:hover {
    background: var(--surface1);
}

.tree {
    overflow-y: auto;
    padding: 8px 0;
    flex: 1;
}

.tree-item {
    cursor: pointer;
    user-select: none;
}

.tree-folder > .tree-label {
    display: flex;
    align-items: center;
    padding: 4px 12px;
    gap: 6px;
    color: var(--subtext0);
    font-size: 13px;
    font-weight: 500;
}

.tree-folder > .tree-label:hover {
    background: var(--surface0);
}

.tree-folder > .tree-label::before {
    content: "\25B6";
    font-size: 8px;
    transition: transform 0.15s;
}

.tree-folder.open > .tree-label::before {
    transform: rotate(90deg);
}

.tree-folder > .tree-children {
    display: none;
    padding-left: 12px;
}

.tree-folder.open > .tree-children {
    display: block;
}

.tree-file {
    display: flex;
    align-items: center;
    padding: 4px 12px 4px 24px;
    gap: 6px;
    font-size: 13px;
    color: var(--text);
    text-decoration: none;
    border-radius: 4px;
    margin: 1px 4px;
}

.tree-file:hover {
    background: var(--surface0);
}

.tree-file.active {
    background: var(--surface1);
    color: var(--accent);
    font-weight: 500;
}

.content {
    flex: 1;
    overflow-y: auto;
    padding: 0 40px 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.top-bar {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px 16px;
    position: sticky;
    top: 0;
    background: var(--base);
    z-index: 10;
}

.breadcrumb {
    flex: 1;
    font-size: 12px;
    color: var(--overlay1);
    text-align: center;
}

.breadcrumb span {
    color: var(--text);
    font-weight: 500;
}


.sidebar.collapsed {
    width: 0 !important;
    min-width: 0;
    overflow: hidden;
    border: none;
}

.sidebar.collapsed + .resize-handle {
    display: none;
}


#note-content {
    max-width: var(--line-width);
    width: 100%;
    line-height: 1.6;
    font-size: 1.05em;
}

#note-content h1 {
    font-size: 2em;
    margin: 0.7em 0 0.1em;
    font-weight: 700;
}

#note-content .note-title {
    margin-top: 0;
    color: var(--accent);
}

#note-content .note-meta {
    font-size: 0.85em;
    color: var(--subtext0);
    margin-bottom: 1em;
    line-height: 1.6;
}

#note-content h2 {
    font-size: 1.6em;
    margin: 0.4em 0;
    font-weight: 700;
}

#note-content h3 {
    font-size: 1.37em;
    margin: 0.6em 0 0.05em;
    font-weight: 700;
}

#note-content h4 {
    font-size: 1.12em;
    margin: 0.6em 0 0.05em;
    font-weight: 700;
}

#note-content h5 {
    font-size: 1em;
    margin: 0.6em 0 0.05em;
    font-weight: 700;
}

#note-content p {
    margin-bottom: 0.3em;
}

#note-content a {
    color: var(--blue);
    text-decoration: none;
}

#note-content a:hover {
    text-decoration: underline;
}

#note-content code {
    background: var(--code-bg);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 13px;
}

#note-content pre {
    background: var(--code-bg);
    border: 1px solid var(--surface0);
    border-radius: 8px;
    padding: 16px;
    overflow-x: auto;
    margin: 0.75em 0;
    line-height: normal;
}

.code-wrapper {
    position: relative;
}

.code-wrapper .copy-btn {
    position: absolute;
    top: 6px;
    right: 6px;
    background: var(--surface1);
    border: none;
    border-radius: 4px;
    color: var(--overlay1);
    cursor: pointer;
    padding: 4px 8px;
    font-size: 11px;
    font-family: var(--font);
    opacity: 0;
    transition: opacity 0.15s;
    z-index: 1;
}

.code-wrapper:hover .copy-btn {
    opacity: 1;
}

.code-wrapper .copy-btn:hover {
    background: var(--accent);
    color: var(--base);
}

.code-wrapper .copy-btn.copied {
    opacity: 1;
}

#note-content pre code {
    background: none;
    padding: 0;
    font-size: 13px;
}

#note-content blockquote {
    border-left: 3px solid var(--accent);
    padding: 8px 16px;
    margin: 0.75em 0;
    background: var(--mantle);
    border-radius: 0 4px 4px 0;
}

#note-content img {
    max-width: 100%;
    border-radius: 8px;
    margin: 10px 0;
}

#note-content table {
    border-collapse: collapse;
    width: 100%;
    margin: 0.75em 0;
}

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

#note-content th {
    background: var(--mantle);
    font-weight: 600;
}

#note-content ul,
#note-content ol {
    padding-left: 1.5em;
}

#note-content li {
    margin: 0;
}

.welcome {
    text-align: center;
    padding-top: 20vh;
    color: var(--overlay1);
}

.welcome h2 {
    color: var(--accent) !important;
    border: none !important;
}

.tag {
    display: inline-block;
    background: var(--tag-bg);
    color: var(--tag-text);
    padding: 1px 8px;
    border-radius: 12px;
    font-size: 12px;
    margin: 1px 2px;
}

.cardlink {
    display: flex;
    border: 1px solid var(--surface1);
    border-radius: 8px;
    overflow: hidden;
    margin: 0.75em 0;
    text-decoration: none;
    color: var(--text);
    transition: border-color 0.15s;
}

.cardlink:hover {
    border-color: var(--accent);
}

.cardlink-content {
    flex: 1;
    padding: 12px 16px;
    min-width: 0;
}

.cardlink-title {
    font-weight: 600;
    font-size: 0.95em;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cardlink-description {
    font-size: 0.8em;
    color: var(--subtext0);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.cardlink-host {
    font-size: 0.75em;
    color: var(--overlay1);
    margin-top: 6px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.cardlink-host img {
    width: 14px;
    height: 14px;
    border-radius: 2px;
}

.cardlink-image {
    width: 160px;
    min-height: 90px;
    object-fit: cover;
    flex-shrink: 0;
}

.outline-panel {
    width: 260px;
    min-width: 160px;
    background: var(--mantle);
    overflow-y: auto;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.outline-header {
    font-size: 11px;
    font-weight: 600;
    color: var(--overlay1);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 8px 12px 4px;
}

.outline-tree {
    font-size: 12px;
}

.outline-item {
    cursor: pointer;
    user-select: none;
    padding: 3px 12px;
    color: var(--subtext0);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    border-left: 2px solid transparent;
}

.outline-item:hover {
    background: var(--surface0);
}

.outline-item.active {
    color: var(--text);
    border-left-color: var(--accent);
    background: var(--surface0);
}

.outline-resize-handle {
    width: 1px;
    cursor: col-resize;
    background: var(--surface0);
    flex-shrink: 0;
    transition: background 0.15s;
    padding: 0 6px;
    margin: 0 -6px;
    background-clip: content-box;
}

.outline-resize-handle:hover,
.outline-resize-handle.active {
    background: var(--accent);
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 20px;
    color: var(--text);
    cursor: pointer;
    padding: 4px 8px;
    line-height: 1;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 99;
}

@media (max-width: 768px) {
    .menu-toggle {
        display: block;
    }

    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        width: 280px !important;
        height: 100%;
        z-index: 100;
        transform: translateX(-100%);
        transition: transform 0.2s ease;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar.open ~ .sidebar-overlay {
        display: block;
    }

    .resize-handle {
        display: none;
    }

    .content {
        padding: 0 16px 40px;
    }

    .top-bar {
        padding: 8px 10px;
    }

    .menu-toggle {
        margin: 0 0 0 -20px;
    }

    .theme-toggle {
        margin: 0 -20px 0 0;
    }

    .cardlink-image {
        width: 100px;
    }

    .outline-panel {
        display: none;
    }
}
