/* Почта Domus Regia — «тихая роскошь»: тёплая слоновая кость, тёмно-синий, золото; Cormorant Garamond + Onest, как на сайте.
   Светлая и тёмная тема (как в системе или по выбору). Без внешних ресурсов и инлайн-стилей (их запрещает CSP). */
@font-face { font-family: Onest; src: url(/fonts/onest-cyrillic.woff2) format('woff2'); font-weight: 100 900; font-display: swap; unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: Onest; src: url(/fonts/onest-latin.woff2) format('woff2'); font-weight: 100 900; font-display: swap; unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: Cormorant; src: url(/fonts/cormorant-600-cyrillic.woff2) format('woff2'); font-weight: 600; font-display: swap; unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: Cormorant; src: url(/fonts/cormorant-600-latin.woff2) format('woff2'); font-weight: 600; font-display: swap; unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

:root {
  --bg: #efebe3; --panel: #fbfaf7; --panel2: #f5f2ec; --raise: #ffffff; --hover: #f1ede5; --sel: #ebe4d6;
  --ink: #17181c; --ink2: #50525a; --ink3: #8b8c93; --line: #e6e0d5; --line2: #d9d1c2;
  --navy: #1d2a44; --navy2: #2b3c5e; --on-navy: #f4f1ea; --navy-soft: #e7ebf3;
  --gold: #a47e3b; --gold2: #8a6830; --gold-soft: #f4ead6; --gold-line: #d8c08f;
  --accent: var(--navy); --on-accent: #fff;
  --danger: #b0372d; --danger-soft: #f8e5e2; --ok: #3d7050; --ok-soft: #e1eee4;
  --shadow: 0 1px 2px rgba(26, 24, 20, .05), 0 8px 24px -12px rgba(26, 24, 20, .18);
  --shadow-lg: 0 30px 80px -20px rgba(15, 20, 35, .45);
  --r: 14px; --r-sm: 9px;
  --side: #1b2640; --side-ink: #e9e6df; --side-ink2: #a3abbd; --side-hover: rgba(255,255,255,.06); --side-sel: rgba(212,182,120,.14);
  --ease: cubic-bezier(.2,.7,.2,1);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    --bg: #0c1018; --panel: #131925; --panel2: #18202e; --raise: #1c2433; --hover: #1d2635; --sel: #253048;
    --ink: #ece9e2; --ink2: #b4b5bb; --ink3: #7d8291; --line: #263043; --line2: #324058;
    --navy: #9fb4dc; --navy2: #bccbe8; --on-navy: #0c1018; --navy-soft: #1f2a40;
    --gold: #d2b06d; --gold2: #e0c48c; --gold-soft: #2a2416; --gold-line: #6b5a35;
    --accent: #c9ab6c; --on-accent: #12151c;
    --danger: #ef7d70; --danger-soft: #3a1f1d; --ok: #84c29a; --ok-soft: #1b3024;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 10px 30px -14px rgba(0,0,0,.6);
    --side: #0a0e15; --side-hover: rgba(255,255,255,.05);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0c1018; --panel: #131925; --panel2: #18202e; --raise: #1c2433; --hover: #1d2635; --sel: #253048;
  --ink: #ece9e2; --ink2: #b4b5bb; --ink3: #7d8291; --line: #263043; --line2: #324058;
  --navy: #9fb4dc; --navy2: #bccbe8; --on-navy: #0c1018; --navy-soft: #1f2a40;
  --gold: #d2b06d; --gold2: #e0c48c; --gold-soft: #2a2416; --gold-line: #6b5a35;
  --accent: #c9ab6c; --on-accent: #12151c;
  --danger: #ef7d70; --danger-soft: #3a1f1d; --ok: #84c29a; --ok-soft: #1b3024;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 10px 30px -14px rgba(0,0,0,.6);
  --side: #0a0e15; --side-hover: rgba(255,255,255,.05);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--ink); font: 400 14.5px/1.5 Onest, system-ui, sans-serif; -webkit-font-smoothing: antialiased; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3 { font-family: Cormorant, Georgia, serif; font-weight: 600; line-height: 1.1; margin: 0; letter-spacing: .005em; }
p { margin: 0; }
a { color: inherit; }
hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.sprite { display: none; }
.ic { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.muted { color: var(--ink2); }
.small { font-size: 12.5px; }
.grow { flex: 1; }
kbd { font: 500 11px ui-monospace, Consolas, monospace; padding: 1px 6px; border: 1px solid var(--line2); border-bottom-width: 2px; border-radius: 5px; color: var(--ink2); background: var(--panel); }

/* знак */
.wordmark { font: 600 17px/1 Cormorant, Georgia, serif; letter-spacing: .22em; color: #f4f1ea; display: inline-flex; flex-direction: column; gap: 5px; white-space: nowrap; }
.wordmark small { font: 700 7.5px/1 Onest, sans-serif; letter-spacing: .58em; color: #d4b678; }
.wordmark--sm { font-size: 14px; }
.wordmark--dark { color: var(--ink); }
.wordmark--dark small { color: var(--gold); }

/* кнопки и поля */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid transparent; background: none; padding: 9px 16px; font-size: 13.5px; font-weight: 600; line-height: 1.2; white-space: nowrap; text-decoration: none; border-radius: var(--r-sm); transition: background .2s, color .2s, border-color .2s, transform .12s, box-shadow .2s; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: default; }
.btn .ic { width: 17px; height: 17px; }
.btn--primary { background: var(--accent); color: var(--on-accent); box-shadow: 0 1px 0 rgba(255,255,255,.08) inset, 0 6px 16px -8px rgba(29,42,68,.6); }
.btn--primary:hover:not(:disabled) { filter: brightness(1.12); }
.btn--gold { background: linear-gradient(180deg, #b48d46, #9a763a); color: #fff; box-shadow: 0 6px 18px -8px rgba(154,118,58,.8); }
.btn--gold:hover:not(:disabled) { filter: brightness(1.07); }
.btn--ghost { border-color: var(--line2); background: var(--raise); }
.btn--ghost:hover:not(:disabled) { border-color: var(--ink3); }
.btn--danger { border-color: color-mix(in srgb, var(--danger) 45%, transparent); color: var(--danger); background: transparent; }
.btn--danger:hover:not(:disabled) { background: var(--danger); color: #fff; }
.btn--key { background: var(--raise); border-color: var(--line2); color: var(--ink); padding: 12px; font-size: 14.5px; }
.btn--key:hover { border-color: var(--gold); }
.btn--key .ic { width: 22px; height: 22px; color: var(--gold); }
.btn--lg { padding: 13px 18px; font-size: 15px; }
.btn--sm { padding: 7px 12px; font-size: 13px; }
.btn--block { width: 100%; }
.iconbtn { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border: 0; border-radius: var(--r-sm); background: none; color: var(--ink2); text-decoration: none; flex: none; transition: background .15s, color .15s; }
.iconbtn:hover { background: var(--hover); color: var(--ink); }
.iconbtn.is-on { color: var(--gold); }
.iconbtn.is-on .ic { fill: var(--gold); }
.iconbtn--light { color: rgba(255,255,255,.75); }
.iconbtn--light:hover { background: rgba(255,255,255,.12); color: #fff; }
.link { background: none; border: 0; padding: 0; color: var(--gold2); font-weight: 500; cursor: pointer; text-decoration: none; }
.link:hover { text-decoration: underline; }
.link--sm { font-size: 12.5px; }
.link--center { align-self: center; color: var(--ink2); }
.error { color: var(--danger); font-size: 13px; }
.ok { color: var(--ok); font-size: 13px; background: var(--ok-soft); padding: 10px 12px; border-radius: var(--r-sm); }
.input, .fld input, .fld select, .fld textarea, select.input { width: 100%; border: 1px solid var(--line2); background: var(--raise); padding: 10px 12px; font-size: 14.5px; border-radius: var(--r-sm); outline: none; transition: border-color .15s, box-shadow .15s; min-width: 0; }
.input:focus, .fld input:focus, .fld select:focus, .fld textarea:focus { border-color: var(--gold); box-shadow: 0 0 0 3px color-mix(in srgb, var(--gold) 18%, transparent); }
.fld textarea { resize: vertical; line-height: 1.55; }
.fld { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 500; color: var(--ink2); }
.fld small, .fld__label small { font-weight: 400; color: var(--ink3); }
.fld__label { font-size: 13px; font-weight: 500; color: var(--ink2); }
.fld__addr { display: flex; }
.fld__addr input { border-radius: var(--r-sm) 0 0 var(--r-sm); }
.fld__addr > span { display: flex; align-items: center; padding: 0 12px; border: 1px solid var(--line2); border-left: 0; border-radius: 0 var(--r-sm) var(--r-sm) 0; background: var(--panel2); color: var(--ink2); font-weight: 400; white-space: nowrap; }
.fld__pw { position: relative; display: block; }
.fld__pw input { padding-right: 86px; }
.eye { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); border: 0; background: none; color: var(--ink3); font-size: 12px; padding: 6px 8px; border-radius: 6px; }
.eye:hover { color: var(--ink); background: var(--hover); }
.check { display: flex; align-items: flex-start; gap: 9px; font-size: 13.5px; color: var(--ink2); cursor: pointer; }
.check--sm { font-size: 12.5px; align-items: center; }
input[type=checkbox], input[type=radio] { accent-color: var(--gold); width: 16px; height: 16px; margin: 2px 0 0; flex: none; }
.switch { display: flex; align-items: center; gap: 12px; font-size: 14px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch__ui { width: 40px; height: 23px; border-radius: 12px; background: var(--line2); position: relative; flex: none; transition: background .2s; }
.switch__ui::after { content: ''; position: absolute; top: 3px; left: 3px; width: 17px; height: 17px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s var(--ease); }
.switch input:checked + .switch__ui { background: var(--gold); }
.switch input:checked + .switch__ui::after { transform: translateX(17px); }
.switch input:focus-visible + .switch__ui { outline: 2px solid var(--gold); outline-offset: 2px; }
.seg { display: inline-flex; padding: 3px; gap: 3px; border-radius: 11px; background: var(--panel2); border: 1px solid var(--line); }
.seg button, .seg label span { display: flex; align-items: center; gap: 7px; justify-content: center; border: 0; background: none; padding: 7px 14px; border-radius: 8px; font-size: 13.5px; color: var(--ink2); cursor: pointer; }
.seg label { flex: 1; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg button.is-on, .seg input:checked + span { background: var(--raise); color: var(--ink); box-shadow: var(--shadow); font-weight: 600; }
.seg--block { display: flex; }
.code { font: 500 13px/1.4 ui-monospace, Consolas, monospace; background: var(--panel2); border: 1px solid var(--line); padding: 7px 10px; border-radius: 7px; letter-spacing: .06em; user-select: all; overflow-wrap: anywhere; }
.code--big { font-size: 17px; padding: 9px 13px; }
.inline { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.inline .input { width: auto; flex: 1; min-width: 160px; }
.input--code { max-width: 140px; letter-spacing: .3em; text-align: center; font-family: ui-monospace, Consolas, monospace; }
.stack { display: flex; flex-direction: column; gap: 8px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* ═════════ вход ═════════ */
.auth { min-height: 100%; display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(400px, 1fr); background: var(--panel); }
.auth__art { position: relative; display: flex; flex-direction: column; justify-content: space-between; padding: 44px 52px; color: #f4f1ea; background: #1b2640 url(/login.webp) center / cover no-repeat; isolation: isolate; overflow: hidden; }
.auth__art::before { content: ''; position: absolute; inset: 0; z-index: -1; background: linear-gradient(180deg, rgba(13,18,30,.55) 0%, rgba(13,18,30,.05) 40%, rgba(13,18,30,.78) 100%); }
.auth__brand { display: flex; align-items: center; gap: 14px; }
.auth__quote { max-width: 520px; animation: rise .9s var(--ease) .1s both; }
.auth__eyebrow { font-size: 11px; font-weight: 700; letter-spacing: .32em; text-transform: uppercase; color: #d4b678; margin-bottom: 14px; }
.auth__big { font: 600 clamp(28px, 3.1vw, 42px)/1.12 Cormorant, Georgia, serif; text-wrap: balance; }
.auth__big em { color: #e0c48c; }
.auth__panel { display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 22px; padding: 40px 28px; }
.auth__mobile-brand { display: none; align-items: center; gap: 12px; }
.auth__view { width: min(380px, 100%); display: flex; flex-direction: column; gap: 16px; animation: rise .5s var(--ease) both; }
.auth__view h1 { font-size: 40px; color: var(--ink); }
.auth__view .muted { margin-top: -8px; }
.auth__row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.auth__foot { font-size: 12px; color: var(--ink3); text-align: center; }
.or { display: flex; align-items: center; gap: 12px; font-size: 12px; color: var(--ink3); }
.or::before, .or::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.code-input { text-align: center; letter-spacing: .6em; font: 500 26px ui-monospace, Consolas, monospace; padding: 14px; border: 1px solid var(--line2); border-radius: var(--r); background: var(--raise); outline: none; }
.code-input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px color-mix(in srgb, var(--gold) 18%, transparent); }
.meter { height: 4px; border-radius: 2px; background: var(--line); overflow: hidden; margin-top: -8px; }
.meter i { display: block; height: 100%; width: 0; background: var(--danger); transition: width .25s, background .25s; }
.meter i.m2 { background: var(--gold); }
.meter i.m3 { background: var(--ok); }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } }

/* ═════════ каркас ═════════ */
.app { height: 100dvh; display: grid; grid-template-columns: 264px minmax(330px, 410px) minmax(0, 1fr); gap: 10px; padding: 10px 10px 10px 0; animation: fade .35s ease both; }
@keyframes fade { from { opacity: 0; } }

.side { background: var(--side); color: var(--side-ink); display: flex; flex-direction: column; gap: 6px; padding: 18px 14px 12px; min-height: 0; overflow-y: auto; }
.side__top { display: flex; align-items: center; justify-content: space-between; padding: 0 6px 10px; }
.side__brand { display: flex; align-items: center; gap: 11px; }
.side__close { display: none; color: var(--side-ink2); }
.side__compose { padding: 12px; margin-bottom: 10px; }
.side__compose kbd { margin-left: auto; border-color: rgba(255,255,255,.25); background: transparent; color: rgba(255,255,255,.75); }
.side__label { font-size: 10.5px; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; color: var(--side-ink2); padding: 10px 10px 4px; opacity: .8; }
.boxes, .folders { display: flex; flex-direction: column; gap: 1px; }
.boxes button, .folders button { display: flex; align-items: center; gap: 11px; background: none; border: 0; border-radius: 9px; color: var(--side-ink2); padding: 8px 10px; text-align: left; transition: background .15s, color .15s; }
.boxes button:hover, .folders button:hover { background: var(--side-hover); color: var(--side-ink); }
.boxes button.is-on, .folders button.is-on { background: var(--side-sel); color: #f0dcae; }
.folders button span { flex: 1; }
.boxes .avatar { width: 28px; height: 28px; font-size: 11px; }
.boxes__label { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.boxes__name { font-size: 13.5px; font-weight: 600; color: var(--side-ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.boxes__addr { font-size: 11.5px; opacity: .75; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.boxes b, .folders b { font: 600 11px/1 Onest, sans-serif; color: #1b2640; background: #d4b678; padding: 4px 7px; min-width: 22px; text-align: center; border-radius: 10px; }
.folders b.muted-b { background: rgba(255,255,255,.1); color: var(--side-ink2); }
.folders b:empty, .boxes b:empty { display: none; }
.side__ar { display: flex; align-items: center; gap: 8px; margin: 10px 4px 0; padding: 9px 11px; border-radius: 10px; background: rgba(212,182,120,.12); color: #e7cf9d; font-size: 12.5px; }
.side__ar span { flex: 1; }
.side__ar .link { color: #f0dcae; font-size: 12px; }
.side__foot { position: relative; margin-top: auto; padding-top: 12px; }
.me { display: flex; align-items: center; gap: 10px; width: 100%; border: 0; background: none; color: var(--side-ink); padding: 8px; border-radius: 11px; text-align: left; }
.me:hover { background: var(--side-hover); }
.me__text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.me__text b { font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me__text small { font-size: 11.5px; color: var(--side-ink2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me .ic { color: var(--side-ink2); }
.menu { position: absolute; left: 0; right: 0; bottom: calc(100% + 6px); z-index: 30; background: var(--raise); color: var(--ink); border: 1px solid var(--line); border-radius: 13px; box-shadow: var(--shadow-lg); padding: 6px; display: flex; flex-direction: column; animation: rise .18s var(--ease) both; }
.menu button { display: flex; align-items: center; gap: 11px; border: 0; background: none; padding: 9px 10px; border-radius: 8px; text-align: left; font-size: 13.5px; }
.menu button:hover { background: var(--hover); }
.menu .ic { color: var(--ink2); }
.scrim { position: fixed; inset: 0; background: rgba(10,14,22,.5); z-index: 40; }

/* панели */
.list, .read { background: var(--panel); border-radius: var(--r); box-shadow: var(--shadow); min-height: 0; }
.list { display: flex; flex-direction: column; overflow-y: auto; }
.list__head { position: sticky; top: 0; z-index: 2; background: color-mix(in srgb, var(--panel) 92%, transparent); backdrop-filter: blur(8px); padding: 16px 16px 10px; display: flex; flex-direction: column; gap: 11px; border-bottom: 1px solid var(--line); }
.list__bar { display: flex; align-items: center; gap: 4px; }
.list__menu { display: none; }
.list__title { flex: 1; min-width: 0; }
.list__title h2 { font-size: 30px; color: var(--ink); }
.list__title p { font-size: 12px; color: var(--gold2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list__title p:empty { display: none; }
.search { display: flex; align-items: center; gap: 9px; border: 1px solid var(--line); background: var(--panel2); padding: 0 10px 0 12px; border-radius: 11px; color: var(--ink3); transition: border-color .15s, background .15s; }
.search:focus-within { border-color: var(--gold); background: var(--raise); }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; padding: 9px 0; color: var(--ink); }
.search--card { background: var(--raise); }
.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.chips button { border: 1px solid var(--line); background: transparent; padding: 4px 12px; font-size: 12.5px; white-space: nowrap; color: var(--ink2); border-radius: 20px; transition: all .15s; }
.chips button:hover { border-color: var(--ink3); color: var(--ink); }
.chips button.is-on { background: var(--ink); border-color: var(--ink); color: var(--panel); }
.bulk { display: flex; align-items: center; gap: 2px; background: var(--gold-soft); padding: 4px 8px; border-radius: 10px; }
.bulk button { display: inline-flex; padding: 7px; border: 0; background: none; color: var(--ink); border-radius: 7px; }
.bulk button:hover { background: rgba(0,0,0,.06); }
.bulk .check { margin-right: auto; }

.items { list-style: none; margin: 0; padding: 6px; }
.row { position: relative; display: grid; grid-template-columns: 38px minmax(0, 1fr); gap: 12px; padding: 12px 12px 12px 10px; border-radius: 12px; cursor: pointer; transition: background .12s; animation: rowin .25s var(--ease) both; }
@keyframes rowin { from { opacity: 0; transform: translateY(3px); } }
.row + .row, li + li .row { margin-top: 1px; }
.row:hover { background: var(--hover); }
.row.is-on { background: var(--sel); }
.row__left { position: relative; width: 38px; height: 38px; }
.row__left input { position: absolute; inset: 11px; opacity: 0; }
.row:hover .row__left input, .row__left input:checked, .has-selection .row__left input { opacity: 1; z-index: 1; }
.row:hover .avatar, .has-selection .row .avatar { opacity: 0; }
.avatar { display: flex; align-items: center; justify-content: center; width: 38px; height: 38px; border-radius: 50%; font: 600 13px Onest, sans-serif; color: #fff; text-transform: uppercase; flex: none; transition: opacity .15s; letter-spacing: .02em; }
.avatar--lg { width: 46px; height: 46px; font-size: 16px; }
.avatar--sm { width: 28px; height: 28px; font-size: 11px; }
.a0 { background: #26365a; } .a1 { background: #a47e3b; } .a2 { background: #4d6079; } .a3 { background: #85583a; } .a4 { background: #3b6a62; } .a5 { background: #6d5374; }
.row__top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; color: var(--ink2); }
.when { flex: none; font-size: 11.5px; color: var(--ink3); }
.subj, .snip, .by { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.subj { font-size: 13.5px; color: var(--ink); margin-top: 1px; }
.snip { color: var(--ink3); font-size: 12.5px; padding-right: 22px; }
.by { color: var(--gold2); font-size: 11.5px; }
.unread .who, .unread .subj { font-weight: 650; color: var(--ink); }
.unread .when { color: var(--gold2); font-weight: 650; }
.unread::before { content: ''; position: absolute; left: 3px; top: 50%; width: 6px; height: 6px; margin-top: -3px; border-radius: 50%; background: var(--gold); }
.warnmark { color: var(--danger); font-weight: 700; margin-right: 4px; }
.clip { color: var(--ink3); margin-left: 5px; display: inline-flex; vertical-align: -3px; }
.clip .ic { width: 14px; height: 14px; }
.row__star { position: absolute; right: 8px; bottom: 8px; border: 0; background: none; padding: 3px; color: var(--ink3); opacity: 0; transition: opacity .15s; display: inline-flex; border-radius: 6px; }
.row__star .ic { width: 15px; height: 15px; }
.row:hover .row__star, .row__star.is-on { opacity: 1; }
.row__star.is-on { color: var(--gold); }
.row__star.is-on .ic { fill: var(--gold); }
.more { background: none; border: 0; padding: 16px; color: var(--gold2); font-size: 13px; font-weight: 500; }
.empty { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; color: var(--ink2); padding: 64px 20px; }
.empty__mark { width: 56px; height: 56px; border-radius: 50%; background: var(--panel2); display: flex; align-items: center; justify-content: center; color: var(--ink3); }
.empty__mark .ic { width: 24px; height: 24px; }
.empty__emblem { opacity: .55; }
.empty__title { font: 600 26px Cormorant, Georgia, serif; color: var(--ink); }
.empty--read { margin: auto; }

/* письмо */
.read { display: flex; flex-direction: column; overflow: hidden; }
.msg { flex: 1; min-height: 0; display: flex; flex-direction: column; animation: rise .3s var(--ease) both; }
.msg__bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.msg__back { display: none; }
.msg__scroll { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; padding: 22px 28px 26px; }
.msg__subject { font-size: 34px; color: var(--ink); overflow-wrap: anywhere; text-wrap: balance; }
.msg__head { display: flex; align-items: center; gap: 13px; }
.msg__who { min-width: 0; flex: 1; }
.msg__from, .msg__to, .msg__by { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg__from b { font-weight: 650; }
.msg__from span { color: var(--ink3); font-size: 13px; }
.msg__to, .msg__by { color: var(--ink2); font-size: 13px; }
.msg__by { color: var(--gold2); }
.msg__date { color: var(--ink3); white-space: nowrap; font-size: 12.5px; align-self: flex-start; }
.warn { display: flex; gap: 10px; background: var(--danger-soft); color: var(--danger); padding: 11px 13px; border-radius: 10px; font-size: 13px; }
.atts { list-style: none; display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; }
.atts:empty { display: none; }
.atts a { display: flex; align-items: center; gap: 10px; border: 1px solid var(--line); background: var(--panel2); padding: 8px 12px; border-radius: 10px; font-size: 13px; text-decoration: none; transition: border-color .15s; max-width: 100%; }
.atts a span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.atts a:hover { border-color: var(--gold); }
.atts small { color: var(--ink3); }
.atts .risky { border-color: var(--danger); color: var(--danger); }
.thread { border: 1px solid var(--line); border-radius: 10px; font-size: 13px; overflow: hidden; }
.thread summary { padding: 9px 12px; cursor: pointer; color: var(--gold2); font-weight: 600; }
.thread ul { list-style: none; margin: 0; padding: 4px; border-top: 1px solid var(--line); max-height: 200px; overflow-y: auto; }
.thread li button { display: flex; width: 100%; justify-content: space-between; gap: 12px; border: 0; background: none; padding: 7px 9px; text-align: left; border-radius: 7px; }
.thread li button:hover { background: var(--hover); }
.thread li span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thread time { flex: none; color: var(--ink3); }
.msg__body { flex: 1 0 auto; min-height: 340px; width: 100%; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.quick { display: flex; align-items: center; gap: 11px; border: 1px solid var(--line); background: var(--panel2); color: var(--ink3); padding: 11px 14px; border-radius: 12px; text-align: left; transition: border-color .15s; }
.quick:hover { border-color: var(--gold); color: var(--ink2); }

/* ═════════ новое письмо ═════════ */
.composer { position: fixed; right: 22px; bottom: 0; z-index: 35; width: min(640px, calc(100vw - 32px)); max-height: calc(100dvh - 40px); display: flex; flex-direction: column; background: var(--raise); border: 1px solid var(--line); border-bottom: 0; border-radius: 14px 14px 0 0; box-shadow: var(--shadow-lg); animation: up .3s var(--ease) both; }
@keyframes up { from { transform: translateY(30px); opacity: 0; } }
.composer.is-max { right: 50%; bottom: 50%; transform: translate(50%, 50%); width: min(1200px, calc(100vw - 40px)); height: min(860px, calc(100dvh - 40px)); max-height: none; border-radius: 16px; border-bottom: 1px solid var(--line); animation: none; }
.composer.is-min .composer__cols, .composer.is-min .composer__foot { display: none; }
.composer.is-min { width: 320px; }
.composer__form { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.composer__head { display: flex; align-items: center; gap: 4px; background: var(--side); color: #f4f1ea; padding: 7px 8px 7px 16px; border-radius: 14px 14px 0 0; cursor: default; }
.composer.is-max .composer__head { border-radius: 16px 16px 0 0; }
.composer__head strong { font-size: 13.5px; font-weight: 600; flex: none; }
.composer__saved { flex: 1; font-size: 11.5px; color: rgba(255,255,255,.55); padding-left: 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.composer__cols { display: flex; min-height: 0; flex: 1; overflow: hidden; }
.composer__main { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; padding: 2px 16px 10px; overflow-y: auto; }
.composer__side { flex: 1.15 1 0; min-width: 0; display: flex; flex-direction: column; gap: 6px; padding: 10px 14px; background: var(--panel2); border-left: 1px solid var(--line); }
.composer__side iframe { flex: 1; min-height: 360px; width: 100%; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
/* строки полей окна письма (класс общий со строкой списка — сбрасываем её оформление) */
.composer .row { display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--line); padding: 0; border-radius: 0; animation: none; cursor: auto; grid-template-columns: none; }
.composer .row:hover { background: none; }
.composer .row label { flex: none; width: 58px; font-size: 13px; color: var(--ink3); }
.composer .row input, .composer .row select { flex: 1; min-width: 0; border: 0; outline: 0; background: none; padding: 10px 0; font-size: 14px; }
.composer .row select:disabled { opacity: .75; }
.composer .row:focus-within { border-bottom-color: var(--gold); }
#c-text { flex: 1; min-height: 220px; width: 100%; border: 0; background: none; padding: 14px 0; font-size: 14.5px; line-height: 1.65; resize: none; outline: 0; }
.chipfiles { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; }
.chipfiles li { display: flex; align-items: center; gap: 6px; font-size: 12.5px; background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 4px 4px 4px 9px; max-width: 100%; }
.chipfiles li span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chipfiles button { border: 0; background: none; color: var(--ink3); padding: 2px; display: inline-flex; border-radius: 5px; }
.chipfiles button:hover { color: var(--danger); }
.chipfiles .ic { width: 14px; height: 14px; }
.composer__foot { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--line); }
.tools { flex: 1; display: flex; flex-wrap: wrap; align-items: center; gap: 2px; min-width: 0; }
.tools > button, .tools__file { border: 0; background: none; height: 32px; min-width: 32px; padding: 0 8px; border-radius: 7px; font-size: 13px; color: var(--ink2); display: inline-flex; align-items: center; justify-content: center; position: relative; cursor: pointer; }
.tools > button:hover, .tools__file:hover { background: var(--hover); color: var(--ink); }
.tools__file input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.tools select { border: 1px solid var(--line); background: var(--raise); height: 30px; padding: 0 6px; font-size: 12.5px; color: var(--ink2); border-radius: 7px; max-width: 120px; }
.composer__drop { position: absolute; inset: 44px 0 0; display: flex; align-items: center; justify-content: center; background: color-mix(in srgb, var(--gold-soft) 92%, transparent); border: 2px dashed var(--gold); border-radius: 0 0 14px 14px; font-weight: 600; color: var(--gold2); pointer-events: none; }

/* ═════════ страницы: настройки и админка ═════════ */
dialog { border: 0; padding: 0; color: var(--ink); background: none; }
dialog::backdrop { background: rgba(10,14,22,.55); backdrop-filter: blur(3px); }
.page { width: min(1120px, calc(100vw - 32px)); height: min(820px, calc(100dvh - 32px)); max-width: none; max-height: none; border-radius: 18px; background: var(--panel); box-shadow: var(--shadow-lg); overflow: hidden; }
.page[open] { animation: rise .28s var(--ease) both; }
.page__wrap { display: grid; grid-template-columns: 250px minmax(0, 1fr); height: 100%; }
.page__nav { background: var(--panel2); border-right: 1px solid var(--line); padding: 22px 12px; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.page__title { font: 600 24px Cormorant, Georgia, serif; padding: 0 10px 14px; }
.page__nav button { display: flex; align-items: center; gap: 11px; border: 0; background: none; padding: 9px 11px; border-radius: 9px; text-align: left; font-size: 13.5px; color: var(--ink2); }
.page__nav button:hover { background: var(--hover); color: var(--ink); }
.page__nav button.is-on { background: var(--raise); color: var(--ink); font-weight: 600; box-shadow: var(--shadow); }
.page__nav button.is-on .ic { color: var(--gold); }
.page__body { position: relative; overflow-y: auto; padding: 30px 36px 40px; }
.page__close { position: absolute; top: 14px; right: 14px; z-index: 3; }
.sec { display: flex; flex-direction: column; gap: 16px; max-width: 760px; animation: rise .25s var(--ease) both; }
.sec > h2, .sec__head h2 { font-size: 34px; }
.sec__head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding-right: 40px; }
.card { background: var(--raise); border: 1px solid var(--line); border-radius: var(--r); padding: 20px 22px; display: flex; flex-direction: column; gap: 14px; }
.card h3 { font-size: 22px; }
.card__head { display: flex; gap: 14px; align-items: flex-start; }
.card__head > div:last-child { display: flex; flex-direction: column; gap: 4px; }
.card__ic { width: 40px; height: 40px; border-radius: 11px; background: var(--gold-soft); color: var(--gold2); display: flex; align-items: center; justify-content: center; flex: none; }
.card__ic .ic { width: 20px; height: 20px; }
.form { display: flex; flex-direction: column; gap: 14px; }
.form__foot { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.tfa { display: grid; grid-template-columns: 168px minmax(0, 1fr); gap: 18px; align-items: start; }
.tfa img { width: 168px; height: 168px; border-radius: 12px; border: 1px solid var(--line); background: #fff; padding: 6px; }
.keys-list, .dev-list, .tpl-list, .log { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.keys-list li, .dev-list li, .tpl-list li { display: flex; align-items: center; gap: 13px; padding: 11px 0; border-top: 1px solid var(--line); }
.keys-list li:first-child, .dev-list li:first-child, .tpl-list li:first-child { border-top: 0; }
.li__ic { width: 36px; height: 36px; border-radius: 10px; background: var(--panel2); display: flex; align-items: center; justify-content: center; color: var(--ink2); flex: none; }
.li__main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.li__main b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.li__main small { color: var(--ink3); font-size: 12px; }
.li__empty { color: var(--ink3); font-size: 13px; padding: 6px 0; }
.tag { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 10px; background: var(--ok-soft); color: var(--ok); white-space: nowrap; }
.steps { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 7px; color: var(--ink2); }
.log li { display: grid; grid-template-columns: 140px minmax(0, 1fr); gap: 14px; padding: 9px 0; border-top: 1px solid var(--line); font-size: 13px; }
.log li:first-child { border-top: 0; }
.log time { color: var(--ink3); }

/* таблица ящиков */
.table { display: flex; flex-direction: column; background: var(--raise); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.trow { display: grid; grid-template-columns: minmax(0, 2.2fr) minmax(0, 1.3fr) minmax(0, 1fr) 28px; gap: 14px; align-items: center; padding: 12px 16px; border: 0; border-top: 1px solid var(--line); background: none; text-align: left; transition: background .12s; }
.trow:first-child { border-top: 0; }
.trow:hover { background: var(--hover); }
.trow.is-off { opacity: .55; }
.trow__who { display: flex; align-items: center; gap: 12px; min-width: 0; }
.trow__who > div { min-width: 0; display: flex; flex-direction: column; }
.trow__who b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trow__who small, .trow__meta { font-size: 12.5px; color: var(--ink3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trow .ic { color: var(--ink3); }
.badges { display: inline-flex; flex-wrap: wrap; gap: 5px; }
.badge { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 10px; background: var(--panel2); color: var(--ink2); white-space: nowrap; border: 1px solid var(--line); }
.badge--navy { background: var(--navy-soft); color: var(--navy); border-color: transparent; }
.badge--gold { background: var(--gold-soft); color: var(--gold2); border-color: transparent; }
.badge--ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge--off { background: var(--danger-soft); color: var(--danger); border-color: transparent; }

/* карточка ящика */
.drawer { position: absolute; top: 0; right: 0; bottom: 0; width: min(460px, 100%); background: var(--panel); border-left: 1px solid var(--line); box-shadow: -30px 0 60px -30px rgba(0,0,0,.4); display: flex; flex-direction: column; z-index: 5; animation: slide .3s var(--ease) both; }
@keyframes slide { from { transform: translateX(40px); opacity: 0; } }
.drawer__head { display: flex; align-items: center; gap: 13px; padding: 20px 18px 16px 22px; border-bottom: 1px solid var(--line); }
.drawer__title { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.drawer__title h3 { font-size: 22px; overflow-wrap: anywhere; }
.drawer__body { flex: 1; overflow-y: auto; padding: 18px 22px 24px; }
.actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.act { display: flex; flex-direction: column; align-items: center; gap: 7px; border: 1px solid var(--line); background: var(--raise); padding: 12px 6px; border-radius: 12px; font-size: 12px; text-align: center; color: var(--ink2); transition: border-color .15s, color .15s; }
.act:hover:not(:disabled) { border-color: var(--gold); color: var(--ink); }
.act .ic { width: 20px; height: 20px; color: var(--gold2); }
.act:disabled { opacity: .45; cursor: default; }
.members { display: flex; flex-direction: column; gap: 4px; max-height: 240px; overflow-y: auto; border: 1px solid var(--line); background: var(--raise); padding: 8px 12px; border-radius: var(--r-sm); }

/* окна поменьше */
.sheet { width: min(520px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); border-radius: 16px; background: var(--panel); box-shadow: var(--shadow-lg); }
.sheet[open] { display: flex; flex-direction: column; animation: rise .22s var(--ease) both; }
.sheet--sm { width: min(420px, calc(100vw - 24px)); }
.sheet__form { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.sheet__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 16px 6px 22px; }
.sheet__head h3 { font-size: 25px; }
.sheet__body { padding: 10px 22px 6px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.sheet__foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 18px 18px; }
.cred { display: grid; grid-template-columns: auto 1fr; gap: 10px 16px; margin: 0; align-items: center; }
.cred dt { font-size: 12.5px; color: var(--ink3); }
.cred dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.keys { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; margin: 0; padding: 8px 22px 24px; }
.keys dt { font: 500 12px ui-monospace, Consolas, monospace; background: var(--panel2); border: 1px solid var(--line); padding: 2px 8px; border-radius: 6px; text-align: center; }
.keys dd { margin: 0; color: var(--ink2); }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 60; display: flex; align-items: center; gap: 16px; background: #141a26; color: #f4f1ea; padding: 12px 14px 12px 18px; border-radius: 12px; font-size: 13.5px; box-shadow: 0 18px 40px -10px rgba(0,0,0,.5); animation: rise .25s var(--ease) both; max-width: calc(100vw - 24px); }
.toast.is-bad { background: #4a1f1b; }
.toast__act { border: 0; background: rgba(255,255,255,.12); color: #f0dcae; font-weight: 600; padding: 6px 12px; border-radius: 8px; }
.toast__act:hover { background: rgba(255,255,255,.2); }

/* ═════════ ИИ-помощник ═════════ */
.btn--ai { background: linear-gradient(135deg, #2b3c5e, #1d2a44 55%, #6f5a2e); color: #f6ecd6; box-shadow: 0 6px 16px -8px rgba(29,42,68,.7); }
.btn--ai:hover:not(:disabled) { filter: brightness(1.15); }
.btn--ai .ic { color: #e6c98c; }
.btn--ai.is-on { box-shadow: 0 0 0 2px var(--gold), 0 6px 16px -8px rgba(29,42,68,.7); }
.seg--sm button { padding: 5px 10px; font-size: 12.5px; }
.input--sm { padding: 6px 9px; font-size: 13px; width: auto; }
.read { position: relative; flex-direction: row; }
.read > .msg, .read > .empty { flex: 1; min-width: 0; }
.ai { width: 380px; flex: none; display: flex; flex-direction: column; border-left: 1px solid var(--line); background: linear-gradient(180deg, var(--panel2), var(--panel) 30%); min-height: 0; animation: slide .28s var(--ease) both; }
.ai__head { display: flex; align-items: center; gap: 11px; padding: 14px 12px 12px 16px; border-bottom: 1px solid var(--line); }
.ai__badge { width: 34px; height: 34px; border-radius: 10px; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #2b3c5e, #1d2a44 55%, #6f5a2e); color: #e6c98c; flex: none; }
.ai__title { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.ai__title b { font: 600 19px Cormorant, Georgia, serif; }
.ai__title small { font-size: 11.5px; color: var(--ink3); }
.ai__body { flex: 1; min-height: 0; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.ai__actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ai__actions button { display: flex; align-items: flex-start; gap: 9px; border: 1px solid var(--line); background: var(--raise); padding: 10px; border-radius: 11px; text-align: left; transition: border-color .15s, transform .12s; }
.ai__actions button:hover { border-color: var(--gold); }
.ai__actions button:active { transform: translateY(1px); }
.ai__actions button.is-main { border-color: var(--gold-line); background: var(--gold-soft); }
.ai__actions .ic { color: var(--gold2); margin-top: 1px; }
.ai__actions span { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.ai__actions b { font-size: 13px; font-weight: 600; }
.ai__actions small { font-size: 11.5px; color: var(--ink3); }
.ai__reply { display: flex; flex-direction: column; gap: 9px; padding: 12px; border: 1px solid var(--gold-line); border-radius: 12px; background: var(--raise); animation: rise .2s var(--ease) both; }
.ai__reply textarea { resize: vertical; font-size: 13.5px; }
.ai__row { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.ai__out { display: flex; flex-direction: column; gap: 10px; }
.aic { border: 1px solid var(--line); background: var(--raise); border-radius: 12px; overflow: hidden; animation: rise .2s var(--ease) both; }
.aic__head { display: flex; align-items: center; gap: 8px; padding: 9px 12px; border-bottom: 1px solid var(--line); font-size: 12px; font-weight: 600; color: var(--gold2); text-transform: uppercase; letter-spacing: .06em; }
.aic__head span { flex: 1; }
.aic__head button { border: 0; background: none; color: var(--ink3); padding: 2px; display: inline-flex; border-radius: 5px; }
.aic__head button:hover { color: var(--ink); }
.aic__head .ic { width: 15px; height: 15px; }
.aic__text { padding: 12px 14px; font-size: 13.5px; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; }
.aic__text.is-loading::after { content: ''; display: inline-block; width: 7px; height: 15px; margin-left: 2px; vertical-align: -2px; background: var(--gold); animation: blink 1s steps(2) infinite; }
.aic__text .mark { background: var(--gold-soft); color: var(--gold2); border-radius: 4px; padding: 0 3px; }
@keyframes blink { 50% { opacity: 0; } }
.aic__foot { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 12px 12px; }
.aic__foot .btn { padding: 6px 10px; font-size: 12.5px; }
.aic__q { padding: 10px 14px 0; font-size: 12.5px; color: var(--ink3); font-style: italic; }
.ai__ask { display: flex; align-items: center; gap: 6px; padding: 10px 10px 10px 14px; border-top: 1px solid var(--line); background: var(--panel); }
.ai__ask input { flex: 1; min-width: 0; border: 1px solid var(--line2); background: var(--raise); border-radius: 20px; padding: 9px 14px; font-size: 13.5px; outline: none; }
.ai__ask input:focus { border-color: var(--gold); }
.ai__empty { text-align: center; color: var(--ink3); font-size: 12.5px; padding: 6px 10px; }

.tools__ai { background: linear-gradient(135deg, #2b3c5e, #1d2a44 55%, #6f5a2e) !important; color: #f6ecd6 !important; gap: 5px; font-weight: 600; }
.tools__ai .ic { width: 15px; height: 15px; color: #e6c98c; }
.cai { position: absolute; right: 12px; bottom: 58px; width: min(380px, calc(100% - 24px)); background: var(--raise); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-lg); padding: 14px; display: flex; flex-direction: column; gap: 10px; z-index: 3; animation: rise .2s var(--ease) both; }
.cai__label { display: flex; align-items: center; gap: 7px; font-size: 11.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--gold2); }
.cai__label .ic { width: 15px; height: 15px; }
.cai__write { display: flex; flex-direction: column; gap: 8px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.cai__write textarea { border: 1px solid var(--line2); background: var(--panel); border-radius: 10px; padding: 9px 11px; font-size: 13.5px; resize: vertical; outline: none; }
.cai__write textarea:focus { border-color: var(--gold); }
.cai__row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.cai__grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.cai__grid button { border: 1px solid var(--line); background: var(--panel); padding: 8px 10px; border-radius: 9px; font-size: 13px; text-align: left; transition: border-color .15s; }
.cai__grid button:hover { border-color: var(--gold); }
#c-text.is-ai { background: linear-gradient(90deg, transparent, var(--gold-soft), transparent); background-size: 200% 100%; animation: shimmer 1.6s linear infinite; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }

/* разбор письма */
.iconbtn--sm { width: 28px; height: 28px; }
.iconbtn--sm .ic { width: 15px; height: 15px; }
.brief { border: 1px solid var(--gold-line); border-radius: 14px; background: linear-gradient(180deg, var(--gold-soft), var(--raise) 70%); overflow: hidden; animation: rise .25s var(--ease) both; }
.brief__head { display: flex; align-items: center; gap: 8px; padding: 8px 8px 8px 12px; flex-wrap: wrap; }
.brief__tag { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--gold2); }
.brief__tag .ic { width: 15px; height: 15px; }
.brief__body { padding: 0 16px 6px; display: flex; flex-direction: column; gap: 8px; font-size: 13.5px; }
.brief.is-folded .brief__body, .brief.is-folded .brief__actions { display: none; }
.brief__sum { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 2px; }
.brief__wants { padding: 8px 11px; border-radius: 9px; background: var(--raise); border: 1px solid var(--line); }
.brief__wants b { color: var(--gold2); font-weight: 600; }
.brief__warn { padding: 8px 11px; border-radius: 9px; background: var(--danger-soft); color: var(--danger); font-weight: 500; }
.brief__chips { display: flex; flex-wrap: wrap; gap: 6px; }
.brief__chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--raise); border-radius: 8px; padding: 3px 9px; font-size: 12.5px; color: var(--ink2); max-width: 100%; }
.brief__chip b { color: var(--ink); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
button.brief__chip { cursor: pointer; }
button.brief__chip:hover { border-color: var(--gold); }
.brief__actions { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px 16px 14px; }
.brief__loading { display: flex; flex-direction: column; gap: 7px; padding: 4px 0 8px; }
.brief__loading i { display: block; height: 10px; border-radius: 5px; background: linear-gradient(90deg, var(--line), var(--gold-soft), var(--line)); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; }
.brief__loading i:nth-child(2) { width: 80%; } .brief__loading i:nth-child(3) { width: 55%; }
.badge--red { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
/* перевод в тексте письма */
.trbar { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; padding: 8px 12px; border-radius: 11px; background: var(--navy-soft); color: var(--navy); font-size: 13px; font-weight: 500; }
.trtext { border: 1px solid var(--line); border-radius: 12px; background: var(--raise); padding: 18px 20px; font-size: 14.5px; line-height: 1.65; white-space: pre-wrap; overflow-wrap: anywhere; min-height: 200px; }
.trtext h3 { font-size: 22px; margin-bottom: 10px; white-space: normal; }
.trtext.is-loading #tr-body::after { content: ''; display: inline-block; width: 7px; height: 15px; margin-left: 2px; vertical-align: -2px; background: var(--gold); animation: blink 1s steps(2) infinite; }
.trtext .mark { background: var(--gold-soft); color: var(--gold2); border-radius: 4px; padding: 0 3px; }

/* ИИ поверх письма, когда рядом ему тесно */
@media (max-width: 1500px) {
  .ai { position: absolute; top: 0; right: 0; bottom: 0; z-index: 4; width: min(400px, 100%); box-shadow: -24px 0 50px -24px rgba(0,0,0,.35); border-radius: 0 var(--r) var(--r) 0; }
}

/* ═════════ планшет ═════════ */
@media (max-width: 1180px) {
  .app { grid-template-columns: minmax(300px, 380px) minmax(0, 1fr); padding: 10px; }
  .side { position: fixed; inset: 0 auto 0 0; width: 290px; z-index: 50; transform: translateX(-100%); transition: transform .28s var(--ease); box-shadow: var(--shadow-lg); }
  .app.side-open .side { transform: none; }
  .side__close, .list__menu { display: inline-flex; }
}
/* ═════════ телефон ═════════ */
@media (max-width: 760px) {
  .app { grid-template-columns: minmax(0, 1fr); padding: 0; gap: 0; }
  .list, .read { border-radius: 0; box-shadow: none; }
  .app.is-reading .list, .app:not(.is-reading) .read { display: none; }
  .list__head { padding-top: max(12px, env(safe-area-inset-top)); }
  .msg__back { display: inline-flex; }
  .msg__bar { padding-top: max(10px, env(safe-area-inset-top)); }
  .msg__bar .btn span, .msg__bar .btn { font-size: 12.5px; }
  .msg__scroll { padding: 16px 14px 20px; }
  .msg__subject { font-size: 26px; }
  .msg__date { display: none; }
  .msg__body { min-height: 60dvh; }
  .snip { padding-right: 18px; }
  .row__star { opacity: 1; }
  .row .row__left input { opacity: 0; pointer-events: none; }
  .row:hover .avatar { opacity: 1; }
  input, select, textarea, .search input, #c-text { font-size: 16px !important; }
  .composer, .composer.is-max { inset: 0; width: 100%; height: 100dvh; max-height: none; border-radius: 0; transform: none; }
  .composer__head { border-radius: 0; padding-top: max(7px, env(safe-area-inset-top)); }
  .composer__cols { flex-direction: column; overflow-y: auto; }
  .composer__main { overflow: visible; flex: none; }
  .composer__side { flex: none; border-left: 0; border-top: 1px solid var(--line); }
  .composer__side iframe { height: 70dvh; }
  .composer__foot { flex-wrap: wrap; padding-bottom: max(10px, env(safe-area-inset-bottom)); }
  #c-min { display: none; }
  .auth { grid-template-columns: minmax(0, 1fr); }
  .auth__art { display: none; }
  .auth__mobile-brand { display: flex; }
  .auth__panel { justify-content: flex-start; padding-top: max(40px, env(safe-area-inset-top)); }
  .page, .sheet { width: 100vw; height: 100dvh; max-height: none; border-radius: 0; }
  .page__wrap { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  .page__nav { flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: max(10px, env(safe-area-inset-top)) 56px 10px 10px; scrollbar-width: none; }
  .page__title { display: none; }
  .page__nav button { white-space: nowrap; flex: none; }
  .page__body { padding: 20px 16px 32px; }
  .page__close { top: max(8px, env(safe-area-inset-top)); position: fixed; }
  .sec > h2, .sec__head h2 { font-size: 28px; }
  .card { padding: 16px; }
  .grid2, .tfa { grid-template-columns: minmax(0, 1fr); }
  .trow { grid-template-columns: minmax(0, 1fr) auto 20px; gap: 10px; padding: 12px; }
  .trow__meta { display: none; }
  .drawer { position: fixed; width: 100%; }
  .log li { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .ai { position: fixed; inset: 0; width: 100%; z-index: 45; border-radius: 0; padding-top: env(safe-area-inset-top); }
  .ai__ask { padding-bottom: max(10px, env(safe-area-inset-bottom)); }
  .cai { position: fixed; left: 8px; right: 8px; bottom: 70px; width: auto; }
}
@media (prefers-reduced-motion: reduce) { *, ::before, ::after { animation: none !important; transition: none !important; } }
