:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --text: #1c2330;
  --muted: #6b7484;
  --line: #e4e7ec;
  --hover: #f0f3f7;
  --sel: #e6efff;
  --accent: #2f6fed;
  --accent-text: #ffffff;
  --danger: #d33a3a;
  --ok: #1f9d55;
  --shadow: 0 10px 30px rgba(20, 30, 50, .14);
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12151b; --panel: #1a1f27; --text: #e6e9ef; --muted: #8b94a5;
    --line: #2a313c; --hover: #222a35; --sel: #1f3157; --accent: #5b8cff;
    --danger: #ff6b6b; --ok: #3ccf7f; --shadow: 0 10px 30px rgba(0,0,0,.5);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body, #root { margin: 0; height: 100%; }
body {
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, sans-serif;
  background: var(--bg); color: var(--text);
}
a { color: var(--accent); text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
.hidden { display: none !important; }

/* ---------- кнопки и поля ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--panel); cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--hover); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { color: var(--danger); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn:disabled { opacity: .5; cursor: default; }
.icon-btn { border: 0; background: transparent; cursor: pointer; padding: 4px 8px; border-radius: 6px; color: var(--muted); font-size: 18px; line-height: 1; }
.icon-btn:hover { background: var(--hover); color: var(--text); }
input[type=text], input[type=password], input[type=search], input[type=number], input[type=datetime-local] {
  width: 100%; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--bg); outline: none;
}
input:focus { border-color: var(--accent); }
label { display: block; margin: 10px 0 4px; color: var(--muted); font-size: 13px; }
.check { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 14px; }

/* ---------- вход ---------- */
.auth {
  min-height: 100%; display: grid; place-items: center; padding: 24px;
}
.auth-card {
  width: 100%; max-width: 360px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; padding: 28px; box-shadow: var(--shadow);
}
.logo { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; }
.logo-mark {
  width: 30px; height: 30px; border-radius: 9px; background: var(--accent); color: #fff;
  display: grid; place-items: center; font-size: 16px;
}
.auth-card h1 { font-size: 20px; margin: 18px 0 4px; }
.auth-card .btn.primary { width: 100%; justify-content: center; margin-top: 16px; padding: 10px; }
.auth-switch { margin-top: 14px; text-align: center; color: var(--muted); }
.error { color: var(--danger); margin-top: 10px; min-height: 1em; }
.hint { color: var(--muted); font-size: 13px; }

/* ---------- каркас ---------- */
.app { display: grid; grid-template-columns: 232px 1fr; height: 100%; }
.sidebar {
  background: var(--panel); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 16px 10px; gap: 4px; min-height: 0;
}
.sidebar .logo { padding: 4px 10px 16px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--text);
}
.nav a:hover { background: var(--hover); }
.nav a.active { background: var(--sel); color: var(--accent); font-weight: 600; }
.nav .ico { width: 20px; text-align: center; }
.sidebar .spacer { flex: 1; }
.quota { padding: 10px; font-size: 12px; color: var(--muted); }
.bar { height: 6px; border-radius: 4px; background: var(--line); overflow: hidden; margin: 6px 0; }
.bar > div { height: 100%; background: var(--accent); width: 0; transition: width .3s; }
.bar.warn > div { background: var(--danger); }
.userbox { display: flex; align-items: center; justify-content: space-between; padding: 8px 10px; border-top: 1px solid var(--line); margin-top: 6px; }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.topbar {
  display: flex; align-items: center; gap: 10px; padding: 12px 20px; border-bottom: 1px solid var(--line);
  background: var(--panel); flex-wrap: wrap;
}
.menu-toggle { display: none; }
.crumbs { display: flex; align-items: center; gap: 2px; flex: 1; min-width: 160px; overflow: hidden; font-size: 15px; }
.crumbs a, .crumbs span { padding: 4px 6px; border-radius: 6px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 240px; }
.crumbs a:hover { background: var(--hover); }
.crumbs .sep { color: var(--muted); padding: 0; }
.crumbs .cur { font-weight: 600; }
.topbar input.search { width: 240px; }
.actions { display: flex; gap: 8px; }
.content { flex: 1; overflow: auto; padding: 16px 20px 80px; position: relative; }

/* ---------- список файлов ---------- */
.selbar {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px; margin-bottom: 10px;
  background: var(--sel); border-radius: var(--radius);
}
.selbar .count { font-weight: 600; margin-right: auto; }
table.files { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.files th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12px; padding: 8px 10px; border-bottom: 1px solid var(--line); user-select: none; }
.files th.sortable { cursor: pointer; }
.files td { padding: 7px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.files tr:last-child td { border-bottom: 0; }
.files tbody tr:hover { background: var(--hover); }
.files tbody tr.selected { background: var(--sel); }
.files tbody tr.drop-target { outline: 2px dashed var(--accent); outline-offset: -2px; }
.files .c-check { width: 34px; }
.files .c-size, .files .c-date { color: var(--muted); white-space: nowrap; width: 1%; }
.files .c-act { width: 1%; white-space: nowrap; text-align: right; }
.fname { display: flex; align-items: center; gap: 10px; cursor: pointer; min-width: 0; }
.fname .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fname:hover .nm { color: var(--accent); }
.ficon { width: 30px; height: 30px; border-radius: 7px; display: grid; place-items: center; flex: none; font-size: 15px; background: var(--hover); }
.ficon img { width: 30px; height: 30px; object-fit: cover; border-radius: 7px; }
.ficon.dir { background: #ffe7a6; }
@media (prefers-color-scheme: dark) { .ficon.dir { background: #5a4a1c; } }
.sub { color: var(--muted); font-size: 12px; }
.empty { text-align: center; color: var(--muted); padding: 60px 20px; }
.empty .big { font-size: 42px; margin-bottom: 8px; }

/* ---------- меню, модалки, тосты ---------- */
.ctx {
  position: fixed; z-index: 50; background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: var(--shadow); padding: 5px; min-width: 200px;
}
.ctx button { display: flex; gap: 10px; width: 100%; text-align: left; padding: 7px 10px; border: 0; background: transparent; border-radius: 6px; cursor: pointer; }
.ctx button:hover { background: var(--hover); }
.ctx button.danger { color: var(--danger); }
.ctx hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }

.overlay { position: fixed; inset: 0; background: rgba(10, 15, 25, .45); z-index: 40; display: grid; place-items: center; padding: 16px; }
.modal { background: var(--panel); border-radius: 14px; box-shadow: var(--shadow); width: 100%; max-width: 480px; max-height: 90vh; display: flex; flex-direction: column; }
.modal.wide { max-width: 720px; }
.modal header { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px 6px; font-weight: 600; font-size: 16px; gap: 10px; }
.modal header span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal .body { padding: 6px 18px 12px; overflow: auto; }
.modal footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px 16px; }
.list-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.list-row:last-child { border-bottom: 0; }
.list-row .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.linkbox { display: flex; gap: 6px; margin-top: 4px; }
.linkbox input { font-family: ui-monospace, monospace; font-size: 12px; }
.badge { display: inline-block; padding: 1px 7px; border-radius: 10px; font-size: 11px; background: var(--hover); color: var(--muted); margin-left: 6px; }
.badge.cur { background: var(--accent); color: #fff; }

.picker { border: 1px solid var(--line); border-radius: 8px; max-height: 300px; overflow: auto; }
.picker .row { padding: 8px 10px; cursor: pointer; display: flex; gap: 8px; }
.picker .row:hover { background: var(--hover); }
.picker .row.disabled { opacity: .4; cursor: default; }

.preview { position: fixed; inset: 0; background: rgba(0,0,0,.88); z-index: 45; display: flex; flex-direction: column; }
.preview header { display: flex; align-items: center; gap: 10px; color: #eee; padding: 10px 14px; }
.preview header .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preview header .icon-btn { color: #ddd; }
.preview .stage { flex: 1; display: grid; place-items: center; min-height: 0; padding: 10px; }
.preview .stage img, .preview .stage video { max-width: 100%; max-height: 100%; }
.preview .stage iframe { width: min(1000px, 100%); height: 100%; border: 0; background: #fff; border-radius: 6px; }
.preview .stage pre { background: var(--panel); color: var(--text); padding: 16px; border-radius: 8px; max-width: min(1000px, 100%); max-height: 100%; overflow: auto; white-space: pre-wrap; word-break: break-word; margin: 0; }
.preview .nav-arrow { position: absolute; top: 50%; transform: translateY(-50%); font-size: 30px; color: #fff; background: rgba(255,255,255,.1); border: 0; width: 44px; height: 64px; border-radius: 8px; cursor: pointer; }
.preview .prev { left: 10px; } .preview .next { right: 10px; }

.toasts { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); z-index: 60; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { background: var(--text); color: var(--bg); padding: 9px 16px; border-radius: 8px; box-shadow: var(--shadow); max-width: 90vw; }
.toast.err { background: var(--danger); color: #fff; }

.uploads { position: fixed; right: 16px; bottom: 16px; width: 340px; max-width: calc(100vw - 32px); background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); z-index: 30; }
.uploads header { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; font-weight: 600; border-bottom: 1px solid var(--line); }
.uploads .items { max-height: 260px; overflow: auto; padding: 4px 12px 10px; }
.up-item { padding: 6px 0; font-size: 13px; }
.up-item .nm { display: flex; justify-content: space-between; gap: 8px; }
.up-item .nm span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.up-item.done .bar > div { background: var(--ok); }
.up-item.fail .bar > div { background: var(--danger); }

.dropzone { position: fixed; inset: 0; z-index: 35; background: rgba(47,111,237,.12); border: 3px dashed var(--accent); display: grid; place-items: center; font-size: 22px; font-weight: 600; color: var(--accent); pointer-events: none; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; max-width: 760px; }
.card h2 { margin: 0 0 10px; font-size: 16px; }
.card .row { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; }
.card .row > div { flex: 1; min-width: 160px; }
code.inline { background: var(--hover); padding: 2px 6px; border-radius: 5px; font-size: 13px; word-break: break-all; }
.secret { font-family: ui-monospace, monospace; font-size: 18px; letter-spacing: 1px; padding: 10px; background: var(--hover); border-radius: 8px; text-align: center; margin: 8px 0; user-select: all; }

/* ---------- мобильная вёрстка ---------- */
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 30% 0 0; z-index: 38; transform: translateX(-105%); transition: transform .2s; box-shadow: var(--shadow); }
  .app.menu-open .sidebar { transform: none; }
  .menu-toggle { display: inline-flex; }
  .topbar { padding: 10px 12px; }
  .topbar input.search { width: 100%; order: 5; }
  .content { padding: 12px 10px 80px; }
  .files .c-date, .files th.c-date { display: none; }
  .actions .lbl { display: none; }
}

/* ===================== v2 ===================== */
select, textarea { width: 100%; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); color: inherit; font: inherit; outline: none; }
textarea:focus, select:focus { border-color: var(--accent); }
input[type=date], input[type=time] { width: 100%; padding: 7px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); }
input[type=color] { width: 44px; height: 36px; padding: 2px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); }
.row-inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row-inline input[type=text] { flex: 1; min-width: 140px; }
h4.sect { margin: 18px 0 6px; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
pre.code { background: var(--hover); padding: 10px 12px; border-radius: 8px; overflow: auto; font-size: 13px; }

.sidebar { overflow-y: auto; }
.nav a { padding: 7px 10px; }
.nav-title { font-size: 11px; text-transform: uppercase; color: var(--muted); padding: 14px 10px 4px; letter-spacing: .05em; }
.nav-tags a { display: flex; align-items: center; gap: 10px; padding: 6px 10px; border-radius: 8px; color: var(--text); font-size: 13px; }
.nav-tags a:hover { background: var(--hover); }
.nav-tags a.active { background: var(--sel); color: var(--accent); }
.nav-tags .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; margin: 0 5px; }
.nav-tags .cnt { margin-left: auto; color: var(--muted); font-size: 12px; }

.bell { position: relative; font-size: 18px; }
.bell-count { position: absolute; top: -2px; right: -2px; background: var(--danger); color: #fff; border-radius: 9px; font-size: 10px; padding: 1px 5px; line-height: 1.3; }
.ctx.notif { width: 360px; max-width: calc(100vw - 16px); max-height: 70vh; overflow: auto; padding: 0; }
.notif-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--panel); }
.notif-item { display: block; padding: 10px 12px; border-bottom: 1px solid var(--line); color: var(--text); }
.notif-item:hover { background: var(--hover); }
.notif-item.unread { background: var(--sel); }
.notif-item .nt { font-weight: 600; }

.banner { background: var(--sel); color: var(--accent); padding: 8px 12px; border-radius: var(--radius); margin-bottom: 10px; font-weight: 500; }
.tag { display: inline-block; color: #fff; font-size: 11px; padding: 0 7px; border-radius: 9px; margin-left: 6px; line-height: 18px; vertical-align: 1px; }
.mini { font-size: 12px; }
.icon-btn.star { font-size: 17px; }
.icon-btn.star.on { color: #f5a623; }
.ficon { position: relative; overflow: hidden; }
.ficon .play, .g-tile .play { position: absolute; inset: 0; display: grid; place-items: center; color: #fff; font-size: 12px; text-shadow: 0 0 4px #000; }
.sub.snippet { color: var(--text); opacity: .8; font-style: italic; white-space: normal; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 12px; overflow-x: auto; }
.tab { border: 0; background: none; padding: 8px 12px; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.tab-pane { min-height: 160px; }
table.kv { border-collapse: collapse; width: 100%; }
.kv th { text-align: left; color: var(--muted); font-weight: 500; padding: 6px 12px 6px 0; width: 140px; vertical-align: top; }
.kv td { padding: 6px 0; word-break: break-word; }
.det-thumb { text-align: center; margin-bottom: 12px; }
.det-thumb img { max-width: 100%; max-height: 260px; border-radius: 8px; }
.tag-cloud { display: flex; flex-wrap: wrap; gap: 8px; }
.tag-pick { display: inline-flex; align-items: center; gap: 4px; margin: 0; color: var(--text); border: 1px solid var(--line); border-radius: 20px; padding: 2px 4px 2px 8px; }
.tag-pick .tag { margin: 0; }
.comments { margin-bottom: 10px; }
.comment { padding: 8px 0; border-bottom: 1px solid var(--line); }
.c-head { display: flex; align-items: center; gap: 4px; }
.c-head .icon-btn { margin-left: auto; font-size: 14px; }
.c-body { white-space: pre-wrap; word-break: break-word; margin-top: 2px; }
.act .act-node { font-weight: 500; }

.modal.full { max-width: 1100px; height: 90vh; }
.modal.full .body { display: flex; flex-direction: column; flex: 1; min-height: 0; padding-bottom: 16px; }
.editor-bar { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
textarea.editor { flex: 1; min-height: 300px; resize: none; font: 14px/1.55 ui-monospace, "Cascadia Code", Consolas, monospace; tab-size: 2; }
.md-preview { flex: 1; overflow: auto; padding: 4px 6px; line-height: 1.6; }
.md-preview.light { background: var(--panel); color: var(--text); padding: 20px 28px; border-radius: 8px; max-width: min(900px, 100%); max-height: 100%; }
.md-preview h1 { font-size: 1.6em; margin: .4em 0; } .md-preview h2 { font-size: 1.3em; }
.md-preview pre { background: var(--hover); padding: 10px; border-radius: 6px; overflow: auto; }
.md-preview code { background: var(--hover); padding: 1px 4px; border-radius: 4px; font-size: 90%; }
.md-preview pre code { background: none; padding: 0; }
.md-preview blockquote { border-left: 3px solid var(--line); margin: 0; padding-left: 12px; color: var(--muted); }
.md-preview table { border-collapse: collapse; } .md-preview td, .md-preview th { border: 1px solid var(--line); padding: 4px 8px; }
.md-preview li.task { list-style: none; margin-left: -1.2em; }
.md-preview img { max-width: 100%; }
.qr { display: flex; justify-content: center; margin: 8px auto; width: 230px; background: #fff; padding: 8px; border-radius: 8px; }
.qr svg { width: 100%; height: auto; }
.codes { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; margin: 10px 0; }
.codes code { background: var(--hover); padding: 6px; border-radius: 6px; text-align: center; font-size: 15px; letter-spacing: 1px; }

/* галерея */
.g-month { font-size: 15px; margin: 18px 0 8px; text-transform: capitalize; }
.g-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; }
.g-tile { position: relative; aspect-ratio: 1; background: var(--hover); border-radius: 6px; overflow: hidden; cursor: pointer; }
.g-tile img { width: 100%; height: 100%; object-fit: cover; transition: transform .2s; }
.g-tile:hover img { transform: scale(1.04); }
.g-ph { width: 100%; height: 100%; display: grid; place-items: center; font-size: 36px; }
.g-tile .play { font-size: 26px; }

/* заметки */
.notes { display: grid; grid-template-columns: 260px 1fr; gap: 16px; height: calc(100vh - 120px); }
.notes-list { overflow: auto; }
.note-item { padding: 9px 10px; border-radius: 8px; cursor: pointer; }
.note-item:hover { background: var(--hover); }
.note-item.active { background: var(--sel); }
.note-item .nm { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.note-pane { display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; min-height: 0; }
.note-title { font-size: 16px; }

/* календарь */
.cal-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.cal-head h2 { margin: 0 8px; font-size: 18px; text-transform: capitalize; min-width: 170px; text-align: center; }
.cal-head input[type=search] { width: 260px; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); border-top: 1px solid var(--line); border-left: 1px solid var(--line); background: var(--panel); border-radius: var(--radius); overflow: hidden; }
.cal-dow { padding: 6px; font-size: 12px; color: var(--muted); border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); text-align: center; }
.cal-cell { min-height: 104px; padding: 4px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); overflow: hidden; }
.cal-cell.other { background: var(--bg); color: var(--muted); }
.cal-cell.today .cal-day { background: var(--accent); color: #fff; border-radius: 10px; padding: 0 6px; display: inline-block; }
.cal-day { font-size: 12px; margin-bottom: 3px; }
.cal-ev { font-size: 12px; padding: 1px 5px; margin-bottom: 2px; border-left: 3px solid var(--accent); background: var(--hover); border-radius: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }

/* контакты */
.contacts { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 10px; }
.contact { display: flex; gap: 12px; align-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.contact .nm { font-weight: 600; }
.avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 600; flex: none; }

@media (max-width: 760px) {
  .notes { grid-template-columns: 1fr; height: auto; }
  .note-pane { min-height: 60vh; }
  .cal-cell { min-height: 64px; }
  .cal-ev { font-size: 10px; }
  .g-grid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 3px; }
  .modal.full { height: 100vh; max-height: 100vh; border-radius: 0; }
  .overlay:has(.modal.full) { padding: 0; }
  .c-act .star { display: none; }
}

/* ---------- чат ---------- */
.nav-count { margin-left: auto; background: var(--danger); color: #fff; border-radius: 9px; font-size: 11px; padding: 0 6px; line-height: 18px; min-width: 18px; text-align: center; font-weight: 600; }
.content.talk-content { padding: 0; overflow: hidden; display: flex; }
.talk { display: grid; grid-template-columns: 300px 1fr; flex: 1; min-height: 0; }
.talk-side { border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; background: var(--panel); }
.talk-side-head { display: flex; gap: 8px; padding: 12px; border-bottom: 1px solid var(--line); }
.talk-side-head .btn.primary { flex: 1; justify-content: center; }
.talk-rooms { overflow: auto; flex: 1; }
.talk-item { display: flex; gap: 10px; align-items: center; padding: 10px 12px; color: var(--text); border-bottom: 1px solid var(--line); }
.talk-item:hover { background: var(--hover); }
.talk-item.active { background: var(--sel); }
.talk-item .grow { flex: 1; min-width: 0; }
.talk-item .top, .talk-item .bottom { display: flex; gap: 6px; align-items: center; }
.talk-item .nm { font-weight: 600; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.talk-item .tm { color: var(--muted); font-size: 12px; }
.talk-item .prev { flex: 1; color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.talk-item .nav-count { margin-left: 0; }
.avatar.group { background: var(--hover); font-size: 18px; }
.talk-room { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.talk-head { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--panel); }
.talk-head .grow { flex: 1; min-width: 0; }
.talk-head .nm { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.talk-head .sub { color: var(--muted); font-size: 12px; }
.talk-back { display: none; font-size: 22px; }
.talk-msgs { flex: 1; overflow: auto; padding: 12px 16px; display: flex; flex-direction: column; gap: 2px; }
.talk-more { text-align: center; margin-bottom: 8px; }
.talk-day { align-self: center; color: var(--muted); font-size: 12px; margin: 12px 0 6px; padding: 2px 10px; border-radius: 10px; background: var(--hover); }
.talk-sys { align-self: center; color: var(--muted); font-size: 12px; margin: 6px 0; text-align: center; }
.msg { display: flex; flex-direction: column; align-items: flex-start; margin-top: 8px; max-width: 78%; }
.msg.cont { margin-top: 2px; }
.msg.mine { align-self: flex-end; align-items: flex-end; }
.msg .who { font-size: 12px; color: var(--accent); font-weight: 600; margin: 0 0 2px 10px; }
.msg .bubble { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 7px 10px 5px; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.mine .bubble { background: var(--sel); border-color: transparent; }
.msg .bubble .tm { float: right; margin: 4px 0 0 10px; font-size: 11px; color: var(--muted); }
.talk-compose { display: flex; gap: 8px; align-items: flex-end; padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--panel); }
.talk-compose textarea { flex: 1; resize: none; padding: 9px 12px; border-radius: 18px; border: 1px solid var(--line); background: var(--bg); font: inherit; color: inherit; max-height: 160px; }
.talk-compose .btn { border-radius: 50%; width: 40px; height: 40px; justify-content: center; padding: 0; }
.btn.pulse { animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(47, 111, 237, .25); } }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 8px; }
.chip { display: inline-flex; align-items: center; gap: 2px; background: var(--sel); border-radius: 14px; padding: 2px 4px 2px 10px; }
.chip .icon-btn { width: 22px; height: 22px; font-size: 14px; }
.newchat { display: grid; gap: 10px; }
.btn.big { padding: 14px; gap: 14px; font-size: 22px; text-align: left; white-space: normal; }
.btn.big b { font-size: 14px; }
.btn.big .sub { font-size: 12px; color: var(--muted); }

/* входящий звонок */
.ring { position: fixed; top: 16px; right: 16px; z-index: 60; display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); max-width: calc(100vw - 32px); }
.ring .ring-ico { font-size: 26px; animation: shake 1s infinite; }
.ring .nm { font-weight: 600; }
.ring .sub { color: var(--muted); font-size: 12px; }
@keyframes shake { 0%, 50%, 100% { transform: rotate(0); } 10%, 30% { transform: rotate(-15deg); } 20%, 40% { transform: rotate(15deg); } }

/* окно звонка */
.call { position: fixed; inset: 0; z-index: 55; background: #0d1015; color: #fff; display: flex; flex-direction: column; }
.call-top { display: flex; align-items: center; gap: 6px; padding: 12px 16px; }
.call-top .nm { font-weight: 600; }
.call-top .call-count { color: #9aa3b2; }
.call-top .btn { background: #232a35; border-color: #333c4a; color: #fff; }
.call-grid { flex: 1; min-height: 0; display: grid; gap: 8px; padding: 0 12px; grid-template-columns: 1fr; grid-auto-rows: 1fr; }
.call-grid[data-n="2"] { grid-template-columns: 1fr 1fr; }
.call-grid[data-n="3"], .call-grid[data-n="4"] { grid-template-columns: 1fr 1fr; }
.call-grid[data-n="5"], .call-grid[data-n="6"] { grid-template-columns: repeat(3, 1fr); }
.tile { position: relative; background: #1b212b; border-radius: 12px; overflow: hidden; min-height: 0; }
.tile video { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile.me video { transform: scaleX(-1); }
.tile .label { position: absolute; left: 8px; bottom: 8px; background: rgba(0, 0, 0, .55); padding: 2px 8px; border-radius: 6px; font-size: 13px; }
.tile .label .st { color: #ffb4b4; margin-left: 6px; }
.call-bar { display: flex; justify-content: center; gap: 14px; padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); }
.call-btn { width: 54px; height: 54px; border-radius: 50%; border: 0; background: #2a3240; color: #fff; font-size: 22px; cursor: pointer; }
.call-btn:hover { background: #364154; }
.call-btn.off { background: #f2f4f7; filter: grayscale(1); }
.call-btn.on { background: var(--accent); }
.call-btn.hang { background: #d33a3a; }
.call-btn:disabled { opacity: .35; cursor: default; }
.call-pill { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 56; background: var(--ok); color: #fff; border: 0; border-radius: 20px; padding: 10px 18px; font-weight: 600; box-shadow: var(--shadow); cursor: pointer; }

@media (max-width: 760px) {
  .talk { grid-template-columns: 1fr; }
  .talk.has-room .talk-side { display: none; }
  .talk:not(.has-room) .talk-room { display: none; }
  .talk-back { display: inline-grid; }
  .msg { max-width: 90%; }
  .call-grid[data-n="2"] { grid-template-columns: 1fr; }
  .call-grid[data-n="5"], .call-grid[data-n="6"] { grid-template-columns: 1fr 1fr; }
  .ring { left: 16px; right: 16px; top: 10px; }
}

/* ---------- почта ---------- */
.content.mail-content { padding: 0; overflow: hidden; display: flex; }
.mail { display: grid; grid-template-columns: 220px 360px 1fr; flex: 1; min-height: 0; }
.mail-side { border-right: 1px solid var(--line); background: var(--panel); display: flex; flex-direction: column; min-height: 0; overflow: auto; }
.mail-side-head { display: flex; gap: 6px; padding: 12px; }
.mail-side-head .btn.primary { flex: 1; justify-content: center; }
.mail-acc, .mail-acc-one { margin: 0 12px 8px; padding: 6px 8px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-folders a { display: flex; align-items: center; gap: 8px; padding: 7px 12px; color: var(--text); }
.mail-folders a:hover { background: var(--hover); }
.mail-folders a.active { background: var(--sel); color: var(--accent); font-weight: 600; }
.mail-folders .grow { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-folders .cnt { font-size: 12px; font-weight: 600; color: var(--accent); }
.mail-list { border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.mail-list-head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.mail-list-head input[type=search] { flex: 1 0 100%; padding: 7px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); }
.mail-list-head .sub { color: var(--muted); }
.mail-rows { flex: 1; overflow: auto; }
.mail-row { display: block; padding: 9px 12px; border-bottom: 1px solid var(--line); color: var(--text); }
.mail-row:hover { background: var(--hover); }
.mail-row.active { background: var(--sel); }
.mail-row .top { display: flex; gap: 6px; align-items: center; }
.mail-row .from { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-row .tm { color: var(--muted); font-size: 12px; }
.mail-row .star { color: #e0a800; }
.mail-row .subj { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-row.unread .from, .mail-row.unread .subj { font-weight: 700; color: var(--text); }
.mail-reader { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.mail-actions { display: flex; gap: 6px; flex-wrap: wrap; padding: 8px 12px; border-bottom: 1px solid var(--line); background: var(--panel); }
.mail-actions select { padding: 6px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); }
.mail-actions .lbl { font-size: 13px; }
.mail-head { padding: 12px 16px; border-bottom: 1px solid var(--line); }
.mail-head h2 { margin: 0 0 6px; font-size: 18px; }
.mail-head .sub, .mail-head .tm { color: var(--muted); font-size: 13px; }
.mail-atts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip.att a { color: var(--text); }
.mail-banner { padding: 8px 16px; background: var(--hover); font-size: 13px; }
.mail-frame { flex: 1; width: 100%; border: 0; background: #fff; min-height: 300px; }
.mail-text { flex: 1; overflow: auto; padding: 16px; white-space: pre-wrap; overflow-wrap: anywhere; font-family: inherit; }
.mail-compose-text { width: 100%; margin-top: 10px; resize: vertical; font: inherit; padding: 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); color: inherit; }
.mail-adv .row-inline input[type=number] { width: 90px; }
.mail-back { display: none; font-size: 22px; }

@media (max-width: 1100px) {
  .mail { grid-template-columns: 200px 1fr; }
  .mail-reader { display: none; }
  .mail.has-msg .mail-list { display: none; }
  .mail.has-msg .mail-reader { display: flex; }
  .mail-back { display: inline-grid; }
}
@media (max-width: 760px) {
  .mail { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .mail-side { flex-direction: row; flex-wrap: wrap; align-items: center; border-right: 0; border-bottom: 1px solid var(--line); overflow: visible; }
  .mail-side-head { padding: 8px; }
  .mail-acc, .mail-acc-one { margin: 0 8px; }
  .mail-folders { display: flex; overflow-x: auto; width: 100%; }
  .mail-folders a { white-space: nowrap; }
  .mail.has-msg .mail-side { display: none; }
  .mail.has-msg { grid-template-rows: 1fr; }
  .mail-actions .lbl { display: none; }
}

/* ---------- зашифрованные (E2E) папки ---------- */
.e2e-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.e2e-badge { background: var(--sel); color: var(--accent); font-weight: 600; padding: 4px 10px; border-radius: 12px; }
.e2e-list { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.e2e-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.e2e-row:last-child { border-bottom: 0; }
.e2e-row .ico { font-size: 20px; width: 26px; text-align: center; }
.e2e-row .grow { flex: 1; min-width: 0; color: var(--text); overflow: hidden; text-overflow: ellipsis; }
.e2e-row .sub { color: var(--muted); font-size: 12px; }
.e2e-row.unknown { opacity: .75; }
.e2e-recovery { font-family: ui-monospace, Consolas, monospace; font-size: 15px; letter-spacing: .5px; }
