:root {
    /* layout */
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 132px;

    /* sidebar (общий для обеих тем — всегда тёмный) */
    --sidebar-bg: #161a23;
    --sidebar-border: #1e2028;
    --sidebar-text: #8a8c91;
    --sidebar-text-hover: #ffffff;
    --sidebar-active-bg: #bfb2ff;
    --sidebar-active-text: #4d357f;
    --sidebar-active-border: #bfb2ff;

    /* surfaces (light) */
    --page-bg: #f8f8fd;
    --card-bg: #ffffff;
    --card-bg-soft: #f9fafb;
    --card-bg-hover: #f4f5f8;

    /* text (light) */
    --text-primary: #1a1d23;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    --text-on-accent: #ffffff;

    /* borders (light) */
    --border-color: #e5e7eb;
    --border-strong: #d1d5db;
    --border-soft: #f1f3f5;

    /* shadows (light) */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 8px 24px rgba(79, 125, 249, 0.10);

    /* brand */
    --accent: #4f7df9;
    --accent-hover: #3a6af0;
    --accent-soft: rgba(79, 125, 249, 0.10);
    --accent-softer: rgba(79, 125, 249, 0.04);

    /* status colors */
    --success: #16a34a;
    --warning: #b45309;
    --danger: #dc2626;
}

[data-theme="dark"] {
    /* surfaces (dark) */
    --page-bg: #0d1117;
    --card-bg: #161b22;
    --card-bg-soft: #1c2128;
    --card-bg-hover: #21262d;

    /* text (dark) */
    --text-primary: #e6edf3;
    --text-secondary: #9aa3b1;
    --text-muted: #6e7681;
    --text-on-accent: #ffffff;

    /* borders (dark) */
    --border-color: #2d333b;
    --border-strong: #3d444d;
    --border-soft: #21262d;

    /* shadows (dark) — сильнее, чтобы карточки «всплывали» */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.35);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 12px 28px rgba(0, 0, 0, 0.55);

    /* brand (dark) — слегка светлее для лучшего контраста */
    --accent: #6b94ff;
    --accent-hover: #84a4ff;
    --accent-soft: rgba(107, 148, 255, 0.14);
    --accent-softer: rgba(107, 148, 255, 0.06);

    /* status (dark) — яркие, читаемые на тёмном фоне */
    --success: #4ade80;
    --warning: #fbbf24;
    --danger: #f87171;

    /* sidebar в dark — слегка темнее самого фона, чтобы выделяться */
    --sidebar-bg: #010409;
    --sidebar-border: #21262d;
}

html { color-scheme: light; }
html[data-theme="dark"] { color-scheme: dark; }

* { box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--page-bg);
    color: var(--text-primary);
    margin: 0;
    min-height: 100vh;
}

/* ── Sidebar ── */

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    border-right: 1px solid var(--sidebar-border);
}

.sidebar-scroll {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: #232837 #161a23;
}

.sidebar-scroll::-webkit-scrollbar {
    width: 10px;
}

.sidebar-scroll::-webkit-scrollbar-track {
    background: #161a23;
}

.sidebar-scroll::-webkit-scrollbar-thumb {
    background: #232837;
    border-radius: 999px;
    border: 2px solid #161a23;
}

.sidebar-scroll::-webkit-scrollbar-thumb:hover {
    background: #2b3245;
}

.sidebar-brand {
    padding: 20px 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    background: #2d2f39;
    color: #fff;
    font-size: 1.38rem;
    font-weight: 600;
    border-bottom: 1px solid var(--sidebar-border);
}

.sidebar-brand i {
    font-size: 1.3rem;
    color: #bfb2ff;
}

.sidebar-collapse-toggle {
    width: 32.87px;
    min-width: 32.87px;
    height: 32.87px;
    margin: 10px 10px 10px 0;
    border-radius: 9.39px;
    border: 1.17px solid #bfb2ff;
    background: #000;
    color: #fff;
    font-size: 0.92rem;
    font-weight: 600;
    font-family: 'SF Mono', Consolas, 'Courier New', monospace;
    line-height: 1;
    letter-spacing: 0;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    gap: 0;
    transition: background 0.15s ease;
}

.sidebar-collapse-toggle--floating {
    position: absolute;
    right: -16.435px;
    top: 62px;
    transform: translateY(-50%);
    z-index: 5;
    width: 32.87px;
    min-width: 32.87px;
    height: 32.87px;
    border-radius: 9.39px;
    border: 1.17px solid #4a4f5f;
    font-size: 0.95rem;
}

.sidebar-collapse-toggle:hover {
    background: #111;
}

.sidebar-collapse-toggle--floating:hover {
    transform: translateY(-50%);
}

.sidebar-nav {
    flex: none;
    overflow: visible;
    padding: 12px 0;
}

.sidebar-section {
    font-size: 0.84rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #8a8c91;
    padding: 16px 24px 6px;
    font-weight: 600;
}

/* Заголовок-аккордеон в сайдбаре: визуально как .sidebar-section,
   но кликабельный, со стрелкой-шевроном справа. */
.sidebar-group-toggle {
    width: 100%;
    background: transparent;
    border: none;
    color: #8a8c91;
    font-size: 0.84rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
    padding: 16px 24px 6px;
    margin: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    text-align: left;
    transition: color 0.12s ease;
}

.sidebar-group-toggle:hover { color: var(--sidebar-text-hover, #c9d1d9); }

.sidebar-group-chevron {
    font-size: 0.85rem;
    line-height: 1;
    transition: transform 0.18s ease;
}

.sidebar-group-toggle.is-open .sidebar-group-chevron {
    transform: rotate(180deg);
}

.sidebar-group {
    display: flex;
    flex-direction: column;
}

.sidebar-group[hidden] { display: none; }

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 24px;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 0.875rem;
    transition: all 0.15s ease;
    border-left: 3px solid transparent;
    cursor: pointer;
    border-radius: 8px;
    margin: 2px 10px;
}

.sidebar-link:hover {
    color: var(--sidebar-text-hover);
    background: rgba(255, 255, 255, 0.04);
}

.sidebar-link.active {
    color: var(--sidebar-active-text);
    background: var(--sidebar-active-bg);
    border-left-color: transparent;
}

.sidebar-link i,
.sidebar-link-icon {
    font-size: 1.1rem;
    width: 24px;
    text-align: center;
    flex-shrink: 0;
    color: currentColor;
}

.sidebar-link.active .sidebar-link-icon,
.sidebar-link.active i {
    color: #4d357f;
}

.sidebar-link-icon svg {
    display: block;
}

.sidebar-link-icon--purple {
    color: #bfb2ff;
}

.sidebar-link-label {
    min-width: 0;
}

.sidebar-sublink {
    padding-left: 60px;
    font-size: 0.825rem;
}

.sidebar-chevron {
    font-size: 0.7rem;
    transition: transform 0.2s;
}

[aria-expanded="true"] .sidebar-chevron {
    transform: rotate(180deg);
}

.sidebar-footer {
    border-top: 1px solid var(--sidebar-border);
    padding: 8px 0;
}

/* Аккаунт — единый блок-ссылка в подвале сайдбара */
.sidebar-account {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    margin: 6px 12px 4px;
    border-radius: 10px;
    background: #2d2f39;
    color: var(--sidebar-text);
    text-decoration: none;
    transition: all 0.15s ease;
}

.sidebar-account:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--sidebar-text-hover);
}

.sidebar-account.active {
    background: var(--sidebar-active-bg);
    color: var(--sidebar-active-text);
}

.sidebar-account.active .sidebar-account-name,
.sidebar-account.active .sidebar-account-role,
.sidebar-account.active .sidebar-account-chevron {
    color: var(--sidebar-active-text);
}

.sidebar-account-avatar {
    width: 40px;
    height: 40px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
}

.sidebar-account-avatar img,
.sidebar-account-avatar svg {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.sidebar-account-body {
    flex: 1;
    min-width: 0;
}

.sidebar-account-name {
    font-size: 0.86rem;
    font-weight: 500;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-account-role {
    font-size: 0.72rem;
    color: var(--sidebar-text);
    margin-top: 1px;
}

.sidebar-account-chevron {
    color: var(--sidebar-text);
    font-size: 0.75rem;
    flex-shrink: 0;
    transition: transform 0.15s ease;
}

.sidebar-account:hover .sidebar-account-chevron {
    transform: translateX(2px);
}

/* ── Main Content ── */

.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
}

body.sidebar-collapsed .sidebar {
    width: var(--sidebar-collapsed-width);
}

body.sidebar-collapsed .main-content {
    margin-left: var(--sidebar-collapsed-width);
}

body.sidebar-collapsed .sidebar-brand {
    justify-content: center;
    padding-left: 12px;
    padding-right: 12px;
}

body.sidebar-collapsed .sidebar-brand span,
body.sidebar-collapsed .sidebar-link-label,
body.sidebar-collapsed .sidebar-group-chevron,
body.sidebar-collapsed .sidebar-account-body,
body.sidebar-collapsed .sidebar-account-chevron {
    display: none;
}

body.sidebar-collapsed .sidebar-collapse-toggle {
    margin: 10px auto;
}

body.sidebar-collapsed .sidebar-link {
    margin-left: 8px;
    margin-right: 8px;
    padding-left: 0;
    padding-right: 0;
    justify-content: center;
}

body.sidebar-collapsed .sidebar-group-toggle {
    justify-content: center;
    padding-left: 4px;
    padding-right: 4px;
}

body.sidebar-collapsed .sidebar-section,
body.sidebar-collapsed .sidebar-group-toggle span {
    display: block;
    text-align: center;
    font-size: 0.72rem;
    line-height: 1.2;
    letter-spacing: 0.03em;
    padding-left: 2px;
    padding-right: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: clip;
}

body.sidebar-collapsed .sidebar-account {
    justify-content: center;
    padding-left: 0;
    padding-right: 0;
    margin-left: 8px;
    margin-right: 8px;
}

body.sidebar-collapsed .sidebar-footer .sidebar-link,
body.sidebar-collapsed .sidebar-footer .sidebar-account {
    width: calc(100% - 16px);
    margin-left: 8px;
    margin-right: 8px;
    position: relative;
    left: -4px;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 32px;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
}

.page-title {
    font-size: 1.4rem;
    font-weight: 600;
    margin: 0;
}

.page-body {
    padding: 32px;
}

/* ── Breadcrumbs ── */

.breadcrumbs {
    padding: 12px 32px;
    background: var(--card-bg);
    border-bottom: none;
    font-family: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-weight: 500;
    font-size: 20px;
    line-height: 1;
    letter-spacing: -0.02em;
}

.breadcrumbs a {
    color: #542de2;
    text-decoration: none;
}

.breadcrumbs a:hover {
    text-decoration: underline;
}

.breadcrumbs .separator {
    color: var(--text-secondary);
    margin: 0 10px;
}

.breadcrumbs .current {
    color: var(--text-secondary);
}

/* ── Cards ── */

.card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
    color: var(--text-primary);
}

.card-title {
    font-size: 0.95rem;
    font-weight: 600;
}

/* ── Stats ── */

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
}

/* ── Stub Placeholder ── */

.stub-placeholder {
    text-align: center;
    padding: 60px 20px;
}

.stub-placeholder i {
    font-size: 3.5rem;
    color: var(--border-strong);
}

.stub-placeholder h5 {
    color: var(--text-secondary);
    margin-top: 16px;
    font-weight: 500;
}

.stub-placeholder p {
    color: var(--text-muted);
    margin-top: 8px;
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
    font-size: 0.9rem;
}

/* ── Upload Zone ── */

.upload-zone {
    border: 2px dashed var(--border-color);
    border-radius: 12px;
    padding: 40px 20px;
    text-align: center;
    transition: border-color 0.2s;
    cursor: pointer;
}

.upload-zone:hover {
    border-color: var(--accent);
}

/* ── Login Page ── */

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #161a23;
}

.login-card {
    background: #fcfdfe;
    border-radius: 16px;
    padding: 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.login-card h2 {
    text-align: center;
    margin-bottom: 8px;
    font-weight: 600;
    color: #161a23;
}

.login-logo {
    text-align: center;
    margin-bottom: 12px;
}

.login-logo i {
    font-size: 2.5rem;
    color: #bfb2ff;
}

.login-subtitle {
    text-align: center;
    color: #505050;
    margin-bottom: 32px;
    font-size: 0.9rem;
}

.login-card .form-control {
    padding: 10px 16px;
    border-radius: 8px;
}

.login-card .form-control:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(79, 125, 249, 0.15);
}

.login-card .btn-primary {
    background: #542de2;
    border: 1px solid #542de2;
    padding: 10px;
    border-radius: 8px;
    font-weight: 500;
}

.login-card .btn-primary:hover {
    background: #542de2;
    border-color: #542de2;
}

/* ── Content Rendered ── */

.content-rendered {
    font-size: 1rem;
    line-height: 1.8;
    color: var(--text-primary);
}

.content-rendered h3 {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-primary);
}

.content-rendered h4 {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--text-primary);
}

.content-rendered h5 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.content-rendered p {
    margin-bottom: 1rem;
}

.content-rendered strong {
    color: var(--text-primary);
}

.content-rendered ul {
    padding-left: 1.5rem;
}

.content-rendered li {
    margin-bottom: 0.3rem;
}

.content-rendered hr {
    margin: 1.5rem 0;
    border-color: var(--border-color);
}

.content-rendered blockquote {
    border-left: 3px solid var(--accent);
    padding: 0.8rem 1.2rem;
    margin: 1rem 0;
    background: rgba(79, 125, 249, 0.04);
    border-radius: 0 8px 8px 0;
}

/* ── Tables ── */

.table th {
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
}

.library-list-table th,
.library-list-table td {
    vertical-align: middle;
}

/* ════════════════════════════════════════════════════════════
   PROJECT DETAIL PAGE
   ════════════════════════════════════════════════════════════ */

.project-meta-pills {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* ════════════════════════════════════════════════════════════
   PROJECTS LIST PAGE
   ════════════════════════════════════════════════════════════ */

/* Основная кнопка-действие «+ Добавить …». .projects-new-btn —
   исторический алиас, оставлен ради совместимости со старой разметкой. */
.projects-new-btn,
.entity-create-btn {
    width: 238px;
    height: 48px;
    border-radius: 14px;
    padding: 12px 10px;
    gap: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    background: #542de2;
    color: #fff;
    border: 1px solid #542de2;
    font-size: 1.05rem;
    font-weight: 600;
}

.projects-new-btn:hover,
.entity-create-btn:hover {
    color: #fff;
    background: #542de2;
    border-color: #542de2;
    opacity: 0.95;
}

.projects-new-btn-plus,
.entity-create-btn-plus {
    font-size: 1.35em;
    font-weight: 400;
    line-height: 1;
}

.entity-create-btn--adaptive {
    width: auto;
    min-width: 238px;
    padding-left: 16px;
    padding-right: 16px;
    white-space: nowrap;
}

/* ════════════════════════════════════════════════════════════
   TEMPLATES LIST PAGE
   ════════════════════════════════════════════════════════════ */

.library-form-btn {
    width: 282px;
    height: 60px;
    border-radius: 14px;
    padding: 16px 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    font-size: 18px;
    line-height: 1;
    font-weight: 500;
    text-decoration: none;
}

.library-form-btn--submit {
    background: #542de2;
    border: 1px solid #542de2;
    color: #fff;
}

.library-form-btn--submit:hover {
    background: #542de2;
    border-color: #542de2;
    color: #fff;
    opacity: 0.96;
}

.library-form-btn--cancel {
    background: #fff;
    border: 2px solid #542de2;
    color: #542de2;
}

.library-form-btn--cancel:hover {
    background: #fff;
    border-color: #542de2;
    color: #542de2;
    opacity: 0.96;
}

.library-name-description-form #id_name,
.library-name-description-form #id_message {
    height: 60px;
    min-height: 60px;
    padding-top: 0;
    padding-bottom: 0;
}

.library-name-description-form #id_description {
    height: 60px;
    min-height: 60px;
    padding-top: 16px;
    padding-bottom: 16px;
    resize: none;
    overflow: hidden;
}

.library-name-code-form #id_name,
.library-name-code-form #id_code {
    height: 60px;
    min-height: 60px;
    padding-top: 0;
    padding-bottom: 0;
}

.template-type-badge {
    min-width: 92px;
    height: 36px;
    padding: 8px 12px;
    gap: 10px;
    border-radius: 8px;
    background: #f2f2f7;
    color: var(--text-primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.82rem;
    font-weight: 500;
}

.template-action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    border: 1.5px solid transparent;
    padding: 0;
    text-decoration: none;
    vertical-align: middle;
}

.template-action-btn--edit {
    width: 58px;
    height: 58px;
    border-color: #5b3aff;
    border-radius: 11.6px;
}

.template-action-btn--edit svg {
    width: 22px;
    height: 22px;
    display: block;
}

.template-action-btn--delete {
    width: 58px;
    height: 58px;
    border: none;
    border-radius: 11.6px;
    box-shadow: none;
}

.template-action-btn--delete svg {
    width: 58px;
    height: 58px;
    display: block;
}

.library-action-btn-sm.template-action-btn--edit {
    width: 44px;
    height: 44px;
    border-radius: 10px;
}

.library-action-btn-sm.template-action-btn--edit svg {
    width: 18px;
    height: 18px;
}

.library-action-btn-sm.template-action-btn--delete {
    width: 44px;
    height: 44px;
    border-radius: 10px;
}

.library-action-btn-sm.template-action-btn--delete svg {
    width: 44px;
    height: 44px;
}

.library-form-btn-sm {
    width: 220px;
    height: 46px;
    border-radius: 12px;
    padding: 10px 12px;
    font-size: 16px;
}

.library-editor-btn-sm.template-editor-save-btn,
.library-editor-btn-sm.template-editor-cancel-btn {
    width: 320px;
    height: 48px;
    border-radius: 12px;
    padding: 12px;
    font-size: 16px;
}

/* ════════════════════════════════════════════════════════════
   TEMPLATE EDITOR PAGE
   ════════════════════════════════════════════════════════════ */

.template-editor-params-title {
    font-family: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-weight: 600;
    font-size: 24px;
    line-height: 1;
    letter-spacing: 0;
    color: #161a23;
}

.template-editor-save-btn,
.template-editor-cancel-btn {
    width: 473px;
    max-width: 100%;
    height: 60px;
    border-radius: 14px;
    padding: 16px 12px;
    gap: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-weight: 500;
    font-size: 18px;
    line-height: 1;
    letter-spacing: 0;
}

.template-editor-save-btn {
    background: #542de2 !important;
    border: 1.5px solid #542de2 !important;
    color: #fff !important;
}

.template-editor-save-btn:hover {
    background: #542de2 !important;
    border-color: #542de2 !important;
    color: #fff !important;
    opacity: 0.96;
}

.template-editor-cancel-btn {
    background: #fff !important;
    border: 2px solid #542de2 !important;
    color: #542de2 !important;
}

.template-editor-cancel-btn:hover {
    background: #fff !important;
    border-color: #542de2 !important;
    color: #542de2 !important;
    opacity: 0.96;
}

.templates-table th,
.templates-table td {
    vertical-align: middle;
}

.templates-table td strong {
    display: inline-block;
    vertical-align: middle;
}

.projects-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
}

.projects-summary-card {
    min-width: 250px;
    flex: 1 1 280px;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    border: 1px solid var(--border-color);
    border-radius: 16px;
    background: var(--card-bg);
}

.projects-summary-icon {
    width: 72px;
    height: 72px;
    border-radius: 14px;
    background: #f5f1fe;
    flex-shrink: 0;
    overflow: hidden;
}

.projects-summary-icon svg {
    display: block;
    width: 72px;
    height: 72px;
}

.projects-summary-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.projects-summary-value {
    font-size: 1.9rem;
    font-weight: 700;
    line-height: 1.05;
    color: var(--text-primary);
}

.projects-page-card {
    border-radius: 16px;
}

.projects-page-card .card-body {
    border-radius: 16px;
}

.projects-search-form {
    display: flex;
    align-items: center;
    gap: 12px;
}

.projects-search-input-wrap {
    position: relative;
    flex: 0 0 600px;
    width: 600px;
    max-width: 100%;
    min-width: 0;
}

.projects-search-input-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    font-size: 1rem;
    pointer-events: none;
    z-index: 1;
}

.projects-search-input {
    height: 48px;
    border-radius: 16px;
    padding-left: 44px;
    border: 1px solid var(--border-color);
    box-shadow: none;
}

.projects-search-input:focus {
    border-color: #542de2;
    box-shadow: 0 0 0 3px rgba(84, 45, 226, 0.12);
}

.projects-search-submit {
    width: 48px;
    min-width: 48px;
    height: 48px;
    border: none;
    background: transparent;
    border-radius: 14px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.projects-search-submit svg {
    display: block;
    width: 48px;
    height: 48px;
}

.projects-search-submit:hover {
    filter: brightness(1.06);
}

.projects-search-clear {
    width: 44px;
    min-width: 44px;
    height: 44px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    background: #fff;
}

.projects-search-clear:hover {
    color: #542de2;
    border-color: #542de2;
}

.projects-table th,
.projects-table td {
    vertical-align: middle;
}

.projects-table > :not(caption) > * > * {
    padding-top: 14px;
    padding-bottom: 14px;
    padding-left: 22px;
    padding-right: 22px;
}

.projects-table tbody td {
    line-height: 1.2;
}

.projects-row-link {
    cursor: pointer;
}

.projects-table.table-hover > tbody > tr:hover > * {
    background: transparent !important;
}

.projects-title-link {
    color: #000;
}

.projects-title-link:hover {
    color: #000;
    text-decoration: underline;
}

.projects-action-btn {
    padding: 0;
    border: none;
    background: transparent;
    width: 42px;
    height: 42px;
    border-radius: 9px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.15s ease, transform 0.15s ease;
}

.projects-action-btn svg {
    width: 42px;
    height: 42px;
    display: block;
}

.projects-action-btn--open:hover {
    background: #f2eeff;
}

.projects-action-btn--delete:hover {
    background: #fff1f1;
}

.project-contents-block {
    margin-top: 16px;
}

.content-grid.project-contents-grid {
    display: flex !important;
    flex-wrap: wrap;
    justify-content: flex-start !important;
    align-content: flex-start;
    gap: 16px;
    grid-template-columns: none !important;
}

.content-grid.project-contents-grid .content-card {
    width: 360px;
    max-width: 100%;
    flex: 0 0 360px;
    margin: 0;
}

/* ════════════════════════════════════════════════════════════
   PROJECT CREATE PAGE
   ════════════════════════════════════════════════════════════ */

.project-create-layout {
    width: 100%;
}

.project-create-card {
    width: 100%;
    max-width: 1584px;
    min-height: 186px;
    border-radius: 14px;
    padding: 20px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    box-shadow: 0 0 25.4px 0 rgba(0, 0, 0, 0.19);
    margin: 0 auto;
}

.project-create-form {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.project-create-title {
    margin: 0;
    font-family: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-weight: 600;
    font-size: 20px;
    line-height: 1;
    letter-spacing: 0;
    color: var(--text-primary);
}

.project-create-label {
    margin: 0;
    font-family: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-weight: 500;
    font-size: 18px;
    line-height: 1;
    letter-spacing: 0;
    color: #2e2e2e;
}

.project-create-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.project-create-input-wrap {
    flex: 1;
    min-width: 0;
}

.project-create-input {
    height: 48px;
    border-radius: 14px;
    border: 1px solid var(--border-color);
    box-shadow: none;
    font-family: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-weight: 400;
    font-size: 16px;
    line-height: 1;
    letter-spacing: 0;
    padding: 0 16px;
}

.project-create-input::placeholder {
    font-family: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-weight: 400;
    font-size: 16px;
    line-height: 1;
    letter-spacing: 0;
}

.project-create-input:focus {
    border-color: #542de2;
    box-shadow: 0 0 0 3px rgba(84, 45, 226, 0.12);
}

.project-create-submit-btn {
    width: 238px;
    min-width: 238px;
    height: 48px;
    border-radius: 14px;
    padding: 12px 10px;
    gap: 12px;
    background: #542de2;
    border: 1px solid #542de2;
    color: #fff;
    font-family: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-weight: 600;
    font-size: 18px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.project-create-submit-btn:hover {
    background: #542de2;
    border-color: #542de2;
    color: #fff;
    opacity: 0.96;
}

@media (max-width: 1024px) {
    .project-create-row {
        flex-direction: column;
    }

    .project-create-submit-btn {
        width: 100%;
        min-width: 0;
    }
}

.meta-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--page-bg);
    border: 1px solid var(--border-color);
    border-radius: 100px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.meta-pill i {
    font-size: 0.85rem;
    color: var(--accent);
}

/* ── Section Header ── */
.section-header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 20px;
}

.section-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
    background: rgba(79, 125, 249, 0.1);
    color: var(--accent);
    flex-shrink: 0;
}

.section-icon--accent { background: rgba(99, 102, 241, 0.1); color: #6366f1; }
.section-icon--warning { background: rgba(245, 158, 11, 0.1); color: #f59e0b; }
.section-icon--success { background: rgba(34, 197, 94, 0.1); color: #22c55e; }

.section-title {
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
    color: var(--text-primary);
}

.section-subtitle {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* ── Параметры (компактная сетка) ── */

.params-card .form-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.params-card .form-label i {
    color: var(--accent);
    font-size: 0.95rem;
}

.params-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px 20px;
}

.param-field { min-width: 0; }

.param-field .form-select {
    border-radius: 8px;
    border: 1px solid var(--border-color);
    padding: 8px 12px;
    font-size: 0.9rem;
    transition: all 0.15s ease;
}

.param-field .form-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(79, 125, 249, 0.12);
}

/* ── Brief & CTA ── */

.brief-card .form-control {
    border-radius: 8px;
    border: 1px solid var(--border-color);
    transition: all 0.15s ease;
    resize: vertical;
}

.brief-card .form-control:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(79, 125, 249, 0.12);
}

.cta-card {
    background: linear-gradient(135deg, #4f7df9 0%, #6366f1 100%);
    border: none;
    color: #fff;
    overflow: hidden;
    position: relative;
}

.cta-card::before {
    content: '';
    position: absolute;
    top: -40px;
    right: -40px;
    width: 160px;
    height: 160px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
}

.cta-card::after {
    content: '';
    position: absolute;
    bottom: -50px;
    left: -50px;
    width: 140px;
    height: 140px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.05);
}

.cta-card .card-body {
    position: relative;
    z-index: 1;
}

.cta-illustration {
    text-align: center;
    margin-bottom: 12px;
}

.cta-illustration i {
    font-size: 2.6rem;
    color: #fff;
    filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.2));
}

.cta-pipeline {
    text-align: center;
    font-size: 0.85rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.92);
    margin-bottom: 6px;
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.12);
    border-radius: 100px;
    backdrop-filter: blur(8px);
}

.cta-card .form-text {
    color: rgba(255, 255, 255, 0.78) !important;
    font-size: 0.78rem;
}

.cta-button {
    background: #fff !important;
    color: var(--accent) !important;
    border: none !important;
    font-weight: 600;
    padding: 12px;
    border-radius: 10px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.cta-button:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
}

.cta-button:disabled {
    background: rgba(255, 255, 255, 0.85) !important;
    color: var(--accent) !important;
}

/* ── Status Badge ── */

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 100px;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    background: var(--page-bg);
    color: var(--text-secondary);
    white-space: nowrap;
}

.status-completed { background: rgba(34, 197, 94, 0.12); color: #16a34a; }
.status-generating { background: rgba(79, 125, 249, 0.12); color: var(--accent); }
.status-error { background: rgba(239, 68, 68, 0.12); color: #dc2626; }
.status-titles_ready { background: rgba(245, 158, 11, 0.15); color: #b45309; }
.status-pending { background: rgba(107, 114, 128, 0.12); color: #4b5563; }

/* ── Items Grid (Batches) ── */

.items-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 16px;
}

.items-grid .item-card {
    width: 360px;
    max-width: 100%;
}

.item-card {
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px;
    background: var(--card-bg);
    transition: all 0.15s ease;
}

.item-card:hover {
    border-color: var(--accent);
    box-shadow: 0 4px 16px rgba(79, 125, 249, 0.08);
    transform: translateY(-1px);
}

.item-card--link {
    display: flex;
    flex-direction: column;
    text-decoration: none;
    color: inherit;
    cursor: pointer;
}

.item-card--link:hover {
    color: inherit;
}

.item-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 10px;
}

.item-card-title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.92rem;
}

.item-card-title i {
    color: var(--accent);
}

.item-card-body {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 12px;
    line-height: 1.5;
}

.item-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.item-card-footer i {
    margin-right: 2px;
}

/* ── Content Cards Grid ── */

.content-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.content-card {
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 18px;
    background: var(--card-bg);
    display: flex;
    flex-direction: column;
    gap: 12px;
    transition: all 0.18s ease;
    position: relative;
}

.content-card:hover {
    border-color: var(--accent);
    box-shadow: 0 8px 24px rgba(79, 125, 249, 0.1);
    transform: translateY(-2px);
}

.content-card-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.content-card-icon {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: linear-gradient(135deg, rgba(79, 125, 249, 0.15), rgba(99, 102, 241, 0.15));
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
}

.content-card-title {
    font-weight: 600;
    font-size: 0.98rem;
    color: var(--text-primary);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 2.7em;
}

.content-card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.meta-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 9px;
    background: var(--page-bg);
    border: 1px solid var(--border-color);
    border-radius: 100px;
    font-size: 0.72rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.meta-chip i { font-size: 0.78rem; }

.meta-chip--accent {
    background: rgba(79, 125, 249, 0.1);
    border-color: rgba(79, 125, 249, 0.25);
    color: var(--accent);
}

.content-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: auto;
    padding-top: 8px;
    border-top: 1px dashed var(--border-color);
}

/* ════════════════════════════════════════════════════════════
   WIDTH PICKER (выбор ширины превью контента)
   ════════════════════════════════════════════════════════════ */

.width-picker { position: relative; }

.width-picker-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.width-picker-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    z-index: 1000;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    box-shadow: var(--shadow-lg);
    padding: 6px;
    min-width: 200px;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.width-picker-item {
    background: transparent;
    border: none;
    padding: 8px 12px;
    text-align: left;
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.86rem;
    cursor: pointer;
    transition: background 0.12s ease;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    width: 100%;
}

.width-picker-item-name { font-weight: 500; }
.width-picker-item-size {
    color: var(--text-muted);
    font-size: 0.78rem;
    font-family: 'SF Mono', Consolas, monospace;
}

.width-picker-item:hover { background: var(--card-bg-soft); }

.width-picker-item.is-active {
    background: var(--accent-soft);
    color: var(--accent);
}
.width-picker-item.is-active .width-picker-item-name { font-weight: 600; }
.width-picker-item.is-active .width-picker-item-size { color: var(--accent); opacity: 0.7; }

/* ════════════════════════════════════════════════════════════
   CONTENT EDITOR (новая страница просмотра/редактирования)
   ════════════════════════════════════════════════════════════ */

/* Шапка страницы (заголовок «Редактор контента» + кнопки справа)
   приклеена к верху окна при скролле — но только на странице
   контента (другие страницы остаются как были). Хлебные крошки
   при этом скроллятся как раньше. */
.main-content:has(.editor-layout) .page-header {
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: 0 1px 0 var(--border-color), 0 4px 12px -8px rgba(0, 0, 0, 0.18);
}

/* Кнопки в шапке редактора крупнее обычных btn-sm — чтобы по ним удобно
   было попадать (это основные действия страницы: версии, чат, save). */
.main-content:has(.editor-layout) .page-header .btn,
.main-content:has(.editor-layout) .page-header .width-picker-btn,
.main-content:has(.editor-layout) .page-header .version-picker-btn {
    padding: 8px 14px;
    font-size: 0.96rem;
    line-height: 1.3;
    border-radius: 8px;
}

.main-content:has(.editor-layout) .page-header .btn i,
.main-content:has(.editor-layout) .page-header .width-picker-btn i,
.main-content:has(.editor-layout) .page-header .version-picker-btn i {
    font-size: 1.05rem;
}

.main-content:has(.editor-layout) .page-header #themeToggleBtn {
    width: 38px;
    height: 38px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.editor-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 260px;
    gap: 28px;
    align-items: start;
}

@media (max-width: 1100px) {
    .editor-layout { grid-template-columns: 1fr; }
    .editor-aside { order: -1; display: flex; flex-wrap: wrap; gap: 12px; }
    .editor-aside-card { flex: 1 1 240px; }
}

/* ── Главная колонка ── */

.editor-main {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 36px 25px 48px;
    min-height: 60vh;
    /* Симулируем «читательскую колонку» площадки. Значение приходит
       inline-стилем из шаблона (--preview-width) или меняется на лету
       через width-picker. 0 = «без ограничения» (полная ширина). */
    width: 100%;
    max-width: var(--preview-width, 600px);
    margin: 0 auto;
    transition: max-width 0.18s ease;
}

/* Если выбрано «Full» — растягиваем редактор на весь столбец */
.editor-layout.is-full .editor-main { max-width: none; }

@media (max-width: 720px) {
    .editor-main { padding: 24px 20px 32px; max-width: 100%; }
}

.editor-title {
    font-size: 1.9rem;
    font-weight: 700;
    line-height: 1.2;
    color: var(--text-primary);
    margin: 0 0 24px;
    outline: none;
    border-radius: 6px;
    padding: 4px 6px;
    margin-left: -6px;
    transition: background 0.15s ease;
}

.editor-title:focus { background: var(--card-bg-soft); }

.editor-title:empty::before {
    content: attr(data-placeholder);
    color: var(--text-muted);
    font-weight: 500;
}

/* ── Лента блоков ── */

.editor-blocks {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.block {
    position: relative;
    display: block;
    border-radius: 8px;
    transition: background 0.12s ease;
}

.block:hover { background: var(--card-bg-soft); }
.block:focus-within { background: var(--card-bg-soft); }

/* Рельс слева — кликабельный «handle» для меню блока. Лежит абсолютно
   внутри padding-зоны .editor-main, поэтому НЕ съедает ширину текста:
   контент блока начинается ровно у внутреннего края карточки (25px). */
.block-rail {
    position: absolute;
    top: 0;
    bottom: 0;
    left: -22px;
    width: 18px;
    cursor: pointer;
    border-radius: 6px 0 0 6px;
}

.block-rail::before {
    content: '⋮⋮';
    position: absolute;
    top: 50%;
    left: 2px;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.85rem;
    opacity: 0;
    transition: opacity 0.12s ease;
    pointer-events: none;
    line-height: 0.8;
    letter-spacing: -2px;
}

.block:hover .block-rail::before,
.block:focus-within .block-rail::before { opacity: 1; }

/* Тело блока (то, что редактируется) — обычный sans-serif шрифт.
   Горизонтальный padding = 0, чтобы текст вставал к краю .editor-main
   (т.е. на 25px от внешней границы карточки). */
.block-body {
    outline: none;
    padding: 8px 0;
    line-height: 1.65;
    font-size: 1.02rem;
    color: var(--text-primary);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    border-radius: 4px;
    word-wrap: break-word;
    min-height: 1.65em;
}

.block-body:empty::before {
    content: attr(data-placeholder);
    color: var(--text-muted);
}

/* Заголовки */
.block--heading h1.block-body { font-size: 1.7rem; font-weight: 700; line-height: 1.3; padding: 14px 0 6px; }
.block--heading h2.block-body { font-size: 1.35rem; font-weight: 700; line-height: 1.35; padding: 12px 0 4px; }
.block--heading h3.block-body { font-size: 1.12rem; font-weight: 600; line-height: 1.4; padding: 10px 0 4px; }

/* ── Лид (вводный абзац статьи) ── */

.block-lead-body {
    font-size: 1.15rem;
    line-height: 1.55;
    color: var(--text-primary);
    font-weight: 500;
    border-left: 3px solid var(--accent);
    padding: 10px 0 10px 16px;
}

/* ── Список (ordered/unordered) ── */

.block--list { padding: 6px 0; }

.block-list {
    margin: 0;
    padding-left: 1.6em;
    color: var(--text-primary);
    line-height: 1.6;
}

.block-list-item {
    outline: none;
    padding: 3px 0;
}

.block-list-item:empty::before {
    content: attr(data-placeholder);
    color: var(--text-muted);
}

/* ── Цитата ── */

.block--quote { padding: 10px 0; }

.block-quote {
    margin: 0;
    padding: 12px 0 12px 18px;
    border-left: 3px solid var(--accent);
    background: var(--accent-softer);
    border-radius: 0 8px 8px 0;
}

.block-quote-text {
    outline: none;
    font-size: 1.05rem;
    line-height: 1.55;
    color: var(--text-primary);
    font-style: italic;
}

.block-quote-text::before { content: '«'; }
.block-quote-text::after  { content: '»'; }

.block-quote-text:empty::before {
    content: attr(data-placeholder);
    font-style: normal;
    color: var(--text-muted);
}
.block-quote-text:empty::after { content: ''; }

.block-quote-footer {
    margin-top: 6px;
    font-size: 0.92rem;
    color: var(--text-secondary);
}

.block-quote-footer::before { content: '— '; }

.block-quote-footer.is-empty { display: none; }

.block-quote-author,
.block-quote-role {
    outline: none;
}

.block-quote-author:empty,
.block-quote-role:empty {
    display: none;
}

.block-quote-author:empty + .block-quote-sep { display: none; }
.block-quote-sep:has(+ .block-quote-role:empty) { display: none; }

/* ── Callout ── */

.block--callout { padding: 10px 0; }

.block-callout {
    display: flex;
    flex-direction: column;
    gap: 6px;
    border-radius: 10px;
    padding: 14px 16px;
    border-left: 3px solid var(--accent);
    background: var(--accent-softer);
}

.block-callout-badge {
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--accent);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.block-callout-badge i { font-size: 0.95rem; }

.block-callout-body {
    outline: none;
    font-size: 1rem;
    line-height: 1.6;
    color: var(--text-primary);
    padding: 0;
}

.block-callout--important .block-callout      { border-left-color: var(--danger); background: rgba(220, 38, 38, 0.06); }
.block-callout--important .block-callout-badge { color: var(--danger); }

.block-callout--warning   .block-callout      { border-left-color: var(--warning); background: rgba(180, 83, 9, 0.07); }
.block-callout--warning   .block-callout-badge { color: var(--warning); }

.block-callout--info      .block-callout      { border-left-color: var(--accent); background: var(--accent-softer); }
.block-callout--info      .block-callout-badge { color: var(--accent); }

.block-callout--company   .block-callout      { border-left-color: var(--text-secondary); background: var(--card-bg-soft); }
.block-callout--company   .block-callout-badge { color: var(--text-secondary); }

.block-callout--note      .block-callout      { border-left-color: var(--border-strong); background: var(--card-bg-soft); }
.block-callout--note      .block-callout-badge { color: var(--text-secondary); }

/* ── HR ── */

.block--hr { padding: 14px 0; }

.block-divider {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 0;
}

/* ── Inline-изображение в потоке текста ── */

.block--image {
    padding: 12px 0;
}

.block-image {
    position: relative;
    background: var(--card-bg-soft);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
    width: 100%;
    /* В 2 раза меньше, чем было — чтобы изображение жило в потоке текста,
       а не съедало пол-страницы. */
    max-width: 520px;
    margin: 0 auto;
    aspect-ratio: 16 / 9;
}

.block-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.block-image-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: var(--text-muted);
    padding: 24px;
}

.block-image-placeholder i {
    font-size: 2rem;
    color: var(--border-strong);
    margin-bottom: 4px;
}

.block-image-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
}

/* Кнопка-«троеточие» поверх картинки появляется на ховер */
.block-image-edit {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: rgba(13, 17, 23, 0.65);
    color: #fff;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.15s ease, background 0.15s ease;
    backdrop-filter: blur(6px);
}

.block-image-edit:hover { background: rgba(13, 17, 23, 0.85); }
.block-image:hover .block-image-edit,
.block-image-edit.is-active { opacity: 1; }

/* Спиннер-оверлей при генерации */
.block-image-busy {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(13, 17, 23, 0.45);
    color: #fff;
    backdrop-filter: blur(2px);
}
.block-image.is-busy .block-image-busy { display: flex; }

.block-image-caption {
    max-width: 520px;
    margin: 6px auto 0;
    color: var(--text-muted);
    font-size: 0.78rem;
    text-align: center;
}

/* ── Кнопка добавить параграф в самый низ ── */

.editor-add-tail {
    margin-top: 14px;
    padding: 6px;
    text-align: left;
    opacity: 0.7;
    transition: opacity 0.15s ease;
}

.editor-add-tail:hover { opacity: 1; }

/* ── Поповеры (меню блока и меню картинки) ── */

.block-popover, .image-popover {
    position: absolute;
    z-index: 1100;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    box-shadow: var(--shadow-lg);
    padding: 6px;
    min-width: 220px;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.bp-item {
    background: transparent;
    border: none;
    padding: 8px 12px;
    text-align: left;
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.86rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background 0.12s ease;
}

.bp-item:hover { background: var(--card-bg-soft); }
.bp-item--danger { color: var(--danger); }
.bp-item--danger:hover { background: rgba(220, 38, 38, 0.08); }

.bp-sep {
    height: 1px;
    background: var(--border-color);
    margin: 4px 6px;
}

/* ── Тонкая боковая панель ── */

.editor-aside {
    display: flex;
    flex-direction: column;
    gap: 12px;
    position: sticky;
    top: 16px;
}

.editor-aside-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.editor-aside-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.84rem;
    color: var(--text-primary);
    gap: 10px;
}

.editor-aside-key {
    color: var(--text-secondary);
    font-size: 0.74rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 600;
    flex-shrink: 0;
}

.editor-aside-brief {
    font-size: 0.84rem;
    color: var(--text-secondary);
    line-height: 1.55;
    max-height: 240px;
    overflow-y: auto;
}

.editor-aside-published {
    border-color: rgba(34, 160, 84, 0.35);
    background: rgba(34, 160, 84, 0.06);
}
.editor-published-link {
    display: inline-flex;
    align-items: center;
    max-width: 100%;
    font-size: 0.84rem;
    font-weight: 500;
    color: #1f9d57;
    text-decoration: none;
    word-break: break-all;
}
.editor-published-link:hover { color: #157a42; text-decoration: underline; }
.editor-published-link .editor-published-link-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
[data-theme="dark"] .editor-aside-published {
    border-color: rgba(52, 199, 109, 0.35);
    background: rgba(52, 199, 109, 0.10);
}
[data-theme="dark"] .editor-published-link { color: #4ade80; }
[data-theme="dark"] .editor-published-link:hover { color: #6ee79b; }

/* ════════════════════════════════════════════════════════════
   ARTICLE VIEW PAGE (legacy — оставлено для совместимости)
   ════════════════════════════════════════════════════════════ */

.article-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: 28px;
    align-items: start;
}

@media (max-width: 1100px) {
    .article-layout {
        grid-template-columns: 1fr;
    }
}

.article-main { min-width: 0; }

/* ── Hero ── */

.article-hero {
    position: relative;
    border-radius: 20px;
    overflow: hidden;
    background: linear-gradient(135deg, #1e293b 0%, #4f7df9 50%, #6366f1 100%);
    padding: 48px 40px 40px;
    color: #fff;
    margin-bottom: 0;
    box-shadow: 0 12px 40px rgba(79, 125, 249, 0.25);
}

.article-hero-overlay {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 20% 20%, rgba(255, 255, 255, 0.12), transparent 40%),
        radial-gradient(circle at 80% 80%, rgba(99, 102, 241, 0.4), transparent 50%);
    pointer-events: none;
}

.article-hero-content {
    position: relative;
    z-index: 1;
}

.article-hero-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 18px;
}

.hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    background: rgba(255, 255, 255, 0.18);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 100px;
    font-size: 0.78rem;
    font-weight: 500;
    color: #fff;
}

.hero-badge i { font-size: 0.7rem; }

.hero-badge--accent {
    background: rgba(255, 255, 255, 0.95);
    color: var(--accent);
    border-color: transparent;
}

.hero-badge--success { background: rgba(34, 197, 94, 0.85); border-color: transparent; }
.hero-badge--danger { background: rgba(239, 68, 68, 0.85); border-color: transparent; }
.hero-badge--neutral { background: rgba(255, 255, 255, 0.18); }

.article-title {
    font-size: 2.1rem;
    font-weight: 700;
    line-height: 1.25;
    margin: 0 0 18px;
    color: #fff;
    letter-spacing: -0.02em;
    text-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
}

@media (max-width: 768px) {
    .article-title { font-size: 1.5rem; }
    .article-hero { padding: 32px 24px 28px; }
}

.article-hero-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 18px;
    font-size: 0.82rem;
    color: rgba(255, 255, 255, 0.88);
}

.article-hero-meta span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.article-hero-meta i { font-size: 0.95rem; opacity: 0.85; }

/* ── Paper ── */

.article-paper {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 56px 64px;
    margin-top: -16px;
    position: relative;
    z-index: 2;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
}

@media (max-width: 768px) {
    .article-paper { padding: 32px 24px; }
}

.article-body {
    font-family: 'Georgia', 'Charter', serif;
    font-size: 1.08rem;
    line-height: 1.8;
    color: var(--text-primary);
    max-width: 720px;
    margin: 0 auto;
}

.article-body h3,
.article-body h4,
.article-body h5 {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

.article-body h3 {
    font-size: 1.6rem;
    font-weight: 700;
    margin-top: 2.2rem !important;
    margin-bottom: 1rem !important;
}

.article-body h4 {
    font-size: 1.3rem;
    font-weight: 700;
    margin-top: 1.8rem !important;
    margin-bottom: 0.8rem !important;
}

.article-body h5 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-top: 1.4rem !important;
    margin-bottom: 0.6rem !important;
    color: var(--text-secondary);
}

.article-body p {
    margin: 0 0 1.2rem;
}

.article-body p:first-of-type::first-letter {
    font-size: 3.4rem;
    font-weight: 700;
    float: left;
    line-height: 1;
    padding: 4px 10px 0 0;
    color: var(--accent);
    font-family: 'Georgia', serif;
}

.article-body strong {
    color: var(--text-primary);
    font-weight: 700;
}

.article-body em {
    color: var(--text-secondary);
}

.article-body ul {
    padding-left: 1.6rem;
    margin: 0 0 1.2rem;
}

.article-body li {
    margin-bottom: 0.4rem;
}

.article-body li::marker {
    color: var(--accent);
}

.article-body hr {
    border: none;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--border-color), transparent);
    margin: 2.4rem 0;
}

.article-body blockquote {
    border-left: 4px solid var(--accent);
    padding: 1rem 1.5rem;
    margin: 1.5rem 0;
    background: rgba(79, 125, 249, 0.05);
    border-radius: 0 10px 10px 0;
    font-style: italic;
    color: var(--text-primary);
}

/* ── Article Extra (RAG) ── */

.article-extra {
    margin-top: 28px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 28px;
}

.rag-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 14px;
}

.rag-card {
    background: var(--page-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 14px;
    transition: border-color 0.15s ease;
}

.rag-card:hover { border-color: var(--accent); }

.rag-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.rag-card-title {
    color: var(--accent);
    font-size: 0.88rem;
}

.rag-score {
    font-size: 0.72rem;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 100px;
}

.rag-score--high { background: rgba(34, 197, 94, 0.15); color: #16a34a; }
.rag-score--mid { background: rgba(245, 158, 11, 0.18); color: #b45309; }
.rag-score--low { background: rgba(107, 114, 128, 0.15); color: #4b5563; }

.rag-card-body {
    font-size: 0.83rem;
    color: var(--text-secondary);
    line-height: 1.55;
    white-space: pre-wrap;
    max-height: 140px;
    overflow: hidden;
    position: relative;
}

.rag-card-body::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 30px;
    background: linear-gradient(transparent, var(--page-bg));
    pointer-events: none;
}

/* ── Aside ── */

.article-aside {
    display: flex;
    flex-direction: column;
    gap: 16px;
    position: sticky;
    top: 24px;
}

@media (max-width: 1100px) {
    .article-aside { position: static; }
}

.aside-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    overflow: hidden;
}

.aside-card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 18px;
    background: var(--page-bg);
    border-bottom: 1px solid var(--border-color);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
}

.aside-card-header i {
    color: var(--accent);
    font-size: 1rem;
}

.aside-list {
    list-style: none;
    margin: 0;
    padding: 6px 0;
}

.aside-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding: 9px 18px;
    font-size: 0.85rem;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-soft);
}

.aside-list li:last-child { border-bottom: none; }

.aside-list-key {
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    flex-shrink: 0;
}

.cost-summary { padding: 14px 18px; }

.cost-summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.cost-summary-row strong {
    color: var(--text-primary);
    font-weight: 600;
}

.cost-summary-row--total {
    border-top: 1px dashed var(--border-color);
    padding-top: 10px;
    margin-top: 4px;
}

.cost-summary-price {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 12px;
    padding: 12px 14px;
    background: linear-gradient(135deg, rgba(79, 125, 249, 0.08), rgba(99, 102, 241, 0.08));
    border-radius: 10px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
}

.cost-price {
    color: var(--accent);
    font-size: 1.05rem;
    font-weight: 700;
}

.aside-brief {
    padding: 14px 18px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.55;
    max-height: 200px;
    overflow-y: auto;
}

/* ════════════════════════════════════════════════════════════
   PROJECT TABS (Обзор / Контент / Пакеты)
   ════════════════════════════════════════════════════════════ */

.project-tabs {
    display: inline-flex;
    background: #ffffff;
    border: 1px solid #ececf6;
    border-radius: 16px;
    padding: 6px;
    gap: 6px;
    box-shadow: 0 0 12px rgba(0, 0, 0, 0.19);
    align-items: center;
}

.project-tab {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 167px;
    height: 46px;
    gap: 10px;
    padding: 10px 20px;
    border-radius: 12px;
    color: #542de2;
    text-decoration: none;
    font-size: 1rem;
    font-weight: 500;
    transition: all 0.15s ease;
    white-space: nowrap;
    box-sizing: border-box;
    background: transparent;
    box-shadow: none;
}

.project-tab:hover {
    color: #542de2;
    background: #f5f1fe;
}

.project-tab.active {
    height: 46px;
    border-radius: 12px;
    padding: 10px 20px;
    background: #ffffff;
    box-shadow: 0 3px 6.1px 0 rgba(84, 45, 226, 0.25);
    color: #542de2;
}

.card {
    background: #ffffff;
    box-shadow: 0 0 14px rgba(0, 0, 0, 0.19);
}

.form-control,
.form-select,
.btn {
    box-shadow: 0 0 8px rgba(0, 0, 0, 0.19);
}

.project-tab i {
    font-size: 0.95rem;
}

.project-tab-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 20px;
    padding: 0 6px;
    border-radius: 100px;
    background: var(--page-bg);
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.project-tab.active .project-tab-count {
    background: rgba(79, 125, 249, 0.2);
    color: var(--accent);
}

/* ════════════════════════════════════════════════════════════
   OVERVIEW STATS
   ════════════════════════════════════════════════════════════ */

.overview-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
}

.overview-stat {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 18px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
}

.overview-stat-icon {
    width: 72px;
    height: 72px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
}

.overview-stat-icon svg,
.overview-stat-icon img {
    width: 72px;
    height: 72px;
    display: block;
    object-fit: cover;
    border-radius: 14px;
}

.overview-stat-value {
    font-family: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-weight: 500;
    font-size: 30px;
    color: var(--text-primary);
    line-height: 1;
    letter-spacing: 0;
    margin-top: 10px;
}

.overview-stat-label {
    font-family: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-weight: 500;
    font-size: 18px;
    color: var(--text-primary);
    line-height: 1;
    letter-spacing: 0;
    text-transform: none;
    margin-top: 0;
}

/* ════════════════════════════════════════════════════════════
   ACTION TILES (Запуск генерации с overview)
   ════════════════════════════════════════════════════════════ */

.action-tiles {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 14px;
}

.action-tile {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 18px 20px;
    background: var(--card-bg);
    border: 1.5px solid var(--border-color);
    border-radius: 14px;
    text-decoration: none;
    color: var(--text-primary);
    transition: all 0.18s ease;
}

.action-tile:hover {
    border-color: var(--accent);
    transform: translateY(-1px);
    box-shadow: 0 6px 22px rgba(79, 125, 249, 0.1);
    color: var(--text-primary);
}

.action-tile-icon {
    width: 46px;
    height: 46px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #4f7df9, #6366f1);
    color: #fff;
    font-size: 1.3rem;
    flex-shrink: 0;
}

.action-tile--accent .action-tile-icon {
    background: linear-gradient(135deg, #f59e0b, #f97316);
}

.action-tile-body {
    flex: 1;
    min-width: 0;
}

.action-tile-title {
    font-weight: 600;
    font-size: 0.98rem;
    color: var(--text-primary);
}

.action-tile-subtitle {
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

.action-tile-arrow {
    color: var(--text-secondary);
    font-size: 1.1rem;
    transition: transform 0.18s ease, color 0.18s ease;
}

.action-tile:hover .action-tile-arrow {
    color: var(--accent);
    transform: translateX(3px);
}

.project-detail-action-tiles {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 24px;
}

.project-detail-topbar {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 16px;
    width: 100%;
}

.project-detail-topbar .project-tabs {
    margin-bottom: 0 !important;
}

.project-detail-delete-form {
    margin: 0 0 0 auto;
    flex-shrink: 0;
}

.project-detail-delete-btn {
    width: 49px;
    height: 49px;
    border: none;
    background: transparent;
    border-radius: 9px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.project-detail-delete-btn svg {
    width: 49px;
    height: 49px;
    display: block;
}

.neuro-page-actions {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.neuro-delete-form {
    margin: 0;
    flex-shrink: 0;
}

.neuro-delete-btn {
    width: 39px;
    height: 39px;
}

.neuro-delete-btn svg {
    width: 39px;
    height: 39px;
}

.project-detail-action-tile {
    min-height: 112px;
    border-radius: 14px;
    border: 1px solid var(--border-color);
    padding: 20px;
    gap: 24px;
}

.project-detail-action-tile-icon {
    width: 72px;
    height: 72px;
    border-radius: 14px;
    background: transparent;
    padding: 0;
}

.project-detail-action-tile-icon svg {
    width: 72px;
    height: 72px;
    display: block;
}

.project-detail-action-arrow {
    width: 54px;
    height: 54px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.project-detail-action-arrow svg {
    display: block;
    width: 54px;
    height: 54px;
}

.project-detail-arrow-link {
    width: 113px;
    height: 36px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}

.project-detail-arrow-link svg {
    width: 113px;
    height: 36px;
    display: block;
}

.project-detail-content-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 16px;
}

.project-detail-content-grid .content-card {
    width: 360px;
    max-width: 100%;
}

.content-open-btn {
    width: 93px;
    height: 31px;
    border-radius: 8px;
    padding: 8px 20px;
    gap: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    background: #542de2;
    color: #fff;
    font-size: 0.86rem;
    font-weight: 600;
    line-height: 1;
}

.content-open-btn:hover {
    background: #542de2;
    color: #fff;
    opacity: 0.95;
}

.project-detail-meta-time {
    width: auto;
    min-width: 108px;
    height: 17px;
    display: inline-flex;
    align-items: center;
    gap: 0;
    color: #505050 !important;
    font-family: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-weight: 500;
    font-size: 14px;
    line-height: 1;
    white-space: nowrap;
}

@media (max-width: 1280px) {
    .project-detail-action-tiles {
        grid-template-columns: 1fr;
    }
}

/* ════════════════════════════════════════════════════════════
   FILTER BAR
   ════════════════════════════════════════════════════════════ */

.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: stretch;
    padding: 12px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
}

.filter-bar-search {
    position: relative;
    flex: 1 1 240px;
    min-width: 200px;
}

.filter-bar-search i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    font-size: 0.95rem;
    pointer-events: none;
}

.filter-bar-search input {
    padding-left: 36px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    font-size: 0.9rem;
    height: 38px;
}

.filter-bar-search input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(79, 125, 249, 0.12);
}

.filter-bar .form-select {
    flex: 0 1 160px;
    min-width: 130px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    font-size: 0.88rem;
    height: 38px;
}

.filter-bar .form-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(79, 125, 249, 0.12);
}

.filter-bar .btn {
    height: 38px;
    border-radius: 8px;
    padding: 0 14px;
}

/* ════════════════════════════════════════════════════════════
   PAGINATION
   ════════════════════════════════════════════════════════════ */

.pagination-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 4px;
}

.pagination-controls {
    display: flex;
    align-items: center;
    gap: 4px;
}

.pagination-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    color: var(--text-secondary);
    text-decoration: none;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    transition: all 0.15s ease;
    font-size: 0.9rem;
}

.pagination-btn:hover:not(.disabled) {
    border-color: var(--accent);
    color: var(--accent);
}

.pagination-btn.disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.pagination-info {
    padding: 0 12px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* ════════════════════════════════════════════════════════════
   FILTER BANNER (например, при фильтрации контента по пакету)
   ════════════════════════════════════════════════════════════ */

.filter-banner {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.08), rgba(249, 115, 22, 0.08));
    border: 1px solid rgba(245, 158, 11, 0.25);
    border-radius: 12px;
}

.filter-banner-icon {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(245, 158, 11, 0.18);
    color: #b45309;
    font-size: 1.05rem;
    flex-shrink: 0;
}

.filter-banner-body {
    flex: 1;
    min-width: 0;
}

.filter-banner-title {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-primary);
}

.filter-banner-subtitle {
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin-top: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.filter-banner-close {
    color: var(--text-secondary);
    text-decoration: none;
    padding: 6px 10px;
    border-radius: 8px;
    transition: all 0.15s ease;
    flex-shrink: 0;
}

.filter-banner-close:hover {
    background: rgba(245, 158, 11, 0.15);
    color: #b45309;
}

/* ════════════════════════════════════════════════════════════
   EMPTY STATE
   ════════════════════════════════════════════════════════════ */

.empty-state {
    text-align: center;
    padding: 56px 20px;
    background: var(--card-bg);
    border: 1px dashed var(--border-color);
    border-radius: 14px;
}

.empty-state i {
    font-size: 3rem;
    color: var(--border-strong);
    display: block;
    margin-bottom: 16px;
}

.empty-state h5 {
    color: var(--text-primary);
    font-weight: 600;
    margin-bottom: 6px;
}

.empty-state p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    max-width: 420px;
    margin: 0 auto;
}

.empty-state a {
    color: var(--accent);
    text-decoration: none;
}

.empty-state a:hover {
    text-decoration: underline;
}

/* ════════════════════════════════════════════════════════════
   LIBRARY HEADER
   ════════════════════════════════════════════════════════════ */

.library-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.library-count {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.1;
}

.library-back-btn {
    width: 195px;
    height: 56px;
    padding: 16px 28px;
    gap: 12px;
    border-radius: 14px;
    border: 1.5px solid #542de2;
    background: #fff;
    color: #542de2;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-weight: 500;
    font-size: 18px;
    line-height: 1;
}

.library-back-btn:hover {
    color: #542de2;
    border-color: #542de2;
    background: #fff;
    opacity: 0.96;
}

.library-back-btn-icon {
    width: 24px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.library-back-btn-icon svg {
    display: block;
}

.content-library-page .filter-bar {
    padding: 14px;
    gap: 12px;
    border-radius: 14px;
}

.content-library-page .filter-bar-search {
    flex: 0 0 553px;
    max-width: 553px;
    min-width: 280px;
}

.content-library-page .filter-bar-search i {
    left: 12px;
    font-size: 1.05rem;
    color: #5b3aff;
}

.content-library-page .filter-bar-search input {
    width: 553px;
    max-width: 100%;
    height: 60px;
    padding: 16px 12px 16px 38px;
    border-radius: 14px;
    border: 1.5px solid #5b3aff;
    box-shadow: 0 6px 16px rgba(91, 58, 255, 0.1);
    font-size: 0.95rem;
}

.content-library-page .filter-bar-search input:focus {
    border-color: #5b3aff;
    box-shadow: 0 0 0 3px rgba(91, 58, 255, 0.12);
}

.content-library-page .filter-bar .form-select {
    width: 215px;
    height: 60px;
    flex: 0 0 215px;
    min-width: 215px;
    border-radius: 14px;
    border: 1.5px solid #5b3aff;
    padding: 16px 12px;
    box-shadow: 0 6px 16px rgba(91, 58, 255, 0.1);
    font-size: 0.93rem;
}

.content-library-page .filter-bar .form-select:focus {
    border-color: #5b3aff;
    box-shadow: 0 0 0 3px rgba(91, 58, 255, 0.12);
}

.content-library-page .filter-bar .btn {
    height: 60px;
    min-width: 60px;
    border-radius: 14px;
    border-width: 1.5px;
    box-shadow: 0 6px 16px rgba(91, 58, 255, 0.12);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.content-library-page .filter-bar .btn.btn-outline-primary {
    border-color: #5b3aff;
    color: #5b3aff;
}

.content-library-page .filter-bar .btn.btn-outline-primary i {
    font-size: 1.15rem;
}

.content-library-page .filter-bar .btn.btn-outline-primary:hover {
    border-color: #5b3aff;
    color: #5b3aff;
    background: #fff;
}

.content-library-page .content-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 16px;
}

.content-library-page .content-grid .content-card {
    width: 360px;
    max-width: 100%;
}

/* ── Переключатель режимов генерации (Одиночная / Репакетинг) ── */
.generation-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.generation-tab {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 18px;
    border: 1.5px solid var(--border-color);
    border-radius: 14px;
    background: var(--card-bg);
    text-decoration: none;
    color: var(--text-primary);
    transition: all 0.18s ease;
}

.generation-tab:hover {
    border-color: var(--accent, #4f7df9);
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(79, 125, 249, 0.08);
    color: var(--text-primary);
}

.generation-tab.active {
    border-color: var(--accent, #4f7df9);
    background: linear-gradient(135deg, rgba(79, 125, 249, 0.06), rgba(99, 102, 241, 0.06));
    box-shadow: 0 4px 18px rgba(79, 125, 249, 0.12);
}

.generation-tab-icon {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #4f7df9, #6366f1);
    color: #fff;
    font-size: 1.25rem;
}

.generation-tab-icon--accent {
    background: linear-gradient(135deg, #f59e0b, #f97316);
}

.generation-tab-body {
    flex: 1;
    min-width: 0;
}

.generation-tab-title {
    font-weight: 600;
    font-size: 0.97rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px;
}

.generation-tab-subtitle {
    font-size: 0.8rem;
    color: var(--text-secondary, #6b7280);
    margin-top: 2px;
}

@media (max-width: 768px) {
    .generation-tabs {
        grid-template-columns: 1fr;
    }
}

/* ── Минималистичные карточки страниц генерации ── */

.gen-form .gen-card {
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: none;
    transition: border-color 0.15s ease;
}

.gen-form .gen-card:hover {
    border-color: var(--border-strong);
}

.gen-section-head {
    display: flex;
    align-items: baseline;
    gap: 12px;
    margin-bottom: 12px;
}

.gen-section-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.gen-section-hint {
    font-size: 0.8rem;
    color: var(--text-secondary, #6b7280);
}

.gen-input {
    border-radius: 8px;
    font-size: 0.93rem;
}

.gen-input:focus {
    border-color: var(--accent, #4f7df9);
    box-shadow: 0 0 0 3px rgba(79, 125, 249, 0.08);
}

.gen-form--batch .gen-card {
    border-radius: 14px;
    box-shadow: 0 0 14px 0 rgba(0, 0, 0, 0.14);
}

.gen-form--batch .form-control,
.gen-form--batch .form-select,
.gen-form--batch .btn {
    box-shadow: none !important;
}

.gen-form--batch .gen-input:focus,
.gen-form--batch .form-select:focus {
    border-color: var(--accent, #4f7df9);
    box-shadow: none !important;
}

.gen-input--wide {
    font-family: 'SF Mono', Consolas, 'Courier New', monospace;
    font-size: 0.88rem;
    min-height: 110px;
}

.gen-form--single {
    width: 100%;
    max-width: none;
}

.gen-form--single .gen-card {
    width: 100%;
    border-radius: 14px;
    box-shadow: 0 0 14px 0 rgba(0, 0, 0, 0.14);
}

.gen-form--single .gen-card--params {
    max-width: none;
}

.gen-form--single .gen-card--brief,
.gen-form--single .gen-submit-wrap {
    max-width: 700px;
}

.gen-form--single .form-control,
.gen-form--single .form-select,
.gen-form--single .btn {
    box-shadow: none !important;
}

.gen-submit-wrap {
    width: 100%;
    text-align: left;
}

.gen-submit-btn {
    width: 100%;
    min-width: 0;
    height: 60px;
    border-radius: 14px;
    padding: 16px 12px;
    background: #542de2 !important;
    border: 1px solid #542de2 !important;
    color: #fff !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-weight: 500;
    font-size: 18px;
    line-height: 1;
    letter-spacing: 0;
}

.gen-submit-btn:hover:not(:disabled) {
    background: #542de2 !important;
    border-color: #542de2 !important;
    color: #fff !important;
    opacity: 0.96;
}

.gen-hint-icon {
    color: var(--text-muted);
    font-size: 0.95rem;
    cursor: help;
    transition: color 0.15s ease;
}

.gen-hint-icon:hover {
    color: var(--accent, #4f7df9);
}

.gen-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.batch-sub-label {
    color: #252233;
    font-family: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-weight: 500;
    font-size: 18px;
    line-height: 1;
    letter-spacing: 0;
}

.batch-inline-input {
    height: 52px;
    min-height: 52px;
    padding: 14px 12px;
    line-height: 24px;
    resize: none;
    overflow-y: hidden;
    scrollbar-width: none;
}

.batch-inline-input::-webkit-scrollbar {
    width: 0;
    height: 0;
    display: none;
}

.gen-params-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
}

@media (max-width: 768px) {
    .gen-row,
    .gen-params-grid {
        grid-template-columns: 1fr;
    }
}

/* Маркер обязательного поля. Вешается на любой контейнер поля
   (.gen-params-grid > div, .item-block-field, .param-cell): красная
   звёздочка в правом верхнем углу. Контейнер автоматически становится
   position: relative, чтобы маркер цеплялся за его края. */
.field-required {
    position: relative;
}

.field-required::after {
    content: '*';
    position: absolute;
    top: 0;
    right: 2px;
    color: var(--danger);
    font-weight: 700;
    font-size: 1.1rem;
    line-height: 1;
    pointer-events: none;
}

/* ── Сетка блоков-материалов на странице репакетинга ── */

.item-blocks-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(390px, 1fr));
    gap: 12px;
    margin-top: 8px;
}

.item-block {
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 14px;
    background: var(--card-bg-soft);
    display: flex;
    flex-direction: column;
    gap: 10px;
    transition: all 0.15s ease;
    position: relative;
}

.item-block:hover {
    border-color: var(--accent);
    background: var(--card-bg);
    box-shadow: 0 2px 8px rgba(79, 125, 249, 0.06);
}

.item-block-head {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 2px;
}

.item-block-num {
    display: none;
}

.item-block-title {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-primary);
}

.item-block-field label {
    display: block;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-secondary, #6b7280);
    margin-bottom: 3px;
}

.item-block-field .form-select {
    border-radius: 6px;
    font-size: 0.85rem;
}

.batch-count-control {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.batch-count-btn {
    width: 24px;
    height: 24px;
    padding: 0;
    border: 0;
    background: transparent;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.batch-count-btn svg {
    display: block;
}

.batch-count-value {
    min-width: 20px;
    text-align: center;
    color: var(--text-primary);
    font-family: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-weight: 600;
    font-size: 18px;
    line-height: 1;
}

.gen-form--batch .gen-submit-wrap {
    max-width: none;
}

/* ── Страница согласования (review) ── */

.review-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.review-item {
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 14px;
    background: var(--card-bg);
    transition: border-color 0.15s ease;
}

.review-item:hover {
    border-color: var(--border-strong);
}

.review-item-head {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 10px;
}

.review-item-num {
    width: auto;
    height: auto;
    background: transparent;
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.3;
    flex-shrink: 0;
}

.review-item .title-text {
    font-weight: 600;
    color: var(--text-primary);
    word-break: break-word;
}

.review-item-params {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    padding: 12px;
    background: var(--card-bg-soft);
    border-radius: 14px;
    margin-bottom: 10px;
}

.review-item-params .param-cell {
    width: 243.75px;
    max-width: 100%;
    flex: 0 0 243.75px;
}

.review-item-params .param-cell label {
    display: block;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-secondary, #6b7280);
    margin-bottom: 6px;
}

.review-item-params .form-select {
    width: 243.75px;
    max-width: 100%;
    height: 60px;
    padding: 16px 12px;
    font-size: 0.9rem;
    border-radius: 14px;
    border-width: 1.5px;
}

.param-saved {
    border-color: #16a34a !important;
    box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.12) !important;
    transition: all 0.15s ease;
}

.regen-section {
    margin-top: 4px;
}

.regen-section .input-group {
    align-items: stretch;
    display: flex;
    gap: 12px;
}

.regen-section .regen-prompt {
    height: 60px;
    border-radius: 14px !important;
    border-width: 1.5px;
    padding: 16px 12px;
    flex: 1 1 auto;
}

.regen-section .btn-regenerate {
    width: 60px;
    height: 60px;
    min-width: 60px;
    padding: 0;
    border-radius: 14px !important;
    border: none !important;
    background: transparent !important;
    color: #5b3aff !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    box-shadow: none !important;
}

.regen-section .btn-regenerate svg {
    width: 60px;
    height: 60px;
    display: block;
}

.review-sidebar {
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: none;
}

.review-waiting-badge {
    color: #f97900;
    background: #ffecda;
    border: 1px solid #ffecda;
    font-weight: 600;
}

.review-sidebar-col {
    padding-top: 44px;
}

#btn-approve {
    background: #542de2 !important;
    border-color: #542de2 !important;
    color: #fff !important;
    width: calc(100% - 80px) !important;
    height: 60px;
    margin: 0 auto;
    display: block;
    border-radius: 14px;
}

#btn-approve:hover:not(:disabled) {
    background: #542de2 !important;
    border-color: #542de2 !important;
    opacity: 0.96;
}

.review-back-link {
    color: #542de2;
    text-decoration: underline;
    text-decoration-color: #542de2;
    font-size: 0.92rem;
}

.review-back-link:hover {
    color: #542de2;
    text-decoration-color: #542de2;
}

@media (max-width: 991.98px) {
    .review-sidebar-col {
        padding-top: 0;
    }
    #btn-approve {
        width: 100% !important;
    }
}

/* ════════════════════════════════════════════════════════════
   IMAGE SLOTS (генерация изображений на странице контента)
   ════════════════════════════════════════════════════════════ */

.image-slots {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
}

.image-slot {
    border: 1px solid var(--border-color);
    border-radius: 14px;
    background: var(--card-bg);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    transition: border-color 0.15s ease;
}

.image-slot:hover { border-color: var(--border-strong); }

.image-slot-head {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.image-slot-num {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 700;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.image-slot-head-body { flex: 1; min-width: 0; }

.image-slot-title {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.image-slot-key {
    font-family: 'SF Mono', Consolas, monospace;
    font-size: 0.72rem;
    padding: 2px 8px;
    border-radius: 100px;
    background: var(--card-bg-soft);
    color: var(--text-secondary);
}

.image-slot-optional {
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 100px;
    background: rgba(245, 158, 11, 0.14);
    color: #b45309;
}

.image-slot-desc {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 4px;
    line-height: 1.45;
}

.image-slot-preview {
    border-radius: 12px;
    overflow: hidden;
    background: var(--card-bg-soft);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-color);

    /* Ограничения, чтобы любая картинка вела себя «как карточка»,
       а не съедала пол-экрана. Aspect-ratio задаётся inline-стилем
       из шаблона по слоту (16:9, 4:3, 1:1, 9:16, 3:2). */
    width: 100%;
    max-width: 720px;
    max-height: 460px;
    margin: 0 auto;
    aspect-ratio: 16 / 9; /* fallback, перебивается inline-стилем */
}

.image-slot-preview img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.image-slot-placeholder {
    text-align: center;
    color: var(--text-muted);
    padding: 24px;
}

.image-slot-placeholder i {
    font-size: 2.2rem;
    display: block;
    margin-bottom: 8px;
    color: var(--border-strong);
}

.image-slot-placeholder span {
    font-size: 0.86rem;
}

.image-slot-versions {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding: 2px;
}

.image-version {
    flex-shrink: 0;
    width: 64px;
    height: 64px;
    border-radius: 8px;
    overflow: hidden;
    border: 2px solid transparent;
    background: var(--card-bg-soft);
    padding: 0;
    cursor: pointer;
    transition: border-color 0.15s ease;
}

.image-version img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.image-version:hover { border-color: var(--border-strong); }
.image-version.is-selected { border-color: var(--accent); }

.image-slot-controls {
    display: grid;
    grid-template-columns: minmax(140px, 1.4fr) minmax(70px, 0.6fr) minmax(160px, 2fr) auto auto;
    gap: 8px;
    align-items: center;
}

.image-slot-controls .form-select,
.image-slot-controls .form-control {
    height: 36px;
    border-radius: 8px;
    font-size: 0.85rem;
}

.image-slot-controls .btn {
    height: 36px;
    border-radius: 8px;
    white-space: nowrap;
}

@media (max-width: 720px) {
    .image-slot-controls {
        grid-template-columns: 1fr 1fr;
    }
    .image-slot-controls .image-slot-custom { grid-column: 1 / -1; }
    .image-slot-controls .image-slot-generate { grid-column: 1 / -1; }
}

/* ════════════════════════════════════════════════════════════
   BRAND LOGOS (CRUD-страница «Логотипы»)
   ════════════════════════════════════════════════════════════ */

.logo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 14px;
}

.logo-card {
    border: 1px solid var(--border-color);
    border-radius: 14px;
    background: var(--card-bg);
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    transition: border-color 0.15s ease;
}

.logo-card:hover { border-color: var(--border-strong); }
.logo-card--default { border-color: rgba(245, 158, 11, 0.55); }

.logo-card-preview {
    height: 110px;
    border-radius: 10px;
    background:
        repeating-conic-gradient(var(--card-bg-soft) 0% 25%, var(--card-bg) 0% 50%) 0 0 / 14px 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.logo-card-preview img {
    max-width: 80%;
    max-height: 80%;
    object-fit: contain;
}

.logo-card-preview i {
    font-size: 2rem;
    color: var(--text-muted);
}

.logo-card-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.92rem;
    line-height: 1.3;
}

.logo-card-meta {
    font-size: 0.78rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

.logo-card-actions {
    display: flex;
    gap: 6px;
    margin-top: auto;
}

/* ════════════════════════════════════════════════════════════
   LOGO EDITOR (модалка размещения логотипа)
   ════════════════════════════════════════════════════════════ */

.logo-editor {
    position: fixed;
    inset: 0;
    z-index: 1080;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.logo-editor[hidden] { display: none; }

.logo-editor-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(13, 17, 23, 0.6);
    backdrop-filter: blur(4px);
}

.logo-editor-panel {
    position: relative;
    z-index: 1;
    width: min(960px, 100%);
    max-height: calc(100vh - 48px);
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.logo-editor-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
}

.logo-editor-hint {
    margin-top: 4px;
    color: var(--text-secondary);
    font-size: 0.82rem;
    line-height: 1.45;
    max-width: 560px;
}

/* Внешний контейнер: центрирует «сцену» и подставляет фон в шахматку,
   чтобы граница картинки была визуально понятна. */
.logo-editor-canvas {
    flex: 1;
    overflow: auto;
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        repeating-conic-gradient(var(--card-bg-soft) 0% 25%, var(--card-bg) 0% 50%) 0 0 / 20px 20px;
    min-height: 320px;
}

/* Сцена — ровно по размеру отображаемой картинки.
   Координаты overlay считаются относительно неё → пиксель в пиксель
   совпадает с реальной геометрией изображения. */
.logo-editor-frame {
    position: relative;
    display: inline-block;
    box-shadow: var(--shadow-md);
    border-radius: 6px;
    overflow: hidden;
    user-select: none;
    line-height: 0;
}

.logo-editor-base {
    display: block;
    max-width: 100%;
    max-height: calc(100vh - 260px);
    pointer-events: none;
}

.logo-editor-overlay {
    position: absolute;
    /* координаты вычисляются JS относительно левого-верхнего угла stage */
    cursor: move;
    box-shadow: 0 0 0 1.5px var(--accent), 0 4px 14px rgba(0, 0, 0, 0.25);
    border-radius: 4px;
    background: transparent;
    box-sizing: border-box;
}

.logo-editor-overlay-img {
    width: 100%;
    height: 100%;
    display: block;
    pointer-events: none;
    user-select: none;
    -webkit-user-drag: none;
}

.logo-editor-handle {
    position: absolute;
    width: 14px;
    height: 14px;
    background: var(--accent);
    border: 2px solid #fff;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.logo-editor-handle[data-corner="tl"] { top: -8px; left: -8px;  cursor: nwse-resize; }
.logo-editor-handle[data-corner="tr"] { top: -8px; right: -8px; cursor: nesw-resize; }
.logo-editor-handle[data-corner="bl"] { bottom: -8px; left: -8px;  cursor: nesw-resize; }
.logo-editor-handle[data-corner="br"] { bottom: -8px; right: -8px; cursor: nwse-resize; }

.logo-editor-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 14px 20px;
    border-top: 1px solid var(--border-color);
    background: var(--card-bg-soft);
}

.logo-editor-status {
    font-family: 'SF Mono', Consolas, monospace;
    font-size: 0.78rem;
    color: var(--text-secondary);
}

/* ════════════════════════════════════════════════════════════
   ACCOUNT PAGE
   ════════════════════════════════════════════════════════════ */

.account-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 18px;
    max-width: 760px;
}

.account-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 24px;
    box-shadow: var(--shadow-sm);
}

.account-card-head {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 18px;
}

.account-card-head-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--accent-soft);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
    flex-shrink: 0;
}

.account-card-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
    line-height: 1.2;
}

.account-card-subtitle {
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* Профиль */

.account-profile {
    display: flex;
    align-items: center;
    gap: 18px;
    padding-top: 4px;
}

.account-avatar {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: linear-gradient(135deg, #4f7df9, #6366f1);
    color: #fff;
    font-size: 1.8rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    text-transform: uppercase;
    box-shadow: 0 6px 20px rgba(79, 125, 249, 0.25);
    overflow: hidden;
}

.account-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.account-profile-name {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.2;
}

.account-profile-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 8px;
}

.account-role-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 100px;
    font-size: 0.75rem;
    font-weight: 600;
    background: var(--accent-soft);
    color: var(--accent);
}

.account-role-badge--admin {
    width: 153px;
    height: 35px;
    border-radius: 8px;
    padding: 8px 16px;
    gap: 10px;
    border: 1px solid #bfb2ff;
    background: #f5f1fe;
    color: #542de2;
    justify-content: center;
    flex-shrink: 0;
    font-family: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-weight: 500;
    font-size: 16px;
    line-height: 1;
    letter-spacing: -0.03em;
}

.account-meta-text {
    font-size: 0.82rem;
    color: var(--text-secondary);
}

/* Переключатель темы */

.theme-picker {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.theme-option {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    padding: 0;
    border: 2px solid var(--border-color);
    border-radius: 14px;
    background: var(--card-bg);
    cursor: pointer;
    overflow: hidden;
    transition: all 0.18s ease;
    text-align: left;
}

.theme-option:hover {
    border-color: var(--border-strong);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.theme-option.active {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.theme-option-preview {
    height: 96px;
    position: relative;
    overflow: hidden;
    border-bottom: 1px solid var(--border-color);
    display: flex;
}

.theme-option-preview-sidebar {
    width: 32%;
    padding: 10px 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.theme-option-preview-content {
    flex: 1;
    padding: 12px 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.theme-option-preview-line {
    height: 6px;
    border-radius: 3px;
}

.theme-option-preview-line--w50 { width: 50%; }
.theme-option-preview-line--w70 { width: 70%; }
.theme-option-preview-line--w90 { width: 90%; }

/* Превью светлой темы */
.theme-option--light .theme-option-preview { background: #f7f8fc; }
.theme-option--light .theme-option-preview-sidebar { background: #0f1117; }
.theme-option--light .theme-option-preview-sidebar .theme-option-preview-line { background: #2d333b; }
.theme-option--light .theme-option-preview-sidebar .theme-option-preview-line:first-child { background: #4f7df9; }
.theme-option--light .theme-option-preview-content .theme-option-preview-line { background: #d1d5db; }

/* Превью тёмной темы */
.theme-option--dark .theme-option-preview { background: #0d1117; }
.theme-option--dark .theme-option-preview-sidebar { background: #010409; }
.theme-option--dark .theme-option-preview-sidebar .theme-option-preview-line { background: #2d333b; }
.theme-option--dark .theme-option-preview-sidebar .theme-option-preview-line:first-child { background: #6b94ff; }
.theme-option--dark .theme-option-preview-content .theme-option-preview-line { background: #2d333b; }

.theme-option-body {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 14px 16px;
}

.theme-option-label {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-primary);
    font-weight: 600;
    font-size: 0.92rem;
}

.theme-option-label i {
    color: var(--text-secondary);
    font-size: 1.05rem;
}

.theme-option.active .theme-option-label i {
    color: var(--accent);
}

.theme-option-check {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 2px solid var(--border-strong);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    flex-shrink: 0;
    transition: all 0.15s ease;
    background: transparent;
}

.theme-option.active .theme-option-check {
    background: var(--accent);
    border-color: var(--accent);
}

.theme-option-check i {
    font-size: 0.75rem;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.theme-option.active .theme-option-check i { opacity: 1; }

/* Logout — отдельная карточка */

.account-logout-row {
    display: flex;
    justify-content: center;
    align-items: center;
}

.account-card-head--session {
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 0;
    flex-wrap: nowrap;
}

.account-card-head-icon--session {
    width: 49px;
    height: 49px;
    border-radius: 8px;
    background: transparent;
    padding: 0;
}

.account-card-head-icon--session svg {
    display: block;
    width: 49px;
    height: 49px;
}

.account-session-text {
    flex: 1;
    min-width: 0;
}

.account-card-head--session .account-card-title {
    font-family: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-weight: 600;
    font-size: 20px;
    line-height: 1;
    letter-spacing: 0;
}

.account-card-head--session .account-card-subtitle {
    font-family: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-weight: 400;
    font-size: 15px;
    line-height: 1;
    letter-spacing: 0;
    margin-top: 6px;
}

.account-logout-text {
    color: var(--text-secondary);
    font-size: 0.88rem;
    line-height: 1.5;
}

.btn-logout {
    width: 186px;
    height: 48px;
    background: #ef5257;
    border: 1px solid #ef5257;
    color: #fff;
    border-radius: 12px;
    padding: 12px 10px;
    gap: 8px;
    font-weight: 600;
    font-size: 0.94rem;
    transition: all 0.15s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-logout:hover {
    background: #ef5257;
    color: #fff;
    border-color: #ef5257;
    opacity: 0.95;
}

@media (max-width: 540px) {
    .theme-picker { grid-template-columns: 1fr; }
    .account-profile { flex-direction: column; align-items: flex-start; text-align: left; }
}

/* ════════════════════════════════════════════════════════════
   DARK MODE — точечные доводки сторонних элементов
   ════════════════════════════════════════════════════════════ */

[data-theme="dark"] .article-body p:first-of-type::first-letter {
    color: var(--accent);
}

[data-theme="dark"] .gen-form .gen-input--wide {
    background: var(--card-bg-soft);
}

[data-theme="dark"] .filter-banner {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.12), rgba(249, 115, 22, 0.10));
    border-color: rgba(245, 158, 11, 0.35);
}

[data-theme="dark"] .filter-banner-icon {
    background: rgba(245, 158, 11, 0.22);
    color: #fbbf24;
}

[data-theme="dark"] .filter-banner-close:hover {
    color: #fbbf24;
}

/* Status-badges — в тёмной теме чуть ярче */
[data-theme="dark"] .status-completed { background: rgba(74, 222, 128, 0.18); color: #4ade80; }
[data-theme="dark"] .status-generating { background: rgba(107, 148, 255, 0.18); color: #84a4ff; }
[data-theme="dark"] .status-error { background: rgba(248, 113, 113, 0.18); color: #f87171; }
[data-theme="dark"] .status-titles_ready { background: rgba(251, 191, 36, 0.18); color: #fbbf24; }
[data-theme="dark"] .status-pending { background: rgba(154, 163, 177, 0.18); color: #9aa3b1; }

/* Bootstrap alert — улучшаем контраст в dark */
[data-bs-theme="dark"] .alert-success { color: #4ade80; }
[data-bs-theme="dark"] .alert-warning { color: #fbbf24; }
[data-bs-theme="dark"] .alert-error,
[data-bs-theme="dark"] .alert-danger { color: #f87171; }

/* Текстовые утилиты Bootstrap */
[data-theme="dark"] .text-muted { color: var(--text-muted) !important; }

/* Inputs/selects — мягкая граница, чтобы выделялись на тёмном card */
[data-theme="dark"] .form-control,
[data-theme="dark"] .form-select {
    background-color: var(--card-bg-soft);
    border-color: var(--border-color);
    color: var(--text-primary);
}

[data-theme="dark"] .form-control:focus,
[data-theme="dark"] .form-select:focus {
    background-color: var(--card-bg-soft);
    border-color: var(--accent);
    color: var(--text-primary);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

[data-theme="dark"] .form-control::placeholder { color: var(--text-muted); }

/* Bootstrap table в dark */
[data-theme="dark"] .table { color: var(--text-primary); --bs-table-bg: transparent; }
[data-theme="dark"] .table > :not(caption) > * > * { background: transparent; color: var(--text-primary); border-bottom-color: var(--border-color); }
[data-theme="dark"] .table-hover > tbody > tr:hover > * { background: var(--card-bg-soft); }

/* Регулировка page-header (он использует --card-bg, что уже корректно работает) */
[data-theme="dark"] .page-header,
[data-theme="dark"] .breadcrumbs {
    background: var(--card-bg);
    border-bottom-color: var(--border-color);
}

/* Buttons в dark */
[data-theme="dark"] .btn-outline-primary {
    color: var(--accent);
    border-color: var(--accent);
}
[data-theme="dark"] .btn-outline-primary:hover {
    background: var(--accent);
    color: #fff;
}

[data-theme="dark"] .btn-outline-secondary {
    color: var(--text-secondary);
    border-color: var(--border-strong);
}
[data-theme="dark"] .btn-outline-secondary:hover {
    background: var(--card-bg-soft);
    color: var(--text-primary);
    border-color: var(--text-secondary);
}

/* Bootstrap badges */
[data-theme="dark"] .bg-info-subtle { background: rgba(107, 148, 255, 0.16) !important; }
[data-theme="dark"] .text-info { color: #84a4ff !important; }
[data-theme="dark"] .bg-warning-subtle { background: rgba(251, 191, 36, 0.18) !important; }
[data-theme="dark"] .text-warning { color: #fbbf24 !important; }

/* ════════════════════════════════════════════════════════════
   НЕЙРОВЫДАЧА (подпроект geo_bot)
   Две страницы: «Запуск» и «Обработки». Минималистичный визуал.
   ════════════════════════════════════════════════════════════ */

/* ── Универсальные блоки ── */

.neuro-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
}

.neuro-section { margin-bottom: 24px; }

.neuro-section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}
.neuro-section-title {
    margin: 0;
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--text-primary);
    display: inline-flex;
    align-items: center;
}
.neuro-section-title i { color: var(--accent); }
.neuro-section-hint {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.neuro-domain-filter {
    margin: 0;
}
.neuro-domain-filter .form-select {
    min-width: 140px;
}
.neuro-top-sites-filter-select {
    min-width: 220px;
    height: 48px;
    font-size: 1rem;
    border-radius: 12px;
    padding-left: 0.9rem;
    padding-right: 2.4rem;
}
.neuro-history-filter {
    margin-right: 0.5rem;
}
.neuro-history-filter-label {
    font-size: 0.95rem;
    color: #111111;
    font-weight: 600;
}
.neuro-history-type-select {
    min-width: 260px;
    height: 48px;
    font-size: 1rem;
    border-radius: 12px;
    padding-left: 0.9rem;
    padding-right: 2.4rem;
}
.neuro-history-new-btn {
    min-height: 48px;
    border-radius: 12px;
    padding: 0.65rem 1.2rem;
    font-size: 1rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
}

/* Прокручиваемый список «Топ сайтов» с залипшей шапкой таблицы. */
.neuro-sources-scroll {
    max-height: 480px;
    overflow-y: auto;
}
.neuro-chart-card .neuro-chart-body.neuro-sources-scroll {
    padding: 0;
    overflow-y: auto;
}
.neuro-sources-scroll .neuro-sources-table thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--card-bg);
}

/* Узкая колонка нумерации в таблице прогонов аналитики. */
.neuro-proc-col-num { width: 56px; }

/* Пустое состояние */
.neuro-empty {
    text-align: center;
    color: var(--text-muted);
    padding: 36px 16px;
    background: var(--card-bg-soft);
    border: 1px dashed var(--border-color);
    border-radius: 12px;
}
.neuro-empty-icon {
    font-size: 2rem;
    color: var(--border-strong);
    margin-bottom: 8px;
    display: block;
}
.neuro-empty p { margin: 0; }

/* ── KPI-плашки ── */

.neuro-kpi-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    margin-bottom: 24px;
}
.neuro-kpi {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 14px 16px;
    transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
.neuro-kpi:hover {
    border-color: var(--border-strong);
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}
.neuro-kpi-label {
    font-size: 0.74rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 6px;
    font-weight: 600;
}
.neuro-kpi-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.1;
}
.neuro-kpi-value-sm {
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.3;
    word-break: break-word;
}

/* ── Бейджи статуса/движка ── */

.neuro-status-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 9px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.neuro-status-ok        { background: rgba(22,163,74,0.12); color: var(--success); }
.neuro-status-completed { background: rgba(22,163,74,0.12); color: var(--success); }
.neuro-status-stopped   { background: rgba(180,83,9,0.12);  color: var(--warning); }
.neuro-status-error     { background: rgba(220,38,38,0.10); color: var(--danger); }
.neuro-status-partial   { background: var(--accent-soft);   color: var(--accent); }
.neuro-status-pending   { background: var(--card-bg-soft);  color: var(--text-secondary); }

.neuro-engine-badge {
    display: inline-flex;
    align-items: center;
    padding: 1px 8px;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.neuro-engine-badge-metric {
    min-width: 96px;
    justify-content: center;
    padding: 4px 12px;
    font-size: 0.78rem;
    line-height: 1.2;
}
/* ── Выбор движков и виджеты параметров API на странице запуска ── */
.neuro-engine-pick {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}
.neuro-engine-pick-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}
.neuro-engine-pick-item input { cursor: pointer; }

.neuro-api-widget {
    border: 1px solid var(--border-color);
    border-radius: 12px;
    margin-bottom: 12px;
    background: var(--card-bg-soft);
}
.neuro-api-widget > summary {
    list-style: none;
    cursor: pointer;
    padding: 10px 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    user-select: none;
}
.neuro-api-widget > summary::-webkit-details-marker { display: none; }
.neuro-api-widget[open] > summary { border-bottom: 1px solid var(--border-color); }
.neuro-api-widget-body { padding: 14px; }
.neuro-api-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
}
.neuro-api-sub-title {
    margin: 14px 0 6px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.neuro-engine-chatgpt     { background: #10ACD3; color: #ffffff; }
.neuro-engine-yandex      { background: #D733B1; color: #ffffff; }
.neuro-engine-chatgpt_api { background: #10A37F; color: #ffffff; }
.neuro-engine-yandex_api  { background: #FC3F1D; color: #ffffff; }

/* Таблица топ-источников */
.neuro-sources-table { margin-bottom: 0; }
.neuro-sources-table th { font-weight: 600; font-size: 0.78rem; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.03em; }
.neuro-domain { font-family: 'SF Mono', Consolas, monospace; }

/* ── Страница «Запуск»: переключатель режимов и формы ── */

.neuro-launch { max-width: 760px; }

.neuro-mode-picker {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 18px;
}
@media (max-width: 600px) {
    .neuro-mode-picker { grid-template-columns: 1fr; }
}

.neuro-mode-btn {
    display: flex;
    align-items: center;
    gap: 14px;
    text-align: left;
    padding: 16px 18px;
    border-radius: 14px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.15s ease;
}
.neuro-mode-btn:hover {
    border-color: var(--border-strong);
    background: var(--card-bg-soft);
    transform: translateY(-1px);
}
.neuro-mode-btn.is-active {
    border-color: #542DE2;
    background: rgba(84, 45, 226, 0.12);
    box-shadow: 0 4px 14px -8px rgba(84, 45, 226, 0.45);
}
.neuro-mode-btn.is-active > i {
    color: #542DE2;
    background: rgba(84, 45, 226, 0.16);
}
.neuro-mode-btn > i {
    font-size: 1.5rem;
    color: var(--accent);
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-soft);
    border-radius: 10px;
}
.neuro-mode-text { display: flex; flex-direction: column; min-width: 0; }
.neuro-mode-title { font-weight: 600; font-size: 0.96rem; }
.neuro-mode-hint  { font-size: 0.78rem; color: var(--text-muted); margin-top: 2px; }

.neuro-launch-form {
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.neuro-form-field { display: flex; flex-direction: column; }
.neuro-form-field .form-control { font-size: 0.95rem; }
.neuro-section-label {
    font-size: 1rem;
    font-weight: 700;
    color: #111111;
}

.neuro-form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 4px;
}
.neuro-launch-submit {
    background: #542DE2;
    border-color: #542DE2;
}
.neuro-launch-submit:hover,
.neuro-launch-submit:focus,
.neuro-launch-submit:active {
    background: #4a26c8 !important;
    border-color: #4a26c8 !important;
}
.neuro-processing-export-btn {
    height: 39px;
    min-height: 39px;
    border-radius: 12px;
    padding: 0 1.05rem;
    font-size: 0.92rem;
    line-height: 1;
    font-weight: 600;
    box-shadow: 0 8px 20px -12px rgba(84, 45, 226, 0.85);
    display: inline-flex;
    align-items: center;
}
.neuro-delete-form {
    display: inline-flex;
    align-items: center;
}

.neuro-date-range {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
@media (max-width: 600px) {
    .neuro-date-range { grid-template-columns: 1fr; }
}

/* ── Конструктор расписания ── */
.neuro-schedule-builder {
    display: flex;
    flex-direction: column;
    gap: 18px;
}
.neuro-sched-narrow { max-width: 160px; }
.neuro-sched-interval-row {
    display: grid;
    grid-template-columns: 160px 1fr;
    gap: 12px;
    align-items: end;
}
@media (max-width: 600px) {
    .neuro-sched-interval-row { grid-template-columns: 1fr; }
}

/* Чипы дней недели */
.neuro-weekday-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.neuro-weekday-chip {
    position: relative;
    cursor: pointer;
    user-select: none;
}
.neuro-weekday-chip input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}
.neuro-weekday-chip span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 46px;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
    background: var(--card-bg);
    transition: all .12s ease;
}
.neuro-weekday-chip:hover span { border-color: #542DE2; color: #542DE2; }
.neuro-weekday-chip input:checked + span {
    background: #542DE2;
    border-color: #542DE2;
    color: #fff;
}
.neuro-weekday-chip input:focus-visible + span {
    outline: 2px solid rgba(84, 45, 226, 0.4);
    outline-offset: 2px;
}

/* Текущий файл вопросов на странице редактирования */
.neuro-sched-current-file {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.88rem;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

/* Чекбокс «активно» */
.neuro-sched-active-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-weight: 500;
    color: var(--text-primary);
}
.neuro-sched-active-toggle input { width: 18px; height: 18px; accent-color: #542DE2; }

/* Действия в списке расписаний */
.neuro-sched-col-actions { width: 140px; }
.neuro-sched-actions {
    text-align: right;
    white-space: nowrap;
}
.neuro-sched-action-btn {
    color: var(--text-secondary);
    padding: 2px 6px;
    font-size: 1.05rem;
    text-decoration: none;
}
.neuro-sched-action-btn:hover { color: #542DE2; }
.neuro-sched-action-danger:hover { color: var(--danger, #dd3d3b); }

/* Drag&drop зона */
.neuro-dropzone {
    display: block;
    border: 2px dashed var(--border-color);
    border-radius: 12px;
    background: var(--card-bg-soft);
    padding: 22px;
    text-align: center;
    cursor: pointer;
    transition: all 0.15s ease;
    margin-bottom: 0;
}
.neuro-dropzone:hover {
    border-color: var(--accent);
    background: var(--accent-softer);
}
.neuro-dropzone.is-dragover {
    border-color: var(--accent);
    background: var(--accent-soft);
    transform: scale(1.005);
}
.neuro-dropzone.is-invalid {
    border-color: var(--danger);
    background: rgba(220,38,38,0.06);
    animation: neuro-dz-shake 0.32s ease-in-out;
}
@keyframes neuro-dz-shake {
    0%,100% { transform: translateX(0); }
    25%     { transform: translateX(-4px); }
    75%     { transform: translateX(4px); }
}
.neuro-dropzone-empty { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.neuro-dropzone-icon { font-size: 1.8rem; color: var(--accent); margin-bottom: 4px; }
.neuro-dropzone-title { font-size: 0.95rem; color: var(--text-primary); font-weight: 500; }
.neuro-dropzone-pick { color: var(--accent); text-decoration: underline; cursor: pointer; }
.neuro-dropzone-hint  { font-size: 0.8rem; color: var(--text-muted); }

.neuro-dropzone-file {
    display: flex;
    align-items: center;
    gap: 12px;
    text-align: left;
}
.neuro-dropzone-file > i {
    font-size: 1.6rem;
    color: var(--accent);
    flex-shrink: 0;
}
.neuro-dropzone-file-meta { flex: 1; min-width: 0; }
.neuro-dropzone-file-name {
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.neuro-dropzone-file-size { font-size: 0.78rem; color: var(--text-muted); }
.neuro-dropzone-clear { color: var(--text-muted); padding: 2px 6px; }
.neuro-dropzone-clear:hover { color: var(--danger); }

/* ── Страница «Обработки»: таблица ── */

.neuro-proc-table { padding: 0; }
.neuro-proc-table table { margin-bottom: 0; }
.neuro-proc-table thead th {
    background: var(--card-bg-soft);
    color: var(--text-secondary);
    font-size: 0.74rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-color);
}
.neuro-proc-table tbody td {
    padding: 12px 14px;
    vertical-align: middle;
    border-top: 1px solid var(--border-color);
}
.neuro-proc-row { cursor: pointer; }
.neuro-proc-row:hover td { background: var(--card-bg-soft); }
.neuro-proc-brand {
    font-weight: 600;
    color: var(--text-primary);
}
.neuro-proc-date {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-family: 'SF Mono', Consolas, monospace;
}
.neuro-proc-link {
    width: 40px;
    text-align: right;
}
.neuro-proc-arrow {
    color: var(--text-muted);
    text-decoration: none;
    transition: all 0.12s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 6px;
}
.neuro-proc-row:hover .neuro-proc-arrow {
    color: var(--accent);
    background: var(--accent-soft);
    transform: translateX(2px);
}
.neuro-proc-col-status { width: 110px; }
.neuro-proc-col-type   { width: 170px; }
.neuro-proc-col-date   { width: 160px; }
.neuro-proc-col-q      { width: 110px; }
.neuro-proc-period {
    font-size: 0.74rem;
    color: var(--text-muted);
    margin-top: 2px;
    font-family: 'SF Mono', Consolas, monospace;
}
.neuro-proc-row--muted td { opacity: 0.6; }

/* Цвета status badges под новые enum-значения PG */
.neuro-status-running { background: var(--accent-soft);   color: var(--accent); }
.neuro-status-failed  { background: rgba(220,38,38,0.10); color: var(--danger); }

/* ── Аналитика: переключатель движков и графики ── */

.neuro-engine-filter {
    display: inline-flex;
    background: var(--card-bg-soft);
    border-radius: 8px;
    padding: 3px;
}
.neuro-engine-filter-tab input { display: none; }
.neuro-engine-filter-tab span {
    display: inline-block;
    padding: 4px 12px;
    font-size: 0.82rem;
    color: var(--text-secondary);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.12s ease;
}
.neuro-engine-filter-tab input:checked + span {
    background: var(--card-bg);
    color: var(--accent);
    font-weight: 600;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

/* Мультивыбор движков (чекбоксы): цветная точка + приглушение выключенных. */
.neuro-engine-filter--multi { flex-wrap: wrap; gap: 2px; }
.neuro-engine-filter-tab--check span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.neuro-engine-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    display: inline-block;
    flex: 0 0 auto;
}
/* Выключенный движок — приглушаем подпись и точку. */
.neuro-engine-filter-tab--check input:not(:checked) + span {
    opacity: 0.4;
    text-decoration: line-through;
}

.neuro-chart-card {
    padding: 14px 16px 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.neuro-chart-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
    flex-wrap: wrap;
}
.neuro-chart-title {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.92rem;
}
.neuro-chart-deltas {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 6px;
}
.neuro-chart-delta {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 10px;
    border-radius: 999px;
    background: var(--card-bg-soft);
    border: 1px solid var(--border-color);
    font-size: 0.74rem;
    font-weight: 600;
}
.neuro-chart-delta-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
}
.neuro-chart-delta-label { color: var(--text-secondary); }
.neuro-chart-delta-val   { color: var(--text-primary); font-family: 'SF Mono', Consolas, monospace; }
.neuro-delta-up   .neuro-chart-delta-val { color: var(--success); }
.neuro-delta-down .neuro-chart-delta-val { color: var(--danger); }
.neuro-delta-zero .neuro-chart-delta-val { color: var(--text-muted); }

.neuro-chart-body {
    position: relative;
    height: 280px;
}

/* Бейдж типа обработки (regular / analytics) */
.neuro-type-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 9px;
    border-radius: 999px;
    font-size: 0.74rem;
    font-weight: 600;
    border: 1px solid transparent;
}
.neuro-type-regular,
.neuro-type-processing {
    background: var(--accent-soft);
    color: var(--accent);
    border-color: var(--accent-soft);
}
.neuro-type-analytics {
    background: rgba(168, 85, 247, 0.12);
    color: #a855f7;
    border-color: rgba(168, 85, 247, 0.20);
}
[data-theme="dark"] .neuro-type-analytics { color: #c084fc; }

/* Раскрывающиеся ответы по вопросу */
.neuro-answers { display: flex; flex-direction: column; gap: 6px; }
.neuro-answer-row {
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: var(--card-bg);
}
.neuro-answer-row > summary {
    list-style: none;
    cursor: pointer;
    padding: 10px 14px;
    display: flex;
    align-items: center;
    gap: 12px;
    user-select: none;
}
.neuro-answer-row > summary::-webkit-details-marker { display: none; }
.neuro-answer-row[open] > summary { border-bottom: 1px solid var(--border-color); }
.neuro-answer-num {
    width: 24px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.82rem;
}
.neuro-answer-q {
    flex: 1;
    color: var(--text-primary);
    font-weight: 500;
}
.neuro-answer-engines { display: flex; gap: 4px; }
.neuro-answer-engines .neuro-engine-badge,
.neuro-answer-engine-head .neuro-engine-badge {
    min-width: 96px;
    justify-content: center;
    padding: 4px 12px;
    font-size: 0.78rem;
    line-height: 1.2;
}
.neuro-answer-body { padding: 10px 14px 14px; display: flex; flex-direction: column; gap: 14px; }
.neuro-answer-engine-block {
    background: var(--card-bg-soft);
    border-radius: 8px;
    padding: 10px 12px;
}
.neuro-answer-engine-head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;
}
.neuro-answer-meta { font-size: 0.78rem; color: var(--text-secondary); }
.neuro-answer-text {
    font-size: 0.95rem;
    line-height: 1.7;
    color: #111111;
    background: rgba(84, 45, 226, 0.04);
    border: 1px solid rgba(84, 45, 226, 0.10);
    border-radius: 10px;
    padding: 12px 14px;
}
.neuro-answer-text > *:first-child { margin-top: 0; }
.neuro-answer-text > *:last-child { margin-bottom: 0; }
.neuro-answer-text p { margin: 0 0 0.7rem; }

/* Заголовки внутри ответа LLM */
.neuro-answer-text .neuro-answer-h {
    color: #1c1340;
    font-weight: 700;
    line-height: 1.3;
    margin: 1.1rem 0 0.5rem;
}
.neuro-answer-text h1.neuro-answer-h { font-size: 1.3rem; }
.neuro-answer-text h2.neuro-answer-h { font-size: 1.18rem; }
.neuro-answer-text h3.neuro-answer-h { font-size: 1.06rem; }
.neuro-answer-text h4.neuro-answer-h,
.neuro-answer-text h5.neuro-answer-h,
.neuro-answer-text h6.neuro-answer-h {
    font-size: 0.97rem;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    color: #4a3d7a;
}

/* Списки */
.neuro-answer-text ul,
.neuro-answer-text ol {
    margin: 0 0 0.7rem;
    padding-left: 1.35rem;
}
.neuro-answer-text li { margin: 0.2rem 0; }
.neuro-answer-text ul { list-style: none; padding-left: 1.4rem; }
.neuro-answer-text ul > li { position: relative; }
.neuro-answer-text ul > li::before {
    content: "";
    position: absolute;
    left: -1.05rem;
    top: 0.62em;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #542de2;
}

/* Инлайн-форматирование */
.neuro-answer-text strong { color: #1c1340; font-weight: 700; }
.neuro-answer-text a {
    color: #542de2;
    text-decoration: underline;
    text-underline-offset: 2px;
    word-break: break-word;
}
.neuro-answer-text a:hover { color: #3d1fb0; }
.neuro-answer-text code {
    font-family: 'SF Mono', Consolas, monospace;
    font-size: 0.88em;
    background: rgba(84, 45, 226, 0.10);
    padding: 0.1em 0.38em;
    border-radius: 5px;
}
.neuro-answer-text .neuro-answer-code {
    margin: 0 0 0.7rem;
    padding: 10px 12px;
    background: #1c1340;
    color: #f3f0ff;
    border-radius: 8px;
    overflow-x: auto;
    font-size: 0.85rem;
    line-height: 1.5;
}
.neuro-answer-text .neuro-answer-code code {
    background: none;
    padding: 0;
    color: inherit;
    font-size: inherit;
}
.neuro-answer-text blockquote {
    margin: 0 0 0.7rem;
    padding: 0.35rem 0 0.35rem 0.9rem;
    border-left: 3px solid #542de2;
    color: #4a3d7a;
    font-style: italic;
}
.neuro-answer-text .neuro-answer-hr {
    border: 0;
    border-top: 1px solid rgba(84, 45, 226, 0.18);
    margin: 1rem 0;
}

/* Блок ссылок-источников под абзацем/пунктом */
.neuro-answer-sources {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin: 0.4rem 0 0.8rem;
}
.neuro-answer-sources-label {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #8a7fb0;
}
.neuro-answer-source {
    display: inline-flex;
    align-items: center;
    max-width: 100%;
    padding: 2px 10px;
    font-size: 0.78rem;
    line-height: 1.5;
    color: #542de2 !important;
    background: rgba(84, 45, 226, 0.08);
    border: 1px solid rgba(84, 45, 226, 0.18);
    border-radius: 999px;
    text-decoration: none !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: background-color .12s ease, border-color .12s ease;
}
a.neuro-answer-source:hover {
    background: rgba(84, 45, 226, 0.16);
    border-color: rgba(84, 45, 226, 0.35);
}
.neuro-answer-text li .neuro-answer-sources { margin-bottom: 0.2rem; }

/* Тёмная тема */
[data-theme="dark"] .neuro-answer-text {
    color: #e8e6f2;
    background: rgba(124, 92, 255, 0.08);
    border-color: rgba(124, 92, 255, 0.18);
}
[data-theme="dark"] .neuro-answer-text .neuro-answer-h { color: #ece9ff; }
[data-theme="dark"] .neuro-answer-text h4.neuro-answer-h,
[data-theme="dark"] .neuro-answer-text h5.neuro-answer-h,
[data-theme="dark"] .neuro-answer-text h6.neuro-answer-h { color: #b6abe6; }
[data-theme="dark"] .neuro-answer-text strong { color: #ece9ff; }
[data-theme="dark"] .neuro-answer-text a,
[data-theme="dark"] .neuro-answer-source { color: #b9a8ff !important; }
[data-theme="dark"] .neuro-answer-text blockquote { color: #b6abe6; }
[data-theme="dark"] .neuro-answer-source {
    background: rgba(124, 92, 255, 0.14);
    border-color: rgba(124, 92, 255, 0.28);
}

.neuro-metrics-section .neuro-section-head,
.neuro-top-sites-section .neuro-section-head {
    min-height: 48px;
    align-items: center;
}

/* ════════════════════════════════════════════════════════════
   VERSION PICKER + BANNER (версии сгенерированного контента)
   ════════════════════════════════════════════════════════════ */

.version-picker { position: relative; }

.version-picker-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.version-picker-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    z-index: 1000;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    box-shadow: var(--shadow-lg);
    padding: 6px;
    min-width: 280px;
    max-width: 360px;
}

.version-picker-list {
    display: flex;
    flex-direction: column;
    gap: 1px;
    max-height: 380px;
    overflow-y: auto;
}

.version-picker-item {
    background: transparent;
    border: none;
    padding: 8px 10px;
    text-align: left;
    border-radius: 8px;
    color: var(--text-primary);
    cursor: pointer;
    transition: background 0.12s ease;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.version-picker-item:hover { background: var(--card-bg-soft); }

.version-picker-item.is-current { background: var(--accent-soft); }
.version-picker-item.is-current .version-picker-item-num { color: var(--accent); font-weight: 700; }

.version-picker-item.is-viewing:not(.is-current) {
    box-shadow: inset 0 0 0 1px var(--border-strong);
}

.version-picker-item-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
}

.version-picker-item-num {
    font-weight: 600;
    font-size: 0.92rem;
}

.version-picker-item-date {
    font-size: 0.74rem;
    color: var(--text-muted);
    font-family: 'SF Mono', Consolas, monospace;
}

.version-picker-item-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    font-size: 0.78rem;
    color: var(--text-secondary);
}

.version-picker-item-tag {
    background: var(--card-bg-soft);
    color: var(--text-secondary);
    padding: 1px 8px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 500;
}

.version-picker-item-note {
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    min-width: 0;
}

/* Баннер «не активная версия / предложение AI» над лентой блоков */
.version-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 14px;
    border-radius: 10px;
    background: var(--accent-softer);
    border: 1px solid var(--accent-soft);
    color: var(--text-primary);
    margin: 0 0 12px;
    font-size: 0.88rem;
}

.version-banner[hidden] { display: none; }

.version-banner.is-old {
    background: rgba(180, 83, 9, 0.07);
    border-color: rgba(180, 83, 9, 0.25);
}

.version-banner.is-revision {
    background: var(--accent-softer);
    border-color: var(--accent-soft);
}

.version-banner-text {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ════════════════════════════════════════════════════════════
   AI CHAT (drawer для доработки контента)
   ════════════════════════════════════════════════════════════ */

.ai-chat {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 400px;
    max-width: 92vw;
    background: var(--card-bg);
    border-left: 1px solid var(--border-color);
    box-shadow: -8px 0 32px -12px rgba(0, 0, 0, 0.18);
    display: flex;
    flex-direction: column;
    z-index: 1070;
    animation: ai-chat-slide 0.18s ease-out;
}

[data-theme="dark"] .ai-chat {
    box-shadow: -8px 0 32px -12px rgba(0, 0, 0, 0.55);
}

.ai-chat[hidden] { display: none; }

@keyframes ai-chat-slide {
    from { transform: translateX(100%); }
    to   { transform: translateX(0); }
}

.ai-chat-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    background: var(--card-bg-soft);
}

.ai-chat-title {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    color: var(--text-primary);
    flex: 1;
}

.ai-chat-title i { color: var(--accent); }

.ai-chat-cost {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.78rem;
    color: var(--text-secondary);
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
}

.ai-chat-close { margin-left: 4px; }

.ai-chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.ai-chat-empty {
    text-align: center;
    color: var(--text-muted);
    padding: 32px 12px;
}

.ai-chat-empty-icon {
    font-size: 2rem;
    color: var(--accent);
    opacity: 0.6;
    margin-bottom: 6px;
}

.ai-chat-empty-title {
    color: var(--text-primary);
    margin-bottom: 6px;
}

.ai-chat-empty-hint {
    font-size: 0.85rem;
    line-height: 1.5;
    margin: 0;
}

.ai-chat-msg {
    max-width: 85%;
    padding: 9px 12px;
    border-radius: 12px;
    font-size: 0.92rem;
    line-height: 1.45;
    color: var(--text-primary);
    background: var(--card-bg-soft);
    word-wrap: break-word;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.ai-chat-msg--user {
    align-self: flex-end;
    background: var(--accent-soft);
    border: 1px solid var(--accent-soft);
}

.ai-chat-msg--assistant {
    align-self: flex-start;
    background: var(--card-bg-soft);
    border: 1px solid var(--border-color);
}

.ai-chat-msg-text {
    white-space: pre-wrap;
}

.ai-chat-msg-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    font-size: 0.7rem;
    color: var(--text-muted);
}

.ai-chat-msg-model,
.ai-chat-msg-cost {
    font-family: 'SF Mono', Consolas, monospace;
}

.ai-chat-msg-cost {
    color: var(--accent);
}

.ai-chat-footer {
    border-top: 1px solid var(--border-color);
    padding: 10px 12px 14px;
    background: var(--card-bg);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ai-chat-controls {
    display: flex;
    gap: 8px;
}

.ai-chat-input-wrap {
    position: relative;
}

.ai-chat-input {
    resize: none;
    padding-right: 44px;
    min-height: 56px;
    max-height: 180px;
    font-size: 0.92rem;
}

.ai-chat-send {
    position: absolute;
    right: 6px;
    bottom: 6px;
    width: 32px;
    height: 32px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.ai-chat-status {
    font-size: 0.78rem;
    color: var(--text-secondary);
    padding: 4px 6px;
    border-radius: 6px;
}

.ai-chat-status.is-loading { color: var(--accent); }
.ai-chat-status.is-success { color: var(--success); }
.ai-chat-status.is-error   { color: var(--danger); }

/* Индикатор «AI печатает» — три прыгающих жирных точки по центру
   ленты чата под последним user-сообщением. */
.ai-chat-typing {
    align-self: center;
    display: inline-flex;
    align-items: flex-end;
    gap: 6px;
    padding: 8px 4px;
    height: 24px;
}

.ai-chat-typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-primary);
    opacity: 0.65;
    animation: ai-chat-typing-bounce 1.2s infinite ease-in-out;
}

.ai-chat-typing-dot:nth-child(2) { animation-delay: 0.18s; }
.ai-chat-typing-dot:nth-child(3) { animation-delay: 0.36s; }

@keyframes ai-chat-typing-bounce {
      0%, 80%, 100% { transform: translateY(0)    scale(0.85); opacity: 0.45; }
    40%             { transform: translateY(-6px) scale(1);    opacity: 1;    }
}

/* ════════════════════════════════════════════════════════════
   ADMIN PANEL (Панель управления)
   Приводим страницы к базовому дизайну: вкладки project-tabs,
   таблицы library-list-table, кнопки template-action-btn / library-form-btn.
   ════════════════════════════════════════════════════════════ */

/* Группа кнопок-действий в строке таблицы */
.admin-actions {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
}

.admin-actions form {
    margin: 0;
    line-height: 0;
}

/* Квадратная кнопка-иконка (блокировка, отзыв доступа) под размер
   library-action-btn-sm (44×44), в стиле базовых action-кнопок. */
.admin-icon-btn {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    border: 1.5px solid var(--border-strong);
    background: #fff;
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.05rem;
    padding: 0;
    cursor: pointer;
    transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.admin-icon-btn:hover {
    color: var(--text-primary);
    border-color: var(--border-strong);
    background: var(--card-bg-hover);
}

.admin-icon-btn--warning {
    border-color: #e0a23b;
    color: #b45309;
}

.admin-icon-btn--warning:hover {
    background: #fff7e9;
    border-color: #d8902a;
    color: #b45309;
}

.admin-icon-btn--danger {
    border-color: #dd3d3b;
    color: #dd3d3b;
}

.admin-icon-btn--danger:hover {
    background: #fff1f1;
    border-color: #dd3d3b;
    color: #dd3d3b;
}

/* Не даём строкам таблицы подсвечиваться при наведении на иконки */
.admin-table th:last-child,
.admin-table td:last-child {
    width: 1%;
    white-space: nowrap;
}

/* Карточка-форма редактирования аккаунта */
.admin-form-card {
    width: 100%;
    max-width: 640px;
}

/* Список выданных доступов к площадкам */
.admin-access-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.admin-access-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: var(--card-bg-soft);
}

.admin-access-info {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    flex-wrap: wrap;
}

/* Форма выдачи доступа: select + кнопка в одну строку, переносится на узких */
.admin-grant-form {
    display: flex;
    align-items: stretch;
    gap: 10px;
    flex-wrap: wrap;
}

.admin-grant-form .form-select {
    flex: 1 1 200px;
    min-width: 0;
}

.admin-grant-form .library-form-btn-sm {
    flex: 0 0 auto;
}

/* ════════════════════════════════════════════════════════════
   LAPTOP RESPONSIVENESS — адаптация под экраны ноутбуков
   ────────────────────────────────────────────────────────────
   Базовая вёрстка проектировалась под широкие мониторы и содержит
   много жёстких пиксельных размеров. Ниже — связный набор
   брейкпоинтов под типовые ноутбуки (1536 / 1366 / 1200 px),
   который ужимает отступы, фиксированные ширины и крупную
   типографику. Блоки идут по убыванию ширины: при наложении
   правил для меньшего экрана срабатывает последний подходящий.
   ════════════════════════════════════════════════════════════ */

/* — Крупные ноутбуки и компактные десктопы (≤1536px) — */
@media (max-width: 1536px) {
    .page-body { padding: 28px; }
    .page-header { padding: 18px 28px; }
    .breadcrumbs { padding: 12px 28px; }
    .project-create-card { padding: 18px; }
}

/* — Типовые ноутбуки 1366×768 и около (≤1366px) — */
@media (max-width: 1366px) {
    :root {
        --sidebar-width: 236px;
    }

    .page-body { padding: 22px 24px; }
    .page-header { padding: 16px 24px; }
    .page-title { font-size: 1.28rem; }
    .breadcrumbs { padding: 12px 24px; font-size: 18px; }

    /* Крупные фикс-кнопки делаем гибкими, чтобы они не вылезали
       за пределы карточек и узких колонок. */
    .library-form-btn { width: auto; min-width: 200px; max-width: 100%; }
    .template-editor-save-btn,
    .template-editor-cancel-btn { width: auto; min-width: 220px; }

    /* Поиск проектов: не держим жёсткие 600px. */
    .projects-search-input-wrap { flex: 1 1 360px; width: auto; }

    /* Чуть компактнее крупная типографика редактора. */
    .editor-title { font-size: 1.7rem; }
    .editor-main { padding: 30px 22px 40px; }
}

/* — Небольшие ноутбуки и крупные планшеты (≤1200px) — */
@media (max-width: 1200px) {
    :root {
        --sidebar-width: 224px;
    }

    .page-body { padding: 20px; }
    .page-header {
        padding: 14px 20px;
        gap: 12px;
        flex-wrap: wrap;
    }
    .breadcrumbs { padding: 10px 20px; font-size: 17px; }

    /* Шапка страницы переносит действия под заголовок при нехватке места. */
    .page-actions { flex-wrap: wrap; }

    /* Двухколоночные раскладки перестраиваются раньше, чтобы основная
       колонка не сжималась слишком сильно из-за боковой панели. */
    .editor-layout { grid-template-columns: 1fr; }
    .editor-aside { order: -1; display: flex; flex-wrap: wrap; gap: 12px; }
    .editor-aside-card { flex: 1 1 240px; }
    .article-layout { grid-template-columns: 1fr; }
}

/* ── Анализ трендов ── */
.trend-overview {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}
.trend-stat {
    display: block;
    padding: 18px 20px;
    background: #fff;
    border: 1px solid #ececf1;
    border-radius: 14px;
    text-decoration: none;
    color: inherit;
    transition: border-color .15s, box-shadow .15s;
}
.trend-stat:hover {
    border-color: #542de2;
    box-shadow: 0 4px 14px rgba(84, 45, 226, .08);
}
.trend-stat--accent { background: #f5f1fe; }
.trend-stat-value { font-size: 28px; font-weight: 700; line-height: 1.1; }
.trend-stat-label { font-size: 13px; color: #6b6b76; margin-top: 4px; }

.trend-idea-rationale {
    background: #f5f1fe;
    border-left: 3px solid #542de2;
    border-radius: 8px;
    padding: 10px 12px;
}
.trend-idea-sources ul { padding-left: 18px; }
.trend-idea-card--dismissed { opacity: .6; }

@media (max-width: 900px) {
    .trend-overview { grid-template-columns: repeat(2, 1fr); }
}

