body {
    background: #f6f8fb;
    color: #182230;
    -webkit-font-smoothing: antialiased;
}

.app-shell { display: flex; min-height: 100vh; }
.app-sidebar { position: fixed; inset: 0 auto 0 0; z-index: 20; display: flex; width: 260px; overflow: hidden; flex-direction: column; background: #fff; }
.app-main { flex: 1 1 0; min-width: 0; margin-left: 260px; }
.app-content { max-width: 1280px; padding: 2.5rem; }
.brand-mark { width: 38px; height: 38px; }
.brand-mark svg { width: 22px; height: 22px; }
.app-sidebar-header { display: flex; align-items: center; justify-content: space-between; flex: 0 0 auto; }
.app-sidebar-nav { flex: 0 0 auto; gap: .125rem !important; margin-top: 1rem; }
.app-nav-link { display: flex; align-items: center; gap: .75rem; width: 100%; min-height: 40px; padding: .5rem .7rem; border-radius: .65rem; color: #5d6877; font-weight: 500; text-align: left; text-decoration: none; transition: background .15s, color .15s; }
.app-nav-link:hover, .app-nav-link.active { color: #3659d6; background: #eef1ff; }
.app-nav-link.active { box-shadow: inset 3px 0 #435dde; }
.app-nav-link:focus-visible, .sidebar-note:focus-visible, .sidebar-close-button:focus-visible, .mobile-icon-button:focus-visible { outline: 3px solid rgba(67, 93, 222, .55); outline-offset: 2px; }
.app-nav-icon { width: 1.15rem; height: 1.15rem; flex: 0 0 1.15rem; }
.sidebar-close-button, .mobile-icon-button { display: inline-flex; width: 44px; height: 44px; align-items: center; justify-content: center; padding: .5rem; }
.sidebar-close-button svg, .mobile-icon-button > svg { width: 1.25rem; height: 1.25rem; }
.mobile-icon-button .theme-icon { display: inline-flex; }
.theme-icon { display: inline-flex; width: 1.15rem; height: 1.15rem; align-items: center; justify-content: center; }
.theme-icon svg { width: 100%; height: 100%; }
.theme-icon-sun { display: none; }
.theme-dark .theme-icon-moon { display: none; }
.theme-dark .theme-icon-sun { display: block; }
.sidebar-backdrop { position: fixed; inset: 0; z-index: 19; display: block; border: 0; background: rgba(13, 20, 33, .55); }
.sidebar-backdrop[hidden] { display: none !important; }
.sidebar-open { overflow: hidden; }
.app-mobile-header { position: sticky; top: 0; z-index: 8; min-height: 64px; }
.app-mobile-header .brand-mark { width: 34px; height: 34px; }
.app-mobile-header .brand-mark svg { width: 20px; height: 20px; }
.sidebar-notes-section, .sidebar-notes { min-height: 0; }
.sidebar-notes-section { display: flex; flex: 1 1 0; flex-direction: column; margin-top: .75rem; }
.sidebar-notes-heading .min-width-0 { min-width: 0; }
.sidebar-notes-back { display: none; width: 36px; height: 36px; flex: 0 0 36px; align-items: center; justify-content: center; padding: 0; border: 0; border-radius: .5rem; color: #5d6877; background: transparent; }
.sidebar-notes-back:hover { color: #3659d6; background: #eef1ff; }
.sidebar-notes-back svg { width: 1.1rem; height: 1.1rem; }
.sidebar-notes-open { padding: .3rem .55rem; border: 1px solid #d8deea; border-radius: .5rem; color: #3659d6; background: transparent; font-size: .8rem; font-weight: 600; white-space: nowrap; }
.sidebar-notes-open:hover { background: #eef1ff; }
.sidebar-note-search { position: relative; flex: 0 0 auto; margin: 0 .5rem .5rem; }
.sidebar-note-search > svg { position: absolute; top: 50%; left: .7rem; width: 1rem; height: 1rem; color: #7b8797; transform: translateY(-50%); pointer-events: none; }
.sidebar-note-search .form-control { min-width: 0; min-height: 36px; padding-left: 2.1rem; border-radius: .55rem; }
.sidebar-notes { flex: 1 1 0; overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; }
.sidebar-actions { flex: 0 0 auto; margin-top: auto; padding-top: 1rem; }
.sidebar-note { display: block; flex: none; width: 100%; padding: .5rem .75rem; border-radius: .5rem; color: #687383; font-size: .9rem; }
.sidebar-note:hover { color: #3659d6; background: #f1f3f6; }
.sidebar-note:focus-visible, .sidebar-notes-back:focus-visible, .sidebar-notes-open:focus-visible { outline: 3px solid rgba(67, 93, 222, .55); outline-offset: 2px; }
.home-card, .stat-card, .note-card, .note-detail { border: 1px solid #e4e8ef; border-radius: 1rem; background: #fff; }
.home-card { padding: 1.75rem; color: #182230; transition: transform .15s, box-shadow .15s; }
.home-card:hover { transform: translateY(-3px); box-shadow: 0 .5rem 1.5rem rgba(40, 55, 85, .1); }
.home-card-primary { color: #fff; background: #435dde; border-color: #435dde; }
.home-card-primary:hover { color: #fff; box-shadow: 0 .75rem 1.75rem rgba(67, 93, 222, .25); }
.stat-card { padding: 1.25rem; }
.home-heading { margin-bottom: .25rem; }
.home-search { display: flex; align-items: center; gap: .75rem; padding: .65rem .75rem; border: 1px solid #d8deea; border-radius: .85rem; background: #fff; transition: border-color .15s, box-shadow .15s; }
.home-search:focus-within { border-color: #8293ef; box-shadow: 0 0 0 .2rem rgba(67, 93, 222, .12); }
.home-search > svg { width: 1.25rem; height: 1.25rem; flex: 0 0 1.25rem; margin-left: .25rem; color: #7b8797; }
.home-search .form-control { min-width: 0; border: 0; background: transparent; box-shadow: none; }
.stat-card-link { color: #182230; transition: transform .15s, box-shadow .15s, border-color .15s; }
.stat-card-link:hover { color: #182230; border-color: #c7d0e0; box-shadow: 0 .35rem 1rem rgba(40, 55, 85, .08); transform: translateY(-2px); }
.stat-card-link:focus-visible, .home-search:focus-within, .home-note-list a:focus-visible { outline: 3px solid rgba(67, 93, 222, .45); outline-offset: 2px; }
.home-note-list { overflow: hidden; border: 1px solid #e4e8ef; border-radius: 1rem; background: #fff; }
.home-note-row { min-width: 0; padding: 1.1rem 1.25rem; }
.home-note-row + .home-note-row { border-top: 1px solid #e8ebf1; }
.home-note-title { min-width: 0; overflow-wrap: anywhere; }
.home-note-preview { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; overflow-wrap: anywhere; white-space: pre-line; }
.home-empty-state { border-style: solid; }
.note-card { min-width: 0; transition: transform .15s, box-shadow .15s; }
.note-card:hover { transform: translateY(-2px); box-shadow: 0 .5rem 1.25rem rgba(40, 55, 85, .1) !important; }
.note-card .card-body, .note-card h2 { min-width: 0; }
.note-excerpt { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden; overflow-wrap: anywhere; white-space: pre-line; }
.empty-state { padding: 3rem 1rem; border: 1px dashed #b8c1ce; border-radius: 1rem; background: #fff; color: #687383; text-align: center; }
.attachment-row { color: #3659d6; background: #f4f6f9; }
.attachment-row:hover { background: #e9edff; }
.markdown-body p { margin: 1rem 0; }
.markdown-body h1, .markdown-body h2, .markdown-body h3 { margin: 1.5rem 0 .75rem; font-weight: 700; }
.markdown-body pre { overflow: auto; padding: 1rem; border-radius: .5rem; background: #e9edf3; }
.markdown-body code { padding: .15rem .3rem; border-radius: .25rem; background: #e9edf3; }
.markdown-body a { color: #3659d6; text-decoration: underline; }
.auth-page { min-height: 100vh; background: #f6f8fb; }
.auth-wrap { width: 100%; max-width: 440px; margin: 2rem auto 0; }
.auth-alert { max-width: 440px; }
.auth-card { border: 1px solid #e4e8ef; border-radius: 1rem; background: #fff; }
.letter-spacing { letter-spacing: .12em; }

.theme-dark { color-scheme: dark; }
.theme-dark body, .theme-dark .auth-page { background: #121722; color: #e9edf5; }
.theme-dark .app-sidebar, .theme-dark .app-main > header, .theme-dark .card, .theme-dark .home-card, .theme-dark .stat-card, .theme-dark .note-card, .theme-dark .note-detail, .theme-dark .auth-card, .theme-dark .empty-state, .theme-dark .list-group-item, .theme-dark .page-link { color: #e9edf5; background: #1b2230 !important; border-color: #303b4d; }
.theme-dark .home-card-primary { color: #fff !important; background: #435dde !important; border-color: #435dde; }
.theme-dark .text-body, .theme-dark .home-card:not(.home-card-primary) h2, .theme-dark .home-card:not(.home-card-primary) { color: #e9edf5 !important; }
.theme-dark .home-search, .theme-dark .home-note-list, .theme-dark .home-empty-state { color: #e9edf5; background: #1b2230; border-color: #303b4d; }
.theme-dark .home-search .form-control { color: #e9edf5; }
.theme-dark .stat-card-link, .theme-dark .stat-card-link:hover { color: #e9edf5; }
.theme-dark .home-note-row + .home-note-row { border-color: #303b4d; }
.theme-dark .text-secondary, .theme-dark .form-text { color: #aab5c6 !important; }
.theme-dark .app-nav-link, .theme-dark .sidebar-note { color: #aab5c6; }
.theme-dark .app-nav-link:hover, .theme-dark .app-nav-link.active, .theme-dark .sidebar-note:hover { color: #b9c5ff; background: #29334a; }
.theme-dark .sidebar-notes-back { color: #aab5c6; }
.theme-dark .sidebar-notes-back:hover { color: #b9c5ff; background: #29334a; }
.theme-dark .sidebar-notes-open { color: #b9c5ff; border-color: #445167; }
.theme-dark .sidebar-notes-open:hover { background: #29334a; }
.theme-dark .form-control, .theme-dark .form-select { color: #e9edf5; background-color: #202a3a; border-color: #445167; }
.theme-dark .form-control::placeholder { color: #8995a8; }
.theme-dark .list-group-item-action:hover, .theme-dark .list-group-item-action:focus, .theme-dark .page-link:hover, .theme-dark .page-link:focus { color: #b9c5ff; background: #29334a !important; }
.theme-dark .page-item.active .page-link { color: #fff; background: #435dde !important; border-color: #435dde; }
.theme-dark .bg-light, .theme-dark .attachment-row { color: #e9edf5 !important; background-color: #263143 !important; }
.theme-dark .attachment-row:hover { background: #303d55 !important; }
.theme-dark .markdown-body pre, .theme-dark .markdown-body code { background: #263143; }

@media (max-width: 767.98px) {
    .app-main { margin-left: 0; }
    .app-sidebar { width: min(20rem, calc(100vw - 3rem)); padding-top: 1rem !important; padding-bottom: 1rem !important; box-shadow: 0 1rem 3rem rgba(13, 20, 33, .2); transform: translateX(-105%); visibility: hidden; transition: transform .22s ease, visibility 0s linear .22s; }
    .app-sidebar.is-open { transform: translateX(0); visibility: visible; transition-delay: 0s; }
    .app-sidebar-nav { margin-top: .85rem; }
    .sidebar-notes-section { margin-top: .75rem; }
    .sidebar-note-search { display: none; }
    .app-sidebar.notes-view-open .app-sidebar-nav, .app-sidebar.notes-view-open .sidebar-actions { display: none !important; }
    .app-sidebar.notes-view-open .sidebar-notes-section { margin-top: .75rem; }
    .app-sidebar.notes-view-open .sidebar-notes-back { display: inline-flex; }
    .app-sidebar.notes-view-open .sidebar-notes-open { display: none; }
    .app-sidebar.notes-view-open .sidebar-note-search { display: block; }
    .app-sidebar.notes-view-open .sidebar-notes { flex: 1 1 0; }
    .app-content { padding: 1rem; }
}

@media (prefers-reduced-motion: reduce) {
    .app-sidebar { transition: none; }
}
