/* =====================================================================
   Закладки и заметки — оформление
   Опирается на переменные :root из css/style.css (--primary, --bg-2 и пр.)
===================================================================== */

/* --- кнопки в общей панели #controls (наследуют базовый стиль кнопок) --- */
#nb-btn-mark.is-on {
    background: var(--primary);
    color: #fff;
}
#nb-btn-mark.is-on:hover {
    background: var(--primary-hover);
    color: #fff;
}
@keyframes nb-pulse {
    0%   { transform: scale(1); }
    40%  { transform: scale(1.18); }
    100% { transform: scale(1); }
}
#nb-btn-mark.nb-pulse { animation: nb-pulse 0.28s ease; }

/* =====================================================================
   Затемнение и панель
===================================================================== */
.nb-scrim {
    position: fixed;
    inset: 0;
    z-index: 150;
    background: rgba(30, 41, 59, 0.28);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s ease;
}
.nb-scrim.is-open { opacity: 1; pointer-events: auto; }

.nb-drawer {
    position: fixed;
    top: 0; right: 0; bottom: 0;
    z-index: 160;
    width: min(380px, 92vw);
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border-left: 1px solid var(--border);
    border-radius: 24px 0 0 24px;
    box-shadow: -20px 0 60px rgba(30, 41, 59, 0.22);
    padding: 22px 20px 16px;
    transform: translateX(105%);
    transition: transform 0.28s cubic-bezier(0.34, 1.1, 0.64, 1);
}
.nb-drawer.is-open { transform: translateX(0); }

.nb-head {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}
.nb-title {
    flex: 1;
    font-size: 20px;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--text);
}
.nb-close {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 12px;
    background: var(--bg-2);
    color: var(--primary);
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease, color 0.15s ease;
}
.nb-close:hover { background: var(--primary); color: #fff; }

/* --- вкладки --- */
.nb-tabs {
    display: flex;
    gap: 6px;
    background: var(--bg-2);
    padding: 5px;
    border-radius: 14px;
    margin-bottom: 16px;
}
.nb-tab {
    flex: 1;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-family: inherit;
    font-size: 15px;
    font-weight: 700;
    padding: 9px 8px;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}
.nb-tab.is-active {
    background: var(--surface);
    color: var(--primary);
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.18);
}
.nb-count {
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    border-radius: 999px;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: #fff;
    font-size: 12px;
    font-weight: 800;
    line-height: 20px;
    text-align: center;
}

/* --- тело панели --- */
.nb-body {
    flex: 1;
    overflow-y: auto;
    padding-right: 4px;
    margin-right: -4px;
}

/* --- большая кнопка-тумблер закладки --- */
.nb-toggle {
    width: 100%;
    border: none;
    border-radius: 16px;
    padding: 15px 16px;
    font-family: inherit;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    color: #fff;
    background: linear-gradient(135deg, var(--primary), var(--accent-2));
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.30);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    margin-bottom: 16px;
}
.nb-toggle:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(99, 102, 241, 0.40); }
.nb-toggle:active { transform: translateY(0) scale(0.99); }
.nb-toggle.is-on {
    background: var(--bg-2);
    color: var(--primary);
    box-shadow: none;
    border: 2px solid var(--border);
}

/* --- редактор заметки текущей страницы --- */
.nb-editor { margin-bottom: 18px; }
.nb-editor-label {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-muted);
    margin-bottom: 8px;
}
.nb-textarea {
    width: 100%;
    min-height: 110px;
    resize: vertical;
    border: 2px solid var(--border);
    border-radius: 14px;
    padding: 12px 14px;
    font-family: inherit;
    font-size: 15px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg-2);
    transition: border-color 0.15s ease, background 0.15s ease;
}
.nb-textarea:focus { outline: none; border-color: var(--primary); background: #fff; }
.nb-saved {
    height: 16px;
    margin-top: 6px;
    font-size: 12px;
    font-weight: 700;
    color: var(--primary);
    opacity: 0;
    transition: opacity 0.2s ease;
}
.nb-saved.show { opacity: 1; }

/* --- списки закладок/заметок --- */
.nb-list-title {
    font-size: 13px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    margin: 6px 2px 10px;
}
.nb-list { display: flex; flex-direction: column; gap: 8px; }
.nb-row { display: flex; align-items: stretch; gap: 6px; }
.nb-row-main {
    flex: 1;
    min-width: 0;
    text-align: left;
    border: none;
    cursor: pointer;
    background: var(--bg-2);
    border-radius: 14px;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 3px;
    font-family: inherit;
    transition: transform 0.12s ease, background 0.15s ease;
}
.nb-row-main:hover { transform: translateY(-1px); background: rgba(99, 102, 241, 0.10); }
.nb-row-main.is-current { box-shadow: inset 0 0 0 2px var(--primary); }
.nb-row-page { font-size: 15px; font-weight: 800; color: var(--primary); }
.nb-row-sub {
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.nb-del {
    flex-shrink: 0;
    width: 40px;
    border: none;
    border-radius: 14px;
    cursor: pointer;
    background: var(--bg-2);
    color: var(--text-muted);
    font-size: 15px;
    transition: background 0.15s ease, color 0.15s ease;
}
.nb-del:hover { background: var(--accent-2); color: #fff; }

/* --- пустые состояния --- */
.nb-empty {
    text-align: center;
    color: var(--text-muted);
    font-size: 14px;
    line-height: 1.6;
    padding: 28px 12px;
}

/* =====================================================================
   Мелкие экраны
   Кнопок в панели стало больше — разрешаем ей переноситься на две
   строки, чтобы ничего не уезжало за край. Панель делаем чуть шире.
===================================================================== */
@media (max-width: 600px) {
    #controls {
        flex-wrap: wrap;
        max-width: calc(100vw - 24px);
        justify-content: center;
    }
    .nb-drawer {
        width: 88vw;
        border-radius: 20px 0 0 20px;
        padding: 18px 16px 14px;
    }
    .nb-title { font-size: 18px; }
}
