:root {
  --bg: #141220;
  --panel: #1b1828;
  --panel-2: #221e33;
  --border: #322c47;
  --text: #EDEAF5;
  --text-dim: #948FAE;
  --accent: #7C5CFC;
  --accent-dim: #4E3DAB;
  --teal: #33C9B0;
  --amber: #E8A33D;
  --red: #E2504F;
  --radius: 10px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
}
a { color: var(--accent); }
button { font-family: inherit; }

/* ---------- Приложение-чат (SPA) ---------- */

#app { display: flex; height: 100vh; }

#sidebar {
  width: 320px;
  min-width: 280px;
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}
#sidebar-header {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
#sidebar-header h1 { font-size: 19px; font-weight: 600; margin: 0; line-height: 1; }
.header-title-group { display: flex; align-items: center; gap: 10px; min-width: 0; }
.header-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.employee-switcher { position: relative; flex-shrink: 0; }
.employee-switcher-btn {
  display: flex; align-items: center; gap: 6px; background: var(--panel-2); border: 1px solid var(--border);
  color: var(--text-dim); font-size: 13px; padding: 7px 12px; border-radius: 10px; cursor: pointer; white-space: nowrap;
}
.employee-switcher-btn:hover { color: var(--text); border-color: var(--accent); }
.employee-switcher-btn .caret { font-size: 10px; }
.employee-dropdown {
  position: absolute; top: 100%; left: 0; margin-top: 4px; z-index: 20;
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px;
  min-width: 190px; max-height: 260px; overflow-y: auto; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}
.employee-dropdown button {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; background: none; border: none;
  color: var(--text); padding: 8px 12px; font-size: 13px; cursor: pointer; white-space: nowrap;
}
.employee-dropdown button:hover { background: var(--accent-dim); }
.employee-dropdown button.active { color: var(--accent); font-weight: 600; }

.bell-wrap { position: relative; flex-shrink: 0; }
.bell-btn { position: relative; font-size: 16px; }
.bell-badge {
  position: absolute; top: -4px; right: -4px; background: var(--red); color: #fff;
  font-size: 10px; font-weight: 700; min-width: 16px; height: 16px; border-radius: 8px;
  padding: 0 4px; display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--panel);
}
.bell-dropdown { left: 0; right: auto; min-width: 280px; max-width: 340px; }
.bell-dropdown .empty-hint { padding: 12px; }
.bell-item {
  display: flex !important; align-items: center; gap: 10px; padding: 10px 12px !important;
  white-space: normal !important;
}
.bell-item-info { flex: 1; min-width: 0; }
.bell-item-title { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bell-item-sub { font-size: 12px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.search-wrap { position: relative; flex-shrink: 0; }
.search-panel { left: 0; right: auto; min-width: 280px; max-width: 340px; padding: 8px; max-height: none; }
.search-input {
  width: 100%; background: var(--panel); border: 1px solid var(--border); color: var(--text);
  border-radius: 8px; padding: 8px 10px; font-size: 13px; font-family: inherit; box-sizing: border-box;
}
.search-input:focus { outline: none; border-color: var(--accent); }
.search-results { margin-top: 6px; max-height: 260px; overflow-y: auto; }
.search-results .empty-hint { padding: 10px 4px; }
.search-status-badge {
  font-size: 10px; padding: 1px 6px; border-radius: 6px; margin-left: auto; flex-shrink: 0;
  background: var(--panel); color: var(--text-dim); border: 1px solid var(--border); white-space: nowrap;
}

.space-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  background: rgba(124, 92, 252, 0.1);
  padding: 8px 16px; border-bottom: 1px solid var(--border);
}
.space-banner button {
  background: var(--accent); border: none; color: #fff; cursor: pointer;
  font-size: 12px; font-weight: 700; padding: 6px 12px; border-radius: 8px;
  flex-shrink: 0; white-space: nowrap;
}
.sound-hint {
  font-size: 11px; color: var(--text-dim); background: rgba(124, 92, 252, 0.1);
  padding: 6px 16px; border-bottom: 1px solid var(--border); cursor: pointer;
}
.space-banner button:hover { filter: brightness(1.12); }
.space-banner-current {
  color: var(--text); font-size: 12px; font-weight: 700;
  background: rgba(124, 92, 252, 0.25); padding: 5px 10px; border-radius: 7px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0;
}

.icon-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  width: 32px;
  height: 32px;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.icon-btn:hover { background: #8E6DFF; }

.icon-btn-ghost {
  background: var(--panel-2);
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 32px;
  height: 32px;
  font-size: 15px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.icon-btn-ghost:hover { color: var(--text); border-color: var(--accent); }

#chat-list { flex: 1; overflow-y: auto; padding: 8px; }
.section-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--text-dim); padding: 12px 10px 6px;
}
.empty-hint { padding: 14px 10px; font-size: 13px; color: var(--text-dim); }

.chat-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px; border-radius: var(--radius); cursor: pointer; position: relative;
}
.chat-item:hover { background: var(--panel-2); }
.chat-item.active { background: var(--accent-dim); }
.chat-emoji { font-size: 20px; width: 24px; text-align: center; flex-shrink: 0; }
.chat-info { flex: 1; min-width: 0; }
.chat-title { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-tag-label {
  display: inline-block; font-size: 9px; font-weight: 700; letter-spacing: 0.02em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%;
  line-height: 1.5; padding: 0 5px; border-radius: 5px; margin-bottom: 2px;
}
.chat-sub { font-size: 12px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.draft-label { color: var(--red); font-weight: 600; }
.reminder-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--red); flex-shrink: 0; }
.chat-pin-toggle {
  opacity: 0; background: none; border: none; color: var(--text-dim); cursor: pointer; font-size: 14px; padding: 4px;
}
.chat-item:hover .chat-pin-toggle { opacity: 1; }
.chat-pin-toggle.pinned { opacity: 1; color: var(--teal); }

.unread-badge {
  background: var(--accent); color: #fff; font-size: 11px; font-weight: 700;
  min-width: 18px; height: 18px; border-radius: 9px; padding: 0 5px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.mention-badge {
  background: var(--amber); color: #1b1400; font-size: 11px; font-weight: 800;
  width: 18px; height: 18px; border-radius: 50%; padding: 0;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}

.archive-link {
  padding: 10px 12px; margin: 4px 8px; border-top: 1px solid var(--border);
  font-size: 13px; color: var(--text-dim); cursor: pointer; text-decoration: none;
  display: flex; align-items: center; justify-content: space-between;
  border-radius: var(--radius);
}
.archive-link:hover { color: var(--text); background: var(--panel-2); }
.favorites-link {
  width: 100%; background: none; border: none; border-top: 1px solid var(--border);
  font-family: inherit; text-align: left;
}

.folder {
  padding: 10px; font-size: 14px; font-weight: 500; color: var(--text);
  cursor: pointer; display: flex; justify-content: space-between; border-radius: var(--radius);
}
.folder:hover { background: var(--panel-2); }
.folder.back-row { color: var(--text-dim); font-weight: 400; font-size: 13px; }

#user-bar {
  display: flex; align-items: center; gap: 8px; padding: 10px 12px;
  border-top: 1px solid var(--border);
}
#user-bar-name { font-size: 13px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Основная область ---------- */

#main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
#empty-state {
  flex: 1; display: flex; align-items: center; justify-content: center;
  color: var(--text-dim); font-size: 14px; flex-direction: column; gap: 10px;
}
.empty-icon { font-size: 34px; }

#chat-view { flex: 1; display: none; flex-direction: column; min-height: 0; }
#chat-header {
  padding: 14px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
#chat-header .chat-emoji { font-size: 22px; }
.chat-header-titlebox { display: flex; flex-direction: column; flex: 1; min-width: 0; gap: 2px; }
#chat-header-title { font-size: 16px; font-weight: 600; cursor: pointer; }
#chat-header-title:hover { text-decoration: underline; text-decoration-style: dotted; }
.tag-badge {
  font-size: 11px; color: var(--teal); background: rgba(51, 201, 176, 0.12);
  border-radius: 6px; padding: 2px 7px; align-self: flex-start;
}
.status-badge { font-size: 12px; color: var(--text-dim); background: var(--panel-2); padding: 5px 10px; border-radius: 8px; }

.header-btn {
  background: none; border: 1px solid var(--border); color: var(--text-dim);
  border-radius: 8px; padding: 6px 10px; font-size: 12px; cursor: pointer;
  display: flex; align-items: center; gap: 5px; text-decoration: none;
}
.header-btn:hover { border-color: var(--accent); color: var(--text); }
.back-btn { display: none; }

#pinned-bar {
  display: none; padding: 6px 20px; background: rgba(124, 92, 252, 0.08);
  border-bottom: 1px solid var(--border); font-size: 13px;
}
.pinned-msg-row { display: flex; align-items: center; gap: 10px; width: 100%; }
.pinned-pin-icon { flex-shrink: 0; }
.pinned-stack {
  position: relative; width: 3px; height: 22px; flex-shrink: 0; display: inline-block;
}
.pinned-stack span {
  position: absolute; left: 0; width: 3px; height: 14px; border-radius: 2px; background: var(--teal);
}
.pinned-stack span:first-child { top: 0; opacity: 0.5; }
.pinned-stack span:last-child { top: 6px; }
.pinned-msg-content {
  flex: 1; display: flex; align-items: center; min-width: 0; cursor: pointer;
  padding: 6px 8px; border-radius: 6px;
}
.pinned-msg-content:hover { background: rgba(255, 255, 255, 0.04); }
.pinned-msg-text { color: var(--teal); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.unpin-x { cursor: pointer; color: var(--text-dim); font-size: 12px; padding: 6px; margin-left: 4px; flex-shrink: 0; }
.unpin-x:hover { color: var(--red); }

#reminders-bar {
  display: none; padding: 10px 20px; background: rgba(232, 163, 61, 0.1);
  border-bottom: 1px solid var(--border); font-size: 13px; flex-direction: column; gap: 6px;
}
.reminder-row { display: flex; align-items: center; gap: 8px; color: var(--amber); }
.reminder-row.overdue { color: var(--red); }
.reminder-row-text { flex: 1; min-width: 0; }
.reminder-row em { font-style: normal; color: var(--text-dim); font-size: 11px; }

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

.msg { display: flex; gap: 8px; max-width: 74%; align-self: flex-start; }
.msg.mine { align-self: flex-end; flex-direction: row-reverse; }
.msg-avatar { margin-top: 2px; }
.msg-bubble {
  background: var(--panel-2); padding: 8px 12px; border-radius: 12px; border-top-left-radius: 4px;
  font-size: 14px; position: relative; min-width: 0;
}
.msg.mine .msg-bubble { background: var(--accent-dim); border-top-left-radius: 12px; border-top-right-radius: 4px; }
.msg-author { font-size: 12px; font-weight: 600; color: var(--teal); margin-bottom: 2px; }
.msg-text { white-space: pre-wrap; word-break: break-word; }
.msg-highlight { background: rgba(124, 92, 252, 0.35); color: inherit; border-radius: 3px; padding: 0 2px; }

.format-toolbar {
  position: fixed; z-index: 50; display: flex; gap: 2px;
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px;
  padding: 4px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}
.format-toolbar button {
  width: 30px; height: 30px; display: flex; align-items: center; justify-content: center;
  background: none; border: none; border-radius: 6px; color: var(--text); font-size: 14px; cursor: pointer;
}
.format-toolbar button:hover { background: var(--accent-dim); }
.highlight-wrap { position: relative; }
.highlight-palette {
  position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%);
  display: flex; gap: 4px; background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 8px; padding: 6px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35); z-index: 60;
}
.color-swatch {
  width: 22px; height: 22px; border-radius: 50%; border: 1px solid rgba(255, 255, 255, 0.25);
  cursor: pointer; padding: 0; flex: none;
}
.color-swatch:hover { transform: scale(1.15); }
.remove-swatch {
  background: var(--panel) !important; color: var(--text-dim); font-size: 11px;
  display: flex; align-items: center; justify-content: center;
}
.msg-meta { display: flex; align-items: center; gap: 8px; margin-top: 4px; font-size: 10px; color: var(--text-dim); }
.msg.is-pinned .msg-bubble { border-left: 2px solid var(--teal); }

.msg-menu-wrap { position: relative; align-self: flex-end; margin-bottom: 4px; }
.msg-menu-btn {
  background: none; border: none; color: var(--text-dim); cursor: pointer;
  font-size: 18px; line-height: 1; padding: 4px 6px; border-radius: 6px;
  opacity: 0; transition: opacity 0.15s, background 0.15s, color 0.15s;
}
.msg:hover .msg-menu-btn, .msg-menu-btn.menu-open { opacity: 1; }
.msg-menu-btn:hover { background: var(--panel-2); color: var(--text); }

.msg-menu {
  position: absolute; bottom: 100%; margin-bottom: 4px; z-index: 5;
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35); min-width: 160px; overflow: hidden;
}
.msg.mine .msg-menu { right: 0; }
.msg:not(.mine) .msg-menu { left: 0; }
.msg-menu.open-down { bottom: auto; top: 100%; margin-bottom: 0; margin-top: 4px; }
.msg-menu button {
  display: block; width: 100%; text-align: left; background: none; border: none;
  color: var(--text); padding: 9px 12px; font-size: 13px; cursor: pointer; white-space: nowrap;
}
.msg-menu button:hover { background: var(--accent-dim); }

.read-receipt { letter-spacing: -2px; color: var(--text-dim); }
.read-receipt.read { color: var(--teal); }

@keyframes pinFlash {
  0% { box-shadow: 0 0 0 0 var(--accent); background-color: var(--accent); }
  50% { box-shadow: 0 0 0 5px var(--accent); background-color: var(--accent); }
  100% { box-shadow: 0 0 0 0 transparent; }
}
.msg.flash-highlight .msg-bubble { animation: pinFlash 0.7s ease-out 2; }

.msg.msg-new .msg-bubble { box-shadow: 0 0 0 2px var(--accent); transition: box-shadow 2s ease; }
.msg.msg-new.msg-new-fade .msg-bubble { box-shadow: 0 0 0 2px transparent; }

.attachment-image { max-width: 240px; max-height: 240px; border-radius: 8px; display: block; margin-top: 4px; cursor: pointer; }

.image-lightbox {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.85); z-index: 200;
  display: flex; align-items: center; justify-content: center; padding: 40px;
}
.image-lightbox img { max-width: 100%; max-height: 100%; border-radius: 8px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5); }
.image-lightbox-close {
  position: absolute; top: 16px; right: 20px; background: rgba(255, 255, 255, 0.1); border: none;
  color: #fff; width: 40px; height: 40px; border-radius: 50%; font-size: 18px; cursor: pointer;
}
.image-lightbox-close:hover { background: rgba(255, 255, 255, 0.2); }
.attachment-file {
  display: flex; align-items: center; gap: 8px; background: rgba(255,255,255,0.06);
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; margin-top: 4px;
  text-decoration: none; color: var(--text); font-size: 13px; max-width: 220px;
}
.attachment-file:hover { border-color: var(--accent); }
.attachment-icon { font-size: 18px; flex-shrink: 0; }
.attachment-meta { min-width: 0; }
.attachment-meta .attachment-filename { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.attachment-meta .attachment-filesize { font-size: 11px; color: var(--text-dim); }

#composer {
  display: flex; flex-direction: column; gap: 8px;
  padding: 14px 20px; border-top: 1px solid var(--border); position: relative;
}
.composer-row { display: flex; gap: 10px; align-items: flex-end; }
.msg-input-rich {
  flex: 1; background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 10px; color: var(--text); padding: 10px 12px; font-size: 14px;
  font-family: inherit; min-height: 42px; max-height: 120px; overflow-y: auto;
  white-space: pre-wrap; word-break: break-word; line-height: 1.4; box-sizing: border-box;
}
.msg-input-rich:focus { outline: none; border-color: var(--accent); }
.msg-input-rich:empty::before {
  content: attr(data-placeholder); color: var(--text-dim); pointer-events: none;
}
.msg-input-rich mark.msg-highlight { background: rgba(124, 92, 252, 0.35); color: inherit; border-radius: 3px; }
#send-btn {
  background: var(--accent); color: #fff; border: none; border-radius: 50%;
  width: 42px; height: 42px; font-size: 20px; cursor: pointer; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; padding: 0;
}
#send-btn:hover { background: #8E6DFF; }

.attach-btn {
  background: none; border: 1px solid var(--border); color: var(--text-dim);
  border-radius: 10px; width: 42px; height: 42px; font-size: 18px; cursor: pointer; flex-shrink: 0;
}
.attach-btn:hover { border-color: var(--accent); color: var(--text); }

.pending-attachment {
  display: flex; align-items: center; gap: 8px; background: var(--panel-2);
  border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; font-size: 13px;
}
.pending-attachment span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pending-attachment .remove-x { cursor: pointer; color: var(--text-dim); flex: none; }
.pending-attachment .remove-x:hover { color: var(--red); }

.mention-autocomplete {
  position: absolute; left: 20px; right: 20px; bottom: 100%; margin-bottom: 6px;
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px;
  overflow: hidden; max-height: 220px; overflow-y: auto; box-shadow: 0 8px 24px rgba(0,0,0,0.35);
}
.mention-option {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px; font-size: 13px; cursor: pointer;
}
.mention-option:hover, .mention-option.active { background: var(--accent-dim); }
.mention { color: var(--teal); font-weight: 600; }
.msg.mentions-me .msg-bubble { box-shadow: 0 0 0 1px var(--amber) inset; }

/* ---------- Аватарки ---------- */

.avatar {
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%; color: #fff; font-weight: 700; flex-shrink: 0;
  object-fit: cover;
}
.avatar.small { width: 28px; height: 28px; font-size: 12px; }
.avatar.tiny { width: 20px; height: 20px; font-size: 10px; }
.avatar.large { width: 56px; height: 56px; font-size: 22px; }

/* ---------- Модалки ---------- */

.modal-overlay {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.5);
  display: none; align-items: center; justify-content: center; z-index: 10;
}
.modal-overlay.show { display: flex; }
.modal { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 20px; width: 340px; max-width: 90vw; }
.modal h3 { margin: 0 0 14px; font-size: 15px; }
.modal label { font-size: 12px; color: var(--text-dim); display: block; margin: 10px 0 5px; }
.modal input[type="text"], .modal input[type="datetime-local"], .modal input[type="date"], .modal input[type="time"], .modal input[type="number"], .modal select {
  width: 100%; background: var(--panel-2); border: 1px solid var(--border); color: var(--text);
  border-radius: 8px; padding: 9px 10px; font-size: 14px; font-family: inherit;
}
.modal input:focus, .modal select:focus { outline: none; border-color: var(--accent); }
.repeat-tag { color: var(--accent); font-size: 12px; white-space: nowrap; }
.emoji-row { max-height: 220px; overflow-y: auto; margin-top: 6px; padding-right: 4px; }
.emoji-group-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-dim); margin: 8px 0 4px; }
.emoji-group-label:first-child { margin-top: 0; }
.emoji-group-row { display: flex; flex-wrap: wrap; gap: 6px; }
.emoji-opt { font-size: 18px; padding: 6px 8px; border-radius: 8px; cursor: pointer; border: 1px solid transparent; background: var(--panel-2); }
.emoji-opt.selected { border-color: var(--accent); background: var(--accent-dim); }

.tag-row { display: flex; gap: 6px; align-items: center; }
.tag-row select { flex: 1; }

.date-time-row { display: flex; gap: 10px; }
.date-time-row > div { flex: 1; }
.date-time-row input { width: 100%; }

.time-select-row { display: flex; align-items: center; gap: 4px; }
.time-select-row select { flex: 1; }
.time-select-row span { color: var(--text-dim); }

.editing-indicator {
  display: flex; align-items: center; gap: 8px; background: rgba(124, 92, 252, 0.15);
  border: 1px solid var(--accent-dim); border-radius: 8px; padding: 6px 10px; font-size: 13px; color: var(--accent);
}
.editing-indicator span:first-child { flex: 1; }
.editing-indicator .remove-x { cursor: pointer; color: var(--text-dim); flex: none; }
.editing-indicator .remove-x:hover { color: var(--red); }

.reply-indicator {
  display: flex; align-items: center; gap: 8px; background: var(--panel-2);
  border-left: 3px solid var(--accent); border-radius: 6px; padding: 6px 10px; font-size: 13px;
}
.reply-indicator-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.reply-indicator-author { color: var(--accent); font-weight: 600; font-size: 12px; }
.reply-indicator-text {
  color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.reply-indicator .remove-x { cursor: pointer; color: var(--text-dim); flex: none; }
.reply-indicator .remove-x:hover { color: var(--red); }

.msg-reply-quote {
  display: flex; flex-direction: column; gap: 1px; border-left: 3px solid var(--accent);
  background: rgba(124, 92, 252, 0.1); border-radius: 4px; padding: 3px 8px; margin-bottom: 4px;
  cursor: pointer; font-size: 12.5px; max-width: 100%;
}
.msg-reply-quote:hover { background: rgba(124, 92, 252, 0.18); }
.msg-reply-author { color: var(--accent); font-weight: 600; }
.msg-reply-text {
  color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%;
}

.edited-tag { color: var(--text-dim); font-style: italic; }

.modal-list { list-style: none; padding: 0; margin: 10px 0; max-height: 280px; overflow-y: auto; }
.modal-list li {
  display: flex; align-items: center; gap: 10px; background: var(--panel-2);
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; margin-bottom: 6px; cursor: default;
}
.modal-list li.clickable { cursor: pointer; }
.modal-list li.clickable:hover { border-color: var(--accent); }
.modal-list .modal-list-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal-list .modal-list-time { color: var(--text-dim); font-size: 12px; flex-shrink: 0; }
.modal-list .empty-hint { padding: 8px 0; }

.pinned-viewall-btn {
  background: none; border: none; color: var(--text-dim); cursor: pointer;
  font-size: 12px; padding: 4px 6px; flex-shrink: 0; border-radius: 6px;
}
.pinned-viewall-btn:hover { color: var(--text); background: rgba(255, 255, 255, 0.06); }
.icon-btn-sm {
  background: var(--panel-2); border: 1px solid var(--border); color: var(--text);
  border-radius: 8px; width: 34px; height: 34px; font-size: 16px; cursor: pointer; flex-shrink: 0;
}
.icon-btn-sm:hover { border-color: var(--accent); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.btn-secondary { background: none; border: 1px solid var(--border); color: var(--text-dim); border-radius: 8px; padding: 8px 14px; font-size: 13px; cursor: pointer; }
.btn-primary { background: var(--accent); border: none; color: #fff; border-radius: 8px; padding: 8px 14px; font-size: 13px; cursor: pointer; }
.btn-primary:hover { background: #8E6DFF; }
.manager-list { max-height: 140px; overflow-y: auto; margin-top: 4px; }
.manager-opt { padding: 8px 10px; font-size: 13px; border-radius: 8px; cursor: pointer; background: var(--panel-2); margin-bottom: 5px; }
.manager-opt:hover { background: var(--accent-dim); }

/* ---------- Мобильная адаптация ---------- */

@media (max-width: 768px) {
  #sidebar, #main { width: 100%; }
  body:not(.chat-open) #main { display: none; }
  body.chat-open #sidebar { display: none; }
  .back-btn { display: flex; }
}

/* ---------- Вспомогательные страницы (вход/регистрация/профиль) ---------- */

.topbar {
  display: flex; align-items: center; gap: 20px; background: var(--panel);
  padding: 12px 20px; border-bottom: 1px solid var(--border);
}
.topbar .brand { font-weight: 700; font-size: 18px; color: var(--text); text-decoration: none; }
.topbar nav { display: flex; gap: 14px; flex: 1; }
.topbar nav a { text-decoration: none; }
.topbar-user { display: flex; align-items: center; gap: 8px; margin-left: auto; }

.link-btn { background: none; border: none; color: var(--accent); cursor: pointer; padding: 0; font-size: 13px; }
.link-btn:hover { text-decoration: underline; }

.page-container { max-width: 480px; margin: 0 auto; padding: 20px 16px 80px; height: auto; overflow: auto; }
body.aux-page { overflow: auto; height: auto; min-height: 100vh; }

.auth-box { max-width: 340px; margin: 60px auto; background: var(--panel); padding: 24px; border-radius: 14px; border: 1px solid var(--border); }
.auth-box h1 { margin-top: 0; }
.auth-box form { display: flex; flex-direction: column; gap: 12px; margin: 16px 0; }
.auth-box label { display: flex; flex-direction: column; gap: 4px; font-size: 14px; color: var(--text-dim); }
.auth-box input { padding: 9px 10px; border: 1px solid var(--border); background: var(--panel-2); color: var(--text); border-radius: 8px; font-size: 14px; }
.auth-box button { background: var(--accent); color: #fff; border: none; border-radius: 8px; padding: 10px 14px; cursor: pointer; font-size: 14px; }
.auth-box button:hover { background: #8E6DFF; }
.error { color: var(--red); }
.empty-state-page { color: var(--text-dim); font-style: italic; text-align: center; margin-top: 60px; }

.profile-card { display: flex; align-items: center; gap: 16px; background: var(--panel); padding: 16px; border-radius: 14px; margin-bottom: 16px; border: 1px solid var(--border); }
.profile-card code { background: var(--panel-2); padding: 2px 6px; border-radius: 4px; }

.avatar-form { display: flex; gap: 10px; align-items: center; margin: 10px 0; flex-wrap: wrap; }
.avatar-form input[type="file"] { color: var(--text-dim); font-size: 13px; max-width: 220px; }

.hint-text { font-size: 13px; color: var(--text-dim); margin-top: -6px; }
.settings-section {
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  padding: 4px 16px; margin-bottom: 14px;
}
.settings-section summary {
  cursor: pointer; padding: 12px 0; font-size: 17px; font-weight: 700; list-style: none;
}
.settings-section summary::-webkit-details-marker { display: none; }
.settings-section summary::before { content: "▸ "; color: var(--text-dim); font-size: 13px; }
.settings-section[open] summary::before { content: "▾ "; }
.settings-section .section-body { padding-bottom: 16px; }
.settings-list { list-style: none; padding: 0; margin: 10px 0; }
.settings-list li {
  display: flex; align-items: center; gap: 10px; background: var(--panel);
  border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px; margin-bottom: 8px;
}
.settings-item-name { flex: 1; }
.color-dot { width: 14px; height: 14px; border-radius: 50%; flex-shrink: 0; display: inline-block; }
.settings-add-form { display: flex; gap: 8px; align-items: center; margin: 14px 0 24px; flex-wrap: wrap; }
.settings-add-form input[type="text"] {
  flex: 1; min-width: 160px; padding: 9px 10px; border: 1px solid var(--border);
  background: var(--panel-2); color: var(--text); border-radius: 8px; font-size: 14px;
}
.settings-add-form input[type="color"] { width: 42px; height: 38px; padding: 2px; border-radius: 8px; border: 1px solid var(--border); background: var(--panel-2); cursor: pointer; }
.space-edit-label { flex-shrink: 0; color: var(--text-dim); font-size: 14px; }

.employee-row { flex-direction: column; align-items: stretch; }
.employee-row-main { display: flex; align-items: center; gap: 10px; row-gap: 8px; flex-wrap: wrap; }
.employee-row-main .settings-item-name { font-weight: 600; flex: 1 1 auto; min-width: 60px; }
.employee-row-main form.inline-form:last-child { margin-left: auto; }
.employee-row select {
  padding: 7px 10px; border: 1px solid var(--border); background: var(--panel-2);
  color: var(--text); border-radius: 8px; font-size: 13px; cursor: pointer;
}
.inline-form { display: inline-flex; align-items: center; gap: 6px; flex-shrink: 0; }
.employee-row .settings-add-form { margin: 10px 0 0; }
.key-reveal-box {
  background: rgba(124, 92, 252, 0.15); border: 1px solid var(--accent);
  border-radius: 10px; padding: 14px 16px; margin: 10px 0 16px;
}
.key-reveal-value {
  font-family: monospace; font-size: 20px; font-weight: 700; letter-spacing: 1px;
  color: var(--accent); margin: 6px 0;
}
.link-btn-danger { color: var(--red); }
.employee-key-line { display: flex; align-items: center; gap: 6px; margin: 6px 0 0; font-size: 13px; color: var(--text-dim); }
.employee-key-value { font-family: monospace; letter-spacing: 0.5px; color: var(--text); }
