:root {
    --bg: #f5f6f8;
    --surface: #ffffff;
    --surface-soft: #fafafa;
    --border: #e7e9ee;

    --text: #17191c;
    --text-soft: #686d76;
    --text-muted: #9ca1aa;

    --accent: #111827;
    --accent-hover: #252b36;

    --heading: #6C8CFF;
    --heading-soft: rgba(108, 140, 255, 0.12);

    --danger: #dc2626;
    --danger-soft: #fef2f2;

    --paper: #fffefa;
    --paper-line: #e5e7eb;
    --paper-margin: #f0a0a0;

    --header-height: 64px;
    --footer-height: 56px;

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;

    --shadow-sm:
        0 1px 2px rgba(0, 0, 0, 0.04);

    --shadow-md:
        0 8px 30px rgba(0, 0, 0, 0.08);
}


* {
    box-sizing: border-box;
}


html {
    width: 100%;
    min-height: 100%;
    -webkit-text-size-adjust: 100%;
}


body {
    margin: 0;
    width: 100%;
    min-height: 100dvh;

    background: var(--bg);
    color: var(--text);

    font-family:
        Inter,
        ui-sans-serif,
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;

    overflow-x: hidden;
    overflow-y: auto;
}


button,
input,
textarea {
    font: inherit;
}


button {
    border: 0;
}


button,
a {
    -webkit-tap-highlight-color: transparent;
}


::selection {
    background: rgba(108, 140, 255, 0.18);
}


.app-header {
    background: rgba(255, 255, 255, 0.92);
    border-bottom: 1px solid var(--border);

    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);

    z-index: 50;
}


.brand {
    color: var(--text);
    text-decoration: none;
}


.brand-icon {
    width: 30px;
    height: 30px;

    display: flex;
    align-items: center;
    justify-content: center;

    border-radius: 9px;

    background: #111827;
    color: white;

    font-size: 15px;
    font-weight: 700;

    box-shadow:
        0 4px 10px rgba(17, 24, 39, 0.18);
}


.brand-name {
    font-size: 17px;
    font-weight: 700;
    letter-spacing: -0.03em;
}


.icon-btn {
    width: 38px;
    height: 38px;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    border-radius: 10px;

    background: transparent;
    color: var(--text-soft);

    cursor: pointer;

    transition:
        background 0.2s ease,
        color 0.2s ease,
        transform 0.15s ease;
}


.icon-btn:hover {
    background: #f3f4f6;
    color: var(--text);
}


.icon-btn:active {
    transform: scale(0.94);
}


.header-btn {
    height: 38px;

    padding: 0 14px;

    align-items: center;
    justify-content: center;

    border-radius: 9px;

    background: transparent;
    color: var(--text-soft);

    font-size: 13px;
    font-weight: 600;

    cursor: pointer;

    transition: 0.2s ease;
}


.header-btn:hover {
    background: #f3f4f6;
    color: var(--text);
}


.download-btn {
    height: 38px;

    display: flex;
    align-items: center;
    justify-content: center;

    gap: 7px;

    padding: 0 14px;

    border-radius: 9px;

    background: var(--accent);
    color: white;

    font-size: 13px;
    font-weight: 600;

    cursor: pointer;

    box-shadow:
        0 3px 10px rgba(17, 24, 39, 0.14);

    transition:
        background 0.2s ease,
        transform 0.15s ease,
        box-shadow 0.2s ease;
}


.download-btn:hover {
    background: var(--accent-hover);

    box-shadow:
        0 5px 16px rgba(17, 24, 39, 0.18);
}


.download-btn:active {
    transform: translateY(1px);
}


.sidebar {
    background: #fafbfc;

    border-right: 1px solid var(--border);

    transition:
        transform 0.28s ease,
        box-shadow 0.28s ease;
}


.sidebar-top {
    padding: 22px 16px 16px;
}


.sidebar-label {
    margin: 0 0 3px;

    color: var(--text-muted);

    font-size: 10px;
    font-weight: 700;

    letter-spacing: 0.12em;
}


.sidebar-title {
    margin: 0;

    color: var(--text);

    font-size: 20px;
    font-weight: 700;

    letter-spacing: -0.03em;
}


.new-page-btn {
    height: 42px;

    display: flex;
    align-items: center;
    justify-content: center;

    gap: 8px;

    border-radius: 10px;

    background: white;
    border: 1px solid var(--border);

    color: var(--text);

    font-size: 13px;
    font-weight: 600;

    cursor: pointer;

    box-shadow: var(--shadow-sm);

    transition:
        background 0.2s ease,
        border-color 0.2s ease,
        transform 0.15s ease,
        box-shadow 0.2s ease;
}


.new-page-btn:hover {
    background: #f8f9fa;
    border-color: #d9dce2;

    box-shadow:
        0 4px 12px rgba(0, 0, 0, 0.05);
}


.new-page-btn:active {
    transform: scale(0.98);
}


.pages-list {
    padding: 4px 10px 16px;

    scrollbar-width: thin;
    scrollbar-color: #d8dbe0 transparent;
}


.pages-list::-webkit-scrollbar {
    width: 5px;
}


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


.pages-list::-webkit-scrollbar-thumb {
    background: #d8dbe0;
    border-radius: 20px;
}


.page-item {
    width: 100%;

    display: flex;
    align-items: center;

    gap: 10px;

    padding: 10px 11px;

    margin-bottom: 3px;

    border-radius: 9px;

    background: transparent;
    color: var(--text-soft);

    text-align: left;

    cursor: pointer;

    transition:
        background 0.18s ease,
        color 0.18s ease;
}


.page-item:hover {
    background: #f0f2f5;
    color: var(--text);
}


.page-item.active {
    background: #eceef1;
    color: var(--text);
}


.page-item-icon {
    width: 28px;
    height: 28px;

    flex-shrink: 0;

    display: flex;
    align-items: center;
    justify-content: center;

    border-radius: 7px;

    background: white;
    border: 1px solid var(--border);

    font-size: 13px;
}


.page-item.active .page-item-icon {
    background: #111827;
    border-color: #111827;
    color: white;
}


.page-item-content {
    min-width: 0;
    flex: 1;
}


.page-item-title {
    display: block;

    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;

    font-size: 13px;
    font-weight: 600;
}


.page-item-preview {
    display: block;

    margin-top: 2px;

    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;

    color: var(--text-muted);

    font-size: 11px;
}


.sidebar-bottom {
    padding: 12px;

    border-top:
        1px solid var(--border);
}


.temporary-info {
    display: flex;
    align-items: center;

    gap: 9px;

    padding: 10px;

    border-radius: 9px;

    background: #f5f6f8;
}


.status-dot {
    width: 7px;
    height: 7px;

    flex-shrink: 0;

    border-radius: 50%;

    background: #22c55e;

    box-shadow:
        0 0 0 4px rgba(34, 197, 94, 0.10);
}


.editor-area {
    display: flex;
    flex-direction: column;

    min-width: 0;
    min-height: 0;

    background: var(--bg);
}


.editor-toolbar {
    min-height: 68px;

    display: flex;
    align-items: center;
    justify-content: space-between;

    gap: 15px;

    padding: 10px 22px;

    background: rgba(255, 255, 255, 0.72);
    border-bottom: 1px solid var(--border);

    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);

    z-index: 10;
}


.page-title-input {
    width: min(500px, 100%);

    padding: 0;

    border: none;
    outline: none;

    background: transparent;

    color: var(--text);

    font-size: 16px;
    font-weight: 700;

    letter-spacing: -0.025em;
}


.page-title-input::placeholder {
    color: #b4b8bf;
}


.page-meta {
    margin: 3px 0 0;

    color: var(--text-muted);

    font-size: 11px;
}


.toolbar-btn {
    width: 34px;
    height: 34px;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    border-radius: 8px;

    background: transparent;
    color: var(--text-muted);

    font-size: 14px;

    cursor: pointer;

    transition:
        background 0.2s ease,
        color 0.2s ease,
        transform 0.15s ease;
}


.toolbar-btn:hover {
    background: #f0f1f3;
    color: var(--text);
}


.toolbar-btn:active {
    transform: scale(0.94);
}


.heading-btn {
    font-family:
        Georgia,
        "Times New Roman",
        serif;

    font-size: 13px;
    font-weight: 800;

    color: var(--text-muted);
}


.heading-btn:hover {
    background: var(--heading-soft);
    color: var(--heading);
}


.heading-btn.active {
    background: var(--heading-soft);
    color: var(--heading);

    box-shadow:
        inset 0 0 0 1px rgba(108, 140, 255, 0.16);
}


.toolbar-btn.danger:hover {
    background: var(--danger-soft);
    color: var(--danger);
}


.paper-container {
    flex: 1;

    min-height: 0;

    overflow: auto;

    padding: 28px;

    display: flex;
    justify-content: center;

    scrollbar-width: thin;
    scrollbar-color: #d5d8dd transparent;
}


.paper-container::-webkit-scrollbar {
    width: 7px;
}


.paper-container::-webkit-scrollbar-track {
    background: transparent;
}


.paper-container::-webkit-scrollbar-thumb {
    background: #d5d8dd;
    border-radius: 20px;
}


.paper {
    position: relative;

    width: min(900px, 100%);

    min-height: 100%;

    background-color: var(--paper);

    border: 1px solid #e8e5dc;

    border-radius: 5px;

    box-shadow:
        0 3px 15px rgba(0, 0, 0, 0.045);

    overflow: hidden;
}


.lined-paper {
    background-image:
        repeating-linear-gradient(
            to bottom,
            transparent 0,
            transparent 31px,
            var(--paper-line) 31px,
            var(--paper-line) 32px
        );
}


.paper-margin {
    position: absolute;

    top: 0;
    bottom: 0;

    left: 66px;

    width: 1px;

    background: var(--paper-margin);

    opacity: 0.65;

    pointer-events: none;
}


.note-editor {
    position: relative;

    z-index: 2;

    width: 100%;

    min-height: 100%;

    display: block;

    padding: 13px 40px 60px 86px;

    border: none;
    outline: none;

    background: transparent;

    color: #24272c;

    font-family:
        Inter,
        ui-sans-serif,
        system-ui,
        sans-serif;

    font-size: 15px;

    line-height: 32px;

    white-space: pre-wrap;

    overflow-wrap: anywhere;
    word-break: break-word;

    cursor: text;
}


.note-editor:empty::before {
    content: attr(data-placeholder);

    color: #aeb2b9;

    pointer-events: none;
}


.note-editor:focus {
    outline: none;
}


.note-editor > div,
.note-editor > p {
    margin: 0;

    min-height: 32px;

    line-height: 32px;
}


.note-editor .note-heading {
    margin: 0;

    min-height: 40px;

    color: #6C8CFF;

    font-size: 22px;

    font-weight: 800;

    line-height: 40px;

    letter-spacing: -0.025em;
}


.note-editor .note-heading:hover {
    color: #5c7df5;
}


.plain-paper {
    background-image: none;
}


.plain-paper .paper-margin {
    display: none;
}


.plain-paper .note-editor {
    line-height: 1.75;
}


.plain-paper .note-editor > div,
.plain-paper .note-editor > p {
    line-height: 1.75;
    min-height: 0;
}


.plain-paper .note-editor .note-heading {
    line-height: 1.25;
}


.editor-footer {
    min-height: var(--footer-height);

    display: flex;
    align-items: center;
    justify-content: space-between;

    gap: 15px;

    padding: 8px 20px;

    background: rgba(255, 255, 255, 0.92);
    border-top: 1px solid var(--border);

    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);

    z-index: 10;
}


.footer-control {
    display: flex;
    align-items: center;

    gap: 8px;
}


.footer-icon {
    font-size: 14px;
}


.footer-label {
    color: var(--text-soft);

    font-size: 12px;
    font-weight: 600;
}


.paper-switch {
    display: flex;

    padding: 3px;

    border-radius: 8px;

    background: #f0f1f3;
}


.paper-option {
    min-width: 58px;
    height: 28px;

    padding: 0 10px;

    border-radius: 6px;

    background: transparent;

    color: var(--text-muted);

    font-size: 11px;
    font-weight: 600;

    cursor: pointer;

    transition:
        background 0.2s ease,
        color 0.2s ease,
        box-shadow 0.2s ease;
}


.paper-option:hover {
    color: var(--text-soft);
}


.paper-option.active {
    background: white;

    color: var(--text);

    box-shadow:
        0 1px 4px rgba(0, 0, 0, 0.08);
}


.editor-stats {
    display: flex;
    align-items: center;

    gap: 7px;

    color: var(--text-muted);

    font-size: 11px;
}


.stat-separator {
    color: #d0d3d8;
}


.built-by {
    color: #a4a8af;

    font-size: 10px;
    font-weight: 500;

    letter-spacing: 0.01em;

    white-space: nowrap;
}


.built-by strong {
    color: #777d86;

    font-weight: 700;
}


.sidebar-overlay {
    position: fixed;

    inset: 0;

    background: rgba(15, 23, 42, 0.28);

    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);

    z-index: 60;

    opacity: 0;

    visibility: hidden;

    pointer-events: none;

    transition:
        opacity 0.28s ease,
        visibility 0.28s ease;
}


.sidebar-overlay.show {
    opacity: 1;

    visibility: visible;

    pointer-events: auto;
}


.modal {
    position: fixed;

    inset: 0;

    z-index: 100;

    display: flex;

    align-items: center;
    justify-content: center;

    padding: 20px;

    background: rgba(15, 23, 42, 0.35);

    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);

    opacity: 1;

    transition: opacity 0.2s ease;
}


.modal.hidden {
    display: none;
}


.modal-card {
    width: min(400px, 100%);

    padding: 26px;

    border: 1px solid var(--border);

    border-radius: 16px;

    background: white;

    box-shadow:
        0 25px 70px rgba(0, 0, 0, 0.16);

    text-align: center;
}


.modal-icon {
    width: 42px;
    height: 42px;

    display: flex;

    align-items: center;
    justify-content: center;

    margin: 0 auto 15px;

    border-radius: 12px;

    background: var(--danger-soft);

    color: var(--danger);

    font-size: 18px;
}


.modal-card h3 {
    margin: 0;

    font-size: 18px;
    font-weight: 700;

    letter-spacing: -0.025em;
}


.modal-card p {
    margin: 8px 0 22px;

    color: var(--text-soft);

    font-size: 13px;

    line-height: 1.6;
}


.modal-actions {
    display: flex;

    gap: 9px;
}


.modal-cancel,
.modal-danger {
    flex: 1;

    height: 40px;

    border-radius: 9px;

    font-size: 12px;
    font-weight: 600;

    cursor: pointer;

    transition: 0.2s ease;
}


.modal-cancel {
    background: #f3f4f6;
    color: var(--text);
}


.modal-cancel:hover {
    background: #e9eaed;
}


.modal-danger {
    background: var(--danger);
    color: white;
}


.modal-danger:hover {
    background: #b91c1c;
}


@media (max-width: 900px) {

    .sidebar {
        width: 230px;
    }

    .paper-container {
        padding: 20px;
    }

    .note-editor {
        padding-left: 72px;
    }

    .paper-margin {
        left: 54px;
    }

}


@media (max-width: 767px) {

    body {
        overflow-x: hidden;
        overflow-y: auto;
    }


    .app-header {
        height: 58px;
        min-height: 58px;

        padding-left: 10px;
        padding-right: 10px;
    }


    .brand-name {
        font-size: 16px;
    }


    .brand-icon {
        width: 28px;
        height: 28px;
    }


    .sidebar {
        position: fixed;

        top: 0;
        bottom: 0;
        left: 0;

        width: min(290px, 84vw);

        z-index: 70;

        transform: translateX(-105%);

        background: #fafbfc;

        box-shadow: none;
    }


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

        box-shadow:
            10px 0 40px rgba(0, 0, 0, 0.12);
    }


    .editor-toolbar {
        min-height: 58px;

        padding: 8px 12px;
    }


    .page-title-input {
        font-size: 14px;
    }


    .page-meta {
        font-size: 10px;
    }


    .toolbar-btn {
        width: 32px;
        height: 32px;
    }


    .heading-btn {
        font-size: 12px;
    }


    .paper-container {
        padding: 12px 8px 14px;
    }


    .paper {
        min-height: 100%;

        border-radius: 3px;

        box-shadow:
            0 2px 8px rgba(0, 0, 0, 0.04);
    }


    .paper-margin {
        left: 42px;
    }


    .note-editor {
        padding:
            13px
            14px
            50px
            55px;

        font-size: 15px;

        line-height: 32px;
    }


    .note-editor .note-heading {
        font-size: 20px;

        line-height: 38px;

        min-height: 38px;
    }


    .note-editor > div,
    .note-editor > p {
        min-height: 32px;
        line-height: 32px;
    }


    .editor-footer {
        min-height: 52px;

        padding:
            7px
            10px
            calc(7px + env(safe-area-inset-bottom));

        gap: 8px;
    }


    .footer-control {
        gap: 5px;
    }


    .footer-icon {
        display: none;
    }


    .paper-option {
        min-width: 54px;
        height: 28px;
    }


    .editor-stats {
        font-size: 10px;

        white-space: nowrap;
    }


    .built-by {
        font-size: 9px;
    }


    .stat-separator {
        display: none;
    }


    #charCount {
        display: none;
    }


    .modal {
        padding: 15px;
    }


    .modal-card {
        padding: 22px;

        border-radius: 14px;
    }

}


@media (max-width: 420px) {

    .download-btn {
        width: 38px;
        padding: 0;
    }


    .download-btn span:first-child {
        font-size: 18px;
    }


    .editor-toolbar {
        gap: 6px;
    }


    .paper-container {
        padding-left: 5px;
        padding-right: 5px;
    }


    .paper-margin {
        left: 36px;
    }


    .note-editor {
        padding-left: 47px;
        padding-right: 12px;
    }


    .note-editor .note-heading {
        font-size: 19px;

        line-height: 37px;
    }


    .paper-option {
        min-width: 50px;

        padding-left: 7px;
        padding-right: 7px;
    }


    .built-by {
        font-size: 8px;
    }

}


@media (hover: none) {

    .page-item:hover {
        background: transparent;
    }


    .page-item.active {
        background: #eceef1;
    }


    .download-btn:hover {
        background: var(--accent);
    }


    .toolbar-btn:hover {
        background: transparent;
        color: var(--text-muted);
    }


    .heading-btn:hover {
        background: transparent;
        color: var(--text-muted);
    }


    .heading-btn.active {
        background: var(--heading-soft);
        color: var(--heading);
    }

}


@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {

        scroll-behavior: auto !important;

        transition-duration: 0.01ms !important;

        animation-duration: 0.01ms !important;

        animation-iteration-count: 1 !important;
    }

}
