/* ==================== АИДА — компоненты ====================
   Карточки, кнопки, поля, вкладки, списки, таблицы, плашки — в стиле megaboard
   (frontend/src/components/ui и классы ui-card / ui-btn / ui-input / tbl-* из index.css).
   Имена классов — прежние, чтобы разметка разделов (static/js) продолжала работать. */

/* ---------- карточки ---------- */

.card {
    background: rgb(var(--surface));
    border: 1px solid rgb(var(--border));
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-card);
    margin-bottom: 16px;
    min-width: 0;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid rgb(var(--border));
}

.card-header h2 {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    font-size: 16px;
    line-height: 22px;
    font-weight: 600;
    letter-spacing: -0.008em;
    color: rgb(var(--ink));
}

.card-header h2 .icon { display: inline-flex; color: rgb(var(--ink-faint)); }
.card-header h2 > .ic { color: rgb(var(--ink-faint)); }

.card-body { padding: 16px; }

/* ---------- вкладки-«таблетки» (Tabs в megaboard) ---------- */

.tabs {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 4px;
    margin: 0 0 16px;
    border-radius: var(--radius-control);
    background: rgb(var(--surface-2));
}

.tab {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 6px 14px;
    border: 0;
    border-radius: var(--radius-control);
    background: transparent;
    color: rgb(var(--ink-muted));
    font-size: 15px;
    line-height: 22px;
    font-weight: 500;
    white-space: nowrap;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}
.tab:hover { color: rgb(var(--ink)); }
.tab.active { background: rgb(var(--surface)); color: rgb(var(--brand)); box-shadow: 0 1px 2px #0000000d; }
.tab:disabled { opacity: 0.4; cursor: not-allowed; }

/* ---------- кнопки (Button в megaboard) ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-height: 40px;
    padding: 0 16px;
    border: 1px solid transparent;
    border-radius: var(--radius-control);
    font-size: 15px;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.16s ease-out;
}
.btn:hover { text-decoration: none; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; box-shadow: none; transform: none !important; }

.btn-primary { background: rgb(var(--brand)); border-color: rgb(var(--brand)); color: #fff; box-shadow: var(--shadow-brand); }
.btn-primary:hover:not(:disabled) { background: rgb(var(--brand-mid)); border-color: rgb(var(--brand-mid)); transform: translateY(-1px); }

.btn-outline, .btn-secondary { background: rgb(var(--surface)); border-color: rgb(var(--border)); color: rgb(var(--ink-muted)); }
.btn-outline:hover:not(:disabled), .btn-secondary:hover:not(:disabled) { color: rgb(var(--ink)); border-color: rgb(var(--ink-faint)); }

.btn-success { background: rgb(var(--success)); border-color: rgb(var(--success)); color: #fff; }
.btn-success:hover:not(:disabled) { background: rgb(var(--success) / 0.9); }

.btn-danger { background: rgb(var(--danger)); border-color: rgb(var(--danger)); color: #fff; }
.btn-danger:hover:not(:disabled) { background: rgb(var(--danger) / 0.9); }

.btn-ghost { background: transparent; color: rgb(var(--ink-muted)); }
.btn-ghost:hover:not(:disabled) { background: rgb(var(--surface-raised)); color: rgb(var(--ink)); }

.btn-soft { background: rgb(var(--brand-tint)); color: rgb(var(--brand-strong)); }
.btn-soft:hover:not(:disabled) { background: rgb(var(--brand-soft)); }

.btn-sm { min-height: 32px; padding: 0 12px; font-size: 14px; gap: 6px; }
.btn-icon { padding: 0; width: 40px; flex: none; }
.btn-sm.btn-icon { width: 32px; }

/* квадратная кнопка-значок 32px */
.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    width: 32px;
    height: 32px;
    padding: 0;
    border: 1px solid rgb(var(--border));
    border-radius: var(--radius-control);
    background: rgb(var(--surface));
    color: rgb(var(--ink-muted));
    font-size: 15px;
    line-height: 1;
    cursor: pointer;
    transition: all 0.16s ease-out;
}
.icon-btn:hover { color: rgb(var(--ink)); border-color: rgb(var(--ink-faint)); }
.icon-btn.danger, .icon-btn.delete { color: rgb(var(--danger)); }
.icon-btn.danger:hover, .icon-btn.delete:hover { border-color: rgb(var(--danger) / 0.6); background: rgb(var(--danger) / 0.08); }
.icon-btn.ghost { border-color: transparent; background: none; }
.icon-btn.ghost:hover { background: rgb(var(--surface-raised)); border-color: transparent; }
.icon-btn + .icon-btn { margin-left: 4px; }

@media (width <= 899.98px) {
    .btn { min-height: 44px; }
    .btn-sm { min-height: 40px; }
}

/* ---------- поля (Input / Select / Textarea в megaboard) ---------- */

.form-group { margin-bottom: 14px; }

.form-label {
    display: block;
    margin-bottom: 4px;
    font-size: 14px;
    line-height: 20px;
    font-weight: 500;
    color: rgb(var(--ink-muted));
}

.form-hint { margin-top: 4px; font-size: 13px; line-height: 18px; color: rgb(var(--ink-faint)); }

.form-input, .form-textarea, .form-select, .ai-input {
    width: 100%;
    min-height: 40px;
    padding: 8px 12px;
    border: 1px solid rgb(var(--border));
    border-radius: var(--radius-control);
    background-color: rgb(var(--surface-raised));
    color: rgb(var(--ink));
    font-size: 15px;
    line-height: 22px;
    outline: none;
    transition: border-color 0.16s, box-shadow 0.16s;
}
.form-input::placeholder, .form-textarea::placeholder, .ai-input::placeholder { color: rgb(var(--ink-faint)); opacity: 0.8; }
.form-input:focus, .form-textarea:focus, .form-select:focus, .ai-input:focus {
    border-color: rgb(var(--brand));
    box-shadow: 0 0 0 2px rgb(var(--brand) / 0.4);
}
.form-input:disabled, .form-textarea:disabled, .form-select:disabled { opacity: 0.6; cursor: not-allowed; }
.form-input.mono { font-family: var(--font-mono); font-size: 13px; }
textarea.form-input, .form-textarea { resize: vertical; min-height: 80px; }
.form-textarea { min-height: 180px; }
select.form-input, .form-select { padding-right: 34px; }
input[type='search'].form-input { padding-left: 36px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m21 21-4.34-4.34'/%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: 12px center; background-size: 16px 16px; }
html.dark input[type='search'].form-input { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a5b2c4' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m21 21-4.34-4.34'/%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3C/svg%3E"); }

.form-row { display: flex; gap: 12px; flex-wrap: wrap; }
.form-row .form-group { flex: 1; min-width: 140px; }

/* ---------- списки-строки (как строки таблиц megaboard) ---------- */

.dialog-list { display: flex; flex-direction: column; }

.dialog-list-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-bottom: 1px solid rgb(var(--border));
    border-radius: 0;
    background: transparent;
    cursor: default;
    transition: background-color 0.12s;
}
.dialog-list-item:last-child { border-bottom: 0; }
.dialog-list-item[data-href], .dialog-list-item[onclick] { cursor: pointer; }
.dialog-list-item[data-href]:hover, .dialog-list-item[onclick]:hover { background: rgb(var(--surface-raised) / 0.6); }
html:not(.dark) .dialog-list-item[data-href]:hover, html:not(.dark) .dialog-list-item[onclick]:hover { background: rgb(var(--row-hover)); }

/* список — единственное содержимое карточки: строки идут на всю её ширину, как в таблице */
.card-body:has(> .dialog-list:only-child) { padding: 4px 0; }
.card-body:has(> .dialog-list:only-child) .dialog-list-item { padding-left: 16px; padding-right: 16px; }

.dialog-list-item .status-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    width: 32px;
    height: 32px;
    border: 1px solid rgb(var(--border));
    border-radius: var(--radius-control);
    background: rgb(var(--surface-raised));
    color: rgb(var(--ink-faint));
    font-size: 13px;
    line-height: 1;
}
.dialog-list-item .status-icon.done { color: rgb(var(--success)); }
.dialog-list-item .status-icon.dot { border: 0; background: none; width: 20px; font-size: 12px; }

.dialog-list-item .dialog-info { flex: 1; min-width: 0; }
.dialog-list-item .dialog-name { font-size: 15px; line-height: 22px; font-weight: 500; color: rgb(var(--ink)); overflow-wrap: anywhere; }
.dialog-list-item .dialog-name a { color: inherit; }
.dialog-list-item .dialog-name a:hover { color: rgb(var(--brand-strong)); }
.dialog-meta { font-size: 13px; line-height: 18px; color: rgb(var(--ink-muted)); overflow-wrap: anywhere; }

.add-dialog-btn, .add-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 14px;
    border: 1px dashed rgb(var(--border));
    border-radius: var(--radius-control);
    background: transparent;
    color: rgb(var(--ink-muted));
    font-size: 14px;
    cursor: pointer;
    transition: all 0.15s;
}
.add-dialog-btn:hover, .add-btn:hover { border-color: rgb(var(--brand)); color: rgb(var(--brand)); }

/* ---------- таблицы (DataTable в megaboard: .md-table) ---------- */

.md-table, .tr-preview-table-wrap, .c2-table-wrap, .matrix-container {
    overflow: auto;
    border: 1px solid rgb(var(--border));
    border-radius: var(--radius-card);
    background: rgb(var(--surface));
}
/* таблица вплотную внутри карточки: рамка и скругления — от самой карточки */
.card > .md-table, .card > .c2-table-wrap, .card-body[style*='padding:0'] > .c2-table-wrap, .card-body[style*='padding:0'] > .md-table {
    border: 0;
    border-radius: calc(var(--radius-card) - 1px);
}

.data-table, .c2-table, .tr-preview-table, .matrix-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 15px;
    line-height: 22px;
}

.data-table th, .c2-table th, .tr-preview-table th, .matrix-table th {
    position: sticky;
    top: 0;
    z-index: 10;
    padding: 8px 12px;
    border-bottom: 1px solid rgb(var(--border));
    background: rgb(var(--surface-2));
    color: rgb(var(--ink-muted));
    font-size: 13px;
    line-height: 18px;
    font-weight: 600;
    text-align: left;
    text-transform: none;
    letter-spacing: 0;
    white-space: nowrap;
    user-select: none;
}

.data-table td, .c2-table td, .tr-preview-table td, .matrix-table td {
    padding: 8px 12px;
    border-bottom: 1px solid rgb(var(--border));
    vertical-align: middle;
    text-align: left;
}
.data-table tbody tr:last-child > td, .c2-table tbody tr:last-child > td, .tr-preview-table tbody tr:last-child > td, .matrix-table tbody tr:last-child > td { border-bottom: 0; }

.data-table tbody tr, .c2-table tbody tr { transition: background-color 0.12s; }
.data-table tbody tr:hover > td, .c2-table tbody tr:hover > td, .tr-preview-table tbody tr:hover > td { background: rgb(var(--surface-raised) / 0.6); }
html:not(.dark) .data-table tbody tr:hover > td, html:not(.dark) .c2-table tbody tr:hover > td, html:not(.dark) .tr-preview-table tbody tr:hover > td { background: rgb(var(--row-hover)); }
.data-table tbody tr[data-href], .c2-table tbody tr[data-href] { cursor: pointer; }

.data-table th.sortable { cursor: pointer; }
.data-table th.sortable:hover { color: rgb(var(--ink)); }
.data-table th .th-in { display: inline-flex; align-items: center; gap: 4px; }
.data-table .num, .data-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table .nowrap { white-space: nowrap; }
.data-table .cell-title { font-weight: 500; color: rgb(var(--ink)); overflow-wrap: anywhere; }
.data-table .cell-sub { font-size: 13px; line-height: 18px; color: rgb(var(--ink-muted)); }
.data-table td.empty { padding: 40px 12px; text-align: center; color: rgb(var(--ink-faint)); }
.data-table .row-actions { text-align: right; white-space: nowrap; width: 1%; }

.with-ic { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.with-ic > .ic { color: rgb(var(--ink-faint)); }
.dot-mark { display: inline-block; flex: none; width: 9px; height: 9px; border-radius: 50%; background: currentColor; }
.status-line { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }

/* раздел «Пользователи»: мини-график активности и окно с выданным паролем */
.sparkline { display: block; fill: rgb(var(--brand)); }
.ic-success { color: rgb(var(--success)); }
.icon-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.issued-grid { display: grid; grid-template-columns: 80px 1fr auto; align-items: center; gap: 8px; }
.issued-password { font-size: 16px; font-weight: 600; user-select: all; }

/* ---------- бейджи и «таблетки» (Chip в megaboard) ---------- */

.chip, .c2-chip, .badge, .tr-badge, .db-speaker-chip, .db-stale {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 8px;
    border: 1px solid rgb(var(--border));
    border-radius: 999px;
    background: rgb(var(--surface-raised));
    color: rgb(var(--ink-muted));
    font-size: 13px;
    line-height: 18px;
    font-weight: 400;
    white-space: nowrap;
    vertical-align: middle;
}
.chip { margin-left: 6px; }
.chip-brand { background: rgb(var(--brand-soft)); border-color: transparent; color: rgb(var(--brand-strong)); }
.chip-success, .c2-chip-ok, .tr-badge { background: rgb(var(--success) / 0.15); border-color: transparent; color: rgb(var(--success)); }
.chip-warning, .c2-chip-warn, .db-stale { background: rgb(var(--warning) / 0.15); border-color: transparent; color: rgb(var(--warning)); }
.chip-danger { background: rgb(var(--danger) / 0.15); border-color: transparent; color: rgb(var(--danger)); }
.tr-badge, .db-stale { margin-left: 6px; font-size: 12px; line-height: 16px; font-weight: 500; }

/* ---------- плашки-уведомления (Alert в megaboard) ---------- */

.call-alert, .tr-warning, .error-hint, .tc-privacy-note, .tc-summary-ok, .tc-summary-diff, .alert {
    padding: 12px;
    border: 1px solid rgb(var(--alert-amber-border));
    border-radius: var(--radius-control);
    background: rgb(var(--alert-amber-bg));
    color: rgb(var(--alert-amber-ink));
    font-size: 15px;
    line-height: 22px;
    margin: 10px 0;
}
.call-alert-error, .error-hint, .alert-red { background: rgb(var(--alert-red-bg)); border-color: rgb(var(--alert-red-border)); color: rgb(var(--alert-red-ink)); }
.call-alert-warn, .tr-warning, .tc-summary-diff, .alert-amber { background: rgb(var(--alert-amber-bg)); border-color: rgb(var(--alert-amber-border)); color: rgb(var(--alert-amber-ink)); }
.tc-privacy-note, .tc-summary-ok, .alert-green { background: rgb(var(--alert-green-bg)); border-color: rgb(var(--alert-green-border)); color: rgb(var(--alert-green-ink)); }
.alert-sky { background: rgb(var(--alert-sky-bg)); border-color: rgb(var(--alert-sky-border)); color: rgb(var(--alert-sky-ink)); }
.call-alert .btn { margin-left: 8px; vertical-align: middle; }
.call-alert a, .tr-warning a { color: inherit; text-decoration: underline; }
.tr-warning { margin: 0 0 14px; }
.error-hint { margin-top: 12px; }

/* ---------- пустые состояния, загрузка ---------- */

.empty-state, .empty-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 48px 16px;
    text-align: center;
    color: rgb(var(--ink-faint));
}
.empty-state .icon, .empty-block-icon { display: inline-flex; font-size: 28px; line-height: 1; opacity: 0.6; }
.empty-state .icon .ic, .empty-block-icon .ic { width: 32px; height: 32px; }
.empty-state p, .empty-block p { max-width: 460px; font-size: 15px; font-weight: 500; color: rgb(var(--ink-muted)); }

.loading { display: inline-block; animation: pulse 1.2s infinite; }
.dots-animation::after { content: ''; animation: dots 1.5s steps(4, end) infinite; }

/* скелетон (Skeleton / PageSkeleton в megaboard) */
.skeleton { border-radius: 4px; background: rgb(var(--surface-raised)); animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite; }

/* ---------- страница диалога: исходный текст и чат ---------- */

.dialog-panels {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    height: calc(100vh - 300px);
    min-height: 400px;
}

.panel {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
    border: 1px solid rgb(var(--border));
    border-radius: var(--radius-card);
    background: rgb(var(--surface));
    box-shadow: var(--shadow-card);
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    gap: 8px;
    padding: 8px 16px;
    border-bottom: 1px solid rgb(var(--border));
    background: rgb(var(--surface-2));
    color: rgb(var(--ink-faint));
    font-size: 12px;
    line-height: 16px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.panel-header .char-count { font-weight: 400; text-transform: none; letter-spacing: 0; color: rgb(var(--ink-faint)); }

.panel-body { flex: 1; min-height: 0; overflow-y: auto; padding: 16px; }

.source-text-content, #sourceText {
    white-space: pre-wrap;
    font-size: 15px;
    line-height: 1.6;
    color: rgb(var(--ink));
    outline: none;
}
.source-text-content { min-height: 100%; }
.source-text-content:empty::before { content: attr(data-placeholder); color: rgb(var(--ink-faint)); }

.chat-area {
    height: 100%;
    overflow-y: auto;
    padding: 14px;
    border-radius: var(--radius-control);
    background: rgb(var(--surface-2) / 0.6);
}

.message-wrapper { overflow: hidden; margin-bottom: 6px; }

.message {
    width: fit-content;
    max-width: 90%;
    padding: 8px 12px;
    border-radius: var(--radius-card);
    border-bottom-left-radius: 4px;
    cursor: pointer;
    transition: background-color 0.12s;
}
.message.speaker1 { background: rgb(var(--surface)); border: 1px solid rgb(var(--border)); }
.message.speaker1:hover { background: rgb(var(--surface-raised)); }
.message.speaker2 { background: rgb(var(--brand-tint)); border: 1px solid rgb(var(--brand) / 0.2); }
.message.speaker2:hover { background: rgb(var(--brand-soft)); }

.message-header { display: none; }
.speaker-name { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; }
.speaker1 .speaker-name { color: rgb(var(--ink-muted)); }
.speaker2 .speaker-name { color: rgb(var(--brand-strong)); }
.message-text { color: rgb(var(--ink)); font-size: 15px; line-height: 1.45; }

.highlighted-message { background: rgb(var(--cat-amber) / 0.22) !important; animation: highlightPulse 1.5s ease-in-out; }
@keyframes highlightPulse { 0%, 100% { background: rgb(var(--cat-amber) / 0.22); } 50% { background: rgb(var(--cat-amber) / 0.4); } }
.highlight { background: rgb(var(--cat-amber) / 0.3); border-radius: 2px; }

.legend { display: flex; gap: 14px; font-size: 12px; color: rgb(var(--ink-muted)); text-transform: none; letter-spacing: 0; font-weight: 400; }
.legend-item { display: flex; align-items: center; gap: 5px; }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; }
.legend-dot.respondent { background: rgb(var(--surface)); border: 1px solid rgb(var(--ink-faint)); }
.legend-dot.interviewer { background: rgb(var(--brand-soft)); border: 1px solid rgb(var(--brand) / 0.4); }

/* ---------- вопросы проекта ---------- */

.question-list { list-style: none; }
.question-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    margin-bottom: 6px;
    border: 1px solid rgb(var(--border));
    border-radius: var(--radius-control);
    background: rgb(var(--surface-raised));
    cursor: grab;
}
.question-item .question-text { flex: 1; min-width: 0; }
.question-item .question-actions { display: flex; gap: 4px; opacity: 0; transition: opacity 0.15s; }
.question-item:hover .question-actions, .question-item:focus-within .question-actions { opacity: 1; }
.question-item .action-btn {
    display: inline-flex;
    padding: 5px;
    border: 0;
    border-radius: 7px;
    background: none;
    color: rgb(var(--ink-muted));
    font-size: 13px;
    cursor: pointer;
}
.question-item .action-btn:hover { background: rgb(var(--border)); color: rgb(var(--ink)); }
.question-item .action-btn.delete:hover { color: rgb(var(--danger)); }
.question-item.dragging { opacity: 0.5; cursor: grabbing; }
.question-item.drag-over { border-color: rgb(var(--brand)); background: rgb(var(--brand-tint)); }
.drag-handle { display: inline-flex; color: rgb(var(--ink-faint)); cursor: grab; }

/* ---------- матрица анализа ---------- */

/* Таблица прокручивается внутри себя: шапка и колонка «Вопрос» остаются на месте, как закреплённые
   колонки в таблицах megaboard; обе полосы прокрутки — в пределах окна */
.matrix-container { max-height: calc(100vh - 230px); min-height: 240px; }
.matrix-table { font-size: 14px; line-height: 20px; }
.matrix-table th:first-child, .matrix-table td:first-child { position: sticky; left: 0; }
.matrix-table th:first-child { z-index: 20; }
.matrix-table td:first-child { z-index: 5; background: rgb(var(--surface)); box-shadow: inset -1px 0 0 rgb(var(--border)); }
@media (width < 640px) { .matrix-table th:first-child, .matrix-table td:first-child { position: static; } }
.matrix-table th, .matrix-table td { vertical-align: top; border-right: 1px solid rgb(var(--border)); white-space: normal; }
.matrix-table th:last-child, .matrix-table td:last-child { border-right: 0; }
.matrix-table th { min-width: 180px; }
.matrix-table td { position: relative; }
.matrix-table th.question-col { min-width: 200px; background: rgb(var(--success) / 0.12); color: rgb(var(--ink)); }
.matrix-table th.summary-col { min-width: 220px; background: rgb(var(--brand) / 0.12); color: rgb(var(--ink)); }
.matrix-table td.summary-col { background: rgb(var(--brand) / 0.05); }
html:not(.dark) .matrix-table th.question-col { background: color-mix(in srgb, rgb(var(--success)) 12%, rgb(var(--surface-2))); }
html:not(.dark) .matrix-table th.summary-col { background: color-mix(in srgb, rgb(var(--brand)) 12%, rgb(var(--surface-2))); }

.cell-summary { color: rgb(var(--ink)); font-size: 13px; line-height: 1.5; }
.cell-summary .summary-label-block { margin-top: 10px; margin-bottom: 2px; }
.cell-summary .summary-label-block:first-child { margin-top: 0; }
.cell-summary .summary-label, .response-label { color: rgb(var(--brand-strong)); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; }
.cell-summary .summary-quote { color: rgb(var(--ink-muted)); }
.cell-summary p { margin: 0 0 6px; }
.cell-summary p:last-child { margin-bottom: 0; }

.cell-quote, .response-quote {
    border-left: 2px solid rgb(var(--cat-amber));
    background: rgb(var(--cat-amber) / 0.12);
    font-style: italic;
    border-radius: 0 6px 6px 0;
}
.cell-quote { padding: 6px 10px; margin-bottom: 6px; font-size: 13px; }
.clickable-quote { cursor: pointer; transition: background 0.2s; }
.clickable-quote:hover { background: rgb(var(--cat-amber) / 0.24); }
.cell-comment { color: rgb(var(--ink-muted)); font-size: 13px; line-height: 1.4; }

.cell-loading-overlay {
    position: absolute;
    inset: 0;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgb(var(--surface) / 0.85);
}
.cell-loading-overlay::after {
    content: '';
    width: 20px;
    height: 20px;
    border: 2px solid rgb(var(--border));
    border-top-color: rgb(var(--brand));
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

/* ---------- вопрос к ИИ ---------- */

.ai-section {
    padding: 16px;
    margin-bottom: 16px;
    border: 1px solid rgb(var(--brand) / 0.25);
    border-radius: var(--radius-card);
    background: rgb(var(--brand-tint) / 0.6);
}
.ai-section h3 {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 12px;
    color: rgb(var(--brand-strong));
    font-size: 12px;
    line-height: 16px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.ai-input-row { display: flex; gap: 10px; margin-bottom: 12px; }
.ai-input { flex: 1; background-color: rgb(var(--surface)); }

.example-q {
    padding: 3px 10px;
    border: 1px solid rgb(var(--brand) / 0.25);
    border-radius: 999px;
    background: rgb(var(--surface));
    color: rgb(var(--brand-strong));
    font-size: 13px;
    line-height: 18px;
    cursor: pointer;
    transition: background 0.15s;
}
.example-q:hover { background: rgb(var(--brand-soft)); }
.example-questions-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.example-questions-left { display: flex; gap: 6px; flex-wrap: wrap; }

.ai-response {
    display: none;
    margin-top: 12px;
    padding: 14px;
    border: 1px solid rgb(var(--border));
    border-radius: var(--radius-control);
    background: rgb(var(--surface));
    line-height: 1.6;
}
.ai-response.visible { display: block; }
.ai-response-content { font-size: 15px; line-height: 1.6; }
.response-text p { margin-bottom: 10px; }
.response-text p:last-child { margin-bottom: 0; }
.response-header { margin: 16px 0 10px; font-size: 16px; font-weight: 600; color: rgb(var(--ink)); }
.response-header:first-child { margin-top: 0; }
.response-list-item { margin: 8px 0; padding-left: 8px; }
.response-num { margin-right: 4px; color: rgb(var(--brand-strong)); font-weight: 600; }
.response-bullet { position: relative; margin: 6px 0; padding-left: 16px; }
.response-bullet::before { content: '•'; position: absolute; left: 4px; color: rgb(var(--brand)); }
.response-quote { display: inline; padding: 2px 8px; margin: 0 2px; }
.response-label-block { margin-top: 12px; margin-bottom: 4px; }
.response-label-block:first-child { margin-top: 0; }
.response-text strong { color: rgb(var(--ink)); font-weight: 600; }

/* ---------- настройки: подключение к ИИ ---------- */

.settings-section { margin-bottom: 24px; }
.settings-section h3 { margin-bottom: 12px; font-size: 16px; line-height: 22px; font-weight: 600; color: rgb(var(--ink)); }

.provider-option, .tr-scenario-card {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    margin-bottom: 8px;
    border: 1px solid rgb(var(--border));
    border-radius: var(--radius-control);
    background: rgb(var(--surface));
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}
.provider-option:hover, .tr-scenario-card:hover { border-color: rgb(var(--ink-faint)); }
.provider-option.selected, .tr-scenario-card.selected { border-color: rgb(var(--brand)); background: rgb(var(--brand-tint)); }
.provider-option input[type='radio'] { margin-top: 2px; }
.provider-info { flex: 1; min-width: 0; }
.provider-name { margin-bottom: 2px; font-weight: 500; color: rgb(var(--ink)); }
.provider-desc { font-size: 13px; line-height: 18px; color: rgb(var(--ink-muted)); }
.provider-config { display: none; margin-top: 12px; padding: 14px; border: 1px solid rgb(var(--border)); border-radius: var(--radius-control); background: rgb(var(--surface-raised)); }
.provider-config.visible { display: block; }
.provider-config .form-input, .provider-config .form-select { background-color: rgb(var(--surface)); }

/* ---------- списки вопросов (шаблоны) ---------- */

.template-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    margin-bottom: 8px;
    border: 1px solid rgb(var(--border));
    border-radius: var(--radius-control);
    background: rgb(var(--surface));
    transition: border-color 0.2s;
}
.template-card:hover { border-color: rgb(var(--ink-faint)); }
.template-info { display: flex; align-items: center; gap: 12px; min-width: 0; }
.template-info h3 { font-size: 15px; font-weight: 500; color: rgb(var(--ink)); }
.template-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- адаптив ---------- */

@media (max-width: 1024px) {
    .dialog-panels { grid-template-columns: 1fr; height: auto; }
    .dialog-panels .panel { max-height: 70vh; }
}
