:root {
    --red: #e63946;
    --cream: #f1faee;
    --cyan: #a8dadc;
    --blue: #457b9d;
    --navy: #1d3557;
    --navy-deep: #101f36;
    --panel: rgba(29, 53, 87, 0.68);
    --panel-strong: rgba(16, 31, 54, 0.82);
    --border: rgba(168, 218, 220, 0.18);
    --muted: rgba(241, 250, 238, 0.62);
    --shadow: 0 24px 70px rgba(3, 13, 28, 0.42);
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    background: var(--navy-deep);
}

body {
    margin: 0;
    min-height: 100vh;
    overflow-x: hidden;
    color: var(--cream);
    font-family: "DM Sans", sans-serif;
    background:
        radial-gradient(circle at 15% 10%, rgba(69, 123, 157, 0.34), transparent 32rem),
        radial-gradient(circle at 88% 90%, rgba(230, 57, 70, 0.20), transparent 27rem),
        linear-gradient(145deg, #0d1a2d 0%, #1d3557 54%, #13243d 100%);
}

button,
input {
    font: inherit;
}

button {
    color: inherit;
}

.ambient {
    position: fixed;
    z-index: 0;
    width: 260px;
    height: 260px;
    border-radius: 50%;
    filter: blur(22px);
    pointer-events: none;
    opacity: 0.34;
}

.ambient-one {
    top: 7%;
    right: 7%;
    background: var(--cyan);
}

.ambient-two {
    bottom: 4%;
    left: 5%;
    background: var(--red);
}

.app-shell {
    position: relative;
    z-index: 1;
    width: min(933px, calc(100% - 32px));
    margin: 34px auto;
}

.glass-panel {
    border: 1px solid var(--border);
    background: var(--panel);
    box-shadow: var(--shadow);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    min-height: 92px;
    padding: 18px 20px;
    border-radius: 24px 24px 14px 14px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 13px;
}

.brand-mark {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    background:
        linear-gradient(135deg, var(--red) 0 46%, transparent 46% 54%, var(--cyan) 54% 100%);
    box-shadow: inset 0 0 0 1px rgba(241, 250, 238, 0.18);
}

.brand h1,
.panel-heading h2 {
    margin: 0;
    line-height: 1;
}

.brand h1 {
    font-size: 1.18rem;
    letter-spacing: -0.02em;
}

.eyebrow {
    margin: 0 0 7px;
    color: var(--cyan);
    font-size: 0.66rem;
    font-weight: 700;
    letter-spacing: 0.16em;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.button,
.icon-button,
.tool-button,
.color-swatch,
.context-menu button {
    border: 0;
    cursor: pointer;
    transition: transform 160ms ease, background 160ms ease, opacity 160ms ease, border-color 160ms ease;
}

.button:hover,
.icon-button:hover,
.tool-button:hover,
.color-swatch:hover,
.context-menu button:hover {
    transform: translateY(-1px);
}

.button {
    min-height: 42px;
    padding: 0 15px;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 700;
}

.button-primary {
    background: var(--red);
    box-shadow: 0 10px 28px rgba(230, 57, 70, 0.24);
}

.button-primary:hover {
    background: #ef4351;
}

.button-secondary {
    border: 1px solid rgba(168, 218, 220, 0.18);
    background: rgba(168, 218, 220, 0.08);
}

.save-status {
    color: var(--muted);
    font-size: 0.74rem;
    white-space: nowrap;
}

.save-status.dirty {
    color: var(--cyan);
}

.save-status.saving {
    color: var(--cream);
}

.save-status.saved {
    color: var(--cyan);
}

.workspace {
    display: grid;
    grid-template-columns: 248px minmax(0, 1fr);
    min-height: 650px;
    margin-top: 12px;
    overflow: hidden;
    border-radius: 14px 14px 24px 24px;
}

.notes-panel {
    padding: 21px 16px;
    border-right: 1px solid var(--border);
    background: rgba(11, 29, 50, 0.28);
}

.panel-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.panel-heading h2 {
    font-size: 1rem;
}

.count-badge {
    display: inline-grid;
    place-items: center;
    min-width: 27px;
    height: 27px;
    padding: 0 8px;
    border-radius: 999px;
    color: var(--navy);
    background: var(--cyan);
    font-size: 0.72rem;
    font-weight: 800;
}

.search-field {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 42px;
    margin: 19px 0 14px;
    padding: 0 12px;
    border: 1px solid rgba(168, 218, 220, 0.14);
    border-radius: 12px;
    background: rgba(16, 31, 54, 0.46);
    color: var(--muted);
}

.search-field input {
    width: 100%;
    border: 0;
    outline: 0;
    color: var(--cream);
    background: transparent;
    font-size: 0.82rem;
}

.search-field input::placeholder,
.title-input::placeholder {
    color: rgba(241, 250, 238, 0.36);
}

.notes-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 524px;
    overflow-y: auto;
    padding-right: 3px;
}

.notes-list::-webkit-scrollbar,
.editor::-webkit-scrollbar {
    width: 6px;
}

.notes-list::-webkit-scrollbar-thumb,
.editor::-webkit-scrollbar-thumb {
    border-radius: 999px;
    background: rgba(168, 218, 220, 0.22);
}

.note-card {
    width: 100%;
    padding: 12px;
    border: 1px solid transparent;
    border-radius: 13px;
    text-align: left;
    background: rgba(241, 250, 238, 0.035);
}

.note-card:hover {
    border-color: rgba(168, 218, 220, 0.14);
    background: rgba(168, 218, 220, 0.07);
}

.note-card.active {
    border-color: rgba(230, 57, 70, 0.58);
    background: rgba(230, 57, 70, 0.11);
}

.note-card-title {
    display: block;
    overflow: hidden;
    color: var(--cream);
    font-size: 0.82rem;
    font-weight: 700;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.note-card-excerpt {
    display: -webkit-box;
    margin-top: 5px;
    overflow: hidden;
    color: var(--muted);
    font-size: 0.72rem;
    line-height: 1.35;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.note-card-time {
    display: block;
    margin-top: 8px;
    color: rgba(168, 218, 220, 0.62);
    font-size: 0.64rem;
}

.empty-state {
    padding: 32px 14px;
    border: 1px dashed rgba(168, 218, 220, 0.16);
    border-radius: 14px;
    color: var(--muted);
    text-align: center;
    font-size: 0.78rem;
    line-height: 1.5;
}

.editor-panel {
    min-width: 0;
    padding: 21px;
    background: rgba(18, 40, 68, 0.26);
}

.editor-meta {
    display: flex;
    align-items: center;
    gap: 12px;
}

.title-input {
    width: 100%;
    min-width: 0;
    border: 0;
    outline: 0;
    color: var(--cream);
    background: transparent;
    font-size: 1.28rem;
    font-weight: 700;
    letter-spacing: -0.025em;
}

.icon-button {
    min-width: 72px;
    height: 36px;
    border: 1px solid rgba(230, 57, 70, 0.28);
    border-radius: 10px;
    background: rgba(230, 57, 70, 0.07);
    color: #ff8790;
    font-size: 0.72rem;
    font-weight: 700;
}

.icon-button:disabled {
    cursor: not-allowed;
    opacity: 0.36;
    transform: none;
}

.toolbar {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 19px;
    padding: 8px;
    overflow-x: auto;
    border: 1px solid rgba(168, 218, 220, 0.12);
    border-radius: 13px;
    background: rgba(12, 28, 48, 0.42);
}

.tool-button {
    display: inline-grid;
    place-items: center;
    flex: 0 0 auto;
    width: 34px;
    height: 34px;
    border: 1px solid transparent;
    border-radius: 9px;
    background: transparent;
    font-size: 0.78rem;
}

.tool-button:hover,
.tool-button.active {
    border-color: rgba(168, 218, 220, 0.16);
    background: rgba(168, 218, 220, 0.09);
}

.tool-button.wide {
    width: 42px;
    font-weight: 700;
}

.toolbar-divider {
    flex: 0 0 auto;
    width: 1px;
    height: 24px;
    margin: 0 2px;
    background: rgba(168, 218, 220, 0.13);
}

.color-swatches {
    display: flex;
    gap: 6px;
    padding: 0 2px;
}

.color-swatch,
.context-colors button {
    width: 22px;
    height: 22px;
    border: 2px solid rgba(241, 250, 238, 0.16);
    border-radius: 50%;
}

.color-swatch:hover,
.context-colors button:hover {
    border-color: var(--cream);
}

.swatch-red {
    background: var(--red) !important;
}

.swatch-cream {
    background: var(--cream) !important;
}

.swatch-cyan {
    background: var(--cyan) !important;
}

.swatch-blue {
    background: var(--blue) !important;
}

.editor {
    min-height: 490px;
    max-height: 490px;
    margin-top: 13px;
    overflow-y: auto;
    padding: 24px;
    border: 1px solid rgba(168, 218, 220, 0.10);
    border-radius: 17px;
    outline: none;
    background:
        linear-gradient(rgba(241, 250, 238, 0.025) 1px, transparent 1px),
        rgba(7, 20, 36, 0.43);
    background-size: 100% 34px;
    box-shadow: inset 0 1px 0 rgba(241, 250, 238, 0.025);
    color: var(--cream);
    font-size: 16px;
    line-height: 1.72;
    caret-color: var(--red);
}

.editor:empty::before {
    color: rgba(241, 250, 238, 0.30);
    content: attr(data-placeholder);
    pointer-events: none;
}

.editor h1,
.editor h2,
.editor h3,
.editor .note-heading,
.editor .auto-heading {
    margin: 1.3em 0 0.45em;
    color: var(--cyan);
    font-weight: 700;
    letter-spacing: -0.035em;
    line-height: 1.14;
}

.editor h1 {
    font-size: 2rem;
}

.editor h2,
.editor .note-heading,
.editor .auto-heading {
    font-size: 1.45rem;
}

.editor h3 {
    font-size: 1.18rem;
}

.editor blockquote {
    margin: 1em 0;
    padding: 0.2em 0 0.2em 1em;
    border-left: 3px solid var(--red);
    color: var(--cyan);
}

.editor-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-top: 12px;
    color: var(--muted);
    font-size: 0.68rem;
}

.shortcut-hint {
    text-align: right;
}

.context-menu {
    position: fixed;
    z-index: 20;
    display: none;
    width: 190px;
    padding: 12px;
    border-radius: 15px;
    background: rgba(15, 33, 56, 0.92);
}

.context-menu.open {
    display: block;
    animation: context-in 130ms ease-out;
}

.context-menu p {
    margin: 0 0 9px;
    color: var(--cyan);
    font-size: 0.65rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.context-row {
    display: flex;
    gap: 7px;
}

.context-row + .context-row {
    margin-top: 8px;
}

.context-menu button {
    display: inline-grid;
    place-items: center;
    flex: 1;
    min-width: 31px;
    height: 31px;
    border: 1px solid rgba(168, 218, 220, 0.12);
    border-radius: 8px;
    background: rgba(168, 218, 220, 0.06);
    font-size: 0.72rem;
}

.context-colors button {
    flex: 0 0 27px;
    height: 27px;
    padding: 0;
}

.toast {
    position: fixed;
    z-index: 30;
    right: 22px;
    bottom: 22px;
    max-width: min(360px, calc(100% - 44px));
    padding: 12px 15px;
    border: 1px solid rgba(168, 218, 220, 0.18);
    border-radius: 12px;
    background: rgba(16, 31, 54, 0.94);
    box-shadow: var(--shadow);
    color: var(--cream);
    font-size: 0.78rem;
    opacity: 0;
    pointer-events: none;
    transform: translateY(12px);
    transition: opacity 180ms ease, transform 180ms ease;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.toast.error {
    border-color: rgba(230, 57, 70, 0.48);
}

@keyframes context-in {
    from {
        opacity: 0;
        transform: translateY(4px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@media (max-width: 760px) {
    .app-shell {
        width: min(100% - 20px, 933px);
        margin: 10px auto;
    }

    .topbar {
        align-items: flex-start;
        flex-direction: column;
        border-radius: 20px 20px 12px 12px;
    }

    .topbar-actions {
        width: 100%;
        flex-wrap: wrap;
    }

    .save-status {
        order: 3;
        width: 100%;
    }

    .workspace {
        grid-template-columns: 1fr;
    }

    .notes-panel {
        border-right: 0;
        border-bottom: 1px solid var(--border);
    }

    .notes-list {
        max-height: 190px;
    }

    .editor-panel {
        padding: 16px;
    }

    .editor {
        min-height: 430px;
        max-height: 60vh;
        padding: 18px;
    }

    .editor-footer {
        align-items: flex-start;
        flex-direction: column;
    }

    .shortcut-hint {
        text-align: left;
    }
}
