:root {
    --page-bg: #f4f8fd;
    --panel: #ffffff;
    --blue: #0878f9;
    --blue-hover: #0666d9;
    --text: #142b50;
    --muted: #6683ad;
    --border: #dfebfa;
    --soft-blue: #eaf3ff;
    --nav: #202020;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-height: 100vh;
    background: var(--page-bg);
    color: var(--text);
    font-family: Arial, Helvetica, sans-serif;
    font-size: 14px;
}

button, input, textarea { font: inherit; }
button { cursor: pointer; }

button:focus-visible {
    outline: 2px solid #78b5ff;
    outline-offset: 2px;
}

.title-field:focus,
.note-content:focus {
    outline: none !important;
}

/* APP LAYOUT — accommodates fixed sidebar and navbar */

.app {
    display: grid;
    grid-template-columns: 413px minmax(0, 1fr);
    gap: 16px;
    max-width: 1800px;
    min-height: 100vh;
    margin: 0 0 0 55px;
    padding-right: 20px;
}

/* SIDEBAR — supplied styling */

aside.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    background-color: #202020;
    min-height: 100vh;
    width: 55px;
    align-items: center;
    justify-content: flex-start;
    padding-left: 10px;
}

.logo {
    padding-bottom: 25%;
}

.logo i {
    color: blue;
    font-size: 30px;
    font-weight: 1000;
}

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

.list-items ul li a,
.profile ul li a {
    color: white;
    text-decoration: none;
    line-height: 30px;
    font-size: 16px;
    padding-left: 8px;
}

.sidebar-list {
    width: 100%;
}

.sidebar-list ul li {
    line-height: 30px;
}

.profile {
    position: absolute;
    bottom: 0;
}

.sidebar .profile ul li a {
    display: inline-block;
}

/* NAVBAR — supplied styling */

nav {
    grid-column: 1 / -1;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color:  #7e7e7e;
    padding: 0.1rem 1rem;
    margin-bottom: 0.5%;
    min-height: 48px;
}

nav h1 {
    font-size: 1.2rem;
    color: #fff;
    margin: 0.67em 0;
}

nav button {
    background-color: #333;
    color: #fff;
    border-radius: 5px;
    border: none;
    padding: 0.4rem 0.8rem;
    cursor: pointer;
}

.nav-links {
    display: flex;
    align-items: center;
}

/* NOTES LIST */

.notes-panel {
    min-width: 0;
    align-self: start;
    min-height: 100vh;
    padding: 30px 15px 26px;
    background: #fff;
    border-radius: 0 0 12px 12px;
    box-shadow: 0 3px 15px rgba(42,82,135,.04);
}

.notes-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin: 5px 5px 13px;
}

.notes-heading h2 {
    margin: 0;
    font-size: 25px;
    letter-spacing: -.5px;
}

.new-note-button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    flex-shrink: 0;
    padding: 11px 14px;
    border: 0;
    border-radius: 9px;
    background: var(--blue);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
}

.new-note-button:hover,
.save-button:hover { background: var(--blue-hover); }

.search-box {
    position: relative;
    margin: 0 5px 18px;
}

.search-icon {
    position: absolute;
    top: 50%;
    left: 13px;
    transform: translateY(-50%);
    color: #6584ad;
    font-size: 19px;
    pointer-events: none;
}

.search-box input {
    width: 100%;
    height: 42px;
    padding: 0 13px 0 40px;
    border: 1px solid #d8e6fa;
    border-radius: 10px;
    outline: none;
    background: white;
    color: var(--text);
}

.search-box input:focus { border-color: #80b7ff; }
.search-box input::placeholder { color: #6886b0; }

.filters {
    display: flex;
    align-items: center;
    gap: 7px;
    margin: 0 5px 19px;
    overflow-x: auto;
    scrollbar-width: none;
}

.filters::-webkit-scrollbar { display: none; }

.filter-button {
    flex-shrink: 0;
    padding: 10px 13px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: #5275a5;
    white-space: nowrap;
    font-size: 12px;
}

.filter-button.active {
    background: var(--blue);
    color: white;
}

.note-list {
    display: flex;
    flex-direction: column;
    gap: 12px;

    /* Added: limit height and scroll through notes */
    max-height: 60vh;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: #c5d8f0 transparent;
}

.note-list::-webkit-scrollbar {
    width: 6px;
}

.note-list::-webkit-scrollbar-track {
    background: transparent;
}

.note-list::-webkit-scrollbar-thumb {
    background: #c5d8f0;
    border-radius: 10px;
}

.note-list::-webkit-scrollbar-thumb:hover {
    background: #8fb7e8;
}

.note-card {
    padding: 17px 16px 15px;
    border: 1px solid #e0ebfa;
    border-radius: 12px;
    background: #fff;
    cursor: pointer;
    transition: border-color .15s, background .15s;
}

.note-card:hover {
    border-color: #9cc6ff;
    background: #fbfdff;
}

.note-card.active {
    border: 1px solid #3787ff;
    background: #f0f6ff;
}

.note-card-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
}

.note-card h3 {
    overflow: hidden;
    margin: 0 0 8px;
    color: #142b50;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.4;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.note-preview {
    display: -webkit-box;
    overflow: hidden;
    margin: 0 0 11px;
    color: #6483b0;
    font-size: 13px;
    line-height: 1.6;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.note-card-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 7px;
    color: #6583ad;
    font-size: 11px;
}

/* CATEGORY DOT COLORS AND DROPDOWN */

.category-dot {
    background: #000000;
}

.category-dot.analysis {
    background: #16b85a;
}

.category-dot.lessons {
    background: #ffd21f;
}

.category-dot.none {
    background: #000000;
}

.category-dot.category-clickable {
    cursor: pointer;
    outline: none;
}

.category-dot.category-clickable:hover {
    transform: scale(1.25);
}

.category-label {
    position: relative;
}

.category-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    z-index: 1001;
    display: none;
    min-width: 145px;
    padding: 5px;
    border: 1px solid #dfebfa;
    border-radius: 10px;
    background: #ffffff;
    box-shadow: 0 8px 24px rgba(20, 43, 80, 0.15);
}

.category-dropdown.open {
    display: block;
}

.category-option {
    display: flex;
    align-items: center;
    gap: 9px;
    width: 100%;
    padding: 10px;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: #142b50;
    text-align: left;
    font-size: 13px;
}

.category-option:hover {
    background: #eaf3ff;
}

.category-option .category-dot {
    width: 9px;
    height: 9px;
    flex-shrink: 0;
}

.category-dot {
    display: inline-block;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #0878f9;
    flex-shrink: 0;
}

.category-dot.analysis { background: #16b85a; }
.category-dot.lessons { background: #ff9417; }
.category-dot.rules { background: #8b42ed; }
.category-dot.ideas { background: #12b9d1; }

.note-menu-button {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 25px;
    height: 25px;
    margin: -5px -5px 0 0;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: #5177a7;
    font-size: 20px;
}

.note-menu-button:hover { background: #e2edfc; }

.empty-notes {
    padding: 35px 12px;
    color: var(--muted);
    text-align: center;
    line-height: 1.7;
}

/* EDITOR */

.editor-panel {
    display: flex;
    flex-direction: column;
    min-width: 0;
    height: calc(100vh - 42px);
    min-height: 720px;
    margin: 21px 0;
    padding: 0 22px 17px;
    background: #fff;
    border: 1px solid #e3edfa;
    border-radius: 12px;
    box-shadow: 0 3px 15px rgba(42,82,135,.035);
}

.editor-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    padding: 19px 0 15px;
}

.editor-header-left,
.editor-header-right {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.back-button {
    padding: 0;
    border: 0;
    background: transparent;
    color: #406795;
    font-size: 14px;
}

.back-button:hover { color: var(--blue); }

.note-date {
    color: #5f80ad;
    font-size: 12px;
}

.category-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 20px;
    background: #f0f6ff;
    color: #0878f9;
    font-size: 12px;
}

.title-field {
    width: 100%;
    min-width: 0;
    padding: 1px 4px 15px;
    border: 0;
    border-bottom: 1px solid #dfebfa;
    border-radius: 0;
    outline: none;
    background: transparent;
    color: #142b50;
    font-size: clamp(22px, 2vw, 29px);
    font-weight: 700;
    letter-spacing: -.6px;
}

.title-field::placeholder { color: #9aacc4; }

.note-content {
    flex: 1;
    width: 100%;
    min-height: 0;
    padding: 20px 8px 12px;
    overflow-y: auto;
    border: 0;
    border-radius: 0;
    outline: none;
    background: transparent;
    color: #23436f;
    font-size: 15px;
    line-height: 1.85;
    overflow-wrap: anywhere;
    scrollbar-width: thin;
    scrollbar-color: #d9e6f7 transparent;
}

.note-content:empty::before {
    content: "Start writing your note...";
    color: #91a5c2;
    pointer-events: none;
}

.note-content h2,
.note-content h3 {
    color: #142b50;
    line-height: 1.4;
}

.note-content h2 { font-size: 19px; }
.note-content h3 { font-size: 16px; }
.note-content p { margin: 0 0 14px; }
.note-content ul, .note-content ol { padding-left: 25px; }

.note-content blockquote {
    margin: 24px 0;
    padding: 5px 0 5px 17px;
    border-left: 4px solid var(--blue);
    color: #5278a8;
    font-style: italic;
}

.note-content a { color: var(--blue); }
.note-content img { max-width: 100%; }

/* BOTTOM TOOLBAR */

.editor-bottom {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 12px;
}

.format-toolbar {
    display: flex;
    align-items: center;
    flex: 1;
    min-width: 0;
    gap: 5px;
    padding: 7px 9px;
    border: 1px solid #e2edfc;
    border-radius: 10px;
    background: #f8fbff;
}

.tool-button {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    min-width: 35px;
    height: 34px;
    padding: 0 8px;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: #18365f;
    font-size: 18px;
}

.tool-button:hover,
.tool-button.active {
    background: #e6f1ff;
    color: var(--blue);
}

.tool-button:disabled {
    opacity: .35;
    cursor: not-allowed;
}

.tool-button.bold {
    font-size: 21px;
    font-weight: bold;
}

.tool-button.italic {
    font-family: Georgia, serif;
    font-size: 21px;
    font-style: italic;
}

.tool-button.underline {
    font-size: 20px;
    text-decoration: underline;
}

.tool-divider {
    width: 1px;
    height: 24px;
    margin: 0 4px;
    background: #d8e5f7;
    flex-shrink: 0;
}

.tool-spacer { flex: 1; }

.menu-wrap {
    position: relative;
    flex-shrink: 0;
}

.more-button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 48px;
    border: 1px solid transparent;
    border-radius: 10px;
    background: transparent;
    color: #31527c;
    font-size: 23px;
}

.more-button:hover,
.more-button.active {
    background: #eaf3ff;
    border-color: #dceaff;
    color: var(--blue);
}

.menu-popup {
    position: absolute;
    right: 0;
    bottom: calc(100% + 8px);
    z-index: 20;
    display: none;
    width: 190px;
    padding: 6px;
    border: 1px solid #dce8f8;
    border-radius: 10px;
    background: #fff;
    box-shadow: 0 8px 25px rgba(30,65,110,.13);
}

.menu-popup.open { display: block; }

.menu-popup button {
    display: block;
    width: 100%;
    padding: 10px 11px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: #29496f;
    text-align: left;
    font-size: 13px;
}

.menu-popup button:hover {
    background: #edf5ff;
    color: var(--blue);
}

/* FOOTER ACTIONS */

.editor-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 18px;
}

.save-status {
    flex: 1;
    overflow: hidden;
    color: #7290b6;
    font-size: 11px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.action-button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 11px 14px;
    border: 1px solid #deebfb;
    border-radius: 9px;
    background: #fff;
    color: #46678f;
    font-size: 13px;
}

.action-button:hover { background: #f1f7ff; }

.save-button {
    border-color: var(--blue);
    background: var(--blue);
    color: white;
    font-weight: 600;
}

.save-button:hover { color: white; }

/* FULL-SCREEN EDITOR MODE */

.app.fullscreen-mode {
    display: block;
    width: 100%;
    max-width: none;
    min-height: 100vh;
    margin: 0;
    padding: 0;
}

.fullscreen-mode .sidebar,
.fullscreen-mode .notes-panel,
.fullscreen-mode nav {
    display: none;
}

.fullscreen-mode .editor-panel {
    width: 100%;
    height: 100vh;
    min-height: 0;
    margin: 0;
    padding: 0 5vw 22px;
    border: 0;
    border-radius: 0;
    box-shadow: none;
}

.fullscreen-mode .editor-header {
    padding-top: 22px;
}

.fullscreen-mode .note-content {
    padding: 28px 8px 20px;
    font-size: 16px;
    line-height: 1.95;
}

.fullscreen-mode .title-field {
    font-size: 32px;
}

.fullscreen-mode .editor-bottom {
    margin-top: 15px;
}

.fullscreen-mode .editor-actions {
    margin-bottom: 4px;
}



.note-options-wrap {
    position: relative;
    flex-shrink: 0;
}

.note-menu-button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: inherit;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
}

.note-menu-button:hover,
.note-menu-button[aria-expanded="true"] {
    background: #eef3f9;
}

.note-options-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 5px);
    right: 0;
    z-index: 1000;
    width: 165px;
    padding: 5px;
    background: #ffffff;
    border: 1px solid #e1e7ef;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.14);
}

.note-options-dropdown.open {
    display: block;
}

.note-options-dropdown button {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 11px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: #202b3c;
    font: inherit;
    font-size: 14px;
    text-align: left;
    cursor: pointer;
}

.note-options-dropdown button:hover {
    background: #f1f5f9;
}

.note-option-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 17px;
    color: #64748b;
    font-size: 16px;
}

.note-options-dropdown .note-option-delete {
    color: #dc2626;
}

.note-options-dropdown .note-option-delete .note-option-icon {
    color: #dc2626;
}

.note-options-dropdown .note-option-delete:hover {
    background: #fef2f2;
}


/* INLINE NOTE IMAGES */

.note-content .note-image-block {
    display: block;
    width: min(100%, 680px);
    max-width: 100%;
    margin: 18px 0;
    padding: 0;
    overflow: auto;
    resize: horizontal;
    border: 1px solid transparent;
    border-radius: 9px;
    line-height: 0;
}

.note-content .note-image-block:hover {
    border-color: #dce8f8;
}

.note-content .note-image-block img {
    display: block;
    width: 100%;
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    object-fit: contain;
}

.note-content .note-image-block img[src=""] {
    display: none;
}

.note-content .note-image-block + p {
    min-height: 1em;
}

#insertImageButton:disabled {
    opacity: .4;
    cursor: not-allowed;
}

@media (max-width: 760px) {
    .note-content .note-image-block {
        width: 100%;
        resize: none;
    }
}



/* TABLET */

@media (min-width: 1500px) {
    .app {
        grid-template-columns: 430px minmax(0,1fr);
        gap: 18px;
        padding-right: 24px;
    }

    .notes-panel {
        padding-right: 17px;
        padding-left: 17px;
    }

    .editor-panel {
        padding-right: 26px;
        padding-left: 26px;
    }
}

@media (max-width: 1100px) and (min-width: 761px) {
    .app {
        grid-template-columns: 320px minmax(0,1fr);
        gap: 10px;
        padding-right: 10px;
    }

    .notes-panel {
        padding-right: 10px;
        padding-left: 10px;
    }

    .editor-panel {
        padding-right: 15px;
        padding-left: 15px;
    }

    .tool-button {
        min-width: 30px;
        padding: 0 5px;
    }

    .format-toolbar {
        gap: 2px;
        padding: 6px;
    }

    .tool-divider { margin: 0 2px; }
    .editor-header-right { gap: 7px; }
}

/* MOBILE */

@media (max-width: 760px) {

    .app {
    display: flex;
    flex-direction: column;
    gap: 0;
    min-height: 100vh;
    margin: 0;
    padding: 0 0 40px;
    }

    aside.sidebar {
        position: fixed;
        bottom: 0;
        top: unset;
        left: 0;
        width: 100%;
        height: 65px;
        min-height: unset;
        background-color: #202020;
        display: flex;
        flex-direction: row;
        align-items: center;
        justify-content: flex-start;
        padding: 0;
        z-index: 1000;
    }

    /* MOBILE SIDEBAR LAYOUT */

    .sidebar-list {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: center;
        width: 100%;
        height: 100%;
        padding:0 12px;
        gap: 12px;
    }

    .list-items {
        min-width: 0;
        width: 100%;
    }

    .list-items ul {
        display: flex;
        align-items: center;
        justify-content: space-evenly;
        width: 100%;
        gap: 0;
        margin: 0;
        padding: 0;
    }

    .list-items ul li,
    .profile ul li {
        list-style: none;
    }

    .list-items ul li a,
    .profile ul li a {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 44px;
        height: 44px;
        padding: 0;
        color: white;
        text-decoration: none;
    }

    .list-items ul li i,
    .profile ul li i {
        font-size: 1.7rem;
    }

    .logo {
        display: none;
        padding: 0;
    }

    .profile {
        position: static;
        margin: 0;
        padding: 0;
        flex-shrink: 0;
    }

    .profile ul {
        display: flex;
        align-items: center;
        justify-content: center;
        margin: 0;
        padding: 0;
    }

    .d {
        display: none;
    }

    /* NAVBAR */

    nav {
        padding: 0.1rem 1rem;
        margin-bottom: 0;
    }

    /* NOTES PANEL */

    .notes-panel {
        min-height: auto;
        padding: 18px 14px 15px;
        border-radius: 0;
        border-bottom: 1px solid #e1ebf9;
    }

    .notes-heading {
        margin-top: 0;
    }

    .notes-heading h2 {
        font-size: 23px;
    }

    .search-box {
        margin-bottom: 12px;
    }

    .filters {
        margin-bottom: 13px;
    }

    .note-list {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    .note-card {
        min-width: 0;
        padding: 12px 10px;
    }

    .note-card h3 {
        font-size: 12px;
    }

    .note-preview {
        font-size: 11px;
    }

    .note-card-meta {
        gap: 5px;
        font-size: 10px;
    }

    /* EDITOR */

    .editor-panel {
        display: flex;
        height: auto;
        min-height: 75vh;
        margin: 0;
        padding: 0 15px 90px;
        border: 0;
        border-radius: 0;
        box-shadow: none;
    }

    .editor-header {
        padding-top: 17px;
    }

    .title-field {
        font-size: 23px;
    }

    .note-content {
        min-height: 370px;
        padding: 19px 4px 15px;
    }

    .editor-bottom {
        gap: 7px;
    }

    .format-toolbar {
        gap: 1px;
        padding: 5px 3px;
    }

    .tool-button {
        min-width: 29px;
        height: 33px;
        padding: 0 4px;
        font-size: 16px;
    }

    .tool-button.bold,
    .tool-button.italic {
        font-size: 19px;
    }

    .tool-divider {
        height: 20px;
        margin: 0 1px;
    }

    .more-button {
        width: 34px;
        height: 42px;
    }

    .editor-actions {
        margin-top: 13px;
    }

    /* FULLSCREEN EDITOR */

    .fullscreen-mode .editor-panel {
        height: 100vh;
        min-height: 0;
        padding: 0 16px 14px;
    }

    .fullscreen-mode .editor-header {
        padding-top: 17px;
    }

    .fullscreen-mode .title-field {
        font-size: 25px;
    }

    .fullscreen-mode .note-content {
        min-height: 0;
        padding: 20px 4px 12px;
        font-size: 15px;
    }
}


/* SMALL MOBILE SCREENS */

@media (max-width: 480px) {

    .sidebar-list {
        padding: 0 5px;
        gap: 5px;
    }

    .list-items ul {
        justify-content: space-evenly;
    }

    .list-items ul li a,
    .profile ul li a {
        width: 40px;
        height: 44px;
    }

    .list-items ul li i,
    .profile ul li i {
        font-size: 1.6rem;
    }

    .profile {
        position: static;
        margin: 0;
        padding: 0;
        flex-shrink: 0;
    }

    .profile ul {
        display: flex;
        align-items: center;
        justify-content: center;
        margin: 0;
        padding: 0;
    }

    .logo {
        display: none;
    }

    .d {
        display: none;
    }
}

@media (max-width: 380px) {
    .note-list { grid-template-columns: 1fr; }

    .editor-panel {
        padding-right: 10px;
        padding-left: 10px;
    }

    .format-toolbar {
        gap: 0;
        padding: 4px 2px;
    }

    .tool-button {
        min-width: 25px;
        padding: 0 2px;
    }

    .tool-divider { margin: 0; }

    .action-button { padding: 10px; }

    .fullscreen-mode .editor-panel {
        padding-right: 10px;
        padding-left: 10px;
    }
}
