:root {
    color-scheme: light;
    --app-bg: #1d1d20;
    --sidebar: #2f2f31;
    --sidebar-hover: #3b3b3d;
    --sidebar-active: #505050;
    --note: #1d1d20;
    --note-soft: #2b2b2e;
    --text: #f4f4f4;
    --muted: #b8b8b8;
    --line: #3f3f42;
    --accent: #8ab4f8;
    --danger: #b3261e;
    --shadow: 0 18px 45px rgba(0, 0, 0, 0.12);
}

* {
    box-sizing: border-box;
}

body {
    min-height: 100vh;
    margin: 0;
    background: var(--app-bg);
    color: var(--text);
    font-family: "Segoe UI", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    overflow: hidden;
}

button,
input,
textarea {
    font: inherit;
}

button {
    border: 0;
    cursor: pointer;
    color: inherit;
}

.login-page {
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: 24px;
    background: #1d1d20;
}

.login-box {
    width: min(420px, 100%);
    border: 1px solid #3c3c40;
    border-radius: 10px;
    background: #2f2f31;
    color: #f4f4f4;
    box-shadow: 0 18px 45px rgba(0, 0, 0, 0.35);
    padding: 30px;
}

.login-box h1,
.brand h1 {
    margin: 0;
    font-size: 26px;
    font-weight: 650;
    letter-spacing: 0;
}

.login-box p,
.brand p,
.empty p {
    color: var(--muted);
    line-height: 1.5;
}

.login-box p {
    color: #d0d0d0;
}

.field {
    display: grid;
    gap: 8px;
    margin-top: 22px;
}

.field label {
    color: #d6d6d6;
    font-size: 14px;
    font-weight: 700;
}

input,
textarea {
    width: 100%;
    border: 1px solid transparent;
    border-radius: 6px;
    background: #fff;
    color: var(--text);
    outline: 0;
}

input:focus,
textarea:focus {
    border-color: rgba(0, 0, 0, 0.22);
    box-shadow: 0 0 0 2px rgba(215, 166, 0, 0.2);
}

.password-input:focus {
    border-color: #8ab4f8;
    box-shadow: 0 0 0 2px rgba(138, 180, 248, 0.2);
}

.password-input {
    padding: 13px 14px;
    background: #1d1d20;
    border-color: #5a5a5e;
    color: #ffffff;
    caret-color: #ffffff;
}

.password-input:-webkit-autofill {
    -webkit-text-fill-color: #ffffff;
    box-shadow: 0 0 0 1000px #1d1d20 inset;
}

.primary-btn,
.secondary-btn,
.icon-btn,
.danger-btn {
    min-height: 42px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-weight: 600;
}

.primary-btn {
    width: 100%;
    margin-top: 18px;
    background: #1f1f1f;
    color: #fff;
}

.secondary-btn,
.icon-btn {
    background: transparent;
    color: var(--text);
    border: 1px solid transparent;
}

.danger-btn {
    background: transparent;
    color: var(--danger);
    border: 1px solid transparent;
}

.secondary-btn:hover,
.icon-btn:hover,
.danger-btn:hover {
    background: rgba(0, 0, 0, 0.07);
}

.notice,
.error {
    margin-top: 16px;
    border-radius: 6px;
    padding: 12px 14px;
    font-size: 14px;
    line-height: 1.45;
}

.notice {
    background: #242426;
    color: #f0d98a;
    border: 1px solid #6f5f24;
}

.error {
    display: none;
    background: #351f20;
    color: #ffd5d1;
    border: 1px solid #7a3835;
}

.app {
    display: grid;
    grid-template-columns: 320px minmax(0, 1fr);
    min-height: 100vh;
    background: var(--app-bg);
}

.sidebar {
    border-right: 1px solid var(--line);
    background: var(--sidebar);
    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr);
    min-height: 100vh;
}

.sidebar-top {
    padding: 22px 20px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.brand p {
    margin: 3px 0 0;
    font-size: 13px;
}

.toolbar {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 10px;
    padding: 6px 16px 14px;
}

.search-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 36px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    overflow: hidden;
}

.search-row input {
    min-height: 38px;
    padding: 0 12px;
    border: 0;
    background: transparent;
}

.icon-btn {
    width: 38px;
    height: 38px;
    font-size: 20px;
    line-height: 1;
}

.secondary-btn {
    padding: 0 13px;
}

.danger-btn {
    padding: 0 12px;
}

.logout-btn {
    width: auto;
    min-width: 64px;
    padding: 0 10px;
    font-size: 13px;
}

.note-list {
    overflow: auto;
    padding: 0 8px 12px;
}

.note-item {
    width: 100%;
    min-height: 74px;
    text-align: left;
    border-radius: 6px;
    border: 0;
    background: transparent;
    padding: 12px 14px;
    display: grid;
    gap: 6px;
}

.note-item:hover,
.note-item:focus-visible {
    background: var(--sidebar-hover);
}

.note-item.active {
    background: var(--sidebar-active);
    box-shadow: inset 4px 0 0 var(--accent);
}

.note-title {
    color: var(--text);
    font-size: 15px;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.note-meta {
    color: var(--muted);
    font-size: 13px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.editor {
    display: grid;
    min-width: 0;
    background: var(--note);
}

#editorPanel {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    min-height: 100vh;
    background: var(--note);
}

#editorPanel[hidden] {
    display: none;
}

.editor-top {
    min-height: 76px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    background: var(--note);
    padding: 14px 22px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 16px;
}

.title-input {
    min-height: 46px;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    font-size: 24px;
    font-weight: 650;
}

.title-input:focus {
    box-shadow: none;
}

.save-state {
    color: var(--muted);
    font-size: 14px;
    white-space: nowrap;
}

.editor-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.body-input {
    min-height: calc(100vh - 76px);
    resize: none;
    border: 0;
    border-radius: 0;
    padding: 24px 34px 42px;
    background:
        repeating-linear-gradient(
            to bottom,
            transparent 0,
            transparent 31px,
            rgba(0, 0, 0, 0.055) 32px
        ),
        var(--note);
    color: var(--text);
    font-size: 17px;
    line-height: 32px;
}

.body-input:focus {
    box-shadow: none;
}

.empty {
    display: grid;
    place-items: center;
    min-height: 100vh;
    padding: 28px;
    text-align: center;
    background: var(--note);
}

.empty[hidden],
[hidden] {
    display: none !important;
}

.empty-inner {
    width: min(520px, 100%);
    padding: 28px;
    border-radius: 10px;
    background: var(--note-soft);
    box-shadow: 0 12px 28px rgba(80, 64, 0, 0.12);
}

.empty .primary-btn {
    width: auto;
    padding: 0 18px;
}

.empty h2 {
    margin: 0;
    font-size: 25px;
    font-weight: 650;
}

.mobile-switch {
    display: none;
}

@media (max-width: 820px) {
    .app {
        grid-template-columns: 1fr;
    }

    .sidebar {
        min-height: auto;
        border-right: 0;
        border-bottom: 1px solid var(--line);
    }

    .sidebar-top {
        padding: 18px 16px 10px;
    }

    .toolbar {
        padding: 4px 12px 12px;
    }

    .note-list {
        max-height: 230px;
    }

    .editor-top {
        grid-template-columns: 1fr;
        align-items: stretch;
        padding: 16px;
    }

    .editor-actions {
        justify-content: space-between;
    }

    .title-input {
        font-size: 22px;
    }

    .body-input {
        min-height: 58vh;
        padding: 18px 18px 32px;
        font-size: 16px;
    }
}

.editor-shell {
    display: block;
    min-height: 100vh;
    background: #1d1d20;
}

.text-editor {
    min-height: 100vh;
    display: grid;
    grid-template-rows: 58px 52px minmax(0, 1fr);
    background: #1d1d20;
    color: #f4f4f4;
}

.window-titlebar {
    display: grid;
    grid-template-columns: auto 46px minmax(180px, 1fr) auto;
    align-items: center;
    gap: 10px;
    min-height: 58px;
    padding: 0 10px 0 18px;
    background: #3a3a3b;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.menu-button,
.top-icon {
    min-height: 40px;
    border-radius: 10px;
    background: transparent;
    color: #f4f4f4;
    border: 0;
}

.menu-button {
    padding: 0 10px;
    font-size: 18px;
    font-weight: 650;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.menu-button:hover,
.top-icon:hover {
    background: rgba(255, 255, 255, 0.11);
}

.top-icon {
    width: 42px;
    font-size: 20px;
}

.open-wrap {
    position: relative;
}

.open-caret {
    font-size: 14px;
    color: #d0d0d0;
}

.open-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    width: min(430px, 80vw);
    z-index: 30;
    border-radius: 10px;
    background: #242427;
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 18px 38px rgba(0, 0, 0, 0.42);
    padding: 8px;
}

.open-dropdown[hidden] {
    display: none;
}

.window-title-input {
    width: min(420px, 100%);
    justify-self: center;
    min-height: 42px;
    padding: 0 16px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: #f4f4f4;
    text-align: center;
    font-size: 18px;
    font-weight: 700;
}

.window-title-input:focus {
    background: rgba(255, 255, 255, 0.1);
    box-shadow: none;
}

.titlebar-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
}

.text-editor .save-state {
    color: #d6d6d6;
    min-width: 80px;
    text-align: right;
    font-size: 13px;
}

.tabs-row {
    min-width: 0;
    overflow: hidden;
    background: #3a3a3b;
    display: flex;
    align-items: end;
    padding: 0 12px 8px 12px;
    border-bottom: 1px solid #303034;
}

.search-wrap {
    position: relative;
    flex: 0 0 220px;
    min-width: 180px;
}

.search-box {
    width: 100%;
    height: 40px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 34px;
    align-items: center;
    border-radius: 10px;
    background: #2b2b2e;
    border: 1px solid rgba(255, 255, 255, 0.1);
    overflow: hidden;
}

.open-dropdown .search-wrap {
    width: 100%;
    min-width: 0;
    flex: none;
}

.open-dropdown .search-box {
    height: 38px;
}

.search-box:focus-within {
    border-color: rgba(138, 180, 248, 0.58);
}

.search-box input {
    height: 100%;
    border: 0;
    border-radius: 0;
    padding: 0 12px;
    background: transparent;
    color: #f4f4f4;
    font-size: 15px;
}

.search-box input::placeholder {
    color: #a8a8ad;
}

.search-box input:focus {
    box-shadow: none;
}

.search-clear {
    width: 34px;
    height: 34px;
    border-radius: 999px;
    background: transparent;
    color: #d6d6d6;
    border: 0;
    font-size: 16px;
    opacity: 0.72;
}

.search-clear:hover {
    background: rgba(255, 255, 255, 0.12);
    opacity: 1;
}

.search-suggestions {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    width: min(420px, 72vw);
    max-height: 330px;
    overflow: auto;
    z-index: 20;
    border-radius: 10px;
    background: #242427;
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 18px 38px rgba(0, 0, 0, 0.42);
    padding: 6px;
}

.open-dropdown .search-suggestions {
    position: static;
    width: 100%;
    max-height: 320px;
    margin-top: 8px;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
}

.search-suggestions[hidden] {
    display: none;
}

.suggestion-item {
    width: 100%;
    min-height: 66px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px;
    border-radius: 8px;
    background: transparent;
}

.suggestion-open {
    min-width: 0;
    min-height: 66px;
    display: grid;
    gap: 5px;
    text-align: left;
    padding: 10px 12px;
    border-radius: 8px;
    background: transparent;
    color: #f4f4f4;
    border: 0;
}

.suggestion-item:hover,
.suggestion-item.active {
    background: #3a3a3d;
}

.suggestion-delete {
    height: 34px;
    padding: 0 10px;
    border-radius: 8px;
    background: transparent;
    color: #ffb8b0;
    border: 1px solid rgba(255, 184, 176, 0.18);
    font-size: 12px;
    opacity: 0;
}

.suggestion-item:hover .suggestion-delete,
.suggestion-item.active .suggestion-delete,
.suggestion-delete:focus-visible {
    opacity: 1;
}

.suggestion-delete:hover {
    background: rgba(255, 184, 176, 0.12);
    border-color: rgba(255, 184, 176, 0.34);
}

.suggestion-title {
    font-size: 15px;
    font-weight: 650;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.suggestion-snippet {
    color: #bdbdc2;
    font-size: 13px;
    line-height: 1.35;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.suggestion-empty {
    padding: 13px 12px;
    color: #bdbdc2;
    font-size: 13px;
}

.search-mark {
    color: #ffffff;
    background: rgba(138, 180, 248, 0.28);
    border-radius: 3px;
}

.text-editor .note-list {
    width: 100%;
    display: flex;
    align-items: end;
    gap: 0;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 0;
    scroll-behavior: smooth;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.text-editor .note-list::-webkit-scrollbar {
    display: none;
}

.tab-empty {
    min-height: 46px;
    display: flex;
    align-items: center;
    padding: 0 14px;
    color: #b8b8b8;
    font-size: 15px;
    white-space: nowrap;
}

.text-editor .note-item {
    flex: 0 0 clamp(170px, 18vw, 260px);
    min-height: 46px;
    padding: 0 8px 0 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-radius: 10px;
    color: #dcdcdc;
    background: transparent;
    border-left: 1px solid rgba(255, 255, 255, 0.14);
}

.text-editor .note-item:hover {
    background: rgba(255, 255, 255, 0.08);
}

.text-editor .note-item.active {
    background: #505050;
    color: #ffffff;
    box-shadow: none;
}

.text-editor .note-title {
    color: inherit;
    font-size: 18px;
    font-weight: 400;
    flex: 1;
    min-width: 0;
}

.text-editor .note-meta {
    display: none;
}

.note-close {
    width: 28px;
    height: 28px;
    border-radius: 999px;
    background: transparent;
    color: inherit;
    border: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    line-height: 1;
    opacity: 0.7;
}

.note-close:hover {
    background: rgba(255, 255, 255, 0.14);
    opacity: 1;
}

.text-editor #editorPanel {
    min-height: 0;
    display: block;
    background: #1d1d20;
}

.text-editor #editorPanel[hidden] {
    display: none;
}

.text-editor .body-input {
    width: 100%;
    min-height: calc(100vh - 110px);
    height: calc(100vh - 110px);
    padding: 16px 22px;
    border: 0;
    border-radius: 0;
    resize: none;
    background: #1d1d20;
    color: #eeeeee;
    caret-color: #eeeeee;
    font-family: "Cascadia Mono", "Consolas", "Liberation Mono", monospace;
    font-size: 17px;
    line-height: 1.65;
    tab-size: 4;
}

.text-editor .body-input::placeholder {
    color: #85858a;
}

.text-editor .body-input:focus {
    box-shadow: none;
    outline: none;
}

.text-editor .empty {
    min-height: calc(100vh - 110px);
    background: #1d1d20;
    color: #d8d8d8;
}

.text-editor .empty-inner {
    background: transparent;
    box-shadow: none;
    padding: 0;
}

.text-editor .empty h2 {
    font-size: 20px;
    font-weight: 500;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
}

@media (max-width: 720px) {
    .text-editor {
        grid-template-rows: 54px 48px minmax(0, 1fr);
    }

    .window-titlebar {
        grid-template-columns: auto 40px minmax(0, 1fr) auto;
        padding-left: 8px;
        gap: 6px;
    }

    .menu-button {
        font-size: 15px;
        padding: 0 8px;
    }

    .window-title-input {
        font-size: 15px;
        padding: 0 8px;
    }

    .text-editor .save-state {
        display: none;
    }

    .tabs-row {
        padding: 0 8px 8px;
    }

    .open-dropdown {
        width: min(340px, 92vw);
    }

    .open-dropdown .search-box {
        height: 36px;
    }

    .search-box input {
        font-size: 13px;
        padding: 0 9px;
    }

    .search-suggestions {
        width: min(340px, 88vw);
    }

    .text-editor .note-item {
        flex-basis: clamp(140px, 44vw, 190px);
    }

    .text-editor .note-title {
        font-size: 15px;
    }

    .text-editor .body-input {
        min-height: calc(100vh - 102px);
        height: calc(100vh - 102px);
        padding: 14px 16px;
        font-size: 15px;
    }
}
