:root {
    --bg: #0f0f0f;
    --surface: #141418;
    --surface-2: #1a1a20;
    --border: #26262f;
    --accent: #e63939;
    --accent-soft: rgba(230, 57, 57, 0.12);
    --gold: #ffc857;
    --text: #f2f2f5;
    --text-muted: #7a7a88;
    --success: #2ec4b6;
    --radius: 14px;
    --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; outline: none; -webkit-tap-highlight-color: transparent; }
input, select, [contenteditable='true'] { user-select: text; }

body {
    font-family: 'Segoe UI', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    height: 100%;
    overflow: hidden;
    display: flex;
}

.notes-app {
    flex: 1;
    min-width: 0;
    min-height: 0;
    display: flex;
    gap: 14px;
    padding: 20px;
    height: 100%;
    overflow: hidden;
    box-sizing: border-box;
}

.notes-sidebar {
    width: clamp(260px, 28vw, 320px);
    flex-shrink: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.notes-sidebar-head {
    padding: 14px;
    border-bottom: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.btn-new-note {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 10px;
    padding: 11px;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    cursor: pointer;
    transition: background 0.2s, transform 0.2s var(--ease);
}

.btn-new-note:hover { background: #ff4d4d; transform: translateY(-1px); }
.btn-new-note svg { width: 14px; height: 14px; }

.search-box {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 8px 11px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.search-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search-box svg { width: 14px; height: 14px; color: var(--text-muted); flex-shrink: 0; }
.search-box input { flex: 1; background: transparent; border: none; color: var(--text); font-size: 12.5px; }

.filter-row { display: flex; gap: 8px; }

/* ===== Custom dropdown (вместо native <select>) ===== */
.rmrp-dd {
    position: relative;
    flex: 1;
    min-width: 0;
}

.rmrp-dd-trigger {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 8px 11px;
    color: var(--text);
    font-size: 11px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

.rmrp-dd-trigger:hover { border-color: #3a3a46; background: #1e1e26; }
.rmrp-dd.is-open .rmrp-dd-trigger {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.rmrp-dd-label {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: left;
}

.rmrp-dd-chevron {
    width: 10px;
    height: 7px;
    color: var(--text-muted);
    flex-shrink: 0;
    transition: transform 0.2s;
}
.rmrp-dd.is-open .rmrp-dd-chevron { transform: rotate(180deg); color: var(--accent); }

.rmrp-dd-menu {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + 6px);
    z-index: 40;
    max-height: 220px;
    overflow-y: auto;
    background: #17171d;
    border: 1px solid #2e2e38;
    border-radius: 12px;
    padding: 6px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55);
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.rmrp-dd-menu[hidden] { display: none !important; }

.rmrp-dd-option {
    border: none;
    background: transparent;
    color: #ddd;
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    font-family: inherit;
    padding: 9px 10px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.rmrp-dd-option:hover { background: #252530; color: #fff; }
.rmrp-dd-option.is-active {
    background: var(--accent-soft);
    color: var(--accent);
}

/* Toolbar compact dropdown */
.rmrp-dd--toolbar {
    flex: 0 1 auto;
    min-width: 108px;
}
.rmrp-dd--toolbar .rmrp-dd-trigger {
    padding: 4px 8px;
    font-size: 10px;
    border-radius: 6px;
    background: #1e1e26;
    min-height: 26px;
}
.rmrp-dd--toolbar .rmrp-dd-menu {
    min-width: 150px;
    right: auto;
}
.rmrp-dd--toolbar .rmrp-dd-option {
    font-size: 11px;
    padding: 7px 9px;
}

/* ===== Color swatch palette (вместо native color picker) ===== */
.rmrp-swatch-wrap {
    position: relative;
    display: inline-flex;
}

.rmrp-swatch-btn {
    width: 24px;
    height: 24px;
    border-radius: 7px;
    border: 2px solid #3a3a46;
    background:
        linear-gradient(var(--swatch, #fff), var(--swatch, #fff)),
        linear-gradient(45deg, #333 25%, transparent 25%, transparent 75%, #333 75%),
        linear-gradient(45deg, #333 25%, transparent 25%, transparent 75%, #333 75%);
    background-size: 100% 100%, 8px 8px, 8px 8px;
    background-position: 0 0, 0 0, 4px 4px;
    background-blend-mode: normal, normal, normal;
    cursor: pointer;
    padding: 0;
    transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
}

.rmrp-swatch-btn:hover {
    border-color: var(--accent);
    transform: scale(1.06);
}
.rmrp-swatch-wrap.is-open .rmrp-swatch-btn {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}
.rmrp-swatch-btn.is-none {
    background:
        linear-gradient(135deg, transparent 46%, #e63939 46%, #e63939 54%, transparent 54%),
        #2a2a33;
}

.rmrp-swatch-menu {
    position: absolute;
    top: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    z-index: 50;
    display: grid;
    grid-template-columns: repeat(6, 22px);
    gap: 6px;
    padding: 10px;
    background: #17171d;
    border: 1px solid #2e2e38;
    border-radius: 12px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55);
}

.rmrp-swatch-menu[hidden] { display: none !important; }

.rmrp-swatch-opt {
    width: 22px;
    height: 22px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: var(--c, #fff);
    cursor: pointer;
    padding: 0;
    transition: transform 0.12s, box-shadow 0.12s;
}
.rmrp-swatch-opt:hover {
    transform: scale(1.12);
    box-shadow: 0 0 0 2px rgba(230, 57, 57, 0.45);
}
.rmrp-swatch-opt.is-none {
    background:
        linear-gradient(135deg, transparent 46%, #e63939 46%, #e63939 54%, transparent 54%),
        #2a2a33;
}

.btn-fav-filter {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.btn-fav-filter svg { width: 14px; height: 14px; }
.btn-fav-filter:hover { border-color: var(--gold); color: var(--gold); }
.btn-fav-filter.active { background: rgba(255, 200, 87, 0.1); border-color: var(--gold); color: var(--gold); }

.notes-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.notes-empty-hint {
    padding: 32px 16px;
    text-align: center;
    color: var(--text-muted);
    font-size: 12.5px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.notes-empty-hint svg { width: 44px; height: 44px; color: #333; }

.note-card {
    position: relative;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 11px;
    padding: 11px 12px 11px 14px;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}

.note-card::before {
    content: '';
    position: absolute;
    left: 0;
    top: 8px;
    bottom: 8px;
    width: 3px;
    border-radius: 3px;
    background: var(--accent);
    opacity: 0;
    transition: opacity 0.2s;
}

.note-card:hover { border-color: #35353f; background: #1e1e26; }
.note-card:hover::before, .note-card.active::before { opacity: 1; }
.note-card.active { border-color: rgba(230, 57, 57, 0.4); background: #1f1a1c; }
.note-card.dragging { opacity: 0.4; }
.note-card.drag-over-top { box-shadow: inset 0 2px 0 var(--accent); }
.note-card.drag-over-bottom { box-shadow: inset 0 -2px 0 var(--accent); }

.note-card-top { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.note-card-title { font-size: 13px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }

.note-card-star-btn {
    background: none;
    border: none;
    color: #444;
    cursor: pointer;
    padding: 0;
    display: flex;
    transition: color 0.2s, transform 0.2s;
}

.note-card-star-btn svg { width: 14px; height: 14px; }
.note-card-star-btn:hover { color: var(--gold); transform: scale(1.1); }
.note-card-star-btn.is-fav { color: var(--gold); }

.note-card-meta { margin-top: 5px; display: flex; gap: 5px; flex-wrap: wrap; }
.tag-badge {
    font-size: 9px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
}

.note-card.active .tag-badge { background: var(--accent-soft); color: var(--accent); }

.drag-handle, .note-sort-actions {
    position: absolute;
    opacity: 0;
    transition: opacity 0.2s;
}

.drag-handle { left: 4px; bottom: 6px; color: #555; cursor: grab; display: flex; }
.drag-handle svg { width: 11px; height: 11px; }
.note-sort-actions { right: 6px; bottom: 5px; display: flex; gap: 3px; }

.note-card:hover .drag-handle, .note-card:hover .note-sort-actions { opacity: 1; }

.sort-arrow {
    width: 18px;
    height: 18px;
    border: none;
    border-radius: 4px;
    background: #252530;
    color: #999;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sort-arrow svg { width: 8px; height: 8px; }
.sort-arrow:hover { background: var(--accent); color: #fff; }
.sort-arrow:disabled { opacity: 0.25; pointer-events: none; }

.notes-workspace {
    flex: 1;
    min-width: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

.workspace-empty {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 600;
}

.workspace-empty svg { width: 80px; height: auto; opacity: 0.5; }

.workspace-inner {
    display: flex;
    flex-direction: column;
    height: 100%;
    opacity: 0;
    transform: translateY(6px);
    transition: opacity 0.25s var(--ease), transform 0.25s var(--ease);
}

.workspace-inner.active { opacity: 1; transform: translateY(0); }

.workspace-header {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    background: var(--surface-2);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.workspace-title { font-size: 17px; font-weight: 800; letter-spacing: -0.01em; }

.workspace-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

.action-btn {
    width: 34px;
    height: 34px;
    border-radius: 9px;
    border: 1px solid var(--border);
    background: #121218;
    color: #aaa;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.action-btn svg { width: 14px; height: 14px; }
.action-btn:hover { border-color: var(--accent); color: #fff; background: var(--accent-soft); }
.action-btn.is-fav { color: var(--gold); border-color: rgba(255, 200, 87, 0.35); }
.action-btn.active-zen { background: var(--accent); color: #fff; border-color: var(--accent); }
.action-btn.danger:hover { color: var(--accent); }

.editor-toolbar {
    padding: 8px 14px;
    border-bottom: 1px solid var(--border);
    background: #121218;
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    align-items: center;
}

.toolbar-btn {
    background: transparent;
    border: none;
    color: #999;
    padding: 6px 9px;
    border-radius: 7px;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: all 0.15s;
}

.toolbar-btn svg { width: 12px; height: 12px; }
.toolbar-btn:hover { background: #22222c; color: #fff; }
.toolbar-btn.is-active { background: var(--accent); color: #fff; }
.toolbar-divider { width: 1px; height: 16px; background: var(--border); margin: 0 2px; }

.toolbar-input-group {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 10px;
    font-weight: 700;
    color: var(--text-muted);
}

.toolbar-size-input {
    width: 36px;
    text-align: center;
    padding: 3px 4px;
    background: #1e1e26;
    border: 1px solid var(--border);
    color: #fff;
    border-radius: 6px;
    font-size: 10px;
    font-weight: 700;
    font-family: inherit;
    -moz-appearance: textfield;
    appearance: textfield;
}
.toolbar-size-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-soft);
}

.toolbar-size-step {
    width: 20px;
    height: 22px;
    border: 1px solid var(--border);
    border-radius: 5px;
    background: #1e1e26;
    color: #aaa;
    cursor: pointer;
    font-size: 12px;
    font-weight: 700;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.toolbar-size-step:hover { background: var(--accent); color: #fff; border-color: var(--accent); }

.workspace-body { flex: 1; overflow-y: auto; padding: 18px 22px; }

.editor-form { display: flex; flex-direction: column; gap: 14px; height: 100%; }
.meta-row { display: grid; grid-template-columns: 1.4fr 1fr; gap: 12px; }

.field label {
    display: block;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 6px;
}

/* .field input — стили из rmrp-controls.css (единая дизайн-система) */
.field input {
    width: 100%;
}

.rich-editor {
    flex: 1;
    min-height: 200px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 11px;
    padding: 14px 16px;
    color: var(--text);
    font-size: 14px;
    line-height: 1.65;
    overflow-y: auto;
}

.rich-editor:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.rich-editor a { color: var(--accent); }
.rich-editor blockquote, .rendered-content blockquote {
    border-left: 3px solid var(--accent);
    padding-left: 12px;
    color: #b0b0bc;
    margin: 6px 0;
}

.rendered-content { font-size: 15px; line-height: 1.7; color: #e4e4ec; }
.rendered-content a { color: var(--accent); }
.rendered-content ul, .rendered-content ol, .rich-editor ul, .rich-editor ol { padding-left: 20px; }

.note-spoiler {
    background: #252530;
    border: 1px dashed rgba(230, 57, 57, 0.5);
    border-radius: 5px;
    padding: 2px 8px;
    color: transparent;
    cursor: pointer;
}

.note-spoiler.revealed { color: #fff; background: var(--accent-soft); border-style: solid; }

.editor-status {
    display: flex;
    justify-content: space-between;
    font-size: 10px;
    color: var(--text-muted);
    margin-top: 6px;
}

.editor-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
    margin-top: auto;
}

.form-btn {
    padding: 9px 16px;
    border-radius: 9px;
    border: none;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
}

.form-btn svg { width: 12px; height: 12px; }
.form-btn.cancel { background: #22222c; color: #aaa; }
.form-btn.cancel:hover { background: #2c2c36; color: #fff; }
.form-btn.submit { background: var(--accent); color: #fff; }
.form-btn.submit:hover { background: #ff4d4d; }

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(6px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s;
    padding: 20px;
}

.modal-overlay.active { opacity: 1; pointer-events: auto; }

.modal-window {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    width: min(90vw, 360px);
    padding: 24px;
    text-align: center;
    transform: scale(0.94);
    transition: transform 0.25s var(--ease);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
}

.modal-overlay.active .modal-window { transform: scale(1); }

.modal-icon {
    width: 48px;
    height: 48px;
    margin: 0 auto 12px;
    border-radius: 50%;
    background: var(--accent-soft);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-icon svg { width: 22px; height: 22px; }
.modal-title { font-size: 15px; font-weight: 800; margin-bottom: 8px; }
.modal-text { font-size: 12.5px; color: var(--text-muted); line-height: 1.5; margin-bottom: 18px; }
.modal-buttons { display: flex; gap: 8px; }

.modal-btn {
    flex: 1;
    padding: 10px;
    border-radius: 9px;
    border: none;
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    cursor: pointer;
}

.modal-btn.confirm { background: var(--accent); color: #fff; }
.modal-btn.deny { background: #22222c; color: #888; }
.modal-btn.deny:hover { color: #fff; }

.modal-icon--link { color: #4dabf7; background: rgba(77, 171, 247, 0.12); }
.modal-text--left { text-align: left; margin-bottom: 10px; }

.modal-field {
    width: 100%;
    margin-bottom: 16px;
    background: #14141a;
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    padding: 11px 12px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.modal-field::placeholder { color: #6e6e78; font-weight: 500; }
.modal-field:hover { border-color: #3a3a46; }
.modal-field:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

/* Editor: без «синей» обводки Chromium */
.rich-editor:focus-visible { outline: none; }
.field input:focus-visible { outline: none; }
.search-box input:focus-visible { outline: none; }
.notes-app input[type="color"] { display: none !important; }

.toast-stack {
    position: fixed;
    bottom: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 10000;
    pointer-events: none;
}

.toast {
    background: #18181e;
    border: 1px solid var(--border);
    border-left: 3px solid var(--success);
    color: #fff;
    padding: 11px 16px;
    border-radius: 10px;
    font-size: 12.5px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
    animation: toastIn 0.35s var(--ease) forwards;
}

.toast.error { border-left-color: var(--accent); }
.toast.leaving { animation: toastOut 0.25s ease forwards; }
.toast-icon { width: 16px; height: 16px; display: flex; }
.toast-icon svg { width: 100%; height: 100%; }

@keyframes toastIn {
    from { opacity: 0; transform: translateX(24px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes toastOut {
    from { opacity: 1; }
    to { opacity: 0; transform: translateX(20px); }
}

.hidden { display: none !important; }

body.zen-focus-active .sidebar { transform: translateX(-100%); width: 0; padding: 0; overflow: hidden; }
body.zen-focus-active .notes-sidebar { width: 0; opacity: 0; border: none; padding: 0; overflow: hidden; }

@media (max-width: 820px) {
    .notes-app { flex-direction: column; overflow-y: auto; }
    .notes-sidebar { width: 100%; max-height: 42vh; }
    .meta-row { grid-template-columns: 1fr; }
}