/* ==============================================================================
   «SmartTrainee» Enterprise Cabinet Design System — Complete Trainee-2 Standard
   Light (Default) & Dark Mode, Precision B2B Corporate Aesthetics, High Legibility
   ============================================================================== */

/* ==============================================================================
   ПАЛИТРЫ КАБИНЕТА (ADR 0028, SPEC 1.189): палитры пронумерованы.
   Палитра 2 (с 2026-11-06, по умолчанию): тёплые нейтрали, один спокойный сине-серый акцент, сообщения Наставника в
   светлой тонировке. Палитра 1 (прежняя, насыщенный синий) включается адресом ?palette=1, возврат — ?palette=2.
   ============================================================================== */

/* --- ПАЛИТРА 2, светлая тема (по умолчанию) --- */
:root, [data-theme="light"] {
  --bg-main: #fbfaf8;
  --bg-sidebar: #f2efe9;
  --bg-card: #ffffff;
  --bg-hover: #e9e5de;
  --border: #dcd7cd;
  --border-light: #c9c3b6;
  --text-primary: #25241f;
  --text-secondary: #4d4943;
  --text-muted: #6c675d;
  --accent: #3a5496;
  --accent-hover: #2b4380;
  --accent-glow: rgba(58, 84, 150, 0.14);
  --green: #3f7d5d;
  --green-glow: rgba(63, 125, 93, 0.13);
  --red: #b84c3a;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --bubble-user: #e2e7f4;
  --bubble-user-text: #25241f;
  --bubble-user-border: #d3daee;
  --bubble-asst: #ffffff;
  --bubble-asst-text: #25241f;
  --bubble-asst-border: #dcd7cd;
  --composer-bg: #ffffff;
  --composer-border: #c9c3b6;
  --topbar-bg: #fbfaf8;
  --popover-bg: #ffffff;
  --modal-bg: #ffffff;
  --shadow-sm: 0 1px 2px rgba(60, 50, 30, 0.05);
  --shadow-md: 0 4px 14px rgba(60, 50, 30, 0.07);
  --shadow-lg: 0 10px 28px rgba(60, 50, 30, 0.10);
  --sidebar-footer-bg: #ebe7df;
  --accent-gradient: linear-gradient(135deg, #4a66ab, #3a5496);
  --brand-from: #2b4380;
  --brand-to: #1b2a52;
  --brand-dot: #6fe0b0;
  --brand-glow: rgba(43, 67, 128, 0.25);
  --avatar-user: #6c675d;
  --mode-active-bg: #ffffff;
  --mode-active-text: #25241f;
  --amber: #b8862a;
}

/* --- ПАЛИТРА 2, тёмная тема --- */
[data-theme="dark"] {
  --bg-main: #1a1917;
  --bg-sidebar: #211f1d;
  --bg-card: #2a2724;
  --bg-hover: #2f2c28;
  --border: rgba(255, 240, 220, 0.08);
  --border-light: rgba(255, 240, 220, 0.15);
  --text-primary: #ece9e3;
  --text-secondary: #aaa59a;
  --text-muted: #8d887c;
  --accent: #7c93d1;
  --accent-hover: #6a82c4;
  --accent-glow: rgba(124, 147, 209, 0.25);
  --green: #5fa07f;
  --green-glow: rgba(95, 160, 127, 0.2);
  --red: #d77565;
  --bubble-user: #2c3550;
  --bubble-user-text: #ece9e3;
  --bubble-user-border: rgba(255, 240, 220, 0.08);
  --bubble-asst: #262320;
  --bubble-asst-text: #ece9e3;
  --bubble-asst-border: rgba(255, 240, 220, 0.08);
  --composer-bg: #211f1d;
  --composer-border: rgba(255, 240, 220, 0.12);
  --topbar-bg: #211f1d;
  --popover-bg: #2a2724;
  --modal-bg: #2a2724;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.32);
  --shadow-lg: 0 10px 28px rgba(0, 0, 0, 0.42);
  --sidebar-footer-bg: #1a1917;
  --accent-gradient: linear-gradient(135deg, #8da2dd, #7c93d1);
  --brand-from: #3b56a3;
  --brand-to: #2b4380;
  --brand-dot: #6fe0b0;
  --brand-glow: rgba(59, 86, 163, 0.35);
  --avatar-user: #5a564e;
  --mode-active-bg: #3a3631;
  --mode-active-text: #ece9e3;
  --amber: #d4a64a;
}

/* --- ПАЛИТРА 1 (прежняя), светлая тема: включается адресом ?palette=1 --- */
html[data-palette="1"] {
  --bg-main: #f8fafc;
  --bg-sidebar: #ffffff;
  --bg-card: #ffffff;
  --bg-hover: #f1f5f9;
  --border: #e2e8f0;
  --border-light: #cbd5e1;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-glow: rgba(37, 99, 235, 0.12);
  --green: #10b981;
  --green-glow: rgba(16, 185, 129, 0.12);
  --red: #ef4444;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --bubble-user: #2563eb;
  --bubble-user-text: #ffffff;
  --bubble-asst: #ffffff;
  --bubble-asst-text: #0f172a;
  --bubble-asst-border: #e2e8f0;
  --composer-bg: #ffffff;
  --composer-border: #cbd5e1;
  --topbar-bg: #ffffff;
  --popover-bg: #ffffff;
  --modal-bg: #ffffff;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 14px rgba(0,0,0,0.08);
  --shadow-lg: 0 10px 28px rgba(0,0,0,0.12);
  --sidebar-footer-bg: #f8fafc;
  --bubble-user-border: transparent;
  --accent-gradient: linear-gradient(135deg, #2563eb, #4f46e5);
  --brand-from: #2b4380;
  --brand-to: #1b2a52;
  --brand-dot: #6fe0b0;
  --brand-glow: rgba(43, 67, 128, 0.25);
  --avatar-user: #334155;
  --mode-active-bg: #2563eb;
  --mode-active-text: #ffffff;
  --amber: #f59e0b;
}

/* --- ПАЛИТРА 1, тёмная тема --- */
html[data-palette="1"][data-theme="dark"] {
  --bg-main: #0b0f19;
  --bg-sidebar: #111827;
  --bg-card: #1f2937;
  --bg-hover: #1e293b;
  --border: rgba(255, 255, 255, 0.08);
  --border-light: rgba(255, 255, 255, 0.15);
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --accent-glow: rgba(59, 130, 246, 0.25);
  --green: #10b981;
  --green-glow: rgba(16, 185, 129, 0.2);
  --red: #ef4444;
  --bubble-user: #3b82f6;
  --bubble-user-text: #ffffff;
  --bubble-asst: #1e293b;
  --bubble-asst-text: #f8fafc;
  --bubble-asst-border: rgba(255, 255, 255, 0.08);
  --composer-bg: #111827;
  --composer-border: rgba(255, 255, 255, 0.12);
  --topbar-bg: #111827;
  --popover-bg: #1f2937;
  --modal-bg: #1e293b;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.2);
  --shadow-md: 0 4px 14px rgba(0,0,0,0.3);
  --shadow-lg: 0 10px 28px rgba(0,0,0,0.4);
  --sidebar-footer-bg: #0b0f19;
  --bubble-user-border: transparent;
  --accent-gradient: linear-gradient(135deg, #3b82f6, #4f46e5);
  --brand-from: #3b56a3;
  --brand-to: #2b4380;
  --brand-dot: #6fe0b0;
  --brand-glow: rgba(59, 86, 163, 0.35);
  --avatar-user: #334155;
  --mode-active-bg: #3b82f6;
  --mode-active-text: #ffffff;
  --amber: #f59e0b;
}

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

/* The same height of the header of the side panel and of the top bar of the chat, so their lines meet. */
:root { --topbar-height: 64px; }
body {
  font-family: var(--font);
  background: var(--bg-main);
  color: var(--text-primary);
  height: 100vh;
  height: 100dvh;
  display: flex;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.2s ease, color 0.2s ease;
}

/* Сетка интерфейса */
.layout { display: flex; width: 100%; height: 100vh; height: 100dvh; }

/* --- БОКОВАЯ ПАНЕЛЬ --- */
.sidebar {
  width: 290px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: transform 0.25s ease, background 0.2s ease;
  z-index: 50;
}

.sidebar-scrim {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 40;
  border: 0;
  background: rgba(15, 23, 42, 0.38);
}

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

.brand {
  background: none;
  border: 0;
  padding: 0;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 16px;
  color: var(--text-primary);
  letter-spacing: -0.3px;
}

.brand-icon {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* the colours of the mark (the dark indigo of the website, ADR 0096) come from the tokens of the palette */
.logo-from { stop-color: var(--brand-from); }
.logo-to { stop-color: var(--brand-to); }
.logo-dot { fill: var(--brand-dot); }

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--green);
  background: var(--green-glow);
  padding: 4px 8px;
  border-radius: 20px;
  font-weight: 500;
}

.status-dot {
  width: 7px;
  height: 7px;
  background: var(--green);
  border-radius: 50%;
}

.sidebar-actions {
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}


.sidebar-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.section-container {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.section-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 6px;
}

.section-label {
  font-size: 11px;
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.matters-search-box {
  position: relative;
  display: flex;
  align-items: center;
  margin: 4px 0 6px 0;
}

.matters-search-box .search-icon {
  position: absolute;
  left: 9px;
  color: var(--text-muted);
  pointer-events: none;
}

.matters-search-input {
  width: 100%;
  height: 30px;
  padding: 0 26px 0 28px;
  font-size: 12px;
  font-family: inherit;
  color: var(--text-primary);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  outline: none;
  transition: all 0.15s ease;
  box-sizing: border-box;
}

.matters-search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-glow);
}

.matters-search-input::placeholder {
  color: var(--text-muted);
}

.matters-search-clear {
  position: absolute;
  right: 5px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
}

.matters-search-clear:hover {
  color: var(--text-primary);
}

/* Список дел */
.matter-list { display: flex; flex-direction: column; gap: 4px; }

.matter-item {
  padding: 9px 12px;
  border-radius: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.matter-item:hover { border-color: var(--accent); background: var(--bg-hover); }
.matter-item.active { border-color: var(--accent); background: var(--bg-hover); box-shadow: 0 0 0 1px var(--accent); }

.matter-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.matter-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.matter-badge {
  font-size: 10px;
  font-weight: 600;
  color: var(--green);
  background: var(--green-glow);
  padding: 2px 6px;
  border-radius: 4px;
  white-space: nowrap;
}

.matter-sub {
  font-size: 11.5px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-header-info {
  display: flex;
  align-items: baseline;
  gap: 10px;
  overflow: hidden;
  min-width: 0;
}

.btn-icon {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 3px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}
.btn-icon:hover { color: var(--text-primary); background: var(--bg-hover); }
.btn-icon.btn-del-chat:hover { color: var(--red); background: rgba(239, 68, 68, 0.08); }
.btn-icon.btn-rename-chat:hover { color: var(--accent); background: var(--accent-glow); }

.btn-rename-topbar {
  background: none;
  border: 1px solid transparent;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}
.btn-rename-topbar:hover {
  color: var(--accent);
  background: var(--bg-hover);
  border-color: var(--border);
}

.chat-title-current {
  cursor: pointer;
  border-radius: 6px;
  padding: 2px 6px;
  margin-left: -6px;
  transition: background 0.15s ease;
}
.chat-title-current:hover {
  background: var(--bg-hover);
}

/* --- ПОДВАЛ БОКОВОЙ ПАНЕЛИ (ЛЕВЫЙ НИЖНИЙ УГОЛ) --- */
.sidebar-footer {
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  background: var(--sidebar-footer-bg);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.footer-actions-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.footer-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
}
.footer-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-light);
}

.footer-btn.danger {
  color: var(--text-muted);
}
.footer-btn.danger:hover {
  color: var(--red);
  background: rgba(239, 68, 68, 0.08);
  border-color: rgba(239, 68, 68, 0.2);
}

.footer-btn-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
}
.footer-btn-icon:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-light);
}

/* --- ОСНОВНАЯ ОБЛАСТЬ ЧАТА --- */
.chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  position: relative;
  background: var(--bg-main);
}

.chat-topbar {
  height: var(--topbar-height);
  padding: 0 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--topbar-bg);
  z-index: 10;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.btn-menu-mobile {
  display: none;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
}

.chat-title-current {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.2px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.language-dropdown-wrapper {
  position: relative;
  display: inline-flex;
}

.btn-globe {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}
.btn-globe:hover,
.btn-globe.active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--bg-hover);
}

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

.language-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 8px 12px;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  border-radius: 6px;
  cursor: pointer;
  text-align: left;
  transition: background 0.12s ease;
}

.language-option:hover {
  background: var(--bg-hover);
  color: var(--accent);
}

.language-option.active {
  background: var(--accent-glow);
  color: var(--accent);
  font-weight: 600;
}

/* Лента сообщений */
.messages-container {
  flex: 1;
  overflow-y: auto;
  scrollbar-gutter: stable;
  padding: 24px;
  display: flex;
  flex-direction: column;
}

.messages-feed {
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-width: 820px;
  margin: 0 auto;
  width: 100%;
}

.message-row { display: flex; gap: 12px; width: 100%; }
.message-row.user { justify-content: flex-end; }
.message-row.assistant { justify-content: flex-start; }

.message-avatar {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.message-avatar.assistant {
  background: linear-gradient(135deg, var(--brand-from), var(--brand-to));
  box-shadow: var(--shadow-sm);
}

.message-avatar.user {
  background: var(--avatar-user);
  box-shadow: var(--shadow-sm);
}

.avatar-monogram {
  color: #fff;
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.5px;
}

.message-content-wrapper { max-width: 85%; display: flex; flex-direction: column; gap: 8px; }
.message-content-wrapper.has-billing { max-width: 96%; }

.message-bubble {
  padding: 14px 18px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.6;
  word-break: break-word;
  box-shadow: var(--shadow-sm);
}

.message-row.user .message-bubble {
  background: var(--bubble-user);
  color: var(--bubble-user-text);
  border: 1px solid var(--bubble-user-border);
  border-bottom-right-radius: 4px;
}

.message-row.assistant .message-bubble {
  background: var(--bubble-asst);
  color: var(--bubble-asst-text);
  border: 1px solid var(--bubble-asst-border);
  border-bottom-left-radius: 4px;
}

/* Форматирование внутри реплик */
.message-bubble strong { font-weight: 600; color: inherit; }
.message-bubble h1, .message-bubble h2, .message-bubble h3, .message-bubble h4 {
  margin: 12px 0 6px 0;
  font-weight: 700;
  color: inherit;
  line-height: 1.35;
}
.message-bubble h1 { font-size: 17px; }
.message-bubble h2 { font-size: 15px; }
.message-bubble h3 { font-size: 14px; }
.message-bubble hr {
  border: none;
  border-top: 2px solid var(--text-primary);
  margin: 12px 0;
}
.message-bubble p { margin: 6px 0; font-size: 14px; line-height: 1.55; }
.message-bubble ul, .message-bubble ol { margin: 6px 0 6px 20px; padding: 0; }
.message-bubble li { margin-bottom: 4px; font-size: 14px; line-height: 1.55; }
.message-bubble li.billing-op-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
  white-space: nowrap;
  margin-bottom: 4px;
  max-width: 100%;
  list-style: none;
}
.message-bubble li.billing-op-row::before {
  content: "•";
  color: var(--text-muted);
  margin-right: 2px;
  margin-left: -14px;
  flex-shrink: 0;
  font-size: 14px;
  line-height: 1;
}
.billing-op-time {
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
}
.billing-op-sep {
  flex-shrink: 0;
  color: var(--text-muted);
}
.billing-op-desc {
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.billing-op-amount {
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.message-bubble code {
  background: rgba(0,0,0,0.06);
  padding: 2px 5px;
  border-radius: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 13px;
}
[data-theme="dark"] .message-bubble code {
  background: rgba(255,255,255,0.1);
}
.message-bubble .reply-block {
  white-space: pre-wrap;
  background: var(--bg-hover);
  border-radius: 6px;
  padding: 8px 12px;
  margin: 8px 0;
  font-size: 13.5px;
  line-height: 1.5;
}
.message-bubble blockquote {
  border-left: 3px solid var(--accent);
  margin: 8px 0;
  padding-left: 10px;
  color: var(--text-secondary);
  font-style: italic;
}
.message-bubble table {
  border-collapse: collapse;
  width: 100%;
  margin: 10px 0;
  font-size: 12.5px;
}
.message-bubble th, .message-bubble td {
  border: 1px solid var(--border);
  padding: 6px 10px;
  text-align: left;
}
.message-bubble th {
  background: var(--bg-hover);
  font-weight: 600;
}
/* The documents the trainee made in a message, under its reply (ADR 0089). */
.reply-documents { display: flex; flex-direction: column; gap: 6px; margin: 10px 0 2px; }
.reply-document { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 8px 12px; background: var(--bg-hover); border: 1px solid var(--border); border-radius: 10px; font-size: 13.5px; }
.reply-document-name { flex: 1 1 180px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reply-document-button { background: var(--accent); color: #fff; border: 0; border-radius: 6px; padding: 5px 12px; font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer; text-decoration: none; }
.reply-document-button:hover { filter: brightness(0.92); }
/* The next requests under the last reply (ADR 0087). */
.next-requests { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 2px; }
.next-request {
  background: var(--bg-main);
  border: 1px solid var(--border);
  border-radius: 14px;
  color: var(--accent);
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  line-height: 1.35;
  padding: 6px 12px;
  text-align: left;
}
.next-request:hover { background: var(--bg-hover); border-color: var(--accent); }
.message-bubble .table-scroll { overflow-x: auto; margin: 10px 0; }
.message-bubble .table-scroll table { margin: 0; width: auto; min-width: 100%; }
.message-bubble td.align-right, .message-bubble th.align-right { text-align: right; white-space: nowrap; }
.message-bubble td.align-center, .message-bubble th.align-center { text-align: center; }



/* Экран приветствия */
/* The mark, the title and the cards stand at the same height on the screens of the Trainee and of the Advisor:
   the block starts at a fixed distance from the top (it is not centred by its own height), and the description
   keeps the room of three lines. */
.welcome-view {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  margin: clamp(24px, 9vh, 88px) auto auto;
  max-width: 680px;
  text-align: center;
  padding: 20px;
}

.welcome-avatar {
  width: 56px;
  height: 56px;
  background: linear-gradient(135deg, var(--brand-from), var(--brand-to));
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
  box-shadow: 0 4px 20px var(--brand-glow);
}

.welcome-title { font-size: 22px; font-weight: 700; color: var(--text-primary); margin-bottom: 10px; }
.welcome-desc { font-size: 14px; color: var(--text-secondary); line-height: 1.5; margin-bottom: 28px; min-height: 4.5em; }

.suggestions-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  width: 100%;
}

.suggestion-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: var(--shadow-sm);
}
.suggestion-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.suggestion-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.suggestion-card-tag {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-glow);
  padding: 2px 6px;
  border-radius: 4px;
}

.suggestion-card-prompt {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
}

/* Индикатор набора */
.typing-indicator {
  display: none;
  align-items: center;
  gap: 4px;
  padding: 8px 14px;
  background: var(--bg-card);
  border-radius: 12px;
  border: 1px solid var(--border);
  width: fit-content;
  margin-top: 8px;
  box-shadow: var(--shadow-sm);
}

.typing-dot {
  width: 6px;
  height: 6px;
  background: var(--text-muted);
  border-radius: 50%;
  animation: typingBounce 1.4s infinite ease-in-out both;
}
.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }
@keyframes typingBounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}

.typing-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-left: 6px;
}

/* Поле ввода (Composer) */
.composer-area {
  padding: 16px 24px 24px 24px;
  background: transparent;
}

.composer-box {
  max-width: 820px;
  margin: 0 auto;
  background: var(--composer-bg);
  border: 1px solid var(--composer-border);
  border-radius: 14px;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: var(--shadow-md);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.composer-box:focus-within {
  border-color: var(--accent);
  box-shadow: 0 4px 18px var(--accent-glow);
}

.composer-input {
  width: 100%;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 14px;
  line-height: 1.5;
  resize: none;
  outline: none;
  max-height: 160px;
}
.composer-input::placeholder { color: var(--text-muted); }

.composer-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.composer-meta {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-attach {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 34px;
  height: 34px;
  padding: 0;
  background: var(--bg-card);
  color: var(--text-secondary);
  font: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}
.btn-attach:hover { border-color: var(--accent); color: var(--accent); background: var(--bg-hover); }
.btn-attach:disabled { opacity: 0.55; cursor: wait; }
.btn-photo[hidden] { display: none; }
.btn-voice:disabled { cursor: not-allowed; }
.btn-voice.recording { color: var(--red); border-color: var(--red); }
.voice-bar { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--border); color: var(--text-secondary); font-size: 13px; }
.voice-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--red); animation: voice-pulse 1.2s ease-in-out infinite; }
.voice-time { flex: 1; font-variant-numeric: tabular-nums; }
.voice-action { background: none; border: 1px solid var(--border); border-radius: 8px; padding: 4px 10px; color: var(--text-secondary); cursor: pointer; font: inherit; }
.voice-action:hover { border-color: var(--accent); color: var(--accent); }
.voice-action.send { background: var(--accent); border-color: var(--accent); color: #fff; }
@keyframes voice-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }
@media (prefers-reduced-motion: reduce) { .voice-dot { animation: none; } }

.upload-status {
  max-width: 470px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11px;
  color: var(--text-muted);
}
.upload-status.pending { color: var(--accent); }
.upload-status.success { color: #15803d; }
.upload-status.error { color: #b91c1c; }

.btn-send {
  background: var(--accent);
  border: none;
  border-radius: 8px;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  cursor: pointer;
  transition: all 0.15s ease;
}
.btn-send:hover { background: var(--accent-hover); transform: scale(1.05); }
.btn-send:disabled {
  background: var(--border-light);
  color: var(--text-muted);
  cursor: not-allowed;
  transform: none;
}

/* --- МОДАЛЬНЫЕ ОКНА --- */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  animation: fadeIn 0.15s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-card {
  background: var(--modal-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  width: 90%;
  max-width: 520px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

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

.modal-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-close {
  background: none;
  border: none;
  font-size: 22px;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
}
.modal-close:hover { color: var(--text-primary); }

/* The pages of the settings (ADR 0028): general, the Trainee, the Advisor. */
.settings-tabs { display: flex; gap: 6px; padding: 10px 20px 0; border-bottom: 1px solid var(--border); }
.settings-tab {
  border: 0;
  background: transparent;
  color: var(--text-secondary);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 14px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.settings-tab:hover { color: var(--text-primary); }
.settings-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.settings-page { display: flex; flex-direction: column; gap: 18px; }
.settings-page[hidden] { display: none; }

.modal-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  max-height: 70vh;
  overflow-y: auto;
}

.setting-section { display: flex; flex-direction: column; gap: 8px; }
.setting-title { font-size: 13px; font-weight: 600; color: var(--text-primary); }

.profile-card {
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12.5px;
}
.profile-field { display: flex; justify-content: space-between; }
.profile-label { color: var(--text-muted); }
.profile-value { font-weight: 600; color: var(--text-primary); }

.mailbox-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  gap: 8px;
  flex-wrap: wrap;
}
.mailbox-editor {
  min-width: 210px;
  flex: 1 1 320px;
  display: flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-card);
  overflow: hidden;
}
.mailbox-local-input {
  width: 100%; min-width: 70px; border: 0; outline: 0; padding: 7px 8px;
  background: transparent; color: var(--text-primary); font: inherit; font-weight: 600;
  text-overflow: ellipsis;  /* a part that does not fit ends with dots, the whole address is in the tooltip */
}
.mailbox-domain {
  padding: 7px 8px 7px 0; color: var(--text-secondary); white-space: nowrap; font-size: 12px;
}

.btn-copy {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
  margin-left: 10px;
}
.btn-copy:hover { filter: brightness(1.1); }
.setting-note { font-size: 11.5px; color: var(--text-muted); line-height: 1.4; }

.theme-options { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.theme-card {
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: left;
  transition: all 0.15s ease;
}
.theme-card:hover { border-color: var(--border-light); }
.theme-card.active { border-color: var(--accent); background: var(--bg-hover); }

.theme-preview {
  height: 48px;
  border-radius: 6px;
  display: flex;
  overflow: hidden;
  border: 1px solid var(--border);
}
.theme-preview.light { background: #fbfaf8; }
.theme-preview.light .theme-p-bar { width: 30%; background: #f4f2ee; border-right: 1px solid #e6e2db; }
.theme-preview.light .theme-p-content { flex: 1; background: #fbfaf8; }
.theme-preview.dark { background: #1a1917; }
.theme-preview.dark .theme-p-bar { width: 30%; background: #211f1d; border-right: 1px solid rgba(255,240,220,0.08); }
.theme-preview.dark .theme-p-content { flex: 1; background: #1a1917; }

.theme-info { display: flex; flex-direction: column; }
.theme-name { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.theme-sub { font-size: 11px; color: var(--text-muted); }

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

.btn-modal-done {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 8px 18px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.btn-modal-done:hover { background: var(--accent-hover); }

.btn-modal-cancel {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.btn-modal-cancel:hover { background: var(--bg-hover); color: var(--text-primary); }

.btn-logout-modal {
  background: none;
  border: none;
  color: var(--red);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 6px;
}
.btn-logout-modal:hover { background: rgba(239, 68, 68, 0.08); }

.form-input {
  width: 100%;
  padding: 9px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-hover);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 13.5px;
  outline: none;
  transition: border-color 0.15s ease;
}
.form-input:focus { border-color: var(--accent); background: var(--bg-card); }

.form-textarea {
  width: 100%;
  padding: 9px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-hover);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 13.5px;
  outline: none;
  resize: vertical;
  transition: border-color 0.15s ease;
}
.form-textarea:focus { border-color: var(--accent); background: var(--bg-card); }

/* Мобильная адаптивность */
@media (max-width: 768px) {
  .sidebar {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-scrim.open { display: block; }
  .btn-menu-mobile { display: flex; }
  .suggestions-grid { grid-template-columns: 1fr; }
  .composer-area { padding: 10px 12px calc(14px + env(safe-area-inset-bottom)); }
  .upload-status { display: none; }
  .btn-attach span { display: none; }
}

/* Login (passwordless email link) */
.login-overlay {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-main); padding: 16px; overflow-y: auto;
}
.login-card {
  width: 100%; max-width: 400px; background: var(--bg-card); color: var(--text-primary);
  border-radius: 12px; padding: 28px; box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
  display: flex; flex-direction: column; gap: 12px;
}
.login-card[hidden] { display: none; }
.login-card h1 { font-size: 20px; margin: 0; }
.login-card p { margin: 0; color: var(--text-secondary); line-height: 1.5; }

.login-card input {
  font: inherit; padding: 10px 12px; border-radius: 8px;
  border: 1px solid var(--text-muted); background: var(--bg-main); color: var(--text-primary);
}
.language-select {
  font: inherit; color: var(--text-primary); background: var(--bg-card);
  border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px; cursor: pointer;
}
.cabinet-language-select { min-width: 104px; font-size: 12px; }

.login-card button {
  font: inherit; padding: 10px 12px; border: 0; border-radius: 8px; cursor: pointer;
  background: var(--accent); color: #fff;
}
.login-card button:hover { background: var(--accent-hover); }

.auth-email-editor {
  display: flex; align-items: center; border: 1px solid var(--text-muted); border-radius: 8px;
  background: var(--bg-main); overflow: hidden;
}
.auth-email-editor input { min-width: 0; flex: 1; border: 0; }
.auth-email-editor span { padding-right: 12px; color: var(--text-secondary); white-space: nowrap; font-size: 13px; }
.login-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}
.login-card .brand-icon {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.login-card .brand-icon svg {
  stroke: none;
}
.login-card .language-dropdown-wrapper {
  position: relative;
  display: inline-flex;
}
.login-card .btn-globe {
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}
.login-card .btn-globe:hover,
.login-card .btn-globe.active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--bg-hover);
}
.login-card .language-dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 140px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px;
  box-shadow: var(--shadow-md);
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.login-card .language-dropdown-menu.start-hidden { display: none; }
.login-card .language-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 8px 12px;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  border-radius: 6px;
  cursor: pointer;
  text-align: left;
  transition: background 0.12s ease;
}
.login-card .language-option:hover {
  background: var(--bg-hover);
  color: var(--accent);
}
.login-card .language-option.active {
  background: var(--accent-glow);
  color: var(--accent);
  font-weight: 600;
}

.login-card .login-note:empty { display: none; }



/* One request at a time: while the answer is being written only sending is closed; the field and the clip stay open
   (see applyBusy, ADR 0028). */
.composer-locked .btn-send { cursor: not-allowed; }
/* While one request of a suggestion waits for the answer, the other suggestions are closed (ADR 0028). */
.request-queued .suggestion-card { opacity: 0.5; cursor: not-allowed; pointer-events: none; }
.message-row.queued .message-bubble { opacity: 0.65; }
.queued-note { display: flex; gap: 10px; align-items: center; margin-top: 4px; font-size: 12px; color: var(--text-muted); }
.queued-cancel { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font: inherit; }
.queued-cancel:hover { text-decoration: underline; }

/* Trainee-4: replies are plain text (no Markdown): line breaks are kept as written. */
.message-bubble.plain { white-space: pre-wrap; overflow-wrap: anywhere; }

/* An event of a reminder coming due: a small label above the trainee's reply. */
.reply-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 4px;
}

/* The answer could not be produced: the reason is shown in place of the reply. */
.message-bubble.failed { border-color: var(--red, #ef4444); color: var(--text-secondary); }

/* Loading older messages at the top of the feed. */
.btn-load-older {
  align-self: center;
  background: none;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 5px 14px;
  margin: 4px 0 12px;
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
}
.btn-load-older:hover { border-color: var(--accent); color: var(--accent); }

/* The matter card (read only). */
.matter-card-section { display: flex; flex-direction: column; gap: 6px; }
.matter-card-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text-muted);
}
.matter-card-text { color: var(--text-primary); line-height: 1.5; white-space: pre-wrap; }
.matter-card-list { margin: 0; padding-left: 18px; color: var(--text-primary); line-height: 1.5; }
.deadline-groups { display: flex; flex-direction: column; gap: 10px; }
.deadline-group { display: flex; flex-direction: column; gap: 4px; }
.deadline-group-header strong { font-size: 13px; color: var(--text-primary); font-weight: 600; }
.deadline-time { color: var(--accent); font-weight: 600; }
.matter-card-money { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.matter-card-money div { background: var(--bg-hover); border-radius: 8px; padding: 8px 10px; }
.matter-card-money span { display: block; font-size: 11px; color: var(--text-muted); }
.matter-card-money strong { font-size: 14px; color: var(--text-primary); }
.risk-groups { display: flex; flex-direction: column; gap: 10px; }
.risk-group {
  border-left: 3px solid var(--border);
  padding: 4px 0 4px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.risk-group.impact-high, .risk-group.impact-critical { border-left-color: var(--red); }
.risk-group.impact-medium { border-left-color: var(--amber); }
.risk-group.impact-low { border-left-color: var(--green); }

.risk-group-header strong {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.risk-group.impact-high .risk-group-header strong,
.risk-group.impact-critical .risk-group-header strong { color: var(--red); }
.risk-group.impact-medium .risk-group-header strong { color: #d97706; }
.risk-group.impact-low .risk-group-header strong { color: #059669; }

[data-theme="dark"] .risk-group.impact-medium .risk-group-header strong { color: #fbbf24; }
[data-theme="dark"] .risk-group.impact-low .risk-group-header strong { color: #34d399; }

.risk-group-items {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.risk-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.risk-item:not(:last-child) {
  padding-bottom: 6px;
  border-bottom: 1px dashed var(--border);
}

/* Closed matters (ADR 0029): a folded section under the open ones, the items dimmed. */
.closed-matters-toggle {
  background: none;
  border: none;
  text-align: left;
  padding: 8px 6px 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text-muted);
  cursor: pointer;
}
.closed-matters-toggle:hover { color: var(--accent); }
.matter-item.closed { opacity: 0.65; }
.matter-card-closed { font-weight: 600; color: var(--text-secondary); }

/* Trainee-4: the trainee's replies laid out in a business style (ADR 0030). */
.message-bubble.formatted { overflow-wrap: anywhere; line-height: 1.55; }
.message-bubble.formatted p { margin: 0 0 10px; }
.message-bubble.formatted p:last-child { margin-bottom: 0; }
.message-bubble.formatted h3, .message-bubble.formatted h4,
.message-bubble.formatted h5, .message-bubble.formatted h6 { margin: 12px 0 6px; font-size: 14.5px; font-weight: 700; }
.message-bubble.formatted ol, .message-bubble.formatted ul { margin: 4px 0 10px; padding-left: 22px; }
.message-bubble.formatted li { margin: 3px 0; }
.message-bubble.formatted li > ol, .message-bubble.formatted li > ul { margin: 4px 0 4px; }
.message-bubble.formatted strong { font-weight: 700; color: var(--text-primary); }
.message-bubble a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.message-row.user .message-bubble a { color: inherit; }
.message-bubble code { font-size: 12.5px; background: var(--bg-hover); padding: 1px 5px; border-radius: 4px; }

/* Renaming a matter from the side panel. */
.matter-header-row { position: relative; }
.btn-rename-matter {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 13px;
  padding: 0 2px;
  opacity: 0;
  transition: opacity 0.15s;
}
.matter-item:hover .btn-rename-matter, .btn-rename-matter:focus { opacity: 1; }
.btn-rename-matter:hover { color: var(--accent); }
@media (hover: none) { .btn-rename-matter { opacity: 1; } }
/* In the form of a matter the delete button of a document is always shown. */
.matter-document .btn-rename-matter { opacity: 1; }

/* Search in the conversation (the mentor's own find, like the browser's). */
.dialog-search { display: flex; align-items: center; gap: 4px; }
.dialog-search input {
  width: 190px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-main);
  color: var(--text-primary);
  font-size: 13px;
}
.search-count { font-size: 12px; color: var(--text-muted); min-width: 36px; text-align: right; }
.search-nav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-card);
  color: var(--text-secondary);
  cursor: pointer;
}
.search-nav-btn:hover { border-color: var(--accent); color: var(--accent); }
.matter-filter {
  max-width: 200px;
  padding: 7px 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-main);
  color: var(--text-primary);
  font-size: 13px;
}
.dialog-search { gap: 6px; }
mark.search-hit { background: #fde68a; color: inherit; border-radius: 2px; padding: 0 1px; }
mark.search-hit.current { background: #f59e0b; }
@media (max-width: 768px) {
  .dialog-search input { width: 100px; }
  .matter-filter { max-width: 110px; }
  .search-count { display: none; }
}

/* The matter card in Markdown. */
.matter-card-text.formatted { white-space: normal; }
.matter-card-text.formatted p { margin: 0 0 6px; }
.matter-card-text.formatted ol, .matter-card-text.formatted ul { margin: 2px 0 6px; padding-left: 22px; }
.matter-card-text.formatted li { margin: 2px 0; }

/* Contacts of the participants in the matter card. */
.participant-contacts { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 2px; font-size: 12.5px; }
.participant-contacts a { color: var(--accent); }

/* Warnings on the account above the feed (ADR 0031). */
.account-banner { padding: 8px 20px 0; }
.account-banner-line {
  border-radius: 8px;
  padding: 8px 12px;
  margin-bottom: 6px;
  font-size: 13px;
  line-height: 1.4;
}
.account-banner-line.warning { background: rgba(245, 158, 11, 0.12); color: #92400e; border: 1px solid rgba(245, 158, 11, 0.35); }
.account-banner-line.error { background: rgba(239, 68, 68, 0.10); color: #991b1b; border: 1px solid rgba(239, 68, 68, 0.35); }
[data-theme="dark"] .account-banner-line.warning { color: #fbbf24; }
[data-theme="dark"] .account-banner-line.error { color: #fca5a5; }

/* Limits changed in the settings (ADR 0031). */
#settings-limits { gap: 10px; }
.limit-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
.limit-row .profile-label { min-width: 70px; }
.limit-input {
  width: 96px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-main);
  color: var(--text-primary);
}
.limit-currency { color: var(--text-muted); }
.limit-spent { width: 100%; font-size: 12px; color: var(--text-muted); padding-left: 78px; }
.limit-lift:disabled { opacity: 0.4; cursor: default; }

/* Renaming a matter: a small dialog in the style of the cabinet. */
.rename-card { max-width: 440px; }
.rename-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.3px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}
.rename-input {
  width: 100%;
  box-sizing: border-box;
  padding: 11px 13px;
  font-size: 15px;
  border: 1px solid var(--border-light);
  border-radius: 10px;
  background: var(--bg-main);
  color: var(--text-primary);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.rename-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.rename-error { min-height: 18px; margin: 8px 0 0; font-size: 12.5px; color: var(--red); }
.rename-card .btn-modal-done:disabled { opacity: 0.6; cursor: default; }

/* ADR 0049: no inline styles under the Content Security Policy. Hidden at first; the script shows it. */
.start-hidden { display: none; }
.brand-inline { display: inline-flex; align-items: center; gap: 8px; }
.brand-name { font-weight: 700; font-size: 15px; color: var(--text-primary); }
/* Authorizations in the settings: what, to whom, and the button to revoke. */
.authorization-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.authorization-row:last-child { border-bottom: none; }
.authorization-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.authorization-details { font-size: 12px; color: var(--text-secondary); }
.btn-danger { color: #dc2626; border-color: #dc2626; }

/* Composer file attachments and Zero-Disk badge (ADR 0047) */
.composer-actions-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}
.btn-attach {
  color: var(--text-secondary);
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}
.btn-attach:hover {
  color: var(--accent);
  background: var(--bg-hover);
}
.zero-disk-badge {
  font-size: 11px;
  color: var(--text-tertiary, #64748b);
  background: var(--bg-secondary, rgba(255, 255, 255, 0.04));
  border: 1px solid var(--border-light, rgba(255, 255, 255, 0.08));
  padding: 3px 8px;
  border-radius: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 320px;
  cursor: default;
  user-select: none;
}
.composer-files-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 12px 4px;
}
.file-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 12px;
  color: var(--text-primary);
}
.file-chip-name {
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.file-chip-size {
  color: var(--text-secondary);
  font-size: 11px;
}
.file-chip-remove {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0 2px;
  font-size: 14px;
  line-height: 1;
}
.file-chip-remove:hover {
  color: #ef4444;
}
.composer-box.drag-over {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-glow);
}

/* Documents section: a card waiting to be filed to a matter stands out. */
.document-item { cursor: default; }
.document-item.waiting { border-color: var(--accent); }
.document-item .matter-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.document-item.expired { opacity: 0.65; }
.document-item.expired .matter-sub { color: var(--red); }

/* Letters section: a received letter that waits for the mentor's decision (ADR 0051). */
.letter-item .letter-subject { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.letter-item .letter-why { font-size: 12px; }
.letter-actions { display: flex; gap: 6px; margin-top: 6px; }
.btn-letter {
  background: none;
  border: 1px solid var(--border-light);
  border-radius: 6px;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 12px;
  padding: 2px 8px;
}
.btn-letter:hover { color: var(--accent); border-color: var(--accent); }

/* The question of the cabinet in its own window instead of the browser's confirm(). */
.confirm-card { max-width: 400px; }
/* The window for correcting a wording: the field grows with the text up to half the screen (ADR 0028). */
.edit-card { max-width: 560px; width: 100%; }
.edit-textarea {
  width: 100%; box-sizing: border-box; min-height: 130px; max-height: 50vh; padding: 11px 13px;
  border: 1px solid var(--border-light); border-radius: 10px; background: var(--bg-card); color: var(--text-primary);
  font: inherit; font-size: 14.5px; line-height: 1.55; resize: vertical; outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.edit-textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.edit-hint { margin: 8px 2px 0; font-size: 12px; color: var(--text-muted); }
.edit-card .btn-modal-done:disabled { opacity: 0.45; cursor: default; }
.confirm-text { margin: 0; font-size: 15px; line-height: 1.5; color: var(--text-primary); }
.confirm-footer { justify-content: flex-end; gap: 10px; }
.btn-modal-danger {
  background: var(--red);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 8px 18px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.btn-modal-danger:hover { filter: brightness(0.92); }


/* --- The Advisor (ADR 0067): the slider of the mode, the chat, the panel of notes, rules and tasks --- */
[hidden] { display: none !important; }
.advisor-mode .trainee-only { display: none !important; }
.advisor-only { display: none !important; }
.advisor-mode .advisor-only { display: inline-flex !important; }

.mode-switch {
  display: inline-flex;
  padding: 3px;
  margin-right: 12px;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: 999px;
}
.mode-option {
  border: 0;
  background: transparent;
  color: var(--text-secondary);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 5px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.mode-option.has-news::after {
  content: '';
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-left: 6px;
  border-radius: 50%;
  background: var(--accent);
  vertical-align: middle;
}
.mode-option.active {
  background: var(--mode-active-bg);
  color: var(--mode-active-text);
  box-shadow: var(--shadow-sm);
}

.message-bubble .chart-picture {
  display: block;
  max-width: 100%;
  margin: 10px 0;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
}
.advisor-report-buttons {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-muted);
}
.advisor-report-buttons a.btn-copy { text-decoration: none; }

.advisor-panel .advisor-panel-list, .settings-page .advisor-panel-list { display: flex; flex-direction: column; gap: 6px; margin: 6px 0 14px; }
.advisor-panel-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  background: var(--bg-card);
  font-size: 12.5px;
  line-height: 1.45;
}
.advisor-panel-text { color: var(--text-primary); overflow-wrap: anywhere; }
/* The notes of the Advisor may be many: the list keeps to a part of the window and scrolls inside (ADR 0067). */
.advisor-notes-scroll, .settings-scroll { max-height: 38vh; overflow-y: auto; padding-right: 4px; }
.advisor-notes-search-row { display: flex; align-items: center; gap: 6px; margin-top: 6px; }
.advisor-notes-search {
  flex: 1;
  min-width: 0;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-main);
  color: var(--text-primary);
  font-size: 13px;
}
.advisor-panel-actions { display: flex; gap: 6px; margin-top: 6px; }
@media (max-width: 720px) {
  .mode-switch { margin-right: 6px; }
  .mode-option { padding: 5px 10px; font-size: 12px; }
}

/* The window of a document (ADR 0080) */
.document-item.clickable { cursor: pointer; }
/* One size and one colour for the text of the window, as in the form of a matter. */
.document-card .modal-body { font-size: 14px; line-height: 1.5; color: var(--text-primary); gap: 16px; }
.document-card .document-head { display: flex; flex-direction: column; gap: 4px; }
.document-card .document-where { font-size: 14px; font-weight: 600; color: var(--text-primary); }
.document-card .document-facts-line { font-size: 12px; color: var(--text-muted); }
.document-card .matter-card-text, .document-card .matter-card-list { font-size: 14px; }
.document-card .matter-card-list li { margin-bottom: 4px; }
.document-card .document-note { font-size: 12px; color: var(--text-muted); }
/* The text of a document the trainee made (ADR 0089). */
.document-card .document-text { font-size: 14px; line-height: 1.5; white-space: pre-wrap; max-height: 40vh; overflow-y: auto; }
.document-card .document-text p { margin: 0 0 8px 0; }
.document-card .document-text table { border-collapse: collapse; font-size: 13px; }
.document-card .document-text th, .document-card .document-text td { border: 1px solid var(--border); padding: 4px 8px; text-align: left; white-space: normal; }
.document-card .table-scroll { overflow-x: auto; }
.document-download { text-decoration: none; display: inline-flex; align-items: center; }

/* Documents in the form of a matter (ADR 0080) */
.matter-document { display: flex; align-items: baseline; gap: 6px; }
.matter-document-open { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; text-align: left; font: inherit; }
.matter-document-open:hover { text-decoration: underline; }
.matter-document-meta { color: var(--text-muted); font-size: 12px; flex: 1; }

/* A reminder at the minute of a dated fact (ADR 0030) */
.deadline-bell-note { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* Export of the costs in the settings (ADR 0082) */
.export-costs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 10px; }
.export-costs select, .export-costs input { font: inherit; padding: 3px 6px; }

/* The file of the costs under a statement in the chat (ADR 0083) */
.billing-export-buttons { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 6px; font-size: 12px; color: var(--text-muted); }
.billing-export-buttons a.btn-copy { text-decoration: none; }
