/* Zorum chat v1 (ZS-DIS-01): page-specific layout on top of web/shared/design.css. */
.workspace { min-height: 0; }
.chat-column { min-height: 0; }
/* The model choice is not offered in the interface for now: the tenant's default profile answers. */
#modelSlot { display: none !important; }

/* Chat screen fits the viewport: header, scrolling messages, composer pinned to the bottom. */
.app-layout { height: 100dvh; min-height: 0; }
.sidebar { overflow: hidden; }
.sidebar .new-item { margin: 20px 0 18px; }
.main-column { height: 100dvh; }
@media (min-width: 641px) {
  .app-layout.sidebar-collapsed { grid-template-columns: minmax(0, 1fr); }
  .app-layout.sidebar-collapsed .sidebar { display: none; }
}

.chat-header { flex-wrap: nowrap; gap: 6px; padding: 8px 12px; min-height: 56px; }
/* ZS-PATCH-009: the title shrinks with an ellipsis; the pencil right after it never does. */
.chat-title-wrap { flex: 1; min-width: 0; display: flex; align-items: center; gap: 2px; }
.chat-title { flex: 0 1 auto; min-width: 0; font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rename-button { flex-shrink: 0; width: 32px; height: 32px; border-radius: 8px; color: var(--muted); }
.rename-button svg.icon { width: 16px; height: 16px; }
.rename-field { flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px; }
.rename-field input { flex: 1; min-width: 0; padding: 5px 8px; border: 1px solid var(--line); border-radius: 8px; font: inherit; font-weight: 600; font-size: 15px; }
.rename-count { flex-shrink: 0; font-size: 12px; color: var(--muted); }
.header-actions { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.header-button { position: relative; width: 40px; height: 40px; border-radius: 10px; color: var(--ink); }
.header-button svg.icon { width: 20px; height: 20px; }
.header-button > span { display: grid; place-items: center; }
.header-button .notification-badge { position: absolute; top: 2px; right: 0; margin: 0; padding: 2px 5px; font-size: 10px; }
#openSettings[aria-expanded="true"] { background: var(--soft); }
.side-panel input[type="checkbox"] { width: auto; flex-shrink: 0; }
.settings-wrap { position: relative; }
.settings-menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; min-width: 220px; padding: 6px;
  display: flex; flex-direction: column; background: var(--white); border: 1px solid var(--line);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-pop);
}
.settings-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 8px; text-align: left; font-size: 13.5px; white-space: nowrap; }
.settings-item:hover { background: var(--soft); }
.settings-item > span { display: grid; place-items: center; }

.chat-empty { margin-top: clamp(40px, 22vh, 220px); text-align: center; }
.chat-empty h1 { margin: 0; }
.composer textarea { min-height: 52px; }
.composer-wrap { padding-bottom: max(16px, env(safe-area-inset-bottom)); }

@media (max-width: 640px) {
  .app-layout { height: 100dvh; }
  .chat-header { padding: 6px 8px; }
  .composer textarea, .composer-wrap input, .side-panel input, .side-panel select, .rename-field input { font-size: 16px; }
  .composer textarea { min-height: 44px; padding: 12px 14px 2px; }
  .composer-bottom { padding: 4px 8px 8px 10px; }
  .composer-wrap { padding: 8px 10px max(10px, env(safe-area-inset-bottom)); }
  .side-panel { z-index: 15; }
  .sidebar:not(.open) { box-shadow: none; }
  /* ZS-NTF-003 §2.11: the feed takes the whole screen, nothing scrolls sideways, «⋯» is a bottom sheet. */
  #notificationsPanel { position: fixed; inset: 0; width: 100%; max-width: 100vw; height: 100dvh; overflow-x: hidden; overflow-y: auto; }
  #notificationsPanel .notif-menu {
    position: fixed; left: 0; right: 0; bottom: 0; top: auto; z-index: 30; min-width: 0; width: 100%;
    border-radius: 14px 14px 0 0; padding: 10px 10px max(14px, env(safe-area-inset-bottom));
  }
  #notificationsPanel .notif-menu-item { padding: 14px 12px; font-size: 15px; }
}

/* ZS-MVP-22: document card extraction section, clarifications, content tables (chat-only) */
.extraction-card, .clarification-card { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin-bottom: 10px; font-size: 13px; }
.kv-line { margin: 2px 0; }
.kv-label { color: var(--muted); }
.clarification-input { border: 1px solid var(--line); border-radius: 8px; padding: 4px 8px; font-size: 12px; }
.content-table { border-collapse: collapse; font-size: 12px; margin-bottom: 12px; }
.content-table td { border: 1px solid var(--line); padding: 2px 6px; white-space: nowrap; }
.viewer-preview { margin-top: 8px; }

/* SPEC-r01 ZS-MVP-27 point 4: unread-count pill on the "Уведомления" sidebar button. */
.notification-badge { margin-left: auto; background: var(--green, #3c6e3f); color: #fff; border-radius: 999px; font-size: 11px; line-height: 1; padding: 3px 7px; }
.notification-badge.urgent { background: var(--danger, #b3261e); }
.notification-badge.urgent::after { content: ""; position: absolute; top: -2px; right: -2px; width: 7px; height: 7px; border-radius: 50%; background: var(--danger, #b3261e); border: 1px solid var(--white, #fff); }

/* ZS-NTF-003 §2.1-§2.4/§2.11: the feed card -- a level stripe, the report in reading order, long
   file names wrap inside the panel, one main button + the «⋯» menu (a bottom sheet on a phone). */
.notif-tabs { display: flex; gap: 4px; margin-bottom: 12px; border-bottom: 1px solid var(--line); }
.notif-tab { padding: 7px 10px; font-size: 12.5px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.notif-tab.active, .notif-tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--green, #3c6e3f); font-weight: 600; }
#notificationsList { margin-top: 12px; }
/* A long file name or headline wraps instead of widening the 300 px panel (design.css is the shared copy). */
.side-panel .item-row { min-width: 0; max-width: 100%; overflow-wrap: anywhere; }
.side-panel .item-row .item-title { min-width: 0; }
.notification-row {
  position: relative; display: block; min-width: 0; max-width: 100%; overflow-wrap: anywhere; word-break: break-word;
  border-left: 4px solid var(--line); padding-left: 12px;
}
.notification-row.unread { background: var(--white); box-shadow: inset 0 0 0 1px var(--line); }
.notification-row.dismissed { opacity: .75; }
.notification-row.level-urgent { border-left-color: var(--danger, #b3261e); }
.notification-row.level-important { border-left-color: var(--amber, #c77700); }
.notification-row.level-info { border-left-color: var(--muted, #8a948c); }
.notification-row.level-noise { border-left-color: var(--line, #d9dfd9); }
.notification-row.notif-highlight { box-shadow: 0 0 0 2px var(--amber, #e0a000); }
.notification-row p { margin: 4px 0; }
.notif-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 11.5px; color: var(--muted); }
.level-badge { font-weight: 650; white-space: nowrap; }
.level-badge.level-urgent { color: var(--danger, #b3261e); }
.level-badge.level-important { color: var(--amber, #c77700); }
.notif-time { white-space: nowrap; }
.notif-title { font-weight: 650; font-size: 13.5px; margin: 4px 0 2px; }
.notif-sender { font-size: 12px; color: var(--muted); }
.deadline-badge { display: inline-block; margin: 6px 0 2px; padding: 2px 8px; border-radius: 999px; font-size: 11.5px; background: var(--amber-soft, #fff3d6); color: var(--amber, #8a5a00); }
.deadline-badge.overdue { background: var(--danger-soft, #fde7e5); color: var(--danger, #b3261e); }
.notif-summary { font-size: 13px; }
.notif-section { margin: 6px 0; font-size: 12.5px; }
.notif-section-title { font-size: 10.5px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); margin: 6px 0 2px; }
.notif-points { margin: 0; padding-left: 18px; }
.notif-why { font-size: 12.5px; }
.notif-sources { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
.notif-source { text-align: left; font-size: 12.5px; color: var(--green, #3c6e3f); text-decoration: underline; overflow-wrap: anywhere; max-width: 100%; }
.notif-caption { font-size: 11px; color: var(--muted); }
.item-meta { font-size: 12px; color: var(--muted); }
.notif-actions { position: relative; margin-top: 8px; align-items: center; }
.btn-pill-primary { background: var(--green, #3c6e3f); color: #fff; border-color: transparent; }
.notif-more { min-width: 34px; }
.notif-menu {
  position: absolute; right: 0; top: calc(100% + 4px); z-index: 8; min-width: 180px; padding: 6px;
  display: flex; flex-direction: column; background: var(--white); border: 1px solid var(--line);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-pop);
}
.notif-menu-item { padding: 9px 12px; border-radius: 8px; text-align: left; font-size: 13px; }
.notif-menu-item:hover { background: var(--soft); }
.notif-reason { margin-top: 8px; padding: 8px; border: 1px solid var(--line); border-radius: var(--radius-sm); display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; }
.notif-reason-option { display: flex; align-items: center; gap: 6px; font-weight: normal; }
.notif-reason-option input { width: auto; margin: 0; }
.notif-reason-note { width: 100%; font: inherit; border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; }
.notif-settings { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 12px; font-size: 12.5px; }
.notif-settings summary { cursor: pointer; font-weight: 600; }
.notif-settings select { width: 100%; }
.notifications-load-more { margin-top: 8px; }
.btn-secondary { padding: 7px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--white); font-size: 12.5px; }

/* ZS-UI-001 §2.1: the feed is wider than the other side panels (design.css .side-panel stays 300 px);
   on a phone (≤ 640 px) the full-screen rule above applies. */
@media (min-width: 1121px) {
  #notificationsPanel { width: 440px; }
}
@media (min-width: 901px) and (max-width: 1120px) {
  #notificationsPanel { width: 400px; }
}
@media (min-width: 641px) and (max-width: 900px) {
  #notificationsPanel { width: min(460px, 100vw); max-width: 100vw; }
}
/* ZS-UI-001 §2.2: a folded card -- title and gist in two lines each, «Подробнее» opens the rest. */
.notif-clamp { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; }
.notification-row.expanded .notif-clamp { display: block; -webkit-line-clamp: unset; line-clamp: none; overflow: visible; }
.notif-title-toggle { cursor: pointer; }
.notif-meta-line { display: flex; flex-wrap: wrap; align-items: center; gap: 0 4px; font-size: 12px; color: var(--muted); margin: 2px 0; }
.notif-meta-line .deadline-badge { margin: 0; }
.notif-full[hidden] { display: none; }

/* SPEC-r01 ZS-MVP-31 point 5: the digest settings weekday picker (a compact checkbox row, not a
   stacked form field) and the read/unread look of one released issue. */
.digest-days { display: flex; flex-wrap: wrap; gap: 8px; }
.digest-day { display: flex; align-items: center; gap: 4px; font-size: 12px; font-weight: normal; }
.digest-day input { margin: 0; }
#digestsList .item-row.item-read { opacity: 0.7; }
#digestsList ul { margin: 4px 0 8px; padding-left: 18px; font-size: 13px; }
/* FIX-r01/F8: a digest line is a real button that opens its source (never a dead hash link), so it
   has to read as body text inside the list rather than as the small muted footer link
   .link-button is elsewhere. */
#digestsList .link-button { font-size: 13px; margin-top: 0; text-align: left; color: var(--ink); }
#digestsList .link-button:hover { text-decoration: underline; }

/* SPEC-r01 ZS-MVP-30: transcript viewer (web/chat/transcript.js) and page renditions */
.transcript-viewer { display: flex; flex-direction: column; gap: 8px; }
.transcript-player { width: 100%; }
.transcript-meta { font-size: 12px; color: var(--muted); margin: 0; }
.transcript-search { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.transcript-search-input { flex: 1 1 200px; min-width: 0; }
.transcript-search-status { font-size: 12px; color: var(--muted); }
.transcript-segments { list-style: none; margin: 0; padding: 0; max-height: 50vh; overflow-y: auto; }
.transcript-segment { display: flex; gap: 8px; padding: 4px 6px; border-radius: 6px; line-height: 1.45; }
.transcript-time { flex: none; font-variant-numeric: tabular-nums; font-size: 12px; background: none; border: 0; color: var(--accent, #2563eb); cursor: pointer; padding: 0; }
.transcript-segment-active { background: rgba(37, 99, 235, 0.12); }
.transcript-match { outline: 2px solid rgba(234, 179, 8, 0.6); }
.transcript-low-confidence .transcript-text { color: var(--muted); font-style: italic; }
.rendition-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; margin-top: 8px; }
.rendition-page { margin: 0; }
.rendition-page img { width: 100%; height: auto; border: 1px solid var(--border, #e5e7eb); border-radius: 6px; }
.rendition-page figcaption { font-size: 11.5px; color: var(--muted); text-align: center; }
/* ZS-MVP-32: «Переслать» menu (PDF / Текст / В мой Telegram) under an answer. */
.forward-wrap { position: relative; display: inline-flex; }
/* ZS-EDN-005 §2: «Сообщить о проблеме» under an answer */
.report-problem-form { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; max-width: 520px; }
.report-problem-form[hidden] { display: none; }
.report-problem-note { width: 100%; box-sizing: border-box; font: inherit; padding: 6px 8px; border: 1px solid var(--line, #d8d8d8); border-radius: 8px; resize: vertical; }
.report-problem-send { align-self: flex-start; }
.report-problem-status.error { color: var(--red, #b3261e); font-size: 13px; }
.forward-menu { position: absolute; top: calc(100% + 4px); left: 0; z-index: 5; display: flex; flex-direction: column; gap: 4px; padding: 6px; background: var(--surface, #fff); border: 1px solid var(--border, #e5e7eb); border-radius: 8px; box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12); }
.forward-menu[hidden] { display: none; }
.forward-menu .btn-pill { white-space: nowrap; text-align: left; }

/* ZS-PATCH-008: "Оставаться в системе" on the login form and the "Мои сессии" dialog. */
.remember-field { display: flex; align-items: center; gap: 8px; margin-top: 16px; font-size: 13px; }
.remember-field input[type="checkbox"] { width: auto; flex-shrink: 0; }
.remember-hint { margin: 4px 0 0; }
.sessions-list { margin-top: 12px; max-height: 50vh; overflow: auto; }
.session-meta { width: 100%; color: var(--muted); font-size: 12px; }

/* ZS-PATCH-014 §2.3.3: the answer passport (and the assumptions block) is muted and smaller than the answer. */
.answer-passport { color: var(--muted); font-size: 0.85em; line-height: 1.6; }
.answer-passport p { margin: 0 0 8px; }
.answer-text .answer-passport { margin-top: 6px; }
.assumptions-block.answer-passport { color: var(--muted); }
.exact-toggle[aria-pressed="true"] { background: var(--soft); }

/* ZS-MEM-002 F3: memory notes under an answer («Запомнил …» · «Отменить», «Предлагаю запомнить …»). */
.memory-notes { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.memory-note { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 6px 10px; border: 1px solid var(--border, #e5e7eb); border-radius: 8px; background: var(--soft, #f5f7f2); font-size: 0.9em; }
.memory-note-text { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.memory-note[data-status="undone"], .memory-note[data-status="declined"] { color: var(--muted); }

/* ZS-MEM-005: «Ждут подтверждения», the badge on «Что Zorum помнит», the owner's profile form. */
.memory-inbox { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.memory-inbox-text { overflow-wrap: anywhere; }
.profile-owner-actions { margin-top: 8px; }
.profile-form { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.profile-form[hidden], .profile-timezone-other[hidden] { display: none; }
.profile-field { display: flex; flex-direction: column; gap: 4px; }
.profile-field textarea, .profile-field input, .profile-field select { width: 100%; }
.profile-field-error:empty, .profile-form-error:empty { display: none; }
/* ZS-PLB-003 §2.4: the «Режим аудитора» checkbox in one row with its caption */
.profile-field[data-field="auditor_mode"] { flex-direction: row; align-items: center; gap: 8px; }
.profile-field[data-field="auditor_mode"] input[type="checkbox"] { width: auto; }
.profile-auditor-hint { margin-top: -4px; }

/* ZS-UI-002: «Обсудить» -- the chip above the question (one line, ellipsis) and the card under the question. */
.pending-context-wrap[hidden] { display: none; }
.pending-context { max-width: 100%; min-width: 0; }
.pending-context-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pending-context .remove-context { flex-shrink: 0; }
.message.user { flex-wrap: wrap; }
.message-cards { flex-basis: 100%; min-width: 0; display: flex; flex-direction: column; align-items: flex-end; }
.message-cards .document-card { max-width: 85%; min-width: 0; }
.notification-context-card { cursor: pointer; }
.notification-context-card .document-name { min-width: 0; overflow-wrap: anywhere; }
@media (max-width: 640px) { .message-cards .document-card { max-width: 94%; } }

/* ZS-UI-003: «Документы» -- a screen in the main column (up to 1100 px, centred) instead of the 300 px
   side panel. One row per document: [icon] name / «источник · дата · размер · доклад» [chip] [Открыть]
   [Обсудить] [⋯] -- buttons of one height in every row, «Открыть»/«Обсудить» of one width. ≤ 900 px: a card
   (name in two lines, the chip, then the buttons across the width); ≤ 640 px: the «⋯» menu is a bottom sheet. */
.workspace.documents-open > .chat-column { display: none !important; }
.documents-screen { flex: 1; min-width: 0; min-height: 0; overflow-x: hidden; overflow-y: auto; }
.documents-screen[hidden] { display: none; }
.documents-inner { max-width: 1100px; margin: 0 auto; padding: 20px 24px 32px; min-width: 0; container: documents / inline-size; }
.documents-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin-bottom: 14px; }
.documents-title { flex: 1 1 auto; min-width: 0; margin: 0; font-size: 20px; line-height: 1.2; }
.documents-count { margin-left: 4px; font-size: 14px; font-weight: 500; color: var(--muted); }
.documents-head .documents-upload, .documents-head .documents-close { height: 36px; padding: 0 14px; font-size: 13px; white-space: nowrap; }
.documents-progress { flex-basis: 100%; font-size: 12px; color: var(--muted); }
.documents-progress[hidden] { display: none; }
/* one line on a desktop window (> 900 px), two lines on a phone; every control stays inside the panel for every
   source/sort pair: only the search gives way (down to 72 px); the selects are as wide as their chosen option and the
   segments never shrink, so the widest pair («Загружены в чате» + «Сначала новые») sets the budget of the narrow sizes below */
.documents-toolbar { display: flex; flex-wrap: nowrap; align-items: center; gap: 8px; margin-bottom: 12px; }
.documents-search { flex: 1 1 240px; min-width: 110px; height: 36px; padding: 0 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--white); font: inherit; font-size: 13px; }
/* a select as wide as its chosen option, not its longest one; a drawn arrow instead of the wide native one */
.documents-select {
  flex: 0 0.0001 auto; width: auto; min-width: 92px; height: 36px; padding: 0 24px 0 8px; border: 1px solid var(--line); border-radius: 8px;
  font: inherit; font-size: 13px; text-overflow: ellipsis; field-sizing: content; appearance: none; -webkit-appearance: none;
  --arrow-right: 8px;
  background-color: var(--white);
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: right calc(var(--arrow-right) + 4px) center, right var(--arrow-right) center;
  background-size: 4px 4px; background-repeat: no-repeat;
}
.doc-segments { display: inline-flex; flex: 0 0 auto; max-width: 100%; overflow-x: auto; padding: 2px; border: 1px solid var(--line); border-radius: 999px; background: var(--white); }
.doc-segment { height: 30px; padding: 0 10px; border-radius: 999px; font-size: 12.5px; color: var(--muted); white-space: nowrap; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.doc-segment[aria-pressed="true"] { background: var(--soft); color: var(--ink); font-weight: 600; }
.doc-segment-count { min-width: 18px; padding: 1px 6px; border-radius: 999px; background: var(--amber-soft); color: var(--amber); font-size: 11px; font-weight: 600; text-align: center; }

.documents-list { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--radius); background: var(--white); }
.documents-list:not(:has(.doc-row:not([hidden]))) { display: none; }
.doc-row {
  position: relative; display: grid; align-items: center; column-gap: 12px; min-height: 62px; padding: 10px 14px;
  grid-template-columns: 30px minmax(0, 1fr) auto 104px 104px 32px;
  grid-template-areas: "icon main chip open discuss more";
  cursor: pointer;
}
.doc-row:not([hidden]) ~ .doc-row:not([hidden]) { border-top: 1px solid var(--line); }
.doc-row:hover { background: var(--bg); }
.doc-row[hidden] { display: none; }
.doc-icon { grid-area: icon; width: 30px; height: 30px; display: grid; place-items: center; border-radius: 8px; background: var(--side); color: var(--muted); }
.doc-icon svg.icon { width: 18px; height: 18px; }
.doc-icon-pdf { background: var(--danger-soft); color: var(--danger); }
.doc-icon-sheet { background: var(--soft); color: var(--green); }
.doc-icon-text, .doc-icon-mail { background: #e8eef7; color: #3d5f8f; }
.doc-icon-image, .doc-icon-slides { background: var(--amber-soft); color: var(--amber); }
.doc-icon-audio { background: #efe9f6; color: #6a4f8f; }
@media (prefers-color-scheme: dark) {
  .doc-icon-text, .doc-icon-mail { background: #1d2633; color: #9db7dc; }
  .doc-icon-audio { background: #261f2e; color: #c3a8e0; }
}
.doc-main { grid-area: main; min-width: 0; }
.doc-name { display: block; font-weight: 600; font-size: 13.5px; line-height: 1.35; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-meta { display: flex; align-items: baseline; min-width: 0; margin-top: 2px; font-size: 12px; line-height: 1.4; color: var(--muted); white-space: nowrap; overflow: hidden; }
.doc-meta > * { flex: none; }
/* a long mail subject gives way first; the report link keeps at least a few words */
.doc-meta > .doc-meta-mail { flex: 0 3 auto; min-width: 4em; overflow: hidden; text-overflow: ellipsis; }
.doc-meta-sep { padding: 0 4px; }
.doc-report-link { font-size: 12px; text-align: left; color: var(--green); text-decoration: underline; text-underline-offset: 2px; }
.doc-meta > .doc-report-link { flex: 0 1 auto; min-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-expired { color: var(--danger); }
.doc-chip {
  grid-area: chip; justify-self: end; display: inline-flex; align-items: center; gap: 6px; height: 24px; max-width: 220px; padding: 0 10px;
  border-radius: 999px; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  background: var(--side); color: var(--muted);
}
.doc-chip::before { content: ""; flex-shrink: 0; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.doc-chip.tone-ok { background: var(--soft); color: var(--green); }
.doc-chip.tone-warn { background: var(--amber-soft); color: var(--amber); }
.doc-chip.tone-error { background: var(--danger-soft); color: var(--danger); }
.doc-chip.is-processing::before { animation: doc-chip-pulse 1.2s ease-in-out infinite; }
@keyframes doc-chip-pulse { 50% { opacity: .25; } }
@media (prefers-reduced-motion: reduce) { .doc-chip.is-processing::before { animation: none; } }
.doc-actions { display: contents; }
.doc-action {
  height: 32px; padding: 0 12px; display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line); border-radius: 8px; background: var(--white); font-size: 13px; white-space: nowrap; color: var(--ink);
}
.doc-action:hover { border-color: #95ad9a; }
.doc-open { grid-area: open; width: 104px; }
.doc-discuss { grid-area: discuss; width: 104px; }
.doc-more-wrap { grid-area: more; position: relative; }
.doc-more { width: 32px; padding: 0; font-size: 16px; }
.doc-menu {
  position: absolute; right: 0; top: calc(100% + 4px); z-index: 12; min-width: 230px; padding: 6px;
  display: flex; flex-direction: column; background: var(--white); border: 1px solid var(--line);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-pop); cursor: default;
}
.doc-menu[hidden] { display: none; }
.doc-menu.doc-menu-up { top: auto; bottom: calc(100% + 4px); }
.doc-menu-item { display: block; padding: 9px 12px; border-radius: 8px; text-align: left; font-size: 13px; color: var(--ink); text-decoration: none; white-space: nowrap; }
.doc-menu-item:hover { background: var(--soft); }
.doc-menu-item[hidden] { display: none; }
.doc-menu-danger { color: var(--danger); }
.doc-menu-sep { height: 1px; margin: 4px 0; background: var(--line); }
.documents-empty { padding: 32px 16px; text-align: center; color: var(--muted); font-size: 13.5px; }
.documents-empty[hidden] { display: none; }
.documents-empty-text { max-width: 520px; margin: 0 auto 12px; }

/* a narrower desktop column (1000 px window with the sidebar): still the row, only tighter -- the
   buttons keep their 32 px and their common width; the card is for a phone/tablet window (≤ 900 px) */
@container documents (max-width: 900px) {
  .doc-row { column-gap: 10px; padding: 10px 12px; }
  .doc-chip { max-width: 170px; }
  .documents-toolbar { gap: 4px; }
  .doc-segment { padding: 0 4px; font-size: 11.5px; gap: 3px; }
  .doc-segment-count { min-width: 16px; padding: 1px 4px; }
  .documents-search { flex-basis: 160px; min-width: 72px; padding: 0 8px; font-size: 12px; }
  .documents-select { padding: 0 18px 0 6px; font-size: 11.5px; --arrow-right: 5px; }
}
@media (max-width: 900px) {
  .documents-toolbar { flex-wrap: wrap; }
  .doc-row {
    grid-template-columns: 30px minmax(0, 1fr); grid-template-areas: "icon main" "chip chip" "actions actions";
    row-gap: 8px; align-items: start;
  }
  .doc-name { white-space: normal; overflow-wrap: anywhere; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; }
  .doc-meta { display: block; white-space: normal; overflow-wrap: anywhere; }
  .doc-meta-sep { padding: 0; }
  .doc-meta > .doc-report-link { white-space: normal; overflow: visible; min-width: 0; }
  .doc-chip { justify-self: start; max-width: 100%; }
  .doc-actions { grid-area: actions; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 40px; gap: 8px; }
  .doc-open, .doc-discuss, .doc-more-wrap { grid-area: auto; width: auto; }
  .doc-action { width: 100%; height: 40px; }
}
@media (max-width: 640px) {
  .documents-inner { padding: 14px 12px 24px; }
  .documents-title { font-size: 18px; }
  /* line 1: search + source + sort; line 2: the status segments across the width */
  .documents-toolbar { flex-wrap: wrap; gap: 8px 4px; }
  .documents-search { flex: 1 1 0; min-width: 72px; padding: 0 8px; font-size: 16px; }
  .documents-select { padding: 0 18px 0 6px; font-size: 12px; --arrow-right: 5px; }
  .doc-segments { order: 1; flex: 1 1 100%; }
  .doc-segment { flex: 1 1 auto; padding: 0 6px; font-size: 12px; gap: 4px; }
  .doc-row { padding: 12px; }
  .doc-menu, .doc-menu.doc-menu-up {
    position: fixed; left: 0; right: 0; bottom: 0; top: auto; z-index: 30; min-width: 0; width: 100%;
    border-radius: 14px 14px 0 0; padding: 10px 10px max(14px, env(safe-area-inset-bottom));
  }
  .doc-menu-item { padding: 14px 12px; font-size: 15px; }
}

/* ZS-UI-003 §2.5: «Доступ к документу» -- «Кто видит» as radio buttons, the raw values folded. */
.document-settings-name { margin: -4px 0 12px; color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.access-choice { margin: 0; padding: 0; border: 0; display: flex; flex-direction: column; gap: 6px; }
.access-option { display: flex; align-items: center; gap: 8px; font-size: 13.5px; font-weight: normal; }
.access-option input { width: auto; margin: 0; }
.access-advanced { margin-top: 8px; font-size: 13px; }
.access-advanced summary { cursor: pointer; color: var(--muted); }
.access-field { margin-top: 8px; display: flex; flex-direction: column; gap: 4px; }
.access-field[hidden] { display: none; }

/* ZS-UI-004 §2.1-2.2: chart cards in the answer (web/chat/chart.js). Series colors: a fixed categorical
   order, each slot stepped separately for the dark surface (the light aqua/yellow/magenta slots sit below
   3:1 -- the «Таблица» view is the text alternative). Text stays in --ink/--muted, never a series color. */
:root {
  --chart-1: #2a78d6; --chart-2: #eb6834; --chart-3: #1baf7a; --chart-4: #eda100;
  --chart-5: #e87ba4; --chart-6: #008300; --chart-7: #6250d6; --chart-8: #e34948;
}
@media (prefers-color-scheme: dark) {
  :root {
    --chart-1: #3987e5; --chart-2: #d95926; --chart-3: #199e70; --chart-4: #c98500;
    --chart-5: #d55181; --chart-6: #008300; --chart-7: #9085e9; --chart-8: #e66767;
  }
}
.chart-cards { display: flex; flex-direction: column; gap: 12px; margin: 12px 0; min-width: 0; }
.chart-card {
  min-width: 0; max-width: 100%; background: var(--white); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 10px 12px 10px; line-height: 1.45;
}
.chart-card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.chart-card-title { font-weight: 600; font-size: 13px; color: var(--ink); min-width: 0; overflow-wrap: anywhere; }
.chart-card-meta { display: inline-flex; align-items: baseline; gap: 6px; flex-shrink: 0; font-size: 11.5px; color: var(--muted); }
.chart-card-body { position: relative; min-width: 0; }
.chart-card-status { margin: 0; padding: 18px 0; color: var(--muted); font-size: 12.5px; }
.chart-card-body .chart-retry { margin-left: 0; }
.chart-card-image { display: block; width: 100%; height: auto; border-radius: 6px; }
.chart-card-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chart-card-actions .btn-pill { font-size: 11px; color: var(--muted); }
.chart-card-actions .btn-pill[aria-pressed="true"] { border-color: var(--green); color: var(--green); }
.chart-card-table { margin-top: 8px; max-width: 100%; overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.chart-card-table th, .chart-card-table td { padding: 6px 10px; font-size: 12px; }
.chart-card-table td:not(:first-child) { text-align: right; font-variant-numeric: tabular-nums; }
.chart-more { margin: 0; font-size: 12px; color: var(--muted); }
/* ZS-FIX-040 §2.3.4: under a chart of an answer whose text has unbound numbers (both themes via --muted). */
.chart-unbound-note { margin: -6px 0 0; font-size: 11.5px; line-height: 1.4; color: var(--muted); }

.zchart { position: relative; min-width: 0; }
.zchart-legend { display: flex; flex-wrap: wrap; gap: 4px 6px; margin-bottom: 6px; }
.zchart-legend-item {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px; font-size: 11.5px;
  border: 1px solid var(--line); background: var(--white); color: var(--ink); max-width: 100%;
}
.zchart-legend-item > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.zchart-legend-item[aria-pressed="false"] { color: var(--muted); }
.zchart-legend-item[aria-pressed="false"] .zchart-swatch { background: transparent; }
.zchart-legend-item[aria-disabled="true"] { cursor: default; }
.zchart-swatch { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; border: 2px solid currentColor; }
.zchart-stage { position: relative; min-width: 0; }
.zchart-svg { display: block; width: 100%; height: auto; overflow: visible; }
.zchart-svg:focus { outline: none; }
.zchart-svg:focus-visible { outline: 3px solid #85b69b; outline-offset: 2px; border-radius: 4px; }
.zchart-svg text { font: 11px var(--font); fill: var(--muted); }
.zc-grid line { stroke: var(--line); stroke-width: 1; }
.zc-zero { stroke: var(--muted); stroke-width: 1; opacity: .6; }
.zc-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.zc-dot { stroke: var(--white); stroke-width: 1.5; }
.zc-guide { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; }
.zc-band { fill: var(--ink); opacity: .06; }
.zchart-tip {
  position: absolute; z-index: 2; pointer-events: none; max-width: calc(100% - 4px); padding: 6px 9px;
  background: var(--white); color: var(--ink); border: 1px solid var(--line); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-pop); font-size: 12px; line-height: 1.45; overflow-wrap: anywhere;
}
.zchart-tip strong { display: block; font-weight: 600; margin-bottom: 2px; }
.zchart-tip-row { white-space: normal; }
.zchart-dot { margin-right: 5px; }
.zchart-note { margin: 6px 0 0; font-size: 11.5px; color: var(--muted); }
.zc-s1 { --zc: var(--chart-1); } .zc-s2 { --zc: var(--chart-2); } .zc-s3 { --zc: var(--chart-3); } .zc-s4 { --zc: var(--chart-4); }
.zc-s5 { --zc: var(--chart-5); } .zc-s6 { --zc: var(--chart-6); } .zc-s7 { --zc: var(--chart-7); } .zc-s8 { --zc: var(--chart-8); }
.zc-bar, .zc-dot { fill: var(--zc); }
.zc-line { stroke: var(--zc); }
.zchart-swatch, .zchart-dot { color: var(--zc); }
.zchart-legend-item[aria-pressed="true"] .zchart-swatch { background: var(--zc); }

/* ZS-ANL-006 §2.3: an offered chart (a pill with a small bar icon under the answer), the view switch on the
   card and the ring of shares with its legend «label — value — share». «Прочие» gets the neutral color. */
.chart-offer { min-width: 0; }
.chart-offer-button { display: inline-flex; align-items: center; gap: 7px; color: var(--ink); }
.chart-offer-icon {
  width: 13px; height: 11px; flex-shrink: 0;
  background: linear-gradient(var(--green), var(--green)) 0 100% / 3px 55% no-repeat,
    linear-gradient(var(--green), var(--green)) 5px 100% / 3px 100% no-repeat,
    linear-gradient(var(--green), var(--green)) 10px 100% / 3px 75% no-repeat;
}
.chart-kinds { display: inline-flex; flex-wrap: wrap; gap: 6px; margin-right: 6px; }
.zc-others { --zc: var(--muted); }
.zc-sector { fill: var(--zc); stroke: var(--white); stroke-width: 1.5; }
.zc-sector.zc-active { stroke: var(--ink); stroke-width: 2; }
.zchart-donut-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 8px; font-size: 12px; color: var(--ink); }
.zchart-donut-item { display: inline-flex; align-items: center; gap: 6px; min-width: 0; max-width: 100%; }
.zchart-donut-item .zchart-swatch { background: var(--zc); }
.zchart-donut-name { overflow-wrap: anywhere; }
.zchart-donut-value { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ZS-UI-005 §2.3: the run feed -- a running step in the text colour, a finished one muted with a green «✓», a
   failed one in the danger colour, «Обдумываю результат…» muted and italic (theme tokens: light and dark). */
.run-events .run-event-line { color: var(--ink); }
.run-events .run-event-done { color: var(--muted); }
.run-events .run-event-done::first-letter { color: var(--green); }
.run-events .run-event-failed { color: var(--danger); }
.run-events .run-event-thinking { color: var(--muted); font-style: italic; }
.run-state.error .run-events .run-event-line { color: var(--danger); }
/* ZS-UI-006: one Zorum answer at a time (ZORUM_CHAT_SINGLE_TURN) -- a disabled «Отправить», the hint under the
   composer while the run is in another dialog, and the quiet «отвечает…» mark of that dialog in the list. */
.send-button:disabled, .send-button:disabled:hover { background: var(--line); color: var(--muted); cursor: not-allowed; }
.run-state.run-elsewhere { display: none; }
.turn-wait { max-width: 760px; margin: 8px auto 0; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; font-size: 12.5px; color: var(--muted); }
.turn-wait[hidden] { display: none; }
.turn-wait-text { flex: 1 1 240px; min-width: 0; }
.turn-wait-button { color: var(--ink); font-size: 12px; padding: 4px 10px; border: 1px solid var(--line); border-radius: 6px; flex-shrink: 0; }
.turn-wait-button:hover { border-color: #95ad9a; }
.turn-wait-button:disabled { color: var(--muted); cursor: default; }
.nav-item .nav-answering { flex-shrink: 0; margin-left: auto; font-size: 11.5px; font-weight: 400; color: var(--muted); }

/* ZS-UI-007: file uploads and drop targets. */
.chat-column, .documents-screen { position: relative; }
.file-drop-active { outline: 3px solid var(--accent, #6366f1); outline-offset: -4px; }
.file-drop-hint { position: absolute; inset: 12px 12px auto; z-index: 20; padding: 20px; border-radius: 12px; background: var(--surface, #fff); color: var(--text, #222); box-shadow: 0 4px 24px #0002; text-align: center; pointer-events: none; }
.file-drop-hint[hidden] { display: none; }
.pending-attachment-label { overflow-wrap: anywhere; min-width: 0; }
.pending-loading { opacity: .8; }
.pending-error { border: 1px solid #ba3434; }
.retry-attachment { border: 0; background: transparent; color: inherit; cursor: pointer; text-decoration: underline; }
.upload-wait { padding: 6px 0; color: var(--text-muted, #666); font-size: 13px; }
