:root {
    --sidebar-width: 300px;
    --navbar-height: 56px;
    --border-color: #e9ecef;
    --sidebar-bg: #f8f9fa;
}

* {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
}

body {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 15px;
    color: #212529;
    background-color: #fff;
}

/* ---------- Страницы входа и создания пароля ---------- */

.auth-wrap {
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    overflow: auto;
}

.auth-card {
    width: 100%;
    max-width: 420px;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    box-shadow: 0 6px 24px rgba(15, 23, 42, 0.06);
}

/* ---------- Верхняя панель ---------- */

.app-navbar {
    flex: 0 0 auto;
    min-height: var(--navbar-height);
    padding: 0.4rem 0.75rem;
    row-gap: 0.25rem;
}

.app-navbar .navbar-brand {
    margin-right: 0.25rem;
}

.search-box {
    max-width: 340px;
    min-width: 120px;
}

.mode-tabs {
    background: var(--sidebar-bg);
    border-radius: 0.375rem;
    padding: 2px;
    gap: 2px;
}

.mode-tabs .nav-link {
    padding: 0.2rem 0.7rem;
    font-size: 0.875rem;
    line-height: 1.4;
    color: #495057;
}

.mode-tabs .nav-link.active {
    background: #fff;
    color: #0d6efd;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.12);
}

/* ---------- Каркас: сайдбар + основная область ---------- */

.app-body {
    flex: 1 1 auto;
    display: flex;
    min-height: 0;
}

.sidebar {
    width: var(--sidebar-width);
    max-width: 85vw;
    flex: 0 0 auto;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
}

.sidebar-body {
    height: 100%;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.sidebar .list-group-item {
    border: 0;
    border-radius: 0;
    background: transparent;
    cursor: pointer;
    padding: 0.55rem 0.9rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.04);
}

.sidebar .list-group-item:hover {
    background: #eef1f5;
}

.sidebar .list-group-item.active {
    background: #e7f1ff;
    color: #0a58ca;
}

.sidebar .list-group-item.active:hover {
    background: #dbe9ff;
}

.sidebar .item-title {
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar .item-meta {
    font-size: 0.75rem;
    color: #6c757d;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar .list-group-item.active .item-meta {
    color: #3d6fb8;
}

.sidebar-empty {
    text-align: center;
}

/* ---------- Основная область ---------- */

.main-pane {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    min-height: 0;
    background: #fff;
}

.pane {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.pane-toolbar {
    flex: 0 0 auto;
    padding: 0.75rem 1rem 0.5rem;
}

.title-input {
    border: 0;
    outline: 0;
    font-size: 1.3rem;
    font-weight: 600;
    padding: 0.25rem 0;
    background: transparent;
}

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

.editor-wrap {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    border-top: 1px solid var(--border-color);
}

.editor-wrap .tox-tinymce {
    flex: 1 1 auto;
    border: 0 !important;
    border-radius: 0 !important;
}

.statusbar {
    flex: 0 0 auto;
    background: #fff;
    min-height: 34px;
    align-items: center;
}

/* ---------- Пароли ---------- */

.form-wrap {
    flex: 1 1 auto;
    overflow-y: auto;
    width: 100%;
    max-width: 640px;
    padding: 1rem;
}

.empty-state {
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
}

/* ---------- Всплывающие уведомления ---------- */

.toast-container {
    position: fixed;
    right: 1rem;
    bottom: 1rem;
    z-index: 1090;
}

@media (max-width: 575.98px) {
    .app-navbar {
        row-gap: 0.35rem;
    }

    .search-box {
        max-width: none;
        order: 10;
        flex-basis: 100%;
    }

    .title-input {
        font-size: 1.15rem;
    }
}
