/* ===== mailer · дизайн в духе macOS / iOS Mail ===== */

/* ---------- токены ---------- */
:root {
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", "Segoe UI", Roboto, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  --bg: #F5F5F7; --panel: #FFFFFF; --panel-rgb: 255,255,255; --sidebar-rgb: 245,245,247;
  --sidebar: rgba(var(--sidebar-rgb), .82); --bar: rgba(255,255,255,.72);
  --fill: rgba(0,0,0,.05); --fill2: rgba(0,0,0,.09); --hover: rgba(0,0,0,.035);
  --line: rgba(0,0,0,.08); --line-strong: rgba(0,0,0,.14);
  --text: #1D1D1F; --muted: #6E6E73; --muted2: #AEAEB2;
  --accent: #007AFF; --accent-rgb: 0,122,255; --accent-text: #FFFFFF; --accent-bg: rgba(var(--accent-rgb), .13);
  --danger: #D70015; --danger-bg: rgba(255,59,48,.12); --ok: #248A3D; --ok-bg: rgba(52,199,89,.14); --warn: #C93400; --warn-bg: rgba(255,149,0,.14);
  --btn-bg: #FFFFFF; --btn-border: rgba(0,0,0,.12); --btn-shadow: 0 1px 1px rgba(0,0,0,.06);
  --shadow: 0 0 0 .5px rgba(0,0,0,.12), 0 10px 30px rgba(0,0,0,.18);
  --blur: saturate(180%) blur(20px);
  --r-sm: 6px; --r: 10px; --r-lg: 12px; --r-xl: 14px;
  --topbar-h: 52px; --sidebar-w: 240px;
  color-scheme: light;
}
html[data-theme="dark"] {
  --bg: #1E1E1E; --panel: #2C2C2E; --panel-rgb: 44,44,46; --sidebar-rgb: 30,30,30;
  --sidebar: rgba(30,30,30,.85); --bar: rgba(30,30,30,.72);
  --fill: rgba(255,255,255,.08); --fill2: rgba(255,255,255,.13); --hover: rgba(255,255,255,.06);
  --line: rgba(255,255,255,.10); --line-strong: rgba(255,255,255,.16);
  --text: #F2F2F7; --muted: #98989D; --muted2: #636366;
  --accent: #0A84FF; --accent-rgb: 10,132,255; --accent-bg: rgba(var(--accent-rgb), .22);
  --danger: #FF453A; --danger-bg: rgba(255,69,58,.16); --ok: #30D158; --ok-bg: rgba(48,209,88,.16); --warn: #FF9F0A; --warn-bg: rgba(255,159,10,.16);
  --btn-bg: #3A3A3C; --btn-border: rgba(255,255,255,.14); --btn-shadow: 0 1px 1px rgba(0,0,0,.3);
  --shadow: 0 0 0 .5px rgba(255,255,255,.12), 0 10px 30px rgba(0,0,0,.55);
  color-scheme: dark;
}
/* акцент по дню недели: цвета macOS (light / dark) */
html[data-palette="1"] { --accent: #007AFF; --accent-rgb: 0,122,255; }
html[data-palette="2"] { --accent: #34C759; --accent-rgb: 52,199,89; }
html[data-palette="3"] { --accent: #AF52DE; --accent-rgb: 175,82,222; }
html[data-palette="4"] { --accent: #30B0C7; --accent-rgb: 48,176,199; }
html[data-palette="5"] { --accent: #FF2D55; --accent-rgb: 255,45,85; }
html[data-palette="6"] { --accent: #FF9500; --accent-rgb: 255,149,0; }
html[data-palette="0"] { --accent: #FF3B30; --accent-rgb: 255,59,48; }
html[data-theme="dark"][data-palette="1"] { --accent: #0A84FF; --accent-rgb: 10,132,255; }
html[data-theme="dark"][data-palette="2"] { --accent: #30D158; --accent-rgb: 48,209,88; }
html[data-theme="dark"][data-palette="3"] { --accent: #BF5AF2; --accent-rgb: 191,90,242; }
html[data-theme="dark"][data-palette="4"] { --accent: #40C8E0; --accent-rgb: 64,200,224; }
html[data-theme="dark"][data-palette="5"] { --accent: #FF375F; --accent-rgb: 255,55,95; }
html[data-theme="dark"][data-palette="6"] { --accent: #FF9F0A; --accent-rgb: 255,159,10; }
html[data-theme="dark"][data-palette="0"] { --accent: #FF453A; --accent-rgb: 255,69,58; }
.swatch[data-hue="1"] { --sw: #007AFF; } .swatch[data-hue="2"] { --sw: #34C759; } .swatch[data-hue="3"] { --sw: #AF52DE; } .swatch[data-hue="4"] { --sw: #30B0C7; }
.swatch[data-hue="5"] { --sw: #FF2D55; } .swatch[data-hue="6"] { --sw: #FF9500; } .swatch[data-hue="0"] { --sw: #FF3B30; }
@supports not (backdrop-filter: blur(1px)) { :root, html[data-theme="dark"] { --bar: var(--bg); --sidebar: rgb(var(--sidebar-rgb)); } }
@media (prefers-reduced-transparency: reduce) { :root, html[data-theme="dark"] { --bar: var(--bg); --sidebar: rgb(var(--sidebar-rgb)); } .sidebar, .topbar, .menu-items { backdrop-filter: none !important; -webkit-backdrop-filter: none !important; } }

/* ---------- база ---------- */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; }
body { font: 13px/1.45 var(--font); -webkit-font-smoothing: antialiased; color: var(--text); background: var(--bg); }
a { color: var(--accent); text-decoration: none; }
dl.meta a:hover, .hint a:hover, table.plain a:hover, .card a:hover { text-decoration: underline; }
::selection { background: rgba(var(--accent-rgb), .3); }
:focus-visible { outline: 3px solid rgba(var(--accent-rgb), .4); outline-offset: 1px; border-radius: var(--r-sm); }
.mono { font-family: var(--mono); font-size: 12px; }
.muted { color: var(--muted); font-weight: 400; }
.nowrap { white-space: nowrap; }
.ellipsis { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hint { color: var(--muted); }
.hint.warn { color: var(--warn); }
.empty { padding: 64px 0; text-align: center; color: var(--muted2); font-size: 15px; }
.ok { color: var(--ok); background: var(--ok-bg); padding: 10px 14px; border-radius: var(--r); font-size: 13px; }
.error { color: var(--danger); }
p.error { background: var(--danger-bg); padding: 10px 14px; border-radius: var(--r); font-size: 13px; }
.ic { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; vertical-align: -4px; flex: none; }
.btn .ic, .ib .ic, .sidebar .ic { width: 16px; height: 16px; }
input[type=checkbox] { accent-color: var(--accent); width: 14px; height: 14px; margin: 0; }
::placeholder { color: var(--muted2); }

/* ---------- каркас ---------- */
.layout { display: flex; min-height: 100vh; }
.main { flex: 1; min-width: 0; padding: 0; }
.content { padding: 0 24px 40px; }
.sidebar { width: var(--sidebar-w); flex: 0 0 var(--sidebar-w); padding: 8px 10px; background: var(--sidebar); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); border-right: 1px solid var(--line); position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; justify-content: space-between; font: 600 12px var(--font); color: var(--muted); text-transform: uppercase; letter-spacing: .05em; padding: 6px 8px 8px; }
.brand .closenav { display: none; }
.sect { font: 600 11px/1 var(--font); color: var(--muted2); text-transform: uppercase; letter-spacing: .04em; padding: 16px 8px 6px; }
.sidebar nav a, .sidebar .domains a { display: flex; align-items: center; gap: 8px; min-height: 28px; padding: 4px 8px; margin: 1px 0; border-radius: var(--r-sm); font-size: 13px; color: var(--text); }
.sidebar nav a:hover, .sidebar .domains a:hover { background: var(--hover); }
.sidebar a.active { background: var(--accent-bg); color: var(--text); font-weight: 500; }
.sidebar nav.folders .ic { color: var(--accent); }
.sidebar nav.tools .ic { color: var(--muted); }
.sidebar .count { margin-left: auto; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.sidebar .count:not(.muted) { font-weight: 600; }
.sidebar .err { color: var(--danger); font-weight: 700; }
.sidebar nav.tools, .sidebar .domains { border-top: 0; margin-top: 0; padding-top: 0; }
.sidebar details summary { display: flex; align-items: center; gap: 4px; cursor: pointer; list-style: none; padding: 2px 4px 2px 0; border-radius: var(--r-sm); }
.sidebar details summary::-webkit-details-marker { display: none; }
.sidebar details summary::before { content: ""; width: 6px; height: 6px; border-right: 1.5px solid var(--muted2); border-bottom: 1.5px solid var(--muted2); transform: rotate(-45deg); margin: 0 6px 0 6px; transition: transform .15s; flex: none; }
.sidebar details[open] summary::before { transform: rotate(45deg); }
.sidebar details summary a.domain { flex: 1; padding: 4px 6px; font-weight: 500; min-height: 0; }
.sidebar details a.account { padding-left: 28px; font-size: 12px; }
.sidebar a.account .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar a.disabled { opacity: .5; }
.empfilter { margin: 4px 0 0; }
.empfilter .chip { width: 100%; height: 28px; justify-content: flex-start; margin-top: 6px; cursor: pointer; }
.empfilter .chip .count { margin-left: auto; }
.backdrop { display: none; }

.topbar { display: flex; align-items: center; gap: 8px; height: var(--topbar-h); padding: 0 20px; position: sticky; top: 0; z-index: 20; background: var(--bar); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); border-bottom: 1px solid var(--line); }
.topbar .menubtn { display: none; }
.search { margin-left: auto; width: 320px; max-width: 40vw; height: 32px; display: flex; align-items: center; gap: 6px; padding: 0 10px; border: 0; border-radius: 999px; background: var(--fill); }
.search:focus-within { background: var(--panel); box-shadow: 0 0 0 3px rgba(var(--accent-rgb), .35); }
.search .ic { width: 15px; height: 15px; color: var(--muted); }
.search input { flex: 1; min-width: 0; padding: 0; border: 0; background: transparent; color: var(--text); font-size: 13px; outline: none; }
.syncbox { display: flex; align-items: center; gap: 4px; color: var(--muted); font-size: 12px; white-space: nowrap; }
.theme-menu summary { display: inline-flex; }
html[data-theme="dark"] .theme-sun { display: none; }
html:not([data-theme="dark"]) .theme-moon { display: none; }

/* ---------- кнопки, чипы ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 28px; padding: 0 12px; font: 500 13px/1 var(--font); border-radius: var(--r-sm); background: var(--btn-bg); border: 1px solid var(--btn-border); box-shadow: var(--btn-shadow); color: var(--text); cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { color: var(--text); }
.btn:active { background: var(--fill2); }
.btn.primary { background: var(--accent); border-color: transparent; color: #fff; font-weight: 600; box-shadow: inset 0 1px 0 rgba(255,255,255,.18), 0 1px 1px rgba(0,0,0,.08); }
.btn.primary:hover { color: #fff; }
.btn.primary:active { filter: brightness(.92); }
.btn.small { height: 24px; padding: 0 9px; font-size: 12px; }
.btn.danger:hover { color: var(--danger); }
.btn:disabled, .btn[disabled] { opacity: .5; cursor: not-allowed; }
.ib { display: inline-flex; align-items: center; gap: 4px; border: 0; background: transparent; color: var(--accent); cursor: pointer; padding: 2px 6px; font-size: 13px; border-radius: 5px; text-decoration: none; }
.ib:hover { background: var(--accent-bg); }
.ib.danger { color: var(--danger); }
.ib.danger:hover { background: var(--danger-bg); }
.ib.icon { width: 30px; height: 30px; justify-content: center; padding: 0; border-radius: var(--r-sm); color: var(--muted); }
.ib.icon:hover { background: var(--fill); color: var(--text); }
form.inl { display: inline; }
.chip { display: inline-flex; align-items: center; gap: 4px; height: 26px; padding: 0 11px; border: 0; border-radius: 999px; background: var(--fill); color: var(--text); font-size: 12px; font-weight: 500; }
.chip:hover { background: var(--fill2); }
.chip.on { background: var(--accent-bg); color: var(--accent); }

/* ---------- меню ---------- */
details.menu { position: relative; display: inline-block; }
details.menu > summary { list-style: none; cursor: pointer; }
details.menu > summary::-webkit-details-marker { display: none; }
.menu-items { position: absolute; right: 0; top: calc(100% + 4px); z-index: 30; min-width: 220px; padding: 5px; border-radius: var(--r); background: rgba(var(--panel-rgb), .86); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); box-shadow: var(--shadow); display: flex; flex-direction: column; text-align: left; }
.menu-items a, .menu-items button { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; padding: 5px 10px; border: 0; background: transparent; color: var(--text); font: 13px var(--font); border-radius: 5px; cursor: pointer; text-decoration: none; white-space: nowrap; }
.menu-items a:hover, .menu-items button:hover { background: var(--accent); color: #fff; }
.menu-items .danger { color: var(--danger); }
.menu-items .ic { color: var(--muted); }
.menu-items .danger .ic { color: var(--danger); }
.menu-items a:hover .ic, .menu-items button:hover .ic { color: #fff; }
.menu-items .on { background: var(--accent-bg); color: var(--accent); }
.menu-title { font: 600 11px var(--font); color: var(--muted2); padding: 6px 10px 2px; }
.swatches { display: flex; gap: 8px; padding: 6px 10px 8px; }
.swatches .swatch { width: 22px; height: 22px; padding: 0; border: 0; border-radius: 50%; background: var(--sw); font-size: 0; color: transparent; flex: none; }
.swatches .swatch:hover { background: var(--sw); }
.swatches .swatch.on { box-shadow: 0 0 0 2px var(--panel), 0 0 0 3.5px var(--sw); }
.bulkmenu .menu-items { right: auto; left: 0; }
table.msgs tr:nth-last-child(-n+3) .menu-items { top: auto; bottom: calc(100% + 4px); }

/* ---------- заголовки страниц ---------- */
.pagehead { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin: 16px 0 12px; }
.pagehead h1 { font-size: 26px; font-weight: 700; letter-spacing: -.02em; margin: 0; }
.pagehead h1 .muted { font-size: 15px; font-weight: 400; }
.filters { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.filters .sep { width: 10px; }
.back { font-size: 13px; }

/* ---------- список писем: трёхстрочные карточки ---------- */
.bulkbar { display: flex; align-items: center; gap: 12px; height: 38px; padding: 6px 12px; border: 1px solid var(--line); border-bottom: 0; border-radius: var(--r-lg) var(--r-lg) 0 0; background: var(--panel); font-size: 12px; color: var(--muted); }
.checkall { display: flex; align-items: center; gap: 6px; }
table.msgs, table.msgs tbody { display: block; }
table.msgs { background: var(--panel); border: 1px solid var(--line); border-radius: 0 0 var(--r-lg) var(--r-lg); }
table.msgs tr { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; grid-template-areas: "cb from date" "cb subj acts"; column-gap: 8px; padding: 9px 12px 9px 0; position: relative; cursor: default; }
table.msgs tr + tr { border-top: 1px solid var(--line); }
table.msgs tr:hover { background: var(--hover); }
table.msgs td { display: block; padding: 0; border: 0; width: auto; }
table.msgs td.cb { grid-area: cb; position: relative; }
table.msgs td.cb input { position: absolute; left: 10px; top: 3px; opacity: 0; }
table.msgs tr:hover td.cb input, table.msgs td.cb input:checked { opacity: 1; }
table.msgs:has(input[name=ids]:checked) td.cb input { opacity: 1; }
table.msgs tr.unread td.cb::before { content: ""; position: absolute; left: 12px; top: 5px; width: 9px; height: 9px; border-radius: 50%; background: var(--accent); }
table.msgs tr:hover.unread td.cb::before, table.msgs tr.unread td.cb input:checked + * { opacity: 0; }
table.msgs td.from { grid-area: from; display: flex; align-items: baseline; gap: 8px; min-width: 0; }
table.msgs td.from > a { flex: 0 1 auto; font-size: 13px; font-weight: 500; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
table.msgs td.from .addr { display: none; }
table.msgs td.from .acct-line { display: block; flex: 1 1 auto; font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
table.msgs td.from .acct-line a { color: inherit; }
table.msgs td.date { grid-area: date; font-size: 12px; color: var(--muted); text-align: right; white-space: nowrap; padding-top: 1px; }
table.msgs td.subj { grid-area: subj; min-width: 0; }
table.msgs td.subj a { display: block; color: var(--text); }
table.msgs td.subj .subjline { display: block; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
table.msgs td.subj .snip { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin: 1px 0 0; font-size: 12px; line-height: 1.35; color: var(--muted); }
table.msgs td.subj .why { font-size: 11px; color: var(--warn); margin-top: 2px; }
table.msgs td.acts { grid-area: acts; align-self: start; display: flex; gap: 2px; opacity: 0; }
table.msgs tr:hover td.acts, table.msgs td.acts details[open] { opacity: 1; }
table.msgs tr.unread td.from > a, table.msgs tr.unread td.subj .subjline { font-weight: 700; }
table.msgs tr.selected, table.msgs tr.selected:hover { background: var(--accent); }
table.msgs tr.selected td, table.msgs tr.selected a, table.msgs tr.selected .acct-line, table.msgs tr.selected td.date, table.msgs tr.selected .why, table.msgs tr.selected .ib.icon { color: #fff; }
table.msgs tr.selected .snip { color: rgba(255,255,255,.85); }
table.msgs tr.selected td.cb::before { background: #fff; }
table.msgs tr.selected .badge { background: rgba(255,255,255,.22); color: #fff; }
table.msgs tr.selected .menu-items, table.msgs tr.selected .menu-items a, table.msgs tr.selected .menu-items button { color: var(--text); }
table.msgs tr.selected .menu-items a:hover, table.msgs tr.selected .menu-items button:hover { color: #fff; }
table.msgs tr.selected .ib.icon:hover { background: rgba(255,255,255,.2); }
.badge { display: inline-block; font-size: 10px; font-weight: 600; border: 0; border-radius: 4px; padding: 1px 5px; margin-left: 6px; vertical-align: middle; background: var(--fill); color: var(--muted); }
.badge.auto { background: var(--warn-bg); color: var(--warn); }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.clip { font-size: 11px; margin-left: 4px; }
.pager { display: flex; gap: 16px; justify-content: center; padding: 14px; color: var(--muted); font-size: 13px; }

/* ---------- панель чтения ---------- */
.panecol { display: none; }
.pane-empty { flex: 1; display: grid; place-items: center; color: var(--muted2); font-size: 15px; }
.pane { flex: 1; width: 100%; border: 0; background: var(--panel); }
.panecol:not(.open) .pane { display: none; }
.panecol.open .pane-empty { display: none; }
@media (min-width: 1200px) {
  html[data-split="1"] body.list-page .content { padding: 0; }
  html[data-split="1"] body.list-page .split { display: grid; grid-template-columns: minmax(360px, 32%) minmax(0, 1fr); height: calc(100vh - var(--topbar-h)); }
  html[data-split="1"] body.list-page .listcol { overflow-y: auto; background: var(--panel); border-right: 1px solid var(--line); }
  html[data-split="1"] body.list-page .panecol { display: flex; flex-direction: column; background: var(--panel); }
  html[data-split="1"] body.list-page .pagehead { margin: 0; padding: 10px 16px 6px; }
  html[data-split="1"] body.list-page .pagehead h1 { font-size: 20px; }
  html[data-split="1"] body.list-page .bulkbar { position: sticky; top: 0; z-index: 5; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; }
  html[data-split="1"] body.list-page table.msgs { border: 0; border-radius: 0; }
  html[data-split="1"] body.list-page .pager { border-top: 1px solid var(--line); }
  html[data-split="1"] body.list-page .empty { padding: 40px 16px; }
}

/* ---------- таблицы, карточки, формы ---------- */
table.plain { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; font-size: 13px; }
table.plain th { padding: 8px 12px; text-align: left; font: 600 11px var(--font); color: var(--muted); border-bottom: 1px solid var(--line); }
table.plain td { padding: 7px 12px; text-align: left; }
table.plain tbody tr:nth-child(even) td { background: var(--hover); }
table.plain tr.disabled td { opacity: .55; }
table.plain tr.haserr td.error { color: var(--danger); }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; margin-bottom: 18px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 16px 18px; margin-top: 14px; }
.card h2 { font-size: 15px; font-weight: 600; margin: 0 0 8px; }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0 14px; }
.inline-form input[type=text], .inline-form input[type=email], .inline-form input[type=password], .inline-form select { height: 28px; min-width: 220px; padding: 0 8px; font-size: 13px; color: var(--text); border: 1px solid var(--line-strong); border-radius: var(--r-sm); background: var(--panel); box-shadow: inset 0 1px 1px rgba(0,0,0,.03); }
.inline-form input:focus, .inline-form select:focus { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(var(--accent-rgb), .3); }

/* ---------- письмо ---------- */
.msgview { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg); }
.msghead { padding: 18px 24px 14px; border-bottom: 1px solid var(--line); }
.msghead h1 { font-size: 20px; font-weight: 600; letter-spacing: -.01em; margin: 0 0 10px; }
.msg-from { display: flex; align-items: center; gap: 12px; margin: 6px 0 10px; }
.avatar { flex: none; width: 36px; height: 36px; border-radius: 50%; background: var(--accent-bg); color: var(--accent); font: 600 15px/36px var(--font); text-align: center; }
.msg-from .who { min-width: 0; }
.msg-from .who b { display: block; font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-from .who .addr { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-from .when { margin-left: auto; font-size: 12px; color: var(--muted); white-space: nowrap; }
dl.meta { display: grid; grid-template-columns: max-content 1fr; gap: 2px 12px; margin: 0 0 12px; font-size: 13px; }
dl.meta dt { color: var(--muted); }
dl.meta dd { margin: 0; overflow-wrap: anywhere; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.primary-actions { margin-bottom: 10px; }
.msgbody { padding: 14px 24px 24px; }
.tabs { display: flex; gap: 8px; margin-bottom: 10px; align-items: center; }
.seg { display: inline-flex; padding: 2px; background: var(--fill); border-radius: 7px; }
.tab { border: 0; background: transparent; padding: 3px 12px; font: 500 12px var(--font); color: var(--text); border-radius: 5px; cursor: pointer; }
.tab.on { background: var(--panel); box-shadow: 0 1px 2px rgba(0,0,0,.12), 0 0 0 .5px rgba(0,0,0,.04); }
html[data-theme="dark"] .tab.on { background: #636366; }
.tabs .imgtoggle { margin-left: auto; }
.htmlview { width: 100%; min-height: 200px; border: 0; border-radius: 8px; background: #fff; }
.textview { white-space: pre-wrap; overflow-wrap: anywhere; font: 14px/1.55 var(--font); margin: 0; }
.ai-out { border: 0; border-radius: var(--r); background: var(--accent-bg); padding: 12px 14px; font-size: 13px; }
.ai-out-text { white-space: pre-wrap; line-height: 1.5; }
.ai-out-actions { display: flex; gap: 6px; margin-top: 8px; }
body.pane-doc { background: var(--panel); }
.pane-doc .content { padding: 0; }
.pane-doc .msgview { border: 0; border-radius: 0; }

/* ---------- история переписки ---------- */
.msgwrap { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; align-items: start; }
.thread { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg); display: flex; flex-direction: column; min-width: 0; }
.thread > summary { list-style: none; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 12px 14px; border-bottom: 1px solid var(--line); cursor: pointer; }
.thread > summary::-webkit-details-marker { display: none; }
.thread > summary .who { min-width: 0; flex: 1; }
.thread > summary .who b { display: block; font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thread > summary .who .addr { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thread-stats { flex-basis: 100%; font-size: 12px; color: var(--muted); }
.thread-body { overflow-y: auto; flex: 1; padding: 8px 12px; display: flex; flex-direction: column; gap: 6px; }
.day { text-align: center; margin: 8px 0 2px; font: 600 11px var(--font); color: var(--muted2); text-transform: uppercase; letter-spacing: .04em; }
.bubble { display: flex; flex-direction: column; gap: 2px; max-width: 86%; padding: 8px 11px; border-radius: 14px; font-size: 12px; color: var(--text); text-decoration: none; }
.bubble.them { align-self: flex-start; background: var(--fill); border-bottom-left-radius: 4px; }
.bubble.me { align-self: flex-end; background: var(--accent-bg); border-bottom-right-radius: 4px; }
.bubble:hover { background: var(--fill2); text-decoration: none; }
.bubble.me:hover { background: rgba(var(--accent-rgb), .24); }
.bubble.current { box-shadow: 0 0 0 2px var(--accent); }
.b-subj { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.b-snip { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; color: var(--muted); }
.b-meta { font-size: 11px; color: var(--muted2); }
.thread-empty { color: var(--muted2); text-align: center; padding: 24px 8px; font-size: 13px; }
.thread-foot { padding: 10px 12px; border-top: 1px solid var(--line); }
@media (min-width: 760px) {
  .msgwrap.has-thread { grid-template-columns: minmax(0, 1fr) 300px; }
  .thread { position: sticky; top: calc(var(--topbar-h) + 12px); max-height: calc(100vh - var(--topbar-h) - 24px); overflow: hidden; }
  /* <details> не везде ведёт себя как flex-контейнер, поэтому высота ленты задаётся явно, а точнее её уточняет скрипт */
  .thread-body { max-height: calc(100vh - var(--topbar-h) - 24px - 140px); }
  .thread > summary { pointer-events: none; }
  .pane-doc .thread { top: 0; max-height: 100vh; border: 0; border-left: 1px solid var(--line); border-radius: 0; }
  .pane-doc .thread-body { max-height: calc(100vh - 140px); }
  .pane-doc .msgwrap { gap: 0; }
}

/* ---------- очередь поддержки ---------- */
.queue { display: flex; flex-direction: column; gap: 12px; max-width: 900px; }
.qcard { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 14px 16px; }
.qhead { display: flex; align-items: center; gap: 10px; }
.qhead .who { min-width: 0; flex: 1; }
.qhead .who b a { color: var(--text); }
.qhead .who .addr { font-size: 12px; color: var(--muted); }
.qage { font-size: 12px; color: var(--muted); white-space: nowrap; }
.qage.old { color: var(--warn); font-weight: 600; }
.qsubj { margin-top: 8px; font-weight: 600; }
.qsubj a { color: var(--text); }
.qsnip { color: var(--muted); font-size: 12px; margin-top: 2px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.qdraft { margin-top: 10px; padding: 10px 12px; border-radius: var(--r); background: var(--accent-bg); font-size: 13px; }
.qdraft.error { background: var(--danger-bg); }
.qdraft-label { display: flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 600; color: var(--accent); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 4px; }
.qdraft-text { white-space: pre-wrap; line-height: 1.5; max-height: 220px; overflow: auto; }
.qactions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.draft-box { margin-bottom: 10px; }

/* ---------- композер ---------- */
.compose { max-width: 860px; }
.compose-form { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 4px 20px 16px; display: flex; flex-direction: column; gap: 0; }
.compose-form .field { display: grid; grid-template-columns: 72px 1fr auto; gap: 8px; align-items: center; padding: 7px 0; border-bottom: 1px solid var(--line); }
.compose-form .field label { font-size: 13px; color: var(--muted); }
.compose-form input[type=text], .compose-form select { border: 0; background: transparent; padding: 3px 0; font: 14px var(--font); color: var(--text); outline: 0; border-radius: 0; width: 100%; }
.compose-form .from-line { font: 14px var(--font); padding: 3px 0; }
.ai-bar { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 12px; padding: 6px 8px; border: 0; border-radius: 8px; background: var(--fill); }
.ai-label { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; color: var(--accent); margin-right: 4px; }
.ai-bar select { height: 24px; padding: 0 8px; font: 12px var(--font); color: var(--text); border: 0; border-radius: 6px; background: var(--btn-bg); box-shadow: var(--btn-shadow); }
.ai-status { color: var(--muted); font-size: 12px; margin-left: auto; }
.ai-out + textarea { margin-top: 10px; }
.compose-form textarea { width: 100%; border: 0; padding: 14px 0; min-height: 300px; resize: vertical; font: 14px/1.55 var(--font); color: var(--text); background: transparent; outline: 0; border-radius: 0; }
.quote-opt { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); padding: 4px 0 10px; }
.send-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding-top: 12px; border-top: 1px solid var(--line); }
.send-bar .hint { font-size: 12px; }
.orig { margin-top: 14px; color: var(--muted); }
.orig summary { cursor: pointer; }
.orig .textview { margin-top: 8px; padding: 12px 14px; border: 0; border-radius: var(--r); background: var(--bg); color: var(--text); }

/* ---------- телефон ---------- */
@media (max-width: 900px) {
  .layout { display: block; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: min(300px, 86vw); height: 100vh; z-index: 50; transform: translateX(-102%); transition: transform .2s ease; box-shadow: var(--shadow); background: rgba(var(--sidebar-rgb), .92); }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .backdrop { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 40; }
  .brand .closenav { display: inline-flex; }
  .topbar .menubtn { display: inline-flex; }
  .topbar { padding: 0 8px; gap: 6px; }
  .search { width: auto; flex: 1; max-width: none; margin-left: 0; }
  .topcompose span { display: none; }
  .topcompose { padding: 0 9px; }
  .syncstate { display: none; }
  .content { padding: 0 12px 30px; }
  .pagehead h1 { font-size: 22px; }
  table.msgs td.cb input, table.msgs td.acts { opacity: 1; }
  table.msgs tr.unread td.cb input { opacity: 0; }
  table.msgs td.subj .subjline { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  .menu-items { position: fixed; left: 8px; right: 8px; bottom: 8px; top: auto; min-width: 0; border-radius: var(--r-xl); padding: 6px; background: rgba(var(--panel-rgb), .92); max-height: 70vh; overflow-y: auto; }
  .menu-items a, .menu-items button { padding: 12px 14px; font-size: 16px; border-radius: 8px; white-space: normal; }
  table.msgs tr:nth-last-child(-n+3) .menu-items { top: auto; bottom: 8px; }
  .topbar .menu-items { position: absolute; left: auto; right: 0; top: calc(100% + 6px); bottom: auto; width: min(320px, calc(100vw - 16px)); max-height: none; }
  .compose-form .field { grid-template-columns: 1fr; gap: 4px; }
  .compose-form { padding: 4px 12px 12px; }
  .compose-form input, .compose-form textarea, .compose-form select, .inline-form input, .inline-form select { font-size: 16px; }
  .send-bar { position: sticky; bottom: 0; background: var(--panel); padding: 10px 0 4px; }
  .send-bar .hint { display: none; }
  dl.meta { grid-template-columns: 1fr; gap: 0; }
  dl.meta dt { margin-top: 6px; }
  .msghead, .msgbody { padding: 12px; }
  .atts { margin: 0 12px; }
  .loga { margin: 10px 12px 4px; }
  .msg-from .when { display: none; }
  .ellipsis { max-width: 160px; }
  .cards { grid-template-columns: 1fr; }
}

/* вложения */
.atts { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px 0 4px; margin: 0 24px; }
.atts.muted { font-size: 12px; color: var(--muted); }
.att { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; padding: 6px 10px; border-radius: 8px; background: var(--fill); color: var(--text); text-decoration: none; font-size: 13px; }
.att:hover { background: var(--fill2); }
.att .ic { flex: none; color: var(--accent); }
.att-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 260px; }
.att-size { color: var(--muted); font-size: 12px; }
.att-inline { width: 100%; font-size: 12px; color: var(--muted); }
.att-inline summary { cursor: pointer; }
.att-inline .att { margin: 6px 6px 0 0; }

/* анализ лога */
.loga { margin: 10px 24px 4px; padding: 12px 14px; border-radius: var(--r); background: var(--accent-bg); font-size: 13px; }
.loga-text { white-space: pre-wrap; line-height: 1.5; margin-bottom: 8px; }
.loga-raw { margin: 6px 0 10px; font-size: 12px; color: var(--muted); }
.loga-raw summary { cursor: pointer; }
.loga-raw pre { white-space: pre-wrap; max-height: 360px; overflow: auto; margin: 6px 0 0; font: 11.5px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--text); }
.qgist { margin-top: 6px; font-size: 12.5px; color: var(--accent); display: flex; gap: 6px; align-items: flex-start; }
.qgist .ic { flex: none; margin-top: 2px; }

/* плашка отмены отправки */
.sendbar { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 60; display: flex; flex-direction: column; gap: 8px; width: min(520px, calc(100vw - 32px)); }
.sendbar-item { position: relative; display: flex; align-items: center; gap: 12px; padding: 12px 14px 14px; border-radius: 12px; background: var(--panel); color: var(--text); box-shadow: 0 8px 30px rgba(0,0,0,.18); border: 1px solid var(--line); font-size: 13px; overflow: hidden; }
.sendbar-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sendbar-bar { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--fill); }
.sendbar-bar i { display: block; height: 100%; width: 100%; background: var(--accent); transition: width .25s linear; }

.att-text { padding: 6px 8px; color: var(--accent); background: transparent; }

/* избранное и напоминания */
.badge.star { background: rgba(255, 159, 10, .18); color: #B25E00; }
html[data-theme="dark"] .badge.star { color: #FFB340; }
.count.due { background: rgba(255, 159, 10, .25); color: #B25E00; }
.starbar { margin-top: 8px; align-items: center; }
.menu-date { display: flex; gap: 6px; align-items: center; padding: 6px 10px; }
.menu-date input { height: 26px; border: 0; border-radius: 6px; padding: 0 6px; font: 12px var(--font); color: var(--text); background: var(--btn-bg); box-shadow: var(--btn-shadow); }
.menu-date button { padding: 4px 8px; font-size: 12px; }

/* вход и уведомления */
body.login-page .sidebar, body.login-page .topbar, body.login-page .sendbar { display: none !important; }
body.login-page .content { padding: 0; }
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(360px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 28px 24px; text-align: center; box-shadow: 0 10px 40px rgba(0,0,0,.08); }
.login-card h1 { font-size: 22px; margin: 10px 0 18px; }
.login-card form { display: flex; flex-direction: column; gap: 10px; }
.login-card input { height: 40px; border: 1px solid var(--line); border-radius: 10px; padding: 0 12px; font: 16px var(--font); color: var(--text); background: var(--bg); }
.login-logo img { border-radius: 14px; }
.menu-note { padding: 4px 12px 8px; font-size: 11.5px; color: var(--muted); }
