[hidden] { display: none !important; }

/* Copy protection for non-admin users */
body.no-copy .markdown-body,
body.no-copy .note-title,
body.no-copy .note-meta {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}
body.no-copy .code-copy-btn {
    display: none !important;
}

/* ===== CSS Variables ===== */
:root {
    --bg: #0a0814;
    --bg2: #0f0c1a;
    --bg3: #1a1528;
    --card: #120d22;
    --border: #2b3242;
    --text: #ffffff;
    --text-muted: #8b8fa3;
    --accent: #646cfd;
    --accent-green: #00ff9c;
    --font-sans: 'Space Grotesk', system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    --sidebar-w: 260px;
    --topbar-h: 56px;
    --radius: 8px;
    --transition: 0.2s ease;
}

/* ===== Reset ===== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-sans);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
}

a { color: var(--accent-green); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #3e4557; }

/* ===== Buttons ===== */
.btn {
    font-family: var(--font-sans);
    font-size: 0.875rem;
    font-weight: 500;
    padding: 0.5rem 1.25rem;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    white-space: nowrap;
}
.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
.btn-primary {
    background: var(--accent-green);
    color: #0a0814;
    font-weight: 600;
}
.btn-primary:hover:not(:disabled) {
    background: #33ffb1;
    box-shadow: 0 0 20px rgba(0, 255, 156, 0.25);
}
.btn-danger {
    background: #ff4757;
    color: #fff;
}
.btn-danger:hover:not(:disabled) {
    background: #ff6b7a;
    box-shadow: 0 0 20px rgba(255, 71, 87, 0.25);
}
.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
}
.btn-ghost:hover:not(:disabled) {
    color: var(--text);
    border-color: #3e4557;
    background: var(--bg3);
}
.btn-small {
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
}
.btn-full {
    width: 100%;
}

/* ===== Inputs ===== */
input[type="text"],
input[type="password"],
select,
textarea {
    font-family: var(--font-sans);
    font-size: 0.9rem;
    background: var(--bg3);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.6rem 0.85rem;
    width: 100%;
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
}
input[type="text"]:focus,
input[type="password"]:focus,
select:focus,
textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(100, 108, 253, 0.15);
}
input::placeholder,
textarea::placeholder {
    color: #555a6e;
}
select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%238b8fa3' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2rem;
}

.form-group {
    margin-bottom: 1rem;
}
.form-group label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.35rem;
    font-weight: 500;
}
.form-group-checkbox {
    display: flex;
    align-items: center;
    padding-top: 1.5rem;
}
.form-group-checkbox label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    margin-bottom: 0;
}
.form-group-checkbox input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent-green);
}

.form-row {
    display: flex;
    gap: 1rem;
}
.form-row > * {
    flex: 1;
}

/* ===== Login Page ===== */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 1rem;
}
.login-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 2.5rem;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 0 60px rgba(100, 108, 253, 0.08), 0 0 120px rgba(0, 255, 156, 0.04);
    text-align: center;
}
.login-logo {
    font-family: var(--font-mono);
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}
.logo-bracket {
    color: var(--text-muted);
    font-weight: 400;
}
.logo-accent {
    color: var(--accent-green);
}
.login-subtitle {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 2rem;
}
.login-card .form-group {
    text-align: left;
}
.login-card .btn {
    margin-top: 0.5rem;
}
.login-error {
    color: #ff4757;
    font-size: 0.85rem;
    margin-top: 1rem;
    padding: 0.5rem;
    border-radius: var(--radius);
    background: rgba(255, 71, 87, 0.1);
}

/* ===== Top Bar ===== */
.topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--topbar-h);
    background: rgba(10, 8, 20, 0.8);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 1.25rem;
    z-index: 100;
    gap: 1rem;
}
.topbar-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: calc(var(--sidebar-w) - 1.25rem);
}
.topbar-logo {
    font-family: var(--font-mono);
    font-size: 1.15rem;
    font-weight: 700;
}
.topbar-center {
    flex: 1;
    max-width: 480px;
}
.search-wrap {
    position: relative;
}
.search-icon {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}
#search-input {
    padding-left: 2.25rem;
    background: var(--bg2);
    border-color: transparent;
    font-size: 0.85rem;
}
#search-input:focus {
    border-color: var(--accent);
    background: var(--bg3);
}
.search-results {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    max-height: 320px;
    overflow-y: auto;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
    z-index: 200;
}
.search-result-item {
    padding: 0.6rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
    transition: background var(--transition);
}
.search-result-item:last-child {
    border-bottom: none;
}
.search-result-item:hover {
    background: var(--bg3);
}
.search-result-item .sr-title {
    font-weight: 600;
    font-size: 0.9rem;
}
.search-result-item .sr-cat {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.15rem;
}
.search-no-results {
    padding: 1rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-left: auto;
}
.user-display {
    font-size: 0.85rem;
    color: var(--text-muted);
}
.admin-badge {
    font-size: 0.7rem;
    font-weight: 600;
    background: var(--accent);
    color: #fff;
    padding: 0.15rem 0.5rem;
    border-radius: 99px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ===== Hamburger ===== */
.hamburger {
    display: none;
    flex-direction: column;
    gap: 4px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
}
.hamburger span {
    display: block;
    width: 20px;
    height: 2px;
    background: var(--text);
    border-radius: 2px;
    transition: all var(--transition);
}

/* ===== Sidebar ===== */
.sidebar {
    position: fixed;
    top: var(--topbar-h);
    left: 0;
    bottom: 0;
    width: var(--sidebar-w);
    background: var(--bg2);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    z-index: 90;
    transition: transform 0.3s ease;
}
.sidebar-inner {
    display: flex;
    flex-direction: column;
    min-height: 100%;
    padding: 0.75rem 0;
}
.sidebar-admin-actions {
    margin-top: auto;
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    border-top: 1px solid var(--border);
}
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 85;
}

/* Category Tree */
.category-tree {
    flex: 1;
}
.cat-item {
    user-select: none;
}
.cat-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    transition: all var(--transition);
}
.cat-header:hover {
    color: var(--text);
    background: var(--bg3);
}
.cat-header .cat-icon {
    font-size: 1rem;
    width: 1.25rem;
    text-align: center;
    flex-shrink: 0;
}
.cat-header .cat-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.cat-header .cat-chevron {
    font-size: 0.7rem;
    transition: transform 0.2s ease;
    color: #555a6e;
}
.cat-item.expanded .cat-chevron {
    transform: rotate(90deg);
}
.cat-notes {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}
.cat-item.expanded .cat-notes {
    max-height: 1000px;
}

/* Category count badge */
.cat-count-badge {
    font-size: 0.65rem;
    font-weight: 600;
    background: var(--bg3);
    color: var(--text-muted);
    padding: 0.1rem 0.45rem;
    border-radius: 99px;
    min-width: 1.3rem;
    text-align: center;
    border: 1px solid var(--border);
    flex-shrink: 0;
}

.note-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 1rem 0.4rem 2.5rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition);
    border-left: 2px solid transparent;
}
.note-link:hover {
    color: var(--text);
    background: var(--bg3);
    padding-left: 2.65rem;
}
.note-link.active {
    color: var(--accent-green);
    border-left-color: var(--accent-green);
    background: rgba(0, 255, 156, 0.04);
}
.note-link .note-icon {
    font-size: 0.75rem;
    opacity: 0.6;
}

/* ===== Content Area ===== */
.content {
    margin-left: var(--sidebar-w);
    margin-top: var(--topbar-h);
    min-height: calc(100vh - var(--topbar-h));
    padding: 2rem;
    display: flex;
    justify-content: center;
}
.note-view,
.empty-state,
.loading-state {
    width: 100%;
    max-width: 900px;
}

/* Empty State */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
    text-align: center;
    color: var(--text-muted);
}
.empty-icon {
    font-size: 3.5rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}
.empty-state h2 {
    font-size: 1.3rem;
    margin-bottom: 0.4rem;
    color: var(--text);
}
.empty-state p {
    font-size: 0.9rem;
}

/* Loading State */
.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
    color: var(--text-muted);
}
.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border);
    border-top-color: var(--accent-green);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 1rem;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===== Breadcrumb ===== */
.note-breadcrumb {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
    padding: 0.4rem 0.75rem;
    background: var(--bg3);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}
.breadcrumb-cat {
    color: var(--accent);
    font-weight: 500;
}
.breadcrumb-sep {
    color: #555a6e;
    font-size: 1rem;
}
.breadcrumb-title {
    color: var(--text);
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ===== Table of Contents ===== */
.note-toc {
    margin-bottom: 1.5rem;
}
.toc-inner {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
}
.toc-title {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.6rem;
    padding-bottom: 0.4rem;
    border-bottom: 1px solid var(--border);
}
.toc-list {
    list-style: none;
    padding: 0;
    margin: 0;
}
.toc-list li {
    margin-bottom: 0.2rem;
}
.toc-list li a {
    display: block;
    font-size: 0.82rem;
    color: var(--text-muted);
    padding: 0.2rem 0;
    text-decoration: none;
    transition: color var(--transition), padding-left var(--transition);
    border-radius: 4px;
}
.toc-list li a:hover {
    color: var(--accent-green);
    text-decoration: none;
    padding-left: 0.25rem;
}
.toc-level-1 { padding-left: 0; }
.toc-level-2 { padding-left: 1rem; }
.toc-level-3 { padding-left: 2rem; }
.toc-level-4 { padding-left: 3rem; }

/* Note View */
.note-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
}
.note-title {
    font-family: var(--font-mono);
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1.3;
    margin-bottom: 0.5rem;
}
.note-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
}
.meta-sep {
    margin: 0 0.1rem;
    color: #555a6e;
}
.note-actions {
    display: flex;
    gap: 0.4rem;
    flex-shrink: 0;
}

/* ===== Markdown Body ===== */
.markdown-body {
    line-height: 1.75;
    font-size: 0.95rem;
    color: #d4d4e8;
    word-break: break-word;
}
.markdown-body h1 {
    font-family: var(--font-mono);
    font-size: 1.6rem;
    color: var(--accent);
    margin: 2rem 0 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}
.markdown-body h2 {
    font-family: var(--font-mono);
    font-size: 1.3rem;
    color: var(--accent);
    margin: 1.75rem 0 0.75rem;
}
.markdown-body h3 {
    font-family: var(--font-mono);
    font-size: 1.1rem;
    color: var(--accent);
    margin: 1.5rem 0 0.6rem;
}
.markdown-body h4 {
    font-family: var(--font-mono);
    font-size: 0.95rem;
    color: var(--accent);
    margin: 1.25rem 0 0.5rem;
}
.markdown-body p {
    margin-bottom: 1rem;
}

/* Better list styling */
.markdown-body ul {
    margin-bottom: 1rem;
    padding-left: 1.5rem;
    list-style: none;
}
.markdown-body ul li {
    position: relative;
    margin-bottom: 0.3rem;
    padding-left: 0.25rem;
}
.markdown-body ul li::before {
    content: '\25B8';
    position: absolute;
    left: -1.1rem;
    color: var(--accent-green);
    font-size: 0.8rem;
    line-height: 1.75;
}
.markdown-body ol {
    margin-bottom: 1rem;
    padding-left: 1.5rem;
}
.markdown-body ol li {
    margin-bottom: 0.3rem;
}
.markdown-body ol li::marker {
    color: var(--accent-green);
    font-weight: 600;
}

/* Code block wrapper with copy button and language label */
.code-block-wrapper {
    position: relative;
    margin-bottom: 1rem;
}
.code-lang-label {
    position: absolute;
    top: 0;
    left: 0;
    font-family: var(--font-mono);
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.2rem 0.6rem;
    background: var(--accent);
    color: #fff;
    border-radius: 0 0 var(--radius) 0;
    z-index: 2;
    font-weight: 600;
}
.code-copy-btn {
    position: absolute;
    top: 0.4rem;
    right: 0.4rem;
    font-family: var(--font-sans);
    font-size: 0.7rem;
    font-weight: 500;
    padding: 0.2rem 0.6rem;
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-muted);
    border: 1px solid var(--border);
    border-radius: 4px;
    cursor: pointer;
    z-index: 2;
    transition: all var(--transition);
    backdrop-filter: blur(4px);
}
.code-copy-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    color: var(--text);
}

.markdown-body pre {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    overflow-x: auto;
    margin-bottom: 0;
    font-size: 0.85rem;
}
.code-block-wrapper .markdown-body pre,
.code-block-wrapper pre {
    margin-bottom: 0;
}
.markdown-body pre code {
    font-family: var(--font-mono);
    background: none;
    padding: 0;
    border: none;
    font-size: inherit;
    color: inherit;
}
.markdown-body code {
    font-family: var(--font-mono);
    background: var(--bg3);
    border: 1px solid var(--border);
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-size: 0.85em;
    color: var(--accent-green);
}

/* Better blockquote styling */
.markdown-body blockquote {
    border-left: 4px solid var(--accent-green);
    padding: 0.75rem 1.25rem;
    margin: 1rem 0;
    background: rgba(0, 255, 156, 0.03);
    border-radius: 0 var(--radius) var(--radius) 0;
    color: var(--text-muted);
}
.markdown-body blockquote p {
    margin-bottom: 0;
}
.markdown-body blockquote blockquote {
    border-left-color: var(--accent);
    background: rgba(100, 108, 253, 0.04);
}

/* Better table styling */
.markdown-body table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1rem;
    font-size: 0.9rem;
    border-radius: var(--radius);
    overflow: hidden;
}
.markdown-body th,
.markdown-body td {
    padding: 0.55rem 0.85rem;
    border: 1px solid var(--border);
    text-align: left;
}
.markdown-body th {
    background: var(--bg3);
    font-weight: 600;
    color: var(--text);
    border-bottom: 2px solid var(--accent);
}
.markdown-body tr:nth-child(even) {
    background: rgba(26, 21, 40, 0.4);
}
.markdown-body tr:hover {
    background: rgba(100, 108, 253, 0.06);
}
.markdown-body img {
    max-width: 100%;
    border-radius: var(--radius);
    margin: 0.5rem 0;
}

/* Better horizontal rule */
.markdown-body hr {
    border: none;
    height: 1px;
    margin: 2.5rem 0;
    background: linear-gradient(to right, transparent, var(--accent-green), var(--accent), transparent);
    opacity: 0.4;
}

.markdown-body a {
    color: var(--accent-green);
}

/* Collapsible details/summary */
.markdown-body details {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 1rem;
    overflow: hidden;
}
.markdown-body details summary {
    padding: 0.65rem 1rem;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text);
    background: var(--bg3);
    border-bottom: 1px solid transparent;
    transition: all var(--transition);
    list-style: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.markdown-body details summary::-webkit-details-marker {
    display: none;
}
.markdown-body details summary::before {
    content: '\25B6';
    font-size: 0.65rem;
    color: var(--accent-green);
    transition: transform 0.2s ease;
}
.markdown-body details[open] summary::before {
    transform: rotate(90deg);
}
.markdown-body details summary:hover {
    background: rgba(100, 108, 253, 0.08);
}
.markdown-body details[open] summary {
    border-bottom-color: var(--border);
}
.markdown-body details > *:not(summary) {
    padding: 0 1rem;
}
.markdown-body details > p:first-of-type {
    padding-top: 0.75rem;
}

/* ===== Mermaid Diagrams ===== */
.mermaid-container {
    margin-bottom: 1rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    display: flex;
    justify-content: center;
    overflow-x: auto;
}
.mermaid-rendered {
    display: flex;
    justify-content: center;
}
.mermaid-rendered svg {
    max-width: 100%;
    height: auto;
}

/* ===== Back to Top Button ===== */
.back-to-top {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--accent-green);
    color: #0a0814;
    border: none;
    font-size: 1.2rem;
    font-weight: 700;
    cursor: pointer;
    z-index: 150;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(0, 255, 156, 0.3);
    transition: all var(--transition);
}
.back-to-top:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 28px rgba(0, 255, 156, 0.45);
    background: #33ffb1;
}

/* ===== Fullscreen Mode ===== */
body.fullscreen-mode .topbar {
    display: none;
}
body.fullscreen-mode .sidebar {
    display: none;
}
body.fullscreen-mode .content {
    margin-left: 0;
    margin-top: 0;
    padding: 2rem 3rem;
}
body.fullscreen-mode .note-view {
    max-width: 800px;
    margin: 0 auto;
}

/* ===== Modal ===== */
.modal {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.15s ease;
}
.modal[hidden] {
    display: none;
}
.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
}
.modal-small .modal-card {
    position: relative;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.75rem;
    width: 100%;
    max-width: 420px;
    z-index: 1;
}
.modal-card h3 {
    margin-bottom: 1.25rem;
    font-size: 1.1rem;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ===== Editor ===== */
.editor-container {
    position: relative;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 12px;
    width: 95vw;
    height: 90vh;
    max-width: 1400px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 1;
}
.editor-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.25rem;
    border-bottom: 1px solid var(--border);
    background: var(--card);
}
.editor-topbar h2 {
    font-size: 1rem;
    font-weight: 600;
}
.editor-topbar-actions {
    display: flex;
    gap: 0.5rem;
}
.editor-fields {
    display: flex;
    gap: 1rem;
    padding: 1rem 1.25rem 0;
}
.editor-fields .form-group {
    flex: 1;
    margin-bottom: 0.5rem;
}
.editor-split {
    display: flex;
    flex: 1;
    overflow: hidden;
}
.editor-pane {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.editor-pane + .editor-pane {
    border-left: 1px solid var(--border);
}
.pane-label {
    padding: 0.4rem 1.25rem;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    font-weight: 600;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
}
#editor-textarea {
    flex: 1;
    resize: none;
    border: none;
    border-radius: 0;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    line-height: 1.6;
    padding: 1rem 1.25rem;
    background: var(--bg);
}
#editor-textarea:focus {
    box-shadow: none;
    border: none;
}
#editor-preview {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 1.25rem;
}

/* ===== Admin Panel ===== */
.admin-container {
    position: relative;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 12px;
    width: 90vw;
    max-width: 700px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 1;
}
.admin-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.25rem;
    border-bottom: 1px solid var(--border);
    background: var(--card);
}
.admin-topbar h2 {
    font-size: 1rem;
    font-weight: 600;
}
.admin-sections {
    overflow-y: auto;
    padding: 1.25rem;
}
.admin-section {
    margin-bottom: 2rem;
}
.admin-section:last-child {
    margin-bottom: 0;
}
.admin-section h3 {
    font-size: 0.95rem;
    margin-bottom: 1rem;
    color: var(--text);
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}
.admin-form {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
}

/* Users List */
.users-list,
.categories-list {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}
.user-item,
.category-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 0.85rem;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.85rem;
}
.user-item .user-info {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

/* ===== Toast ===== */
.toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 999;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.toast {
    padding: 0.65rem 1.25rem;
    border-radius: var(--radius);
    font-size: 0.85rem;
    font-weight: 500;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
    animation: toastIn 0.3s ease forwards;
    max-width: 360px;
}
.toast.success {
    background: rgba(0, 255, 156, 0.12);
    border: 1px solid rgba(0, 255, 156, 0.3);
    color: var(--accent-green);
}
.toast.error {
    background: rgba(255, 71, 87, 0.12);
    border: 1px solid rgba(255, 71, 87, 0.3);
    color: #ff4757;
}
.toast.info {
    background: rgba(100, 108, 253, 0.12);
    border: 1px solid rgba(100, 108, 253, 0.3);
    color: var(--accent);
}
.toast.fade-out {
    animation: toastOut 0.3s ease forwards;
}
@keyframes toastIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes toastOut {
    from { opacity: 1; transform: translateY(0); }
    to { opacity: 0; transform: translateY(10px); }
}

/* ===== Mobile Responsive ===== */
@media (max-width: 768px) {
    .hamburger {
        display: flex;
    }
    .topbar-left {
        min-width: auto;
    }
    .topbar-logo {
        font-size: 1rem;
    }
    .topbar-center {
        display: none;
    }
    .topbar-right .user-display {
        display: none;
    }
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .sidebar-overlay.active {
        display: block;
    }
    .content {
        margin-left: 0;
        padding: 1.25rem;
    }
    .note-title {
        font-size: 1.3rem;
    }
    .note-header {
        flex-direction: column;
    }
    .note-actions {
        align-self: flex-end;
    }
    .editor-container {
        width: 100vw;
        height: 100vh;
        border-radius: 0;
    }
    .editor-split {
        flex-direction: column;
    }
    .editor-pane + .editor-pane {
        border-left: none;
        border-top: 1px solid var(--border);
    }
    .editor-fields {
        flex-direction: column;
        gap: 0;
    }
    .form-row {
        flex-direction: column;
        gap: 0;
    }
    .note-breadcrumb {
        font-size: 0.75rem;
    }
    #fullscreen-btn {
        display: none;
    }
}

@media (max-width: 480px) {
    .topbar-right .admin-badge,
    .topbar-right #admin-toggle-btn {
        display: none;
    }
}

/* ===== Print Styles ===== */
@media print {
    body {
        background: #fff;
        color: #000;
    }
    .topbar,
    .sidebar,
    .sidebar-overlay,
    .back-to-top,
    .note-actions,
    .toast-container,
    #fullscreen-btn,
    .note-breadcrumb,
    .code-copy-btn,
    .code-lang-label {
        display: none !important;
    }
    .content {
        margin-left: 0;
        margin-top: 0;
        padding: 0;
    }
    .note-view {
        max-width: 100%;
    }
    .markdown-body {
        color: #000;
    }
    .markdown-body h1,
    .markdown-body h2,
    .markdown-body h3,
    .markdown-body h4 {
        color: #222;
    }
    .markdown-body pre {
        background: #f4f4f4;
        border-color: #ccc;
    }
    .markdown-body code {
        background: #f4f4f4;
        color: #333;
        border-color: #ccc;
    }
    .markdown-body blockquote {
        border-left-color: #666;
        background: #f9f9f9;
        color: #444;
    }
    .markdown-body table th {
        background: #eee;
        color: #000;
    }
    .markdown-body table td,
    .markdown-body table th {
        border-color: #ccc;
    }
    .markdown-body a {
        color: #0066cc;
    }
    .note-toc {
        border: 1px solid #ccc;
        background: #f9f9f9;
        padding: 1rem;
        break-inside: avoid;
    }
    .note-title {
        color: #000;
    }
    .note-meta {
        color: #666;
    }
}
