/* Рабочее пространство «Дело» (issue #2). Отдельный файл — style.css не трогаем.
   Все цвета берём из токенов :root в style.css, чтобы тема переключалась сама. */

  #mattersView { overflow: hidden; }

  .mt-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 20px 28px 40px;
  }
  .mt-wrap { max-width: 1020px; margin: 0 auto; }

  /* ── Шапка раздела ─────────────────────────────────────────────────────── */
  .mt-title {
    font-size: 21px;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--text-primary);
  }

  .mt-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 13px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    background: var(--bg-elevated);
    color: var(--text-primary);
    font-size: 13px;
    cursor: pointer;
    white-space: nowrap;
    transition: background var(--motion-fast) var(--ease-out),
                border-color var(--motion-fast) var(--ease-out);
  }
  .mt-btn:hover { background: var(--bg-hover); border-color: var(--accent-muted); }
  .mt-btn-primary {
    background: var(--bg-invert);
    color: var(--bg-main);
    border-color: transparent;
  }
  .mt-btn-primary:hover { opacity: 0.88; background: var(--bg-invert); }
  .mt-btn-ghost { background: transparent; border-color: var(--border-soft); color: var(--text-secondary); }
  .mt-btn svg { width: 15px; height: 15px; }

  /* ── Плитки сценариев входа ────────────────────────────────────────────── */

  /* ── Список дел ────────────────────────────────────────────────────────── */
  .mt-list { display: flex; flex-direction: column; gap: 4px; }
  .mt-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-surface);
    cursor: pointer;
    transition: border-color var(--motion-fast) var(--ease-out),
                background var(--motion-fast) var(--ease-out);
  }
  .mt-card:hover { border-color: var(--border-strong); background: var(--bg-elevated); }
  .mt-card-main { flex: 1; min-width: 0; }
  .mt-card-title {
    font-size: 13.5px;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .mt-card-meta {
    margin-top: 2px;
    font-size: 11.5px;
    color: var(--text-faint);
    display: flex;
    gap: 9px;
    flex-wrap: wrap;
  }
  .mt-card-del {
    flex-shrink: 0;
    opacity: 0;
    padding: 6px;
    border: none;
    background: transparent;
    color: var(--text-faint);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: opacity var(--motion-fast) var(--ease-out);
  }
  .mt-card:hover .mt-card-del { opacity: 1; }
  .mt-card-del:hover { color: #e5484d; background: var(--bg-hover); }
  .mt-card-del svg { width: 15px; height: 15px; display: block; }

  .mt-empty {
    padding: 22px 16px;
    text-align: center;
    font-size: 12.5px;
    color: var(--text-faint);
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-md);
  }

  /* ── Полоса стадий ─────────────────────────────────────────────────────── */

  /* ── Заглушка стадии (этап 1) ──────────────────────────────────────────── */
  .mt-stub {
    padding: 32px 24px;
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-lg);
    text-align: center;
    background: var(--bg-surface);
  }
  .mt-stub-name { font-size: 16px; color: var(--text-secondary); margin-bottom: 8px; }
  .mt-stub-hint { font-size: 13px; line-height: 1.6; color: var(--text-faint); max-width: 480px; margin: 0 auto; }


  .mt-title-input {
    width: 100%;
    max-width: 640px;
    padding: 4px 8px;
    margin-left: -8px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-primary);
    font-size: 24px;
    font-weight: 600;
    letter-spacing: -0.02em;
  }
  .mt-title-input:hover { border-color: var(--border-soft); }
  .mt-title-input:focus { outline: none; border-color: var(--input-focus-border); background: var(--input-bg); }

  @media (max-width: 720px) {
    .mt-scroll { padding: 24px 18px 48px; }
  }

  /* ── Стадия «Материалы»: drop-зона и карточки файлов ───────────────────── */



  .mt-doc-list { display: flex; flex-direction: column; gap: 4px; }
  .mt-doc {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-surface);
    overflow: hidden;
  }
  .mt-doc.is-failed { border-color: rgba(229, 72, 77, 0.35); }
  .mt-doc-row { display: flex; align-items: flex-start; gap: 10px; padding: 9px 11px; }
  .mt-doc-icon {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: var(--radius-sm);
    background: var(--bg-hover);
    color: var(--text-muted);
  }
  .mt-doc-icon svg { width: 13px; height: 13px; }
  .mt-doc-main { flex: 1; min-width: 0; }
  .mt-doc-name {
    font-size: 13px;
    color: var(--text-primary);
    word-break: break-word;
  }
  .mt-doc-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 4px;
    font-size: 11.5px;
    color: var(--text-faint);
  }
  .mt-doc-kind-row { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
  .mt-kind {
    padding: 4px 8px;
    border: 1px solid var(--input-border);
    border-radius: var(--radius-sm);
    background: var(--input-bg);
    color: var(--text-secondary);
    font-size: 12px;
    cursor: pointer;
  }
  .mt-kind:focus { outline: none; border-color: var(--input-focus-border); }
  .mt-kind-src { font-size: 11px; color: var(--text-faint); }
  .mt-doc-warn {
    margin-top: 8px;
    font-size: 12px;
    line-height: 1.5;
    color: #d9a441;
  }
  .mt-doc.is-failed .mt-doc-warn { color: #e5484d; }
  .mt-doc-actions { display: flex; gap: 2px; flex-shrink: 0; }
  .mt-icon-btn {
    padding: 6px;
    border: none;
    background: transparent;
    color: var(--text-faint);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: color var(--motion-fast) var(--ease-out),
                background var(--motion-fast) var(--ease-out);
  }
  .mt-icon-btn:hover { color: var(--text-primary); background: var(--bg-hover); }
  .mt-icon-btn svg { width: 15px; height: 15px; display: block; }

  .mt-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11.5px;
    background: var(--bg-hover);
    color: var(--text-muted);
  }
  .mt-badge.is-ok { color: #3fb950; background: rgba(63, 185, 80, 0.12); }
  .mt-badge.is-warn { color: #d9a441; background: rgba(217, 164, 65, 0.13); }
  .mt-badge.is-error { color: #e5484d; background: rgba(229, 72, 77, 0.13); }
  .mt-badge.is-pending { color: var(--text-secondary); }

  .mt-spin {
    width: 10px;
    height: 10px;
    border: 1.5px solid var(--border-strong);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: mt-spin 0.7s linear infinite;
  }
  @keyframes mt-spin { to { transform: rotate(360deg); } }

  .mt-doc-preview {
    border-top: 1px solid var(--border);
    background: var(--bg-page);
    max-height: 420px;
    overflow: auto;
  }
  .mt-doc-preview pre {
    margin: 0;
    padding: 16px;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 12.5px;
    line-height: 1.65;
    color: var(--text-secondary);
    white-space: pre-wrap;
    word-break: break-word;
  }
  .mt-doc-preview-empty { padding: 16px; font-size: 12.5px; color: var(--text-faint); }

  /* ── Стадия «Обезличивание» ────────────────────────────────────────────── */
  /* Плотная двухколоночная раскладка: слева читаем документ, справа правим
     словарь. Оба столбца скроллятся независимо, шапка и подвал зафиксированы —
     юрист не теряет контекст, пролистывая длинный иск. */
  /* ── обезличивание: рабочая поверхность, а не форма ─────────────────────
     Юрист здесь вычитывает документ, поэтому лист устроен как в текстовом
     редакторе: белое поле с полями и тенью, комфортная мера строки, масштаб.
     Раньше текст шёл во всю ширину панели мелким кеглем — читать было тяжело. */
  .mt-an { display: flex; flex: 1; min-height: 0; }
  .mt-an-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

  .mt-page-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 20px 0 40px; }
  .mt-page {
    width: min(820px, calc(100% - 48px));
    margin: 0 auto;
    padding: 48px 56px;
    border: 1px solid var(--border);
    border-radius: 2px;
    background: var(--bg-surface);
    box-shadow: 0 2px 14px rgba(0, 0, 0, 0.22);
  }
  [data-theme="light"] .mt-page {
    background: #fff;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
  }
  /* Редактор документа: лист, на котором юрист правит текст и сразу видит,
     как документ будет выглядеть в суде. Оформление блоков задано правилами
     судебного документа, а не произвольными кнопками. */
  .mt-page.is-doc { padding: 56px 64px 72px; }
  .mt-doc-rich {
    font-family: 'Times New Roman', Georgia, serif;
    font-size: calc(15px * var(--mt-zoom, 1));
    line-height: 1.75;
    color: var(--text-primary);
    outline: none;
  }
  .mt-doc-rich .b-p {
    text-align: justify;
    text-indent: 1.25cm;
    margin-bottom: 2px;
  }
  .mt-doc-rich .b-head {
    text-align: center;
    font-weight: 700;
    margin: 14px 0 4px;
  }
  .mt-doc-rich .b-sub { text-align: center; margin-bottom: 12px; }
  .mt-doc-rich .b-li {
    text-align: justify;
    padding-left: 1.25cm;
    text-indent: -1.25cm;
    margin-bottom: 2px;
  }
  .mt-doc-rich .b-empty { min-height: 1.75em; }
  .mt-doc-rich b { font-weight: 700; }
  /* В материале блоки не форматируем «под суд»: это чужой документ, его нужно
     видеть как есть, а не приводить к нашему шаблону. */
  .mt-doc-rich.is-material .b-p { text-align: left; text-indent: 0; }
  .mt-doc-rich.is-material .b-head { font-weight: 600; text-align: left; margin: 10px 0 2px; }
  .mt-doc-rich.is-material .b-sub { text-align: left; margin-bottom: 4px; }
  /* Курсор в пустом блоке: без этого он схлопывается в невидимую точку. */
  .mt-doc-rich div:empty::after { content: ''; display: inline-block; }


  .mt-page-text {
    font-family: 'Times New Roman', Georgia, serif;
    /* Масштаб меняет кегль листа, а не всей страницы: интерфейс вокруг
       остаётся на месте, как в Word. */
    font-size: calc(15px * var(--mt-zoom, 1));
    line-height: 1.75;
    color: var(--text-primary);
    white-space: pre-wrap;
    word-break: break-word;
  }

  .mt-an-status {
    display: flex; align-items: center; gap: 10px;
    min-height: 30px;
    padding: 0 var(--mt-x);
    border-top: 1px solid var(--border);
    background: var(--bg-elevated);
    font-size: 11px;
    color: var(--text-faint);
    flex-shrink: 0;
  }
  .mt-an-count { flex-shrink: 0; }
  .mt-an-note { display: flex; align-items: center; gap: 6px; }
  .mt-an-note.is-error { color: #e5484d; }

  .mt-zoom {
    display: flex; align-items: center; gap: 2px;
    padding: 1px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
  }
  /* Знаки «−» и «+» — не иконки, а символы, и на тёмном фоне они тонули:
     задаём цвет и вес явно. */
  .mt-zoom .mt-tool {
    color: var(--text-secondary);
    font-size: 15px;
    line-height: 1;
    padding: 3px 8px;
  }
  .mt-zoom .mt-tool:hover { color: var(--text-primary); background: var(--bg-hover); }
  .mt-zoom-val {
    min-width: 38px;
    text-align: center;
    font-size: 11px;
    color: var(--text-faint);
    font-variant-numeric: tabular-nums;
  }

  .mt-chip {
    padding: 2px 7px;
    border-radius: 999px;
    background: var(--bg-hover);
    font-size: 10.5px;
    color: var(--text-muted);
    white-space: nowrap;
  }
  .mt-mode-hint {
    max-width: 340px;
    font-size: 10.5px;
    line-height: 1.4;
    color: var(--text-faint);
  }

  /* Подсветка ПДн: цвет по категории, чтобы взгляд сразу отделял людей от
     реквизитов. Приглушённые тона — читать документ должно быть не больно. */
  .mt-pii {
    padding: 0 2px;
    border-radius: 3px;
    background: rgba(74, 143, 201, 0.16);
    color: var(--text-primary);
    cursor: pointer;
    box-shadow: inset 0 -1px 0 rgba(74, 143, 201, 0.5);
  }
  .mt-pii.cat-person   { background: rgba(74, 143, 201, 0.18); box-shadow: inset 0 -1px 0 rgba(74, 143, 201, 0.55); }
  .mt-pii.cat-org      { background: rgba(63, 185, 80, 0.16);  box-shadow: inset 0 -1px 0 rgba(63, 185, 80, 0.5); }
  .mt-pii.cat-location { background: rgba(217, 164, 65, 0.16); box-shadow: inset 0 -1px 0 rgba(217, 164, 65, 0.5); }
  .mt-pii.cat-contact  { background: rgba(163, 113, 247, 0.16); box-shadow: inset 0 -1px 0 rgba(163, 113, 247, 0.5); }
  .mt-pii.cat-id,
  .mt-pii.cat-bank     { background: rgba(219, 109, 40, 0.15); box-shadow: inset 0 -1px 0 rgba(219, 109, 40, 0.5); }
  .mt-pii.is-sel { outline: 1.5px solid var(--accent); outline-offset: 1px; }
  .mt-pii.is-off {
    background: transparent;
    color: var(--text-faint);
    box-shadow: none;
    text-decoration: line-through;
    text-decoration-color: var(--text-faint);
  }

  /* Словарь замен не уезжает вместе с текстом: он нужен ровно в тот момент,
     когда юрист читает документ, поэтому колонка прокручивается отдельно. */
  .mt-an-side {
    width: 296px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow-y: auto;
    padding: var(--mt-y) var(--mt-x);
    border-left: 1px solid var(--border);
    background: var(--bg-page);
  }
  .mt-an-side .mt-side-head {
    position: sticky;
    top: 0;
    z-index: 2;
    padding-bottom: 4px;
    background: var(--bg-page);
  }
  .mt-an-side .mt-side-note {
    position: sticky;
    top: 22px;
    z-index: 2;
    padding-bottom: 6px;
    margin-bottom: 4px;
    background: var(--bg-page);
  }
  .mt-side-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-faint);
    margin-bottom: 5px;
  }
  .mt-link {
    border: none;
    background: none;
    padding: 0;
    color: var(--accent);
    font-size: 11px;
    cursor: pointer;
    text-transform: none;
    letter-spacing: 0;
  }
  .mt-link:hover { text-decoration: underline; }
  .mt-side-note { font-size: 11px; line-height: 1.45; color: var(--text-faint); margin-bottom: 10px; }
  .mt-side-empty { padding: 14px 10px; font-size: 11.5px; line-height: 1.5; color: var(--text-faint); }
  .mt-side-group { margin-bottom: 10px; }
  .mt-side-cap {
    font-size: 10.5px;
    color: var(--text-faint);
    margin-bottom: 3px;
    padding-left: 2px;
  }

  .mt-rep {
    padding: 6px 7px;
    margin-bottom: 2px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    background: var(--bg-surface);
    cursor: pointer;
  }
  .mt-rep:hover { border-color: var(--border-strong); }
  .mt-rep.is-sel { border-color: var(--accent); background: var(--bg-elevated); }
  .mt-rep.is-other { opacity: 0.55; }   /* запись из другого документа дела */
  .mt-rep.is-off .mt-rep-orig { text-decoration: line-through; }
  /* Две строки вместо одной: «г. Москва, ул. Ленина, д. 5, кв. 10 → …» в одну
     строку не помещался и обрезался — было не видно, на что заменяется. */
  .mt-rep-row { display: flex; flex-direction: column; gap: 2px; }
  .mt-rep-orig {
    min-width: 0;
    font-size: 11.5px;
    color: var(--text-muted);
    line-height: 1.35;
    word-break: break-word;
  }
  .mt-rep-arrow {
    color: var(--text-faint);
    font-size: 10px;
    flex-shrink: 0;
    align-self: flex-start;
    line-height: 1;
  }
  .mt-rep-input {
    width: 100%;
    min-width: 0;
    padding: 2px 5px;
    border: 1px solid transparent;
    border-radius: 4px;
    background: transparent;
    color: var(--text-primary);
    font-size: 11.5px;
  }
  .mt-rep-input:hover { border-color: var(--border-soft); }
  .mt-rep-input:focus { outline: none; border-color: var(--input-focus-border); background: var(--input-bg); }
  .mt-rep-meta { display: flex; align-items: center; gap: 6px; margin-top: 3px; }
  .mt-rep-role {
    padding: 1px 4px;
    border: 1px solid var(--input-border);
    border-radius: 4px;
    background: var(--input-bg);
    color: var(--text-muted);
    font-size: 10.5px;
    cursor: pointer;
  }
  .mt-rep-role:focus { outline: none; border-color: var(--input-focus-border); }
  .mt-rep-count { font-size: 10.5px; color: var(--text-faint); font-variant-numeric: tabular-nums; }
  .mt-rep-toggle {
    margin-left: auto;
    padding: 1px 5px;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: var(--text-faint);
    font-size: 10.5px;
    cursor: pointer;
  }
  .mt-rep-toggle:hover { background: var(--bg-hover); color: var(--text-secondary); }


  /* ── Итог обезличивания ────────────────────────────────────────────────── */

  @media (max-width: 900px) {
    .mt-an { flex-direction: column; }
    .mt-an-side { width: auto; border-left: none; border-top: 1px solid var(--border); max-height: 40vh; }
    .mt-page { width: calc(100% - 20px); padding: 24px 20px; }
  }

  /* ── Стадия «Работа»: материалы | чат | документ ───────────────────────── */
  .mt-wk {
    display: flex;
    height: calc(100vh - 210px);
    min-height: 440px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-surface);
    overflow: hidden;
  }


  .mt-wk-none { font-size: 11px; line-height: 1.45; color: var(--text-faint); padding: 2px; }

  /* ── Чат дела ──────────────────────────────────────────────────────────── */


  .mt-msg { margin-bottom: 14px; font-size: 13px; line-height: 1.65; }
  .mt-msg.is-user { display: flex; justify-content: flex-end; }
  .mt-msg.is-user .mt-msg-body {
    max-width: 78%;
    padding: 7px 11px;
    border-radius: var(--radius-md);
    background: var(--bg-bubble);
    color: var(--text-primary);
    white-space: pre-wrap;
  }
  .mt-msg.is-bot .mt-msg-body { color: var(--text-secondary); }
  .mt-msg.is-bot .mt-msg-body p { margin: 0 0 8px; }
  .mt-msg.is-bot .mt-msg-body ul,
  .mt-msg.is-bot .mt-msg-body ol { margin: 0 0 8px; padding-left: 20px; }
  .mt-msg.is-bot .mt-msg-body li { margin-bottom: 3px; }
  .mt-msg.is-bot .mt-msg-body h1,
  .mt-msg.is-bot .mt-msg-body h2,
  .mt-msg.is-bot .mt-msg-body h3 {
    font-size: 13.5px; color: var(--text-primary); margin: 12px 0 5px;
  }
  .mt-msg-status {
    display: flex; align-items: center; gap: 6px;
    font-size: 11px; color: var(--text-faint); margin-bottom: 5px;
  }


  .mt-caret {
    display: inline-block;
    width: 6px; height: 13px;
    background: var(--accent);
    vertical-align: text-bottom;
    animation: mt-blink 1s steps(2) infinite;
  }
  @keyframes mt-blink { 50% { opacity: 0; } }

  .mt-send {
    flex-shrink: 0;
    width: 31px; height: 31px;
    display: flex; align-items: center; justify-content: center;
    border: none;
    border-radius: 50%;
    background: var(--bg-invert);
    color: var(--bg-main);
    cursor: pointer;
  }
  .mt-send:hover { opacity: 0.85; }
  .mt-send svg { width: 14px; height: 14px; }

  /* ── Панель документа ──────────────────────────────────────────────────── */
  .mt-ver-select {
    padding: 2px 5px;
    border: 1px solid var(--input-border);
    border-radius: 4px;
    background: var(--input-bg);
    color: var(--text-muted);
    font-size: 10.5px;
    cursor: pointer;
  }
  .mt-ver-select:focus { outline: none; }


  /* ── Diff версий ───────────────────────────────────────────────────────── */
  .mt-diff-stat {
    padding: 6px 12px;
    font-size: 11px;
    color: var(--text-faint);
    border-bottom: 1px solid var(--border);
  }
  .mt-add { color: #3fb950; }
  .mt-rem { color: #e5484d; }
  .mt-diff {
    flex: 1;
    overflow: auto;
    padding: 8px 0;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 11.5px;
    line-height: 1.6;
  }
  .mt-diff-line {
    display: flex;
    gap: 6px;
    padding: 0 12px;
    color: var(--text-faint);
    white-space: pre-wrap;
    word-break: break-word;
  }
  .mt-diff-line.is-add { background: rgba(63, 185, 80, 0.1); color: var(--text-secondary); }
  .mt-diff-line.is-rem { background: rgba(229, 72, 77, 0.1); color: var(--text-muted); text-decoration: line-through; }
  .mt-diff-sign { flex-shrink: 0; width: 8px; opacity: 0.6; }

    @media (max-width: 900px) {
    .mt-wk { flex-direction: column; height: auto; }
  }

  /* см. основное правило .mt-msg-status выше */
  .mt-msg-step {
    padding: 0 5px;
    border-radius: 999px;
    background: var(--bg-hover);
    font-size: 10px;
    color: var(--text-faint);
    font-variant-numeric: tabular-nums;
  }

  /* ── Источники под ответом ─────────────────────────────────────────────── */
  .mt-srcs {
    margin-top: 9px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 5px;
  }
  .mt-src-group { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
  .mt-src-cap {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-faint);
    margin-right: 2px;
  }
  .mt-src {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 1px 6px;
    border: 1px solid var(--border-soft);
    border-radius: 999px;
    background: var(--bg-surface);
    font-size: 10.5px;
    color: var(--text-muted);
    text-decoration: none;
    cursor: default;
  }
  .mt-src.is-link { cursor: pointer; }
  .mt-src.is-link:hover { border-color: var(--accent); color: var(--text-primary); }
  .mt-src-i {
    min-width: 12px;
    text-align: center;
    color: var(--text-faint);
    font-variant-numeric: tabular-nums;
  }

  /* ── Стадия «Проверка»: три отчёта-светофора ───────────────────────────── */
  .mt-ck-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
  }
  .mt-ck-bar .mt-side-cap { margin-bottom: 0; }
  .mt-ck-bar .mt-ver-select { flex: 0 1 320px; padding: 4px 7px; font-size: 12px; }
  .mt-ck-bar .mt-btn { margin-left: auto; }

  .mt-ck-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 8px;
    align-items: start;
  }
  .mt-ck-card {
    border: 1px solid var(--border);
    border-left: 2px solid var(--border-strong);
    border-radius: var(--radius-md);
    background: var(--bg-surface);
    padding: 11px 12px;
  }
  .mt-ck-card.is-ok   { border-left-color: #3fb950; }
  .mt-ck-card.is-warn { border-left-color: #d9a441; }
  .mt-ck-card.is-fail { border-left-color: #e5484d; }

  .mt-ck-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
  .mt-ck-name { font-size: 13px; color: var(--text-primary); }
  .mt-ck-state {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
  }
  .mt-ck-state.is-ok { color: #3fb950; }
  .mt-ck-state.is-warn { color: #d9a441; }
  .mt-ck-state.is-fail { color: #e5484d; }
  .mt-ck-state.is-idle { color: var(--text-faint); }
  .mt-ck-counts { display: inline-flex; gap: 4px; margin-left: 2px; }
  .mt-ck-counts b {
    font-weight: 600;
    padding: 0 4px;
    border-radius: 999px;
    background: var(--bg-hover);
    font-variant-numeric: tabular-nums;
  }
  .mt-warn-n { color: #d9a441; }

  .mt-ck-hint { margin-top: 5px; font-size: 11px; line-height: 1.45; color: var(--text-faint); }
  .mt-ck-actions { display: flex; align-items: center; gap: 8px; margin-top: 9px; }
  .mt-ck-actions .mt-btn { padding: 4px 10px; font-size: 11.5px; }

  .mt-ck-items {
    margin-top: 10px;
    padding-top: 9px;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 460px;
    overflow-y: auto;
  }
  .mt-ck-item { display: flex; gap: 7px; font-size: 12px; line-height: 1.5; }
  .mt-ck-item-icon { flex-shrink: 0; margin-top: 2px; color: var(--text-faint); }
  .mt-ck-item.is-ok .mt-ck-item-icon { color: #3fb950; }
  .mt-ck-item.is-warn .mt-ck-item-icon { color: #d9a441; }
  .mt-ck-item.is-fail .mt-ck-item-icon { color: #e5484d; }
  .mt-ck-item-body { flex: 1; min-width: 0; }
  .mt-ck-item-title {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    color: var(--text-primary);
  }
  .mt-ck-score, .mt-ck-src {
    padding: 0 5px;
    border-radius: 999px;
    background: var(--bg-hover);
    font-size: 10px;
    color: var(--text-faint);
  }
  .mt-ck-item-detail { margin-top: 2px; color: var(--text-muted); font-size: 11.5px; }
  .mt-ck-quote {
    margin-top: 5px;
    padding: 5px 8px;
    border-left: 2px solid var(--border-strong);
    background: var(--bg-page);
    border-radius: 0 4px 4px 0;
    font-size: 11px;
    line-height: 1.5;
    color: var(--text-faint);
  }
  .mt-ck-quote-src {
    display: block;
    font-size: 10px;
    color: var(--accent);
    margin-bottom: 1px;
  }
  .mt-ck-excerpt { margin-top: 5px; font-size: 11px; }
  .mt-ck-excerpt summary { cursor: pointer; color: var(--text-faint); }
  .mt-ck-excerpt div {
    margin-top: 4px;
    padding: 7px 9px;
    border-radius: var(--radius-sm);
    background: var(--bg-page);
    color: var(--text-muted);
    line-height: 1.55;
    white-space: pre-wrap;
    max-height: 200px;
    overflow-y: auto;
  }

  /* ── Стадия «Выпуск» ───────────────────────────────────────────────────── */
  .mt-rl-bar { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
  .mt-rl-bar .mt-side-cap { margin-bottom: 0; }
  .mt-rl-bar .mt-ver-select { flex: 0 1 340px; padding: 4px 7px; font-size: 12px; }

  .mt-rl { display: flex; gap: 12px; align-items: flex-start; }
  .mt-rl-side { width: 290px; flex-shrink: 0; }
  .mt-rl-block {
    padding: 10px 11px;
    margin-bottom: 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-surface);
  }
  .mt-rl-step {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-primary);
    margin-bottom: 8px;
  }
  .mt-rl-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px; height: 16px;
    border-radius: 50%;
    background: var(--accent);
    color: var(--on-accent);
    font-size: 10px;
  }
  .mt-rl-count { margin-left: auto; font-size: 10.5px; color: var(--text-faint); }
  .mt-rl-note {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    font-size: 11px;
    line-height: 1.45;
    color: var(--text-faint);
  }
  .mt-rl-note.is-ok { color: var(--text-muted); }
  .mt-rl-note svg { flex-shrink: 0; margin-top: 2px; color: var(--private-accent); }

  .mt-rl-field { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
  .mt-rl-field span {
    width: 84px;
    flex-shrink: 0;
    font-size: 10.5px;
    color: var(--text-faint);
    text-align: right;
  }
  .mt-rl-field input {
    flex: 1;
    min-width: 0;
    padding: 4px 7px;
    border: 1px solid var(--input-border);
    border-radius: var(--radius-sm);
    background: var(--input-bg);
    color: var(--input-text);
    font-size: 11.5px;
  }
  .mt-rl-field input:focus { outline: none; border-color: var(--input-focus-border); }
  .mt-rl-area {
    width: 100%;
    resize: vertical;
    padding: 6px 8px;
    margin-bottom: 6px;
    border: 1px solid var(--input-border);
    border-radius: var(--radius-sm);
    background: var(--input-bg);
    color: var(--input-text);
    font-size: 11.5px;
    line-height: 1.5;
  }
  .mt-rl-area:focus { outline: none; border-color: var(--input-focus-border); }

  .mt-rl-actions { display: flex; gap: 6px; margin-bottom: 7px; }
  .mt-rl-actions .mt-btn { padding: 6px 11px; font-size: 12px; }
  .mt-rl-warn {
    padding: 7px 9px;
    border-radius: var(--radius-sm);
    background: var(--bg-sub);
    font-size: 10.5px;
    line-height: 1.45;
    color: var(--text-faint);
  }

  /* Предпросмотр «как на бумаге» — те же поля и отступы, что уйдут в DOCX. */
  .mt-rl-preview { flex: 1; min-width: 0; }
  .mt-rl-preview-head {
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-faint);
    margin-bottom: 6px;
  }
  .mt-rl-page {
    max-height: calc(100vh - 280px);
    overflow-y: auto;
    padding: 26px 20px 26px 40px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: #fff;
    color: #111;
    font-family: 'Times New Roman', Georgia, serif;
    font-size: 14px;
    line-height: 1.5;
  }
  .mt-page-header { margin-left: 48%; margin-bottom: 16px; line-height: 1.25; }
  .mt-page-h { text-align: center; font-weight: bold; margin: 14px 0 10px; }
  .mt-page-p { text-align: justify; text-indent: 1.25cm; margin: 0 0 6px; }
  .mt-page-p.is-list { text-indent: 0; }
  .mt-page-sign { display: flex; justify-content: space-between; margin-top: 10px; }
  .mt-page-ph {
    background: rgba(217, 164, 65, 0.28);
    color: #7a5a10;
    border-radius: 2px;
    padding: 0 2px;
  }

  @media (max-width: 1000px) {
    .mt-rl { flex-direction: column; }
    .mt-rl-side { width: auto; }
    .mt-rl-page { max-height: 60vh; }
  }

  /* ══ ЕДИНЫЙ ХОЛСТ ДЕЛА (issue #4, шаг 7.3) ══════════════════════════════ */
  /* Три зоны одновременно, а не пять экранов по очереди. Высоту держим по
     вьюпорту: рабочая область должна занимать экран, а не жить в скролле. */
  .mt-canvas {
    display: flex;
    flex: 1;             /* .view — флекс-колонка, растягиваемся по ней */
    height: 100%;
    min-height: 0;
    background: var(--bg-page);
  }
  .mt-canvas.is-drop { outline: 2px dashed var(--accent); outline-offset: -8px; }

  /* ── левая колонка ─────────────────────────────────────────────────────── */
  .mt-rail {
    width: 224px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 12px 10px;
    overflow-y: auto;
    border-right: 1px solid var(--border);
  }
  .mt-canvas.rail-collapsed .mt-rail { display: none; }
  .mt-rail-n {
    padding: 0 5px;
    border-radius: 999px;
    background: var(--bg-hover);
    font-size: 10px;
    letter-spacing: 0;
  }
  .mt-rail-doc {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 6px;
    border-radius: var(--radius-sm);
    font-size: 11.5px;
    color: var(--text-muted);
    cursor: pointer;
  }
  .mt-rail-doc:hover { background: var(--bg-hover); color: var(--text-primary); }
  .mt-rail-name {
    flex: 1; min-width: 0;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }

  /* Статус обезличивания у каждого материала: отдельного процесса на всё дело
     больше нет, поэтому состояние читается прямо в списке. */
  .mt-rail-badge {
    flex-shrink: 0;
    padding: 0 5px;
    border-radius: 999px;
    background: var(--bg-hover);
    color: var(--text-faint);
    font-size: 9.5px;
    line-height: 1.7;
    white-space: nowrap;
  }
  .mt-rail-doc.is-ok .mt-rail-badge { background: color-mix(in srgb, #3fb950 18%, transparent); color: #3fb950; }
  .mt-rail-doc.is-local .mt-rail-badge { background: color-mix(in srgb, #a371f7 20%, transparent); color: #a371f7; }
  .mt-rail-doc.is-wait .mt-rail-badge { background: var(--bg-hover); color: var(--accent); }
  .mt-rail-doc.is-err .mt-rail-badge { background: color-mix(in srgb, #f85149 18%, transparent); color: #f85149; }
  .mt-rail-doc.is-idle .mt-rail-badge,
  .mt-rail-doc.is-warn .mt-rail-badge { background: color-mix(in srgb, #d29922 18%, transparent); color: #d29922; }

  /* Действие появляется под курсором: в покое список остаётся списком имён. */
  .mt-rail-act {
    display: flex; align-items: center;
    flex-shrink: 0;
    padding: 2px;
    border: none; border-radius: 4px;
    background: transparent;
    color: var(--text-faint);
    cursor: pointer;
    opacity: 0;
  }
  .mt-rail-doc:hover .mt-rail-act,
  .mt-rail-doc.is-active .mt-rail-act { opacity: 1; }
  .mt-rail-act:hover { background: var(--bg-surface); color: var(--accent); }

  /* Ход работы — индикатор, а не турникет: ничего не блокирует. */
  .mt-steps { display: flex; flex-direction: column; gap: 1px; }
  .mt-step {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 4px 6px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-faint);
    font-size: 11.5px;
    text-align: left;
    cursor: pointer;
  }
  .mt-step:hover { background: var(--bg-hover); color: var(--text-secondary); }
  /* Шаг, которому некуда вести, остаётся отметкой состояния: ни курсора-руки,
     ни подсветки — иначе он обещает переход, которого не будет. */
  .mt-step.is-inert { cursor: default; opacity: 0.55; }
  .mt-step.is-inert:hover { background: transparent; color: var(--text-faint); }
  /* Отметка состояния. Раньше это был кружок с фоном-градиентом — он выглядел
     как сломанная галочка. Теперь: точка — не начато, полукруг — частично,
     настоящая галочка — сделано. */
  .mt-step-mark {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 15px; height: 15px;
    flex-shrink: 0;
    color: var(--text-faint);
  }
  .mt-step-dot {
    width: 6px; height: 6px;
    border: 1px solid var(--border-strong);
    border-radius: 50%;
  }
  .mt-step-half {
    width: 9px; height: 9px;
    border: 1.5px solid #d9a441;
    border-radius: 50%;
    background: linear-gradient(to right, #d9a441 50%, transparent 50%);
  }
  .mt-step.is-done { color: var(--text-secondary); }
  .mt-step.is-done .mt-step-mark { color: #3fb950; }
  .mt-step.is-partial { color: var(--text-muted); }

  /* ── центр: агент ──────────────────────────────────────────────────────── */
  .mt-topbar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
  }
  .mt-crumb {
    padding: 2px 6px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-faint);
    font-size: 12px;
    cursor: pointer;
  }
  .mt-crumb:hover { background: var(--bg-hover); color: var(--text-primary); }
  .mt-topbar .mt-title-input {
    flex: 1;
    max-width: none;
    margin-left: 0;
    padding: 3px 7px;
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 0;
  }

  .mt-agent { flex: 1; min-height: 0; display: flex; flex-direction: column; }
  .mt-agent-loading {
    display: flex; align-items: center; justify-content: center; gap: 8px;
    flex: 1; font-size: 12.5px; color: var(--text-faint);
  }
  .mt-msgs { flex: 1; overflow-y: auto; padding: 18px 0; }
  .mt-msgs > * { max-width: 720px; margin-left: auto; margin-right: auto; padding: 0 20px; }

  .mt-hello { padding: 40px 20px !important; text-align: center; }
  .mt-hello-title { font-size: 17px; color: var(--text-primary); margin-bottom: 7px; }
  .mt-hello-text {
    font-size: 12.5px; line-height: 1.6; color: var(--text-muted);
    max-width: 480px; margin: 0 auto 18px;
  }

  /* Карточка сохранённого черновика в переписке */
  .mt-msg-art {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 11px;
    margin-bottom: 8px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    background: var(--bg-elevated);
    font-size: 12px;
    color: var(--text-secondary);
    cursor: pointer;
  }
  .mt-msg-art:hover { border-color: var(--accent); }
  .mt-msg-art-icon { color: var(--accent); display: flex; }
  .mt-msg-art-text { flex: 1; }
  .mt-msg-art-open { font-size: 11px; color: var(--accent); }

  .mt-suggests { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 9px; }
  .mt-suggest {
    padding: 3px 9px;
    border: 1px solid var(--border-soft);
    border-radius: 999px;
    background: transparent;
    color: var(--text-muted);
    font-size: 11px;
    cursor: pointer;
  }
  .mt-suggest:hover { border-color: var(--accent); color: var(--text-primary); }

  /* Строка ввода как в современных чат-интерфейсах: поле во всю ширину, а
     выбор модели и отправка — тонкой строкой под ним внутри общей рамки.
     Селектор сбоку сжимал поле, и длинный запрос приходилось писать в щель. */
  .mt-composer {
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    gap: 4px;
    padding: 7px 8px 7px 10px;
    border: 1px solid var(--input-border);
    border-radius: var(--radius-lg);
    background: var(--input-bg);
    transition: border-color var(--motion-fast) var(--ease-out);
  }
  .mt-composer:focus-within { border-color: var(--input-focus-border); }
  .mt-composer textarea {
    width: 100%;
    resize: none;
    padding: 0;
    border: none;
    background: transparent;
    color: var(--input-text);
    font-size: 13.5px;
    line-height: 1.5;
    overflow-y: hidden;            /* прокрутка включается с девятой строки */
  }
  .mt-composer textarea:focus { outline: none; }
  .mt-composer-row { display: flex; align-items: center; gap: 6px; }

  /* Выбор модели — там же, где в главном чате: в строке ввода. */
  .mt-model { position: relative; align-self: flex-end; margin-bottom: 9px; flex-shrink: 0; }
  .mt-model-btn {
    display: inline-flex; align-items: center; gap: 2px;
    padding: 2px 5px 2px 7px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: transparent;
    color: var(--text-faint);
    font-size: 10.5px;
    cursor: pointer;
  }
  .mt-model-btn:hover { color: var(--text-primary); border-color: var(--border-strong); }
  .mt-model-menu {
    position: absolute;
    bottom: calc(100% + 6px);
    left: 0;
    min-width: 168px;
    padding: 4px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    background: var(--bg-elevated);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.4);
    display: none;
    z-index: 40;
  }
  .mt-model.is-open .mt-model-menu { display: block; }
  .mt-model-opt {
    display: block; width: 100%;
    padding: 5px 8px;
    border: none; border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    font-size: 12px;
    text-align: left;
    cursor: pointer;
  }
  .mt-model-opt:hover { background: var(--bg-hover); color: var(--text-primary); }
  .mt-model-opt.is-active { color: var(--accent); }

  /* ── правая панель ─────────────────────────────────────────────────────── */
  .mt-panel {
    width: 0;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    border-left: 1px solid var(--border);
    background: var(--bg-surface);
    overflow: hidden;
    transition: width var(--motion-normal) var(--ease-out);
  }
  .mt-canvas.has-panel .mt-panel { width: 46%; min-width: 420px; }
  .mt-panel-head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 9px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-elevated);
    flex-shrink: 0;
  }
  .mt-panel-tabs { flex: 1; }
  .mt-panel-body { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; }

  /* Стадийные экраны стали содержимым панели — снимаем их собственные рамки
     и фиксированные высоты, иначе панель дублировала бы обводку. */
  .mt-panel-body .mt-an,
  .mt-panel-body .mt-wk { height: 100%; border: none; border-radius: 0; }
  .mt-panel-body .mt-rl,
  .mt-panel-body .mt-ck-grid,
  .mt-panel-body .mt-ck-bar,
  .mt-panel-body .mt-rl-bar { padding: 10px 12px; margin: 0; }
  .mt-panel-body .mt-ck-grid { grid-template-columns: 1fr; }
  .mt-panel-body .mt-rl { flex-direction: column; }
  .mt-panel-body .mt-rl-side { width: auto; }
  .mt-panel-body .mt-rl-page { max-height: 46vh; }

  @media (max-width: 1200px) {
    .mt-canvas.has-panel .mt-panel { width: 52%; min-width: 360px; }
  }
  @media (max-width: 980px) {
    .mt-canvas { flex-direction: column; height: auto; }
    .mt-rail { width: auto; border-right: none; border-bottom: 1px solid var(--border); }
    .mt-canvas.has-panel .mt-panel {
      width: auto; min-width: 0; border-left: none;
      border-top: 1px solid var(--border); height: 62vh;
    }
  }

  /* Кнопки формата экспорта словаря */
  .mt-export { display: inline-flex; align-items: center; gap: 6px; }
  .mt-export .mt-link { font-size: 10.5px; }
  .mt-link.is-faint { color: var(--text-faint); }
  .mt-link.is-faint:hover { color: var(--text-muted); }

  /* ══ Правки по обзору: меньше хрома, больше места документу ═════════════ */

  /* Кнопки «Приватный» и смена темы висят поверх всех экранов. В остальных
     разделах место под них заложено, а здесь они перекрывают рабочую область
     и разделу не нужны — скрываем, пока открыты «Дела». */
  body.mt-active #topbar { display: none !important; }

  .mt-wrap-narrow { max-width: 640px; }
  .mt-list-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
  }
  .mt-empty-pane {
    padding: 40px 24px;
    text-align: center;
    font-size: 12.5px;
    line-height: 1.6;
    color: var(--text-faint);
  }
  /* Заголовок + аргумент доверия в пустом списке дел — единственный empty-pane,
     где нужен вложенный текст покрупнее; остальные 8 мест переиспользуют
     mt-empty-pane как есть, одной строкой, эти классы их не задевают. */
  .mt-empty-title { font-size: 13.5px; color: var(--text-secondary); margin-bottom: 8px; }
  .mt-empty-sub { font-size: 11.5px; line-height: 1.6; color: var(--text-faint); max-width: 420px; margin: 0 auto; }

  /* Переключатель дел прямо в шапке — быстрая навигация без выхода в список. */
  .mt-topbar .pr-select { flex: 0 1 260px; }
  .mt-topbar .pr-select-btn { border-color: transparent; background: transparent; font-size: 13px; }
  .mt-topbar .pr-select-btn:hover { background: var(--bg-hover); }


  /* Список замен: пары «было → стало» ровными строками, чтобы взгляд пробегал
     сверху вниз, а не искал стрелку в каждой строке. Подробности строки
     (роль, счётчик, выключатель) показываем только у выбранной и под курсором —
     иначе панель превращается в таблицу с шумом. */
  .mt-an-side .mt-rep { padding: 5px 7px; }
  .mt-an-side .mt-rep-row { flex-direction: row; align-items: baseline; gap: 6px; }
  .mt-an-side .mt-rep-orig { flex: 1 1 46%; min-width: 0; }
  .mt-an-side .mt-rep-input { flex: 1 1 54%; width: auto; }
  .mt-an-side .mt-rep-arrow { align-self: baseline; }
  .mt-an-side .mt-rep-meta { display: none; }
  .mt-an-side .mt-rep.is-sel .mt-rep-meta,
  .mt-an-side .mt-rep:hover .mt-rep-meta { display: flex; }

  /* ══ Правки по второму обзору ═══════════════════════════════════════════ */

  /* Иконка листа вместо цветной точки: точка читалась как индикатор процесса. */
  .mt-rail-ico { display: flex; flex-shrink: 0; color: var(--text-faint); }
  .mt-rail-doc.is-ok .mt-rail-ico { color: #3fb950; }
  .mt-rail-doc.is-warn .mt-rail-ico { color: #d9a441; }
  .mt-rail-doc.is-err .mt-rail-ico { color: #e5484d; }
  .mt-rail-doc.is-wait .mt-rail-ico { color: var(--accent); animation: mt-blink 1s infinite; }

  /* Стрелки при наведении здесь больше нет: она обещала переход даже там, где
     переходить некуда. Состояние шага показывает только отметка слева. */

  /* Сворачивание левой панели */

  /* ── Предпросмотр материала ────────────────────────────────────────────── */
  .mt-panel-label { font-size: 12px; color: var(--text-muted); }
  .mt-pv-head {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 10px 14px 8px;
    border-bottom: 1px solid var(--border);
  }
  .mt-pv-title {
    flex: 1; min-width: 0;
    font-size: 12.5px;
    color: var(--text-primary);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .mt-pv-state { font-size: 10px; color: var(--text-faint); }
  .mt-pv-state.is-ok { color: #3fb950; }

  /* Мелкий масштаб: пробежаться глазами, а не читать вдумчиво — для чтения
     есть полноэкранное окно. */
  .mt-pv-page {
    flex: 1;
    overflow-y: auto;
    padding: 16px 18px;
    font-size: 11.5px;
    line-height: 1.6;
    color: var(--text-secondary);
    white-space: pre-wrap;
    word-break: break-word;
  }
  .mt-pv-pii {
    padding: 0 2px;
    border-radius: 3px;
    background: rgba(74, 143, 201, 0.16);
    color: var(--text-primary);
    cursor: help;
    position: relative;
  }
  .mt-pv-pii.cat-org { background: rgba(63, 185, 80, 0.16); }
  .mt-pv-pii.cat-location { background: rgba(217, 164, 65, 0.16); }
  .mt-pv-pii.cat-contact { background: rgba(163, 113, 247, 0.16); }
  .mt-pv-pii.cat-id, .mt-pv-pii.cat-bank { background: rgba(219, 109, 40, 0.15); }

  /* Наведение показывает, что было на самом деле — быстрая сверка без разбора. */
  .mt-pv-pii:hover::after {
    content: attr(data-real);
    position: absolute;
    left: 0; bottom: calc(100% + 4px);
    z-index: 10;
    padding: 3px 7px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--bg-elevated);
    color: var(--text-primary);
    font-size: 11px;
    white-space: nowrap;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
  }

  .mt-pv-foot {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 9px 12px;
    border-top: 1px solid var(--border);
    background: var(--bg-elevated);
  }
  .mt-pv-meta { flex: 1; font-size: 10.5px; color: var(--text-faint); }
  .mt-pv-foot .mt-btn { padding: 5px 11px; font-size: 12px; }


  /* ══ РАСКЛАДКА IDE ══════════════════════════════════════════════════════ */
  /* Проводник дела | редактор документа | ассистент. Центр экрана занимает сам
     документ: юрист над ним и работает, а переписка — вспомогательная. */
  /* Единая сетка (issue #5, шаг 8.7). До этого каждая полоса интерфейса имела
     свои отступы — 6/9/10/12/20 px, — из-за чего кнопки в соседних рядах не
     стояли на одной вертикали, а сверху и снизу упирались в границы.
     Горизонталь одна на весь раздел, вертикальный ритм кратен 4. */
  .mt-ide {
    --mt-x: 12px;          /* горизонтальные поля всех полос */
    --mt-y: 8px;           /* вертикальные поля полос */
    --mt-gap: 6px;         /* между кнопками в группе */
    --mt-bar: 38px;        /* высота полосы: панель инструментов, вкладки */
    --mt-rail-w: 216px;    /* ширины панелей — юрист меняет их мышью */
    --mt-chat-w: 380px;
    position: relative;
    display: flex; flex: 1; height: 100%; min-height: 0;
    background: var(--bg-page);
  }
  .mt-ide.is-drop { outline: 2px dashed var(--accent); outline-offset: -8px; }

  /* ── сворачивание и ширина панелей ────────────────────────────────────
     Кнопка сворачивания живёт внутри панели, в её верхнем углу: там же, где
     заголовок, и её видно без охоты за границей. Снаружи остаётся только
     кнопка «вернуть» — она нужна ровно тогда, когда панели не видно. */
  .mt-panel-fold {
    display: flex; align-items: center; justify-content: center;
    width: 22px; height: 22px;
    flex-shrink: 0;
    padding: 0;
    border: none; border-radius: 5px;
    background: transparent;
    color: var(--text-faint);
    cursor: pointer;
  }
  .mt-panel-fold:hover { background: var(--bg-hover); color: var(--text-primary); }
  .mt-asst-top { display: flex; justify-content: flex-start; padding: 6px 6px 0; }

  .mt-restore {
    position: absolute;
    top: 50%;
    margin-top: -26px;
    z-index: 20;
    display: none;
    align-items: center; justify-content: center;
    width: 24px; height: 52px;
    padding: 0;
    border: 1px solid var(--border-strong);
    background: var(--bg-elevated);
    color: var(--text-secondary);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
    cursor: pointer;
  }
  .mt-restore:hover {
    color: var(--on-accent, #fff);
    background: var(--accent);
    border-color: var(--accent);
  }
  .mt-restore.is-left { left: 0; border-radius: 0 6px 6px 0; border-left: none; }
  .mt-restore.is-right { right: 0; border-radius: 6px 0 0 6px; border-right: none; }
  .mt-ide.rail-off .mt-restore.is-left { display: flex; }
  .mt-ide.chat-off .mt-restore.is-right { display: flex; }

  /* Граница-ручка: тонкая полоса, реагирующая на курсор. Пределы ширины
     заданы в скрипте, здесь только вид. */
  .mt-resize {
    position: absolute;
    top: 0; bottom: 0;
    z-index: 15;
    width: 7px;
    cursor: col-resize;
    background: transparent;
    transition: background var(--motion-normal) var(--ease-out);
  }
  .mt-resize::after {
    content: '';
    position: absolute;
    top: 0; bottom: 0; left: 3px;
    width: 1px;
    background: transparent;
    transition: background var(--motion-fast) var(--ease-out);
  }
  .mt-resize:hover::after,
  body.mt-resizing .mt-resize::after {
    background: color-mix(in srgb, var(--accent) 55%, transparent);
  }
  /* Ручка стоит на границе панели и считает её по той же переменной, что и
     сама панель — разойтись они не могут. Внутрь панели ручку класть нельзя:
     там прокрутка, и её обрезает (проверяется тестом отрисовки). */
  .mt-resize.is-left { left: var(--mt-rail-w); margin-left: -3px; }
  .mt-resize.is-right { right: var(--mt-chat-w); margin-right: -3px; }
  .mt-ide.rail-off .mt-resize.is-left,
  .mt-ide.chat-off .mt-resize.is-right { display: none; }
  body.mt-resizing { cursor: col-resize; user-select: none; }
  @media (max-width: 1000px) { .mt-resize, .mt-restore { display: none; } }

  /* Панели двигаются плавно, но без «желе»: 220 мс и мягкая кривая. */
  .mt-explorer, .mt-assistant {
    transition: width var(--motion-normal) var(--ease-out),
                opacity var(--motion-normal) var(--ease-out);
  }
  body.mt-resizing .mt-explorer,
  body.mt-resizing .mt-assistant { transition: none; }

  /* ── проводник ─────────────────────────────────────────────────────────── */
  .mt-explorer {
    width: var(--mt-rail-w);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: var(--mt-y) var(--mt-x);
    overflow-y: auto;
    border-right: 1px solid var(--border);
    background: var(--bg-surface);
  }
  .mt-ide.rail-off .mt-explorer { display: none; }
  .mt-exp-top { display: flex; align-items: center; gap: 4px; }
  .mt-exp-back {
    padding: 4px;
    border: none; background: transparent;
    color: var(--text-faint); cursor: pointer; border-radius: var(--radius-sm);
  }
  .mt-exp-back:hover { color: var(--text-primary); background: var(--bg-hover); }
  .mt-explorer .mt-title-input {
    flex: 1; min-width: 0; max-width: none; margin: 0;
    padding: 3px 6px; font-size: 12.5px; font-weight: 500; letter-spacing: 0;
  }
  /* Заголовок группы: имя, счётчик и действие в одну строку, с воздухом до
     самого списка — вплотную читалось как один сплошной блок. */
  .mt-exp-cap {
    display: flex; align-items: center; gap: 6px;
    margin-bottom: 8px;
    padding: 0 4px 5px;
    border-bottom: 1px solid var(--border);
    font-size: 10px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase;
    color: var(--text-muted);
  }
  .mt-exp-cap > span:first-child { flex: 1; min-width: 0; }
  .mt-exp-n {
    padding: 0 5px;
    border-radius: 999px;
    background: var(--bg-hover);
    color: var(--text-faint);
    font-size: 9.5px;
    letter-spacing: 0;
    font-variant-numeric: tabular-nums;
  }
  .mt-exp-add {
    display: flex; align-items: center;
    border: none; background: transparent; color: var(--text-faint);
    line-height: 1; cursor: pointer; padding: 1px; border-radius: 4px;
  }
  .mt-exp-add:hover { color: var(--accent); background: var(--bg-hover); }
  .mt-exp-item {
    display: flex; align-items: center; gap: 6px;
    padding: 4px 6px; border-radius: var(--radius-sm);
    font-size: 11.5px; color: var(--text-muted); cursor: pointer;
  }
  .mt-exp-item:hover { background: var(--bg-hover); color: var(--text-primary); }
  .mt-exp-item.is-active { background: var(--bg-active); color: var(--text-primary); }
  .mt-exp-ver { font-size: 9.5px; color: var(--text-faint); }
  .mt-exp-empty { padding: 4px 6px; font-size: 10.5px; line-height: 1.45; color: var(--text-faint); }
  .mt-exp-empty.is-action {
    display: block; width: 100%; text-align: left;
    padding: 7px 8px;
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-muted);
    font-size: 11px;
    cursor: pointer;
  }
  .mt-exp-empty.is-action:hover { border-color: var(--accent); color: var(--text-primary); }
  .mt-exp-steps { margin-top: auto; padding-top: 9px; border-top: 1px solid var(--border); }

  /* ── редактор ──────────────────────────────────────────────────────────── */
  .mt-editor-area { flex: 1; min-width: 0; display: flex; flex-direction: column; }

  /* Вкладки: без вертикальных рамок между ними — активная различается фоном
     и полоской сверху, как в редакторах кода. Рамки между всеми вкладками
     делали ряд похожим на таблицу. */
  .mt-tabs {
    display: flex; align-items: stretch; gap: 2px;
    padding: 0 6px;
    background: var(--bg-page);
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    flex-shrink: 0;
  }
  .mt-tab {
    display: flex; align-items: center; gap: 6px;
    min-height: var(--mt-bar);
    padding: 0 10px;
    border: none;
    border-radius: 6px 6px 0 0;
    background: transparent;
    color: var(--text-faint);
    font-size: 11.5px;
    cursor: pointer;
    white-space: nowrap;
    max-width: 220px;
  }
  .mt-tab:hover { color: var(--text-secondary); }
  .mt-tab.is-active {
    background: var(--bg-surface);
    color: var(--text-primary);
    box-shadow: inset 0 2px 0 var(--accent);
  }
  /* Вкладка обезличивания отличается от вкладки документа значком щита. */
  .mt-tab.is-anon .mt-tab-ico { color: var(--accent); }
  .mt-tab-ico { display: flex; flex-shrink: 0; }
  .mt-tab-name { overflow: hidden; text-overflow: ellipsis; }
  .mt-tab-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); flex-shrink: 0; }
  .mt-tab-x {
    border: none; background: transparent; color: inherit;
    font-size: 14px; line-height: 1; padding: 0 2px; cursor: pointer; opacity: 0.5;
  }
  .mt-tab-x:hover { opacity: 1; }

  .mt-editor { flex: 1; min-height: 0; display: flex; flex-direction: column; background: var(--bg-surface); }
  .mt-toolbar {
    display: flex; align-items: center; gap: var(--mt-gap);
    min-height: var(--mt-bar);
    padding: 0 var(--mt-x);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
  }
  /* Разделитель групп: слева правка текста, справа действия с документом. */
  .mt-toolbar-sp { flex: 1; }
  .mt-tool {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 5px 9px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-muted);
    font-size: 11.5px;
    cursor: pointer;
  }
  .mt-tool:hover { background: var(--bg-hover); color: var(--text-primary); }
  .mt-tool.is-icon { padding: 5px 7px; }
  .mt-tool.is-primary { border-color: var(--border-strong); color: var(--text-primary); }
  .mt-tool.is-primary:hover { border-color: var(--accent); }

  .mt-editor-body { flex: 1; min-height: 0; overflow-y: auto; }
  /* «Лист»: судебный документ юрист правит так же, как увидит суд, поэтому
     никакого моноширинного шрифта — засечки, мера строки, поля. */
  .mt-paper {
    max-width: 780px;
    margin: 0 auto;
    padding: 22px 24px 60px;
    min-height: 100%;
  }
  /* Замечание — подчёркивание под словами, как ошибка линтера: текст читается,
     а место видно. Подсветка живёт прямо в тексте документа, поэтому она не
     может «уехать» от слов (issue #5, шаг 8.2). */
  .mt-mark {
    background: transparent;
    color: inherit;
    border-bottom: 2px solid #d29922;
    border-radius: 1px;
  }
  .mt-mark.is-fail { border-bottom-color: #f85149; }
  .mt-mark.is-current {
    background: color-mix(in srgb, var(--accent) 18%, transparent);
    border-bottom-width: 2px;
  }

  /* Кнопка-состояние документа: она же и показывает, видит ли ИИ документ,
     и переключает это. Раньше состояние и режим были двумя разными
     элементами, и их приходилось сопоставлять в уме. */
  .mt-doc-state {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 4px 10px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: transparent;
    color: var(--text-muted);
    font-size: 11.5px;
    cursor: pointer;
  }
  .mt-doc-state:hover { border-color: var(--border-strong); color: var(--text-primary); }
  .mt-doc-state.is-ok {
    border-color: color-mix(in srgb, #3fb950 45%, transparent);
    color: #3fb950;
  }
  .mt-doc-state.is-local {
    border-color: color-mix(in srgb, #a371f7 45%, transparent);
    color: #a371f7;
  }
  .mt-doc-state.is-idle {
    border-color: color-mix(in srgb, #d29922 45%, transparent);
    color: #d29922;
  }

  /* Линза и список замен — один блок с общей рамкой: связь между «что видит
     ИИ» и «что именно заменено» должна читаться глазами, без подписей. */
  .mt-lens-group {
    display: flex; align-items: center; gap: 2px;
    padding: 2px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
  }
  .mt-lens-vault {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 4px 9px;
    border: none;
    border-left: 1px solid var(--border);
    border-radius: 0 6px 6px 0;
    background: transparent;
    color: var(--text-faint);
    font-size: 11.5px;
    cursor: pointer;
  }
  .mt-lens-vault:hover { color: var(--text-primary); background: var(--bg-hover); }
  .mt-lens-vault.is-on { color: var(--accent); background: var(--bg-hover); }
  .mt-lens-n {
    padding: 0 5px;
    border-radius: 999px;
    background: var(--bg-hover);
    font-size: 9.5px;
    font-variant-numeric: tabular-nums;
  }

  /* Кнопка обезличивания у необезличенного материала видна всегда: прятать
     следующий шаг под наведение мыши нельзя. */
  .mt-rail-act.is-always { opacity: 1; color: #d29922; }
  .mt-rail-badge[data-anon-doc] { cursor: pointer; }
  .mt-rail-badge[data-anon-doc]:hover { text-decoration: underline; }

  /* ── панель документа: три зоны и меню «ещё» ────────────────────────────
     Кнопок в ряд стало меньше не потому, что убрали возможности, а потому что
     в каждый момент нужны одна-две; остальное живёт в меню. */
  .mt-style-group {
    display: flex; align-items: center; gap: 1px;
    padding: 2px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
  }
  .mt-style {
    min-width: 30px;
    padding: 4px 9px;
    border: none;
    border-radius: 5px;
    background: transparent;
    color: var(--text-muted);
    font-size: 11.5px;
    cursor: pointer;
  }
  .mt-style:hover { background: var(--bg-hover); color: var(--text-primary); }
  .mt-style.is-bold { font-family: 'Times New Roman', Georgia, serif; font-weight: 700; font-size: 13px; }

  .mt-more { position: relative; }
  .mt-more-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 232px;
    padding: 4px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    background: var(--bg-elevated);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4);
    display: none;
    z-index: 60;
  }
  [data-theme="light"] .mt-more-menu { box-shadow: 0 12px 28px rgba(0, 0, 0, 0.14); }
  .mt-more.is-open .mt-more-menu { display: block; }
  .mt-more-item {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    width: 100%;
    padding: 6px 9px;
    border: none; border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    font-size: 12px;
    text-align: left;
    cursor: pointer;
  }
  .mt-more-item:hover { background: var(--bg-hover); color: var(--text-primary); }
  .mt-more-item span { color: var(--text-faint); font-size: 10.5px; }
  .mt-more-row {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    padding: 4px 9px;
  }
  .mt-more-label { font-size: 12px; color: var(--text-secondary); }
  .mt-more-sep { height: 1px; margin: 4px 0; background: var(--border); }

  .mt-sel-cap {
    padding: 0 6px 0 4px;
    color: var(--text-faint);
    font-family: var(--font-ui, inherit);
    font-size: 10.5px;
  }

  .mt-tool-badge {
    margin-left: 5px;
    padding: 0 5px;
    border-radius: 999px;
    background: color-mix(in srgb, #d29922 22%, transparent);
    color: #d29922;
    font-size: 10.5px;
    font-weight: 600;
  }
  .mt-tool-badge.is-fail {
    background: color-mix(in srgb, #f85149 20%, transparent);
    color: #f85149;
  }
  .mt-status-btn.has-issues { color: #d29922; }

  /* Панель замечаний снизу — Problems из IDE. */
  .mt-problems {
    display: none;
    flex-direction: column;
    max-height: 38%;
    border-top: 1px solid var(--border);
    background: var(--bg-elevated);
  }
  .mt-problems.is-open { display: flex; }
  .mt-pb-list { overflow-y: auto; padding: 2px 0 4px; }
  .mt-pb-row {
    display: flex;
    align-items: baseline;
    gap: 7px;
    padding: 5px 12px;
    font-size: 12px;
    line-height: 1.45;
    cursor: pointer;
    border-left: 2px solid transparent;
  }
  .mt-pb-row:hover { background: var(--bg-hover); }
  .mt-pb-row.is-current { background: var(--bg-hover); border-left-color: var(--accent); }
  .mt-pb-dot {
    flex-shrink: 0;
    width: 6px; height: 6px;
    border-radius: 50%;
    background: #d29922;
    transform: translateY(-1px);
  }
  .mt-pb-row.is-fail .mt-pb-dot { background: #f85149; }
  .mt-pb-where {
    flex-shrink: 0;
    min-width: 84px;
    color: var(--text-faint);
    font-size: 11px;
  }
  .mt-pb-title { flex-shrink: 0; color: var(--text-primary); font-weight: 500; }
  .mt-pb-detail {
    flex: 1;
    min-width: 0;
    color: var(--text-faint);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .mt-pb-noplace {
    flex-shrink: 0;
    color: var(--text-faint);
    font-size: 10.5px;
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0 6px;
  }
  .mt-pb-empty {
    display: flex; align-items: center; gap: 7px;
    padding: 12px 14px;
    font-size: 12px;
    line-height: 1.55;
    color: var(--text-faint);
  }
  .mt-pb-empty.is-ok { color: var(--text-secondary); }

  /* ── правки агента в самом документе (issue #5, шаг 8.1) ─────────────────
     Показываем текст целиком, а изменённые куски выделяем: юрист читает
     документ, а не отчёт о различиях. */
  .mt-toolbar.is-proposal { background: var(--bg-elevated); }
  .mt-prop-badge {
    padding: 2px 7px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--accent) 16%, transparent);
    color: var(--accent);
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
  }
  .mt-prop-count { font-size: 11.5px; color: var(--text-faint); white-space: nowrap; }

  .mt-proposal {
    font-family: 'Times New Roman', Georgia, serif;
    font-size: 15px;
    line-height: 1.75;
    color: var(--text-primary);
  }
  .mt-prop-note {
    margin-bottom: 14px;
    padding: 8px 11px;
    border-left: 2px solid var(--accent);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    background: var(--bg-hover);
    font-family: inherit;
    font-size: 12px;
    line-height: 1.55;
    color: var(--text-secondary);
  }
  .mt-hunk-keep { white-space: pre-wrap; word-break: break-word; }

  .mt-hunk {
    position: relative;
    margin: 8px 0;
    border: 1px solid var(--border);
    border-left: 2px solid var(--accent);
    border-radius: var(--radius-sm);
    background: var(--bg-hover);
  }
  .mt-hunk.is-taken { border-left-color: #3fb950; }
  .mt-hunk-body { padding: 8px 11px; white-space: pre-wrap; word-break: break-word; }
  .mt-hunk-inline ins,
  .mt-hunk-new {
    background: color-mix(in srgb, #3fb950 15%, transparent);
    color: var(--text-primary);
    text-decoration: none;
  }
  .mt-hunk-inline del,
  .mt-hunk-old {
    background: color-mix(in srgb, #f85149 14%, transparent);
    color: var(--text-muted);
    text-decoration: line-through;
  }

  .mt-hunk-bar {
    display: flex; align-items: center; gap: 5px;
    padding: 5px 8px;
    border-top: 1px solid var(--border);
    font-family: var(--font-ui, inherit);
  }
  .mt-hunk-kind {
    flex: 1;
    font-size: 10.5px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-faint);
  }
  .mt-hunk-btn {
    padding: 3px 9px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-muted);
    font-size: 11.5px;
    cursor: pointer;
  }
  .mt-hunk-btn:hover { background: var(--bg-surface); color: var(--text-primary); }
  .mt-hunk.is-taken .mt-hunk-btn.is-take {
    border-color: #3fb950;
    color: #3fb950;
  }

  /* ── хронология дела (issue #5, шаг 8.5) ─────────────────────────────────
     Лента событий: слева дата и линия, справа что произошло и откуда взято. */
  /* ── хронология: история дела ───────────────────────────────────────────
     Читается как лента: слева столбец дат на одной вертикали, посередине линия
     с точками, справа — что произошло. Ширина ленты ограничена мерой строки,
     иначе на широком экране дата и событие расходятся на пол-экрана. */
  .mt-tl {
    max-width: 720px;
    margin: 0 auto;
    padding: 8px 0 24px;
  }
  .mt-tl-cap { font-size: 11.5px; color: var(--text-faint); }
  .mt-tl-warn {
    display: flex; gap: 8px;
    margin-bottom: 10px;
    padding: 9px 12px;
    border: 1px solid color-mix(in srgb, #d29922 35%, transparent);
    border-radius: var(--radius-md);
    background: color-mix(in srgb, #d29922 8%, transparent);
    font-size: 12px;
    line-height: 1.5;
    color: var(--text-secondary);
  }
  .mt-tl-warn::before { content: '!'; font-weight: 700; color: #d29922; }

  /* Давность в спокойном состоянии (срок далеко) — та же строка, но без
     тревожной рамки: это ориентир, а не сигнал «разбирайтесь срочно». */
  .mt-tl-warn.is-quiet {
    border-color: var(--border);
    background: var(--bg-surface);
    color: var(--text-faint);
  }
  .mt-tl-warn.is-quiet::before { content: none; }

  .mt-tl-year {
    display: flex; align-items: center; gap: 10px;
    margin: 20px 0 8px;
    padding-left: 78px;
  }
  .mt-tl-year span {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.1em;
    color: var(--text-faint);
  }
  .mt-tl-year::after { content: ''; flex: 1; height: 1px; background: var(--border); }

  .mt-tl-gap { display: flex; padding: 4px 0 4px 78px; }
  .mt-tl-gap span {
    padding: 1px 9px;
    border-radius: 999px;
    background: var(--bg-hover);
    color: var(--text-faint);
    font-size: 10px;
  }

  .mt-tl-list { position: relative; }
  .mt-tl-row { display: flex; align-items: flex-start; gap: 0; padding: 3px 0; }
  .mt-tl-when {
    width: 62px;
    flex-shrink: 0;
    padding-top: 2px;
    text-align: right;
  }
  .mt-tl-day {
    font-size: 12.5px;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.02em;
  }
  /* Точка и линия — общая вертикаль на всю ленту. */
  .mt-tl-dot {
    position: relative;
    flex-shrink: 0;
    width: 8px; height: 8px;
    margin: 7px 16px 0;
    border-radius: 50%;
    background: var(--bg-page);
    box-shadow: inset 0 0 0 2px var(--border-strong);
  }
  .mt-tl-dot::before {
    content: '';
    position: absolute;
    left: 3.5px; top: 10px;
    width: 1px; height: calc(100% + 24px);
    background: var(--border);
  }
  .mt-tl-row:last-child .mt-tl-dot::before { display: none; }
  .mt-tl-row.is-claim .mt-tl-dot,
  .mt-tl-row.is-pretension .mt-tl-dot,
  .mt-tl-row.is-contract .mt-tl-dot { box-shadow: inset 0 0 0 4px var(--accent); }
  .mt-tl-row.is-future .mt-tl-dot { box-shadow: inset 0 0 0 2px #d29922; }

  .mt-tl-body {
    flex: 1;
    min-width: 0;
    padding: 2px 0 10px;
  }
  .mt-tl-label {
    display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
  }
  .mt-tl-flag {
    padding: 0 6px;
    border-radius: 999px;
    background: color-mix(in srgb, #d29922 18%, transparent);
    color: #d29922;
    font-size: 10px;
    font-weight: 400;
  }
  .mt-tl-quote {
    margin-top: 3px;
    font-size: 11.5px;
    line-height: 1.5;
    color: var(--text-faint);
  }
  .mt-tl-src { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 5px; }
  .mt-tl-file {
    display: inline-flex; align-items: center; gap: 3px;
    color: var(--text-faint);
    font-size: 10px;
  }

  /* ── карточки знаний (issue #5, шаг 8.4) ─────────────────────────────────
     Ответ из наших баз, а не из модели: показываем данными, без «текста от
     ИИ», чтобы юрист видел источник, а не пересказ. */
  .mt-ins {
    margin: 8px 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-surface);
    overflow: hidden;
  }
  .mt-ins-head {
    padding: 6px 10px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-hover);
    font-size: 11px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-faint);
  }
  .mt-ins-load,
  .mt-ins-empty {
    display: flex; align-items: center; gap: 7px;
    padding: 10px;
    font-size: 12px;
    line-height: 1.5;
    color: var(--text-faint);
  }
  .mt-ins-note {
    padding: 8px 10px 0;
    font-size: 11px;
    line-height: 1.5;
    color: var(--text-faint);
  }
  .mt-ins-cols { display: flex; gap: 8px; padding: 8px; }
  .mt-ins-col { flex: 1; min-width: 0; }
  .mt-ins-col-head {
    margin-bottom: 5px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
  }
  .mt-ins-col.is-pro .mt-ins-col-head { color: #3fb950; }
  .mt-ins-col.is-contra .mt-ins-col-head { color: #f85149; }

  .mt-ins-case,
  .mt-ins-judge {
    margin: 0 8px 6px;
    padding: 7px 9px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-elevated);
  }
  .mt-ins-col .mt-ins-case { margin: 0 0 6px; }
  .mt-ins-case.is-missing { border-color: color-mix(in srgb, #f85149 45%, var(--border)); }
  .mt-ins-case-top {
    display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px;
    font-size: 11.5px;
    font-weight: 500;
    color: var(--text-primary);
  }
  .mt-ins-court { font-size: 10.5px; font-weight: 400; color: var(--text-faint); }
  .mt-ins-quote {
    margin-top: 4px;
    font-size: 11.5px;
    line-height: 1.5;
    color: var(--text-secondary);
  }

  .mt-ins-bar { display: flex; gap: 2px; margin: 7px 0 5px; height: 16px; }
  .mt-ins-seg {
    display: flex; align-items: center; justify-content: center;
    border-radius: 3px;
    font-size: 9.5px;
    color: #fff;
    overflow: hidden;
  }
  .mt-ins-seg.is-pro { background: #2ea043; }
  .mt-ins-seg.is-part { background: #9e6a03; }
  .mt-ins-seg.is-contra { background: #c93c37; }

  /* Матрица доводов оппонента («Доводы оппонента» в палитре по выделению) */
  .mt-rt-alarm {
    margin: 0 8px 8px;
    padding: 7px 9px;
    border: 1px solid color-mix(in srgb, #c93c37 45%, var(--border));
    border-radius: var(--radius-sm);
    background: color-mix(in srgb, #c93c37 10%, transparent);
    font-size: 11.5px; line-height: 1.5; color: var(--text-secondary);
  }
  .mt-rt-row {
    margin: 0 8px 8px;
    padding: 7px 9px;
    border: 1px solid var(--border);
    border-left: 3px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-elevated);
  }
  .mt-rt-row.is-strong { border-left-color: #2ea043; }
  .mt-rt-row.is-medium { border-left-color: #9e6a03; }
  .mt-rt-row.is-weak { border-left-color: #c93c37; }
  .mt-rt-row.is-none { border-left-color: #c93c37; background: color-mix(in srgb, #c93c37 8%, var(--bg-elevated)); }
  .mt-rt-strength {
    margin-left: auto;
    font-size: 10px; font-weight: 500; letter-spacing: 0.02em;
    color: var(--text-faint);
  }
  .mt-rt-arg, .mt-rt-resp {
    margin-top: 4px;
    font-size: 11.5px; line-height: 1.5;
    color: var(--text-secondary);
  }
  .mt-ins-seg.is-term { background: var(--text-faint); }

  .mt-court-stat { padding: 6px 10px 8px; }
  .mt-court-row {
    display: flex; justify-content: space-between; gap: 10px;
    padding: 3px 0;
    font-size: 11.5px;
    color: var(--text-faint);
  }
  .mt-court-row b { color: var(--text-secondary); font-weight: 500; }

  .mt-msg.is-note {
    margin: 6px 0;
    padding: 7px 10px;
    border-left: 2px solid var(--border-strong);
    font-size: 11.5px;
    line-height: 1.5;
    color: var(--text-faint);
  }

  /* ── палитра команд (issue #5, шаг 8.3) ──────────────────────────────────
     Список возможностей появляется по «/» и по Ctrl+K и исчезает сразу:
     постоянного шума в интерфейсе не остаётся. */
  .mt-palette {
    display: none;
    flex-direction: column;
    margin: 0 10px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    background: var(--bg-elevated);
    box-shadow: 0 12px 34px rgba(0, 0, 0, 0.4);
    overflow: hidden;
  }
  [data-theme="light"] .mt-palette { box-shadow: 0 12px 30px rgba(0, 0, 0, 0.14); }
  .mt-palette.is-open { display: flex; }
  .mt-pal-list { max-height: 300px; overflow-y: auto; padding: 3px; }
  .mt-pal-group {
    padding: 7px 9px 3px;
    font-size: 10px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-faint);
  }
  .mt-pal-row {
    display: flex;
    align-items: baseline;
    gap: 8px;
    padding: 5px 9px;
    border-radius: var(--radius-sm);
    cursor: pointer;
  }
  .mt-pal-row.is-active { background: var(--bg-hover); }
  .mt-pal-title { flex-shrink: 0; font-size: 12.5px; color: var(--text-primary); }
  .mt-pal-hint {
    flex: 1;
    min-width: 0;
    font-size: 11px;
    color: var(--text-faint);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .mt-pal-empty { padding: 10px; font-size: 12px; line-height: 1.5; color: var(--text-faint); }
  .mt-pal-foot {
    padding: 5px 10px;
    border-top: 1px solid var(--border);
    font-size: 10.5px;
    color: var(--text-faint);
  }

  .mt-hello-keys { margin-top: 12px; }
  .mt-key-hint {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 4px 10px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: transparent;
    color: var(--text-muted);
    font-size: 11.5px;
    cursor: pointer;
  }
  .mt-key-hint:hover { border-color: var(--border-strong); color: var(--text-primary); }
  .mt-key-hint kbd {
    padding: 0 4px;
    border: 1px solid var(--border);
    border-radius: 3px;
    background: var(--bg-hover);
    font-family: inherit;
    font-size: 11px;
  }
  .mt-hello-src {
    margin-top: 14px;
    font-size: 10.5px;
    line-height: 1.6;
    color: var(--text-faint);
  }

  /* Действия по выделению: возможности приходят к тексту, а не наоборот. */
  .mt-selbar {
    display: none;
    position: absolute;
    z-index: 30;
    gap: 2px;
    padding: 3px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    background: var(--bg-elevated);
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.38);
    white-space: nowrap;
  }
  [data-theme="light"] .mt-selbar { box-shadow: 0 8px 20px rgba(0, 0, 0, 0.13); }
  .mt-selbar.is-open { display: flex; align-items: center; }
  .mt-sel-act {
    padding: 4px 9px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    font-family: var(--font-ui, inherit);
    font-size: 11.5px;
    cursor: pointer;
  }
  .mt-sel-act:hover { background: var(--bg-hover); color: var(--text-primary); }
  .mt-sel-n {
    padding: 0 8px 0 4px;
    border-left: 1px solid var(--border);
    color: var(--text-faint);
    font-family: var(--font-ui, inherit);
    font-size: 10.5px;
  }

  /* «Изменить…» — точечная правка своей инструкцией, самое частое действие
     в этой панели. Выделена не заливкой (это спорило бы с минимализмом
     остальной панели), а цветом текста — тем же приёмом, что и активные
     состояния в остальном интерфейсе. */
  .mt-sel-act-primary { color: var(--accent); }
  .mt-sel-act-primary:hover { background: var(--bg-hover); color: var(--accent); }
  .mt-sel-sep { display: inline-block; width: 1px; align-self: stretch; margin: 2px 1px; background: var(--border); }

  /* Панель выделения на месте становится полем ввода — без отдельного окна. */
  .mt-sel-input {
    width: 260px;
    padding: 5px 8px;
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-family: var(--font-ui, inherit);
    font-size: 11.5px;
    outline: none;
  }
  .mt-sel-input::placeholder { color: var(--text-faint); }
  .mt-sel-go {
    padding: 4px 10px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--accent);
    font-size: 13px;
    line-height: 1;
    cursor: pointer;
  }
  .mt-sel-go:hover { background: var(--bg-hover); }

  .mt-welcome {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 10px;
    height: 100%;
    min-height: 240px;
    padding: 40px 24px;
    text-align: center;
  }
  .mt-welcome-key { color: var(--text-faint); opacity: 0.5; }
  .mt-welcome-hint {
    font-size: 12px; line-height: 1.6; color: var(--text-faint);
    max-width: 420px; margin: 0 auto 16px;
  }

  .mt-find {
    display: flex; align-items: center; gap: var(--mt-gap);
    min-height: var(--mt-bar);
    padding: 0 var(--mt-x);
    border-bottom: 1px solid var(--border);
    background: var(--bg-elevated);
  }
  .mt-find input {
    padding: 5px 9px;
    border: 1px solid var(--input-border);
    border-radius: var(--radius-sm);
    background: var(--input-bg);
    color: var(--input-text);
    font-size: 11.5px;
    width: 170px;
  }
  .mt-find input:focus { outline: none; border-color: var(--accent); }
  .mt-find-n { flex: 1; font-size: 10.5px; color: var(--text-faint); }

  /* ── док замен снизу (как панель Problems) ─────────────────────────────── */
  .mt-vault-dock { flex-shrink: 0; border-top: 1px solid var(--border); display: none; }
  .mt-vault-dock.is-open { display: block; max-height: 34vh; overflow: hidden; }
  /* Кнопка «свернуть» в панелях снизу: без своего правила она рисовалась
     системной кнопкой браузера и выбивалась из остального интерфейса. */
  .mt-dock-x {
    display: flex; align-items: center; justify-content: center;
    width: 20px; height: 20px;
    padding: 0;
    border: none; border-radius: 4px;
    background: transparent;
    color: var(--text-faint);
    font-size: 15px; line-height: 1;
    cursor: pointer;
  }
  .mt-dock-x:hover { background: var(--bg-hover); color: var(--text-primary); }

  .mt-exp-group { display: flex; flex-direction: column; gap: 2px; }
  .mt-step-name { flex: 1; min-width: 0; }

  .mt-dock-head {
    display: flex; align-items: center; gap: 6px;
    padding: 5px 10px;
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border);
  }
  .mt-dock-title { flex: 1; font-size: 11px; color: var(--text-muted); }
  .mt-dock-body { max-height: 28vh; overflow-y: auto; padding: 4px; }
  .mt-dock-row {
    display: flex; align-items: center; gap: 7px;
    padding: 3px 7px; border-radius: var(--radius-sm);
    font-size: 11.5px; cursor: pointer;
  }
  .mt-dock-row:hover { background: var(--bg-hover); }
  .mt-dock-row.is-sel { background: var(--bg-active); }
  .mt-dock-orig { flex: 0 1 40%; min-width: 0; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .mt-dock-arrow { color: var(--text-faint); font-size: 10px; }
  .mt-dock-input {
    flex: 1 1 40%; min-width: 0;
    padding: 2px 6px;
    border: 1px solid transparent; border-radius: 4px;
    background: transparent; color: var(--text-primary); font-size: 11.5px;
  }
  .mt-dock-input:hover { border-color: var(--border-soft); }
  .mt-dock-input:focus { outline: none; border-color: var(--accent); background: var(--input-bg); }
  .mt-dock-count { font-size: 10px; color: var(--text-faint); font-variant-numeric: tabular-nums; }

  /* ── строка состояния ──────────────────────────────────────────────────── */
  .mt-status {
    display: flex; align-items: center; gap: var(--mt-gap);
    min-height: 32px;
    padding: 4px var(--mt-x);
    border-top: 1px solid var(--border);
    background: var(--bg-elevated);
    font-size: 10.5px;
    color: var(--text-faint);
    flex-shrink: 0;
  }
  .mt-status-info { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .mt-status-btn {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 7px; border: none; border-radius: 4px;
    background: transparent; color: var(--text-faint); font-size: 10.5px; cursor: pointer;
  }
  .mt-status-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
  /* Словарь замен — не служебная ссылка, а рабочий инструмент: он должен
     читаться как кнопка, а не как подпись в углу. */
  .mt-status-btn.is-strong {
    border: 1px solid var(--border);
    color: var(--text-secondary);
    background: var(--bg-surface);
  }
  .mt-status-btn.is-strong:hover { border-color: var(--accent); color: var(--text-primary); }
  .mt-status-n {
    padding: 0 4px;
    border-radius: 999px;
    background: var(--bg-hover);
    color: var(--text-faint);
    font-size: 9.5px;
    font-variant-numeric: tabular-nums;
  }
  .mt-unsaved { color: #d9a441; font-weight: 500; }
  .mt-ok-txt { color: #3fb950; font-weight: 500; }

  /* ── ассистент справа ──────────────────────────────────────────────────── */
  .mt-assistant {
    width: var(--mt-chat-w);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    border-left: 1px solid var(--border);
    background: var(--bg-page);
  }
  .mt-ide.chat-off .mt-assistant { display: none; }
  .mt-assistant .mt-msgs { padding: var(--mt-x) 0; }
  .mt-assistant .mt-msgs > * { max-width: none; padding: 0 var(--mt-x); }
  .mt-assistant .mt-composer { margin: 0 var(--mt-x) var(--mt-x); }
  .mt-assistant .mt-hello { padding: 24px var(--mt-x) !important; }
  .mt-assistant .mt-hello-title { font-size: 14px; }


  @media (max-width: 1000px) {
    .mt-ide { flex-direction: column; height: auto; }
    .mt-explorer { width: auto; border-right: none; border-bottom: 1px solid var(--border); }
    .mt-assistant { width: auto; border-left: none; border-top: 1px solid var(--border); height: 50vh; }
  }
