/* ==================== VARIABLES ==================== */
:root {
    --bg-primary: #0a0a0a;
    --bg-secondary: #141414;
    --bg-tertiary: #1a1a1a;
    --text-primary: #ffffff;
    --text-secondary: #a0a0a0;
    --text-muted: #666666;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --success: #22c55e;
    --warning: #eab308;
    --danger: #ef4444;
    --border: #262626;
    --border-light: #333333;
    --radius: 8px;
    --radius-lg: 12px;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
}

/* ==================== RESET ==================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
}

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

a:hover {
    text-decoration: underline;
}

/* ==================== LAYOUT ==================== */
.app {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 250px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
}

.logo {
    padding: 20px;
    border-bottom: 1px solid var(--border);
}

.logo h1 {
    font-size: 18px;
    font-weight: 600;
}

.nav {
    flex: 1;
    padding: 16px;
}

.nav-link {
    display: block;
    padding: 10px 12px;
    border-radius: var(--radius);
    color: var(--text-secondary);
    transition: all 0.2s;
}

.nav-link:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    text-decoration: none;
}

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

.content {
    flex: 1;
    margin-left: 250px;
    padding: 32px;
    max-width: 1200px;
}

/* ==================== PAGE HEADER ==================== */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
}

.page-header h1 {
    font-size: 28px;
    font-weight: 600;
}

.breadcrumb {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.breadcrumb a {
    color: var(--text-secondary);
}

/* ==================== BUTTONS ==================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--accent);
    color: white;
}

.btn-primary:hover {
    background: var(--accent-hover);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-full {
    width: 100%;
}

.btn-sm {
    padding: 6px 10px;
    font-size: 12px;
}

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

/* ==================== FORMS ==================== */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 14px;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--accent);
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

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

.input-group {
    display: flex;
    gap: 8px;
}

.input-group input {
    flex: 1;
}

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

.hint {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 12px;
}

/* ==================== PROJECTS GRID ==================== */
.projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.project-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    transition: all 0.2s;
    display: block;
    color: inherit;
}

.project-card:hover {
    border-color: var(--accent);
    text-decoration: none;
    transform: translateY(-2px);
}

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

.project-card h3 {
    font-size: 18px;
    font-weight: 600;
}

.project-lang {
    font-size: 12px;
    color: var(--text-muted);
    background: var(--bg-tertiary);
    padding: 2px 8px;
    border-radius: 4px;
}

.project-niche {
    font-size: 14px;
    color: var(--accent);
    margin-bottom: 8px;
}

.project-desc {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.project-meta {
    font-size: 12px;
    color: var(--text-muted);
}

/* ==================== TABS ==================== */
.tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 24px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 4px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.tabs::-webkit-scrollbar { display: none; }

.tab {
    padding: 10px 20px;
    background: none;
    border: none;
    border-radius: var(--radius) var(--radius) 0 0;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
    white-space: nowrap;
    flex-shrink: 0;
}

.tab:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
}

.tab.active {
    color: var(--accent);
    background: var(--bg-secondary);
    border-bottom: 2px solid var(--accent);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* ==================== KEYWORDS TABLE ==================== */
.keyword-research {
    background: var(--bg-secondary);
    padding: 20px;
    border-radius: var(--radius-lg);
    margin-bottom: 24px;
}

.keywords-table {
    width: 100%;
    border-collapse: collapse;
}

.keywords-table th,
.keywords-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.keywords-table th {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
}

.keywords-table tr.used {
    opacity: 0.5;
}

.keywords-table .actions {
    display: flex;
    gap: 8px;
}

/* ==================== BADGES ==================== */
.badge {
    display: inline-block;
    padding: 4px 8px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 4px;
    text-transform: uppercase;
}

.badge-primary { background: #3b82f620; color: #3b82f6; }
.badge-secondary { background: #6b728020; color: #6b7280; }
.badge-long_tail { background: #8b5cf620; color: #8b5cf6; }
.badge-lsi { background: #06b6d420; color: #06b6d4; }
.badge-blog { background: #3b82f620; color: #3b82f6; }
.badge-vc { background: #f9731620; color: #f97316; }
.badge-dzen { background: #eab30820; color: #eab308; }
.badge-telegram { background: #0ea5e920; color: #0ea5e9; }

/* ==================== ARTICLES ==================== */
.articles-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.filter-group select {
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
}

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

.article-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px;
    cursor: pointer;
    transition: all 0.2s;
}

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

.article-card-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
}

.article-card h4 {
    font-size: 15px;
    font-weight: 500;
    margin-bottom: 8px;
    line-height: 1.4;
}

.article-meta {
    font-size: 12px;
    color: var(--text-muted);
}

.seo-score {
    font-size: 12px;
    font-weight: 600;
}

.score-green { color: var(--success); }
.score-yellow { color: var(--warning); }
.score-red { color: var(--danger); }

/* ==================== ARTICLE VIEW ==================== */
.article-view {
    max-height: 70vh;
    overflow-y: auto;
}

.article-meta-info {
    display: flex;
    gap: 16px;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.meta-desc {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 16px;
    padding: 12px;
    background: var(--bg-tertiary);
    border-radius: var(--radius);
}

.audit-summary {
    background: var(--bg-tertiary);
    padding: 16px;
    border-radius: var(--radius);
    margin-bottom: 16px;
}

.audit-summary h4 {
    margin-bottom: 8px;
}

.article-content {
    background: var(--bg-tertiary);
    padding: 20px;
    border-radius: var(--radius);
    margin-bottom: 16px;
}

.article-content pre {
    white-space: pre-wrap;
    word-wrap: break-word;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.7;
}

.article-actions {
    display: flex;
    gap: 12px;
}

/* ==================== MODAL ==================== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal.hidden {
    display: none;
}

.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
}

.modal-content {
    position: relative;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 700px;
    max-height: 90vh;
    overflow: hidden;
    box-shadow: var(--shadow);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid var(--border);
}

.modal-header h2 {
    font-size: 18px;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-secondary);
    cursor: pointer;
}

.modal-body {
    padding: 20px;
    max-height: calc(90vh - 80px);
    overflow-y: auto;
}

/* ==================== EMPTY STATE ==================== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.empty-state p {
    margin-bottom: 20px;
}

/* ==================== NOTIFICATION ==================== */
.notification {
    position: fixed;
    bottom: 80px;
    right: 20px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 24px;
    box-shadow: var(--shadow);
    z-index: 1001;
    animation: slideIn 0.3s ease forwards;
}

@keyframes slideIn {
    from {
        transform: translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* ==================== AI SCORE ====================*/
.ai-score {
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.85em;
}

.ai-score.ai-good {
    background: rgba(34, 197, 94, 0.2);
    color: #22c55e;
}

.ai-score.ai-warning {
    background: rgba(234, 179, 8, 0.2);
    color: #eab308;
}

.ai-score.ai-bad {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

.article-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

.btn-sm {
    padding: 4px 8px;
    font-size: 0.8em;
}

.btn-warning {
    background: #eab308;
    color: #000;
}

.btn-warning:hover {
    background: #ca8a04;
}

/* ==================== RESEARCH KEYWORDS ====================*/
.keywords-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 10px 0;
}

/* ==================== CONTENT SCORE ====================*/
.content-score {
    cursor: pointer;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 600;
    font-size: 0.85em;
}

.score-excellent { background: rgba(34, 197, 94, 0.2); color: #22c55e; }
.score-good { background: rgba(59, 130, 246, 0.2); color: #3b82f6; }
.score-average { background: rgba(234, 179, 8, 0.2); color: #eab308; }
.score-poor { background: rgba(239, 68, 68, 0.2); color: #ef4444; }

.score-section {
    margin: 15px 0;
    padding: 10px;
    background: var(--bg-secondary, #1e1e2e);
    border-radius: 8px;
}

.score-section h4 { margin: 0 0 10px 0; }
.score-section ul { margin: 0; padding-left: 20px; }
.score-section li { margin: 5px 0; }

/* ==================== GENERATION PROGRESS ====================*/
.generation-progress {
    background: var(--bg-secondary, #1e1e2e);
    border: 1px solid var(--border, #333);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
}

.progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    font-weight: 600;
}

.progress-bar-container {
    height: 8px;
    background: var(--bg-tertiary, #2a2a3e);
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #3b82f6, #8b5cf6);
    border-radius: 4px;
    transition: width 0.5s ease;
    width: 0%;
}

.progress-details {
    margin-top: 10px;
    font-size: 0.9em;
    color: var(--text-secondary, #999);
}

.progress-quip {
    margin-top: 12px;
    font-size: 0.85em;
    color: #8b5cf6;
    font-style: italic;
    transition: opacity 0.3s;
    min-height: 20px;
}

.progress-bar-indeterminate {
    animation: indeterminate 2s ease-in-out infinite !important;
    background: linear-gradient(90deg, #3b82f6, #8b5cf6, #3b82f6) !important;
    background-size: 200% 100% !important;
    width: 100% !important;
}

@keyframes indeterminate {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.progress-queue { margin-top: 15px; }

.queue-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.queue-item {
    padding: 4px 10px;
    background: var(--bg-tertiary, #2a2a3e);
    border-radius: 6px;
    font-size: 0.85em;
}

.queue-item.processing {
    background: rgba(59, 130, 246, 0.15);
    color: #3b82f6;
    animation: pulse 1.5s infinite;
}

.queue-item.done { background: rgba(34, 197, 94, 0.15); color: #22c55e; }
.queue-item.error { background: rgba(239, 68, 68, 0.15); color: #ef4444; }

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* Written keywords — только зачёркивание */
.keyword-written td:nth-child(2) strong {
    text-decoration: line-through;
    opacity: 0.6;
}

/* Бейджи площадок */
.platform-badges {
    display: inline-flex;
    gap: 3px;
    margin-left: 8px;
    text-decoration: none !important;
}

.platform-badge {
    font-size: 0.8em;
    opacity: 0.8;
}

/* Dropdown выбора площадки */
.platform-dropdown {
    background: var(--bg-primary, #16161e);
    border: 1px solid var(--border, #333);
    border-radius: 12px;
    box-shadow: 0 4px 25px rgba(0,0,0,0.3);
    width: 260px;
    overflow-y: auto;
    max-height: 80vh;
}

.platform-dropdown-header {
    padding: 12px 15px;
    font-size: 0.9em;
    font-weight: 600;
    color: var(--text-secondary, #999);
    border-bottom: 1px solid var(--border, #333);
}

.platform-options { padding: 5px 0; }

.platform-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 15px;
    cursor: pointer;
    transition: background 0.2s;
}

.platform-option:hover:not(.platform-written) {
    background: var(--bg-secondary, #1e1e2e);
}

.platform-option input[type="radio"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.platform-option.platform-written {
    opacity: 0.5;
    cursor: not-allowed;
    text-decoration: line-through;
}

.platform-option.platform-written input { cursor: not-allowed; }

.platform-icon { font-size: 1.1em; }
.platform-name { flex: 1; }
.platform-hint { font-size: 0.7em; color: var(--text-secondary, #666); margin-left: auto; }
.platform-option.platform-written .platform-hint { display: none; }

.platform-status {
    font-size: 0.75em;
    color: #22c55e;
    background: rgba(34, 197, 94, 0.15);
    padding: 2px 6px;
    border-radius: 4px;
    text-decoration: none;
}

/* Слайдер объёма */
.word-count-slider {
    padding: 15px;
    border-top: 1px solid var(--border, #333);
    background: var(--bg-secondary, #1e1e2e);
}

.slider-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    font-size: 0.9em;
}

.word-count-value {
    font-weight: 700;
    color: var(--accent, #3b82f6);
    font-size: 1.1em;
}

.word-count-slider input[type="range"] {
    width: 100%;
    height: 8px;
    border-radius: 4px;
    background: var(--bg-tertiary, #2a2a3e);
    outline: none;
    cursor: pointer;
    -webkit-appearance: none;
}

.word-count-slider input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--accent, #3b82f6);
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
    transition: transform 0.2s;
}

.word-count-slider input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.15);
}

.slider-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 5px;
    font-size: 0.7em;
    color: var(--text-secondary, #666);
}

.platform-dropdown .generate-btn {
    margin: 15px;
    margin-top: 10px;
    width: calc(100% - 30px);
}

/* ==================== KEYWORD SELECTION ====================*/
.bulk-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 15px;
    background: var(--bg-secondary, #1e1e2e);
    border-radius: 8px;
    border: 1px solid var(--border, #333);
    margin-bottom: 15px;
}

.bulk-actions span {
    font-weight: 600;
}

.keyword-checkbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.confirm-delete-inline {
    animation: fadeIn 0.2s;
}

@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

.keyword-tag {
    background: var(--bg-tertiary, #2a2a3e);
    padding: 4px 10px;
    border-radius: 15px;
    font-size: 0.85em;
}

/* ==================== TEXT SETTINGS ====================*/
.section { margin-bottom: 30px; }

.section-divider {
    border: none;
    border-top: 2px solid var(--border, #333);
    margin: 40px 0;
}

/* Кнопки площадок */
.platform-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.platform-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    background: var(--bg-secondary, #1e1e2e);
    border: 1px solid var(--border, #333);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
    color: inherit;
}

.platform-btn:hover {
    background: var(--bg-tertiary, #2a2a3e);
    transform: translateY(-2px);
}

.platform-btn-icon { font-size: 1.3em; }
.platform-btn-name { font-weight: 500; }

.platform-btn-count {
    background: var(--accent, #3b82f6);
    color: white;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.8em;
    font-weight: 600;
}

.platform-btn-count:empty { display: none; }

/* Chat-like модалка */
.chat-modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.chat-modal {
    background: var(--bg-primary, #16161e);
    border-radius: 16px;
    width: 90%;
    max-width: 600px;
    height: 80vh;
    max-height: 700px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid var(--border, #333);
}

.chat-modal-header h3 { margin: 0; }

.chat-modal-close {
    background: none;
    border: none;
    font-size: 1.5em;
    cursor: pointer;
    color: var(--text-secondary, #999);
    padding: 5px 10px;
}

.chat-modal-close:hover { color: inherit; }

.chat-modal-wide {
    max-width: 700px;
    height: 85vh;
    max-height: 800px;
}

.chat-modal-context {
    padding: 15px 20px;
    border-bottom: 1px solid #262626;
    background: #111;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 250px;
    overflow-y: auto;
}

.context-field label {
    display: block;
    font-size: 12px;
    color: #888;
    margin-bottom: 3px;
    font-weight: 500;
}

.context-field textarea {
    width: 100%;
    padding: 8px 10px;
    background: #0a0a0a;
    border: 1px solid #333;
    border-radius: 6px;
    color: #fff;
    font-family: inherit;
    font-size: 12px;
    resize: none;
    min-height: 36px;
    max-height: 60px;
    line-height: 1.4;
}

.context-field textarea::placeholder { color: #555; }
.context-field textarea:focus { outline: none; border-color: #3b82f6; }

.chat-modal-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.chat-empty {
    text-align: center;
    color: var(--text-secondary, #666);
    padding: 40px;
}

.chat-item {
    background: var(--bg-secondary, #1e1e2e);
    border-radius: 12px;
    padding: 15px;
}

.chat-item-content {
    line-height: 1.6;
    word-break: break-word;
}

.chat-item-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--border, #333);
}

.chat-item-date { font-size: 0.8em; color: var(--text-secondary, #666); }

.chat-item-delete {
    background: none;
    border: none;
    cursor: pointer;
    opacity: 0.5;
    transition: opacity 0.2s;
}

.chat-item-delete:hover { opacity: 1; }

.chat-item { cursor: pointer; transition: border-color 0.2s; border: 1px solid transparent; }
.chat-item:hover { border-color: #3b82f6; }

.chat-item-hint {
    font-size: 0.75em;
    color: #555;
    opacity: 0;
    transition: opacity 0.2s;
}
.chat-item:hover .chat-item-hint { opacity: 1; }

/* Edit overlay */
.chat-edit-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3000;
}

.chat-edit-modal {
    background: #0a0a0a;
    border: 1px solid #333;
    border-radius: 16px;
    width: 90%;
    max-width: 650px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-edit-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid #262626;
}

.chat-edit-header h3 { margin: 0; }

.chat-edit-modal textarea {
    flex: 1;
    padding: 20px;
    background: #141414;
    border: none;
    color: #fff;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.7;
    resize: none;
    min-height: 300px;
}

.chat-edit-modal textarea:focus { outline: none; }

.chat-edit-actions {
    display: flex;
    gap: 10px;
    padding: 15px 20px;
    border-top: 1px solid #262626;
}

.chat-modal-input {
    display: flex;
    gap: 10px;
    padding: 15px 20px;
    border-top: 1px solid var(--border, #333);
    background: var(--bg-secondary, #1e1e2e);
}

.chat-modal-input textarea {
    flex: 1;
    padding: 12px 15px;
    border: 1px solid var(--border, #333);
    border-radius: 12px;
    background: var(--bg-primary, #16161e);
    color: inherit;
    resize: none;
    min-height: 50px;
    max-height: 150px;
    font-family: inherit;
}

.chat-send-btn {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--accent, #3b82f6);
    color: white;
    border: none;
    font-size: 1.2em;
    cursor: pointer;
    transition: transform 0.2s;
    flex-shrink: 0;
}

.chat-send-btn:hover { transform: scale(1.1); }

/* ==================== REFERENCES ====================*/
.section-description {
    color: var(--text-secondary, #999);
    margin-bottom: 20px;
}

.references-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.ref-tab-btn {
    padding: 8px 16px;
    border: 1px solid var(--border, #333);
    background: var(--bg-secondary, #1e1e2e);
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s;
    color: inherit;
}

.ref-tab-btn:hover { background: var(--bg-tertiary, #2a2a3e); }

.ref-tab-btn.active {
    background: var(--accent, #3b82f6);
    color: white;
    border-color: var(--accent, #3b82f6);
}

.references-grid {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.reference-group-title {
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--border, #333);
}

.reference-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 15px;
}

.reference-card {
    background: var(--bg-secondary, #1e1e2e);
    border: 1px solid var(--border, #333);
    border-radius: 12px;
    padding: 15px;
}

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

.reference-title { font-weight: 600; }

.reference-preview {
    font-size: 0.9em;
    color: var(--text-secondary, #999);
    line-height: 1.5;
    max-height: 100px;
    overflow: hidden;
    margin-bottom: 10px;
}

.reference-url {
    display: inline-block;
    font-size: 0.85em;
    color: var(--accent, #3b82f6);
    margin-bottom: 10px;
}

.reference-meta {
    font-size: 0.8em;
    color: var(--text-secondary, #666);
    margin-bottom: 10px;
}

.reference-full-content {
    max-height: 60vh;
    overflow-y: auto;
}

/* ==================== REWRITE MODAL ==================== */
.rewrite-layout {
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-height: 70vh;
}

.rewrite-preview label,
.rewrite-comments label {
    display: block;
    font-size: 13px;
    color: #999;
    margin-bottom: 6px;
    font-weight: 500;
}

.rewrite-article-text {
    max-height: 40vh;
    overflow-y: auto;
    padding: 16px;
    background: #0a0a0a;
    border: 1px solid #333;
    border-radius: 8px;
    font-size: 13px;
    line-height: 1.7;
    color: #ccc;
}

.rewrite-comments textarea {
    width: 100%;
    min-height: 100px;
    padding: 12px;
    background: #0a0a0a;
    border: 1px solid #333;
    border-radius: 8px;
    color: #fff;
    font-family: inherit;
    font-size: 14px;
    resize: vertical;
}

.rewrite-comments textarea::placeholder { color: #555; }
.rewrite-comments textarea:focus { outline: none; border-color: #3b82f6; }

/* ==================== STOPWORDS ==================== */
.stopwords-input-row {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.stopwords-input-row input {
    flex: 1;
    padding: 10px 14px;
    background: #1a1a1a;
    border: 1px solid #333;
    border-radius: 8px;
    color: #fff;
    font-size: 14px;
}

.stopwords-input-row input::placeholder { color: #666; }
.stopwords-input-row input:focus { outline: none; border-color: #3b82f6; }

.stopwords-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.stopwords-empty {
    color: #666;
    font-size: 13px;
}

.stopword-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(239, 68, 68, 0.25);
    border-radius: 20px;
    color: #f87171;
    font-size: 13px;
}

.stopword-tag button {
    background: none;
    border: none;
    color: #f87171;
    cursor: pointer;
    font-size: 14px;
    padding: 0;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.stopword-tag button:hover { opacity: 1; }

/* ==================== RECURRING ERRORS ==================== */
.errors-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.error-card {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 16px;
    background: rgba(234, 179, 8, 0.08);
    border: 1px solid rgba(234, 179, 8, 0.2);
    border-radius: 10px;
    cursor: pointer;
    transition: border-color 0.2s;
}

.error-card:hover {
    border-color: rgba(234, 179, 8, 0.5);
}

.error-card-hint {
    font-size: 0.7em;
    color: #666;
    opacity: 0;
    transition: opacity 0.2s;
    flex-shrink: 0;
    align-self: center;
}

.error-card:hover .error-card-hint { opacity: 1; }

.error-card-text {
    flex: 1;
    font-size: 13px;
    line-height: 1.5;
    color: #e2e2e2;
}

.error-card-delete {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 14px;
    opacity: 0.5;
    transition: opacity 0.2s;
    flex-shrink: 0;
    padding: 0;
}

.error-card-delete:hover { opacity: 1; }

/* ==================== INFORMATION CORE ==================== */
.core-layout {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 40px;
}

.core-orb-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 40px 0 20px;
}

.core-orb {
    --orb-hue: 0;
    --orb-intensity: 0.3;
    position: relative;
    width: 180px;
    height: 180px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.orb-glow {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: radial-gradient(
        circle at 40% 40%,
        hsla(var(--orb-hue), 80%, 65%, var(--orb-intensity)) 0%,
        hsla(var(--orb-hue), 70%, 45%, calc(var(--orb-intensity) * 0.6)) 40%,
        hsla(var(--orb-hue), 60%, 25%, calc(var(--orb-intensity) * 0.3)) 70%,
        transparent 100%
    );
    filter: blur(20px);
    animation: orbPulse 4s ease-in-out infinite, orbRotate 8s linear infinite;
}

.orb-ring {
    position: absolute;
    border-radius: 50%;
    border: 1px solid hsla(var(--orb-hue), 70%, 55%, calc(var(--orb-intensity) * 0.4));
    animation: orbFloat 6s ease-in-out infinite;
}

.orb-ring-1 {
    width: 140%;
    height: 140%;
    animation-delay: 0s;
    animation-duration: 7s;
}

.orb-ring-2 {
    width: 165%;
    height: 165%;
    animation-delay: -2s;
    animation-duration: 9s;
    border-style: dashed;
}

.orb-ring-3 {
    width: 190%;
    height: 190%;
    animation-delay: -4s;
    animation-duration: 11s;
    opacity: 0.5;
}

.orb-center {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    background: radial-gradient(
        circle,
        hsla(var(--orb-hue), 60%, 50%, calc(var(--orb-intensity) * 0.2)) 0%,
        rgba(10, 10, 10, 0.8) 70%
    );
    width: 130px;
    height: 130px;
    border-radius: 50%;
    justify-content: center;
    border: 1px solid hsla(var(--orb-hue), 70%, 55%, calc(var(--orb-intensity) * 0.5));
    backdrop-filter: blur(10px);
}

.orb-percent {
    font-size: 32px;
    font-weight: 700;
    color: hsla(var(--orb-hue), 70%, 65%, 1);
    text-shadow: 0 0 20px hsla(var(--orb-hue), 80%, 55%, 0.5);
}

.orb-label {
    font-size: 11px;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.core-hint {
    margin-top: 20px;
    color: #888;
    font-size: 13px;
    text-align: center;
}

@keyframes orbPulse {
    0%, 100% { transform: scale(1); opacity: 0.8; }
    50% { transform: scale(1.15); opacity: 1; }
}

@keyframes orbRotate {
    0% { filter: blur(20px) hue-rotate(0deg); }
    100% { filter: blur(20px) hue-rotate(30deg); }
}

@keyframes orbFloat {
    0%, 100% { transform: rotate(0deg) scale(1); opacity: 0.6; }
    25% { transform: rotate(3deg) scale(1.02); opacity: 0.8; }
    50% { transform: rotate(-2deg) scale(0.98); opacity: 0.5; }
    75% { transform: rotate(1deg) scale(1.01); opacity: 0.7; }
}

/* Категории ядра */
.core-categories {
    width: 100%;
    max-width: 700px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.core-category {
    background: #141414;
    border: 1px solid #262626;
    border-radius: 12px;
    overflow: hidden;
}

.core-category-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    cursor: pointer;
    font-weight: 600;
    font-size: 15px;
    transition: background 0.2s;
}

.core-category-header:hover {
    background: #1a1a1a;
}

.core-cat-progress {
    font-size: 12px;
    font-weight: 500;
    color: #666;
    background: #1a1a1a;
    padding: 4px 10px;
    border-radius: 10px;
}

.core-category-fields {
    padding: 0 20px 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.core-field label {
    display: block;
    font-size: 13px;
    color: #999;
    margin-bottom: 4px;
}

.core-field textarea {
    width: 100%;
    padding: 10px 12px;
    background: #0a0a0a;
    border: 1px solid #333;
    border-radius: 8px;
    color: #fff;
    font-family: inherit;
    font-size: 13px;
    resize: vertical;
    min-height: 60px;
    transition: border-color 0.2s;
}

.core-field textarea:focus {
    outline: none;
    border-color: #3b82f6;
}

.core-field textarea::placeholder {
    color: #555;
}

/* ==================== AI RESEARCH CHAT ==================== */
.research-chat {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 200px);
    min-height: 500px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.research-chat-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 20px;
    border-bottom: 1px solid var(--border);
}

.research-chat-header h3 { margin-bottom: 4px; }

.research-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.research-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
    color: var(--text-secondary);
}

.research-empty-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.research-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 20px;
    justify-content: center;
}

.research-suggestion {
    padding: 10px 18px;
    background: #1a1a1a;
    border: 1px solid #333;
    border-radius: 20px;
    color: #fff;
    cursor: pointer;
    font-size: 13px;
    font-family: inherit;
    transition: all 0.2s;
    -webkit-appearance: none;
    appearance: none;
}

.research-suggestion:hover {
    border-color: #3b82f6;
    background: rgba(59, 130, 246, 0.15);
    transform: translateY(-1px);
}

.research-msg {
    display: flex;
    gap: 12px;
    max-width: 85%;
}

.research-msg-user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.research-msg-ai {
    align-self: flex-start;
}

.research-msg-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.research-msg-content {
    padding: 12px 16px;
    border-radius: 16px;
    line-height: 1.6;
    font-size: 14px;
    word-break: break-word;
}

.research-msg-user .research-msg-content {
    background: var(--accent);
    color: white;
    border-bottom-right-radius: 4px;
}

.research-msg-ai .research-msg-content {
    background: var(--bg-tertiary);
    border-bottom-left-radius: 4px;
}

.research-msg-ai .research-msg-content h3,
.research-msg-ai .research-msg-content h4 {
    margin: 10px 0 5px;
    font-size: 15px;
}

.research-msg-ai .research-msg-content ul {
    margin: 5px 0;
    padding-left: 20px;
}

.research-msg-ai .research-msg-content li {
    margin: 3px 0;
}

.research-typing {
    color: var(--text-secondary);
}

.typing-dots::after {
    content: '';
    animation: dots 1.5s steps(4, end) infinite;
}

@keyframes dots {
    0% { content: ''; }
    25% { content: '.'; }
    50% { content: '..'; }
    75% { content: '...'; }
    100% { content: ''; }
}

.research-input-area {
    display: flex;
    gap: 10px;
    padding: 16px 20px;
    border-top: 1px solid #262626;
    background: #0a0a0a;
    align-items: flex-end;
}

.research-input-area textarea {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #333;
    border-radius: 24px;
    background: #1a1a1a;
    color: #fff;
    resize: none;
    min-height: 48px;
    max-height: 150px;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.5;
    -webkit-appearance: none;
    appearance: none;
}

.research-input-area textarea::placeholder {
    color: #666;
}

.research-input-area textarea:focus {
    outline: none;
    border-color: #3b82f6;
}

.research-send-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #3b82f6;
    color: #fff;
    border: none;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
    -webkit-appearance: none;
    appearance: none;
}

.research-send-btn:hover { background: #2563eb; transform: scale(1.05); }
.research-send-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* ==================== RESPONSIVE ==================== */
@media (max-width: 768px) {
    .sidebar {
        display: none;
    }
    
    .content {
        margin-left: 0;
        padding: 16px;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
}
