/* Family Mail — токены из макета Claude Design (Nocturne), поверх подмешиваются themeParams Telegram. */
:root {
  --bg: #161826; --surf: #232532; --surf2: #1c1e2b; --line: #313442; --line2: #3f424d;
  --tx: #e9e9ed; --hint: #9397ab; --sub: #75798c;
  --acc: #9184d9; --accTx: #d2cefd; --accTint: #2b2741; --accLine: #423a6a;
  --ok: oklch(0.74 0.12 155); --okT: oklch(0.74 0.12 155/0.14);
  --warn: oklch(0.8 0.12 78); --warnT: oklch(0.8 0.12 78/0.14);
  --err: oklch(0.69 0.15 22); --errT: oklch(0.69 0.15 22/0.14);
  --sec: oklch(0.74 0.13 330); --secT: oklch(0.74 0.13 330/0.14);
  --onAcc: #161826;
  /* Telegram 8.0+ отдаёт свои отступы (устройство + собственная шапка клиента); без них — env() */
  --safe-top: calc(var(--tg-safe-area-inset-top, env(safe-area-inset-top, 0px)) + var(--tg-content-safe-area-inset-top, 0px));
  --safe-bottom: calc(var(--tg-safe-area-inset-bottom, env(safe-area-inset-bottom, 0px)) + var(--tg-content-safe-area-inset-bottom, 0px));
}
.lt {
  --bg: #f4f5fa; --surf: #ffffff; --surf2: #eceef6; --line: #e0e3ee; --line2: #cfd3e5;
  --tx: #1b1d29; --hint: #5f6475; --sub: #7c8194;
  --acc: #6a5cb8; --accTx: #4b3f92; --accTint: #efedfb; --accLine: #d2cefd;
  --ok: oklch(0.52 0.12 155); --okT: oklch(0.52 0.12 155/0.1);
  --warn: oklch(0.58 0.12 70); --warnT: oklch(0.58 0.12 70/0.1);
  --err: oklch(0.53 0.16 22); --errT: oklch(0.53 0.16 22/0.1);
  --sec: oklch(0.5 0.15 330); --secT: oklch(0.5 0.15 330/0.1);
  --onAcc: #ffffff;
}
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--tx); font: 400 13.5px/1.35 Inter, system-ui, sans-serif; -webkit-tap-highlight-color: transparent; overscroll-behavior: none; }
button, input, textarea { font-family: Inter, system-ui, sans-serif; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
input, textarea { outline: none; font-size: 16px; }
/* iOS зумит поле при фокусе, если шрифт меньше 16px — только там держим 16px поверх макетных размеров */
@supports (-webkit-touch-callout: none) { input, textarea, .field, textarea.field, .search input, .row .noteedit input { font-size: 16px !important; } }
::-webkit-scrollbar { width: 0; height: 0; }
@keyframes sk { 0% { opacity: .45 } 50% { opacity: .9 } 100% { opacity: .45 } }
@keyframes sp { to { transform: rotate(360deg) } }

#app, .shell { height: 100%; }
.shell { display: flex; flex-direction: column; background: var(--bg); max-width: 640px; margin: 0 auto; position: relative; overflow: hidden; }
@media (min-width: 900px) { .shell { max-width: 1024px; } }

/* шапка */
.hdr { flex: none; display: flex; align-items: center; gap: 8px; height: 48px; padding: 0 8px 0 6px; background: var(--surf2); border-bottom: 1px solid var(--line); padding-top: var(--safe-top); height: calc(48px + var(--safe-top)); }
.hdr .back { display: flex; align-items: center; gap: 2px; height: 40px; min-width: 44px; padding: 0 8px; color: var(--acc); font: 500 15px/1 Inter; }
.hdr .brand { padding-left: 12px; font: 500 16px/1 Inter; }
.hdr .title { flex: 1; text-align: center; font: 500 16px/1 Inter; padding-right: 44px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hdr .icon { width: 44px; height: 40px; color: var(--hint); font-size: 20px; display: grid; place-items: center; }

.scr { flex: 1; overflow-y: auto; overflow-x: hidden; position: relative; background: var(--bg); -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
/* вкладки: невидимая остаётся в DOM с прежним скроллом (display:none его обнулил бы) */
.pane { flex: 1; min-height: 0; display: flex; flex-direction: column; position: relative; }
.pane.off { position: absolute; left: 0; right: 0; top: calc(48px + var(--safe-top)); bottom: calc(58px + var(--safe-bottom)); visibility: hidden; pointer-events: none; }
.offline { flex: none; display: flex; align-items: center; justify-content: center; gap: 6px; padding: 5px 12px; background: var(--warnT); color: var(--warn); font: 500 11.5px/1 Inter; }

/* верх списка */
.sticky { position: sticky; top: 0; z-index: 3; background: var(--bg); border-bottom: 1px solid var(--line); }
.search { display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 10px; margin: 8px 12px 6px; border-radius: 8px; background: var(--surf); box-shadow: 0 0 0 1px var(--line); }
.search i { color: var(--sub); font-size: 15px; }
.search input { flex: 1; background: none; border: 0; color: var(--tx); font: 400 13px/1 Inter; min-width: 0; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding: 0 12px 8px; }
.chip { flex: none; height: 28px; padding: 0 11px; border-radius: 14px; font: 500 12px/1 Inter; white-space: nowrap; background: transparent; color: var(--hint); border: 1px solid var(--line); display: inline-flex; align-items: center; gap: 4px; }
.chip.on { background: var(--accTint); color: var(--accTx); border-color: var(--acc); }
.chip.facet { border-radius: 8px; font-weight: 400; padding: 0 9px; background: var(--surf); }
.chip.facet.on { background: var(--accTint); }
.chip.facet i { font-size: 11px; opacity: .7; }
.meta { display: flex; align-items: center; justify-content: space-between; padding: 0 12px 8px; font: 400 11.5px/1 Inter; color: var(--sub); }
.meta .tools { display: flex; gap: 2px; align-items: center; white-space: nowrap; }
.meta .tools button { height: 26px; padding: 0 7px; color: var(--hint); font: 400 11.5px Inter; display: flex; align-items: center; gap: 3px; font-size: 14px; position: relative; }
.meta .tools button::before { content: ''; position: absolute; inset: -7px 0; } /* зона нажатия 40px без изменения макета */
.meta .tools button.txt { font: 400 11.5px Inter; }
.meta .tools button.acc { color: var(--acc); font: 500 11.5px Inter; }
.selbar { display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: var(--accTint); border-top: 1px solid var(--accLine); font: 500 12.5px/1 Inter; }
.selbar .lnk { color: var(--acc); font: 500 12px Inter; }
.selbar .off { margin-left: auto; color: var(--hint); font: 400 12px Inter; }

/* строка ящика */
.ghead { position: sticky; top: var(--sticky-h, 0px); z-index: 2; display: flex; align-items: center; gap: 8px; padding: 5px 12px; background: var(--surf2); border-bottom: 1px solid var(--line); font: 500 11px/1 Inter; letter-spacing: .06em; text-transform: uppercase; color: var(--sub); }
.check { flex: none; width: 20px; height: 20px; border-radius: 5px; border: 1px solid var(--line2); background: transparent; color: var(--onAcc); font-size: 13px; display: grid; place-items: center; }
.check.on { background: var(--acc); }
.check.sm { width: 16px; height: 16px; border-radius: 4px; font-size: 11px; }
.row { border-bottom: 1px solid var(--line); background: transparent; content-visibility: auto; contain-intrinsic-size: 60px; }
.row.sel { background: var(--accTint); }
.row .main { display: flex; align-items: center; gap: 9px; padding: 9px 10px 9px 6px; position: relative; cursor: pointer; min-height: 60px; user-select: none; -webkit-user-select: none; }
.row .main .check { position: relative; }
.row .main .check::before { content: ''; position: absolute; inset: -10px; }
.row.dense .main { padding: 7px 10px 7px 6px; min-height: 46px; }
.row .bar { position: absolute; left: 0; top: 6px; bottom: 6px; width: 3px; border-radius: 0 2px 2px 0; }
.av { flex: none; width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; font: 500 13px/1 Inter; color: #f3f5fe; }
.row .av { margin-left: 8px; }
.row .body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.row .addr { font: 400 13.5px/1.2 Inter; color: var(--tx); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .l1 { display: flex; align-items: center; gap: 6px; min-width: 0; }
.row .l2 { display: flex; align-items: center; gap: 6px; font: 400 11.5px/1 Inter; color: var(--sub); white-space: nowrap; overflow: hidden; }
.row .l2 .st { display: flex; align-items: center; gap: 3px; }
.row .l2 .note { overflow: hidden; text-overflow: ellipsis; color: var(--hint); }
.row .right { flex: none; display: flex; align-items: center; gap: 7px; padding-right: 2px; font-size: 14px; color: var(--sub); }
.row .chev { width: 26px; height: 34px; color: var(--sub); font-size: 15px; display: grid; place-items: center; position: relative; }
.row .chev::before { content: ''; position: absolute; inset: -3px -6px; } /* 40px по высоте */
.row .quick { display: flex; gap: 6px; padding: 0 12px 9px 50px; flex-wrap: wrap; }
.row .noteedit { padding: 0 12px 9px 50px; }
.row .noteedit input { width: 100%; height: 32px; padding: 0 9px; border-radius: 8px; background: var(--surf); border: 1px solid var(--acc); color: var(--tx); font: 400 12.5px Inter; }
.badge { flex: none; display: inline-flex; align-items: center; gap: 3px; height: 16px; padding: 0 5px; border-radius: 4px; font: 500 10px/1 Inter; }
.badge.err { background: var(--errT); color: var(--err); }
.badge.warn { background: var(--warnT); color: var(--warn); }
.badge.ok { background: var(--okT); color: var(--ok); }
.count { min-width: 19px; height: 19px; padding: 0 5px; border-radius: 10px; background: var(--acc); color: var(--onAcc); font: 600 11px/19px Inter; text-align: center; }
.scan { display: flex; align-items: center; gap: 2px; color: var(--ok); font: 500 10.5px/1 Inter; }
.scan i { font-size: 13px; }

/* кнопки */
.btn { height: 32px; padding: 0 12px; border-radius: 8px; background: transparent; border: 1px solid var(--line2); color: var(--hint); font: 400 12.5px Inter; display: inline-flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap; }
.btn.acc { border-color: var(--acc); color: var(--acc); font-weight: 500; }
.btn.err { border-color: var(--err); color: var(--err); font-weight: 500; }
.btn.sec { border-color: var(--sec); color: var(--sec); }
.btn.warn { border-color: var(--warn); color: var(--warn); }
.btn.tx { color: var(--tx); }
.btn.sm { height: 28px; padding: 0 9px; font-size: 11.5px; }
.btn.lg { height: 44px; font-size: 14px; font-weight: 500; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .45; cursor: default; }
.lnk { color: var(--acc); font: 500 12px Inter; }
.lnk.mut { color: var(--hint); font-weight: 400; }

/* карточки и списки */
.card { margin: 12px 14px 0; border-radius: 8px; background: var(--surf); box-shadow: 0 0 0 1px var(--line); overflow: hidden; }
.card.pad { padding: 11px 12px; }
.kicker { font: 500 10.5px/1 Inter; letter-spacing: .07em; text-transform: uppercase; color: var(--sub); }
.card .kicker.in { padding: 9px 12px 3px; }
.cell { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 7px 12px; border-top: 1px solid var(--line); }
.cell:first-child, .kicker.in + .cell { border-top: 0; }
.cell .k { flex: none; width: 104px; font: 400 11.5px/1.3 Inter; color: var(--sub); }
.cell .v { flex: 1; font: 400 12.5px/1.3 Inter; color: var(--tx); word-break: break-all; }
.cell .act { color: var(--acc); font: 500 11.5px Inter; }
.item { display: flex; align-items: center; gap: 11px; min-height: 46px; padding: 8px 12px; border-bottom: 1px solid var(--line); cursor: pointer; }
.item:last-child { border-bottom: 0; }
.item i.lead { font-size: 17px; color: var(--acc); }
.item .lbl { flex: 1; min-width: 0; font: 400 13.5px/1.25 Inter; }
.item .sub { margin-top: 3px; font: 400 11.5px/1.3 Inter; color: var(--sub); }
.item .val { font: 400 12.5px/1 Inter; color: var(--sub); }
.item .chev { font-size: 14px; color: var(--sub); }
.section { padding: 15px 14px 6px; display: flex; align-items: baseline; justify-content: space-between; }
.note-p { padding: 0 14px 8px; font: 400 11.5px/1.5 Inter; color: var(--sub); }
.tog { flex: none; width: 42px; height: 25px; border-radius: 13px; border: 1px solid var(--line2); background: transparent; position: relative; padding: 0; }
.tog span { position: absolute; top: 2px; left: 2px; width: 19px; height: 19px; border-radius: 10px; background: var(--sub); transition: left .15s; }
.tog.on { border-color: var(--acc); background: var(--accTint); }
.tog.on span { left: 20px; background: var(--acc); }
.seg { display: flex; gap: 4px; padding: 3px; border-radius: 9px; background: var(--surf2); box-shadow: 0 0 0 1px var(--line); }
.seg button { flex: 1; height: 34px; border-radius: 7px; color: var(--hint); font: 500 12.5px/1 Inter; }
.seg button.on { background: var(--accTint); color: var(--accTx); }
.pill { display: inline-flex; align-items: center; gap: 5px; height: 26px; padding: 0 9px; border-radius: 13px; background: var(--surf2); border: 1px solid var(--line); font: 400 11.5px/1 Inter; color: var(--hint); }
.code { font: 600 22px/1 ui-monospace, Menlo, monospace; letter-spacing: .12em; padding: 7px 11px; border-radius: 8px; background: var(--accTint); color: var(--accTx); border: 1px solid var(--accLine); }
.code.sm { font-size: 12px; padding: 4px 6px; border-radius: 5px; letter-spacing: .06em; border: 0; }
.code.xl { font-size: 30px; letter-spacing: .14em; background: none; border: 0; padding: 0; }
.mono { font-family: ui-monospace, Menlo, monospace; }
.empty { padding: 60px 32px; text-align: center; color: var(--sub); }
.empty i { font-size: 28px; }
.empty .t { margin: 12px 0 4px; font: 500 15px Inter; color: var(--tx); }
.spin { width: 14px; height: 14px; border-radius: 8px; border: 2px solid var(--accLine); border-top-color: var(--acc); animation: sp .8s linear infinite; display: inline-block; }
.skel { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); animation: sk 1.4s ease-in-out infinite; }
.skel .b { height: 9px; border-radius: 5px; background: var(--line2); }
.field { width: 100%; height: 36px; padding: 0 10px; border-radius: 8px; background: var(--surf); border: 1px solid var(--line); color: var(--tx); font: 400 13px Inter; }
.field:focus { border-color: var(--acc); }
textarea.field { height: auto; padding: 10px; line-height: 1.6; resize: none; }
.warnbox { margin: 12px 14px 0; padding: 11px 12px; border-radius: 8px; background: var(--warnT); border: 1px solid var(--warn); }
.warnbox .t { display: flex; align-items: center; gap: 7px; font: 500 12px/1 Inter; color: var(--warn); }
.warnbox .d { margin-top: 6px; font: 400 11.5px/1.45 Inter; color: var(--hint); }
.errbox { margin: 10px 0 0; padding: 11px 12px; border-radius: 8px; background: var(--errT); border: 1px solid var(--err); }
.errbox .t { display: flex; align-items: center; gap: 7px; font: 500 12.5px/1 Inter; color: var(--err); }
.okbox { padding: 11px 12px; border-radius: 8px; background: var(--okT); border: 1px solid var(--ok); color: var(--ok); font: 500 12.5px/1 Inter; }
.danger { margin: 20px 14px 0; padding: 11px 12px; border-radius: 8px; border: 1px dashed var(--err); }

/* низ */
.bulkbar { flex: none; background: var(--surf2); border-top: 1px solid var(--line); padding: 8px 8px 6px; }
.bulkbar .acts { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; }
.bulkbar .act { flex: none; display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 62px; height: 52px; padding: 6px 8px; border-radius: 8px; background: var(--surf); border: 1px solid var(--line); color: var(--tx); font: 400 10.5px/1.15 Inter; }
.bulkbar .act i { font-size: 17px; }
.bulkbar .act.danger { border-color: var(--err); color: var(--err); }
.bulkbar .act.secret { border-color: var(--sec); color: var(--sec); }
.bulkbar .act.on { border-color: var(--acc); background: var(--accTint); color: var(--accTx); }
.tabs { flex: none; position: relative; display: flex; height: calc(58px + var(--safe-bottom)); padding-bottom: calc(6px + var(--safe-bottom)); background: var(--surf2); border-top: 1px solid var(--line); }
.tabs button { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--sub); font: 400 10px/1 Inter; }
.tabs button.on { color: var(--acc); }
.tabs button .ic { position: relative; font-size: 20px; }
.tabs .bdg { position: absolute; top: -3px; right: -9px; min-width: 15px; height: 15px; padding: 0 4px; border-radius: 8px; background: var(--acc); color: var(--onAcc); font: 600 9.5px/15px Inter; }
.fab { position: absolute; right: 14px; top: -56px; width: 48px; height: 48px; border-radius: 24px; background: var(--surf); border: 1px solid var(--accLine); color: var(--acc); font-size: 22px; display: grid; place-items: center; box-shadow: 0 6px 18px rgba(0,0,0,.35); }

/* листы, снек, тост */
.dim { position: absolute; inset: 0; z-index: 8; background: rgba(0,0,0,.55); }
.sheet { position: absolute; left: 0; right: 0; bottom: 0; z-index: 9; display: flex; flex-direction: column; max-height: 82%; background: var(--surf); border-radius: 14px 14px 0 0; box-shadow: 0 -1px 0 var(--line2); padding-bottom: var(--safe-bottom); }
.sheet .hd { display: flex; align-items: center; gap: 10px; padding: 13px 14px 9px; }
.sheet .hd .t { flex: 1; font: 500 15px/1.2 Inter; }
.sheet .hd .x { width: 30px; height: 30px; border-radius: 8px; background: var(--surf2); color: var(--hint); font-size: 15px; display: grid; place-items: center; }
.sheet .sub { padding: 0 14px 8px; font: 400 12px/1.45 Inter; color: var(--sub); }
.sheet .list { overflow-y: auto; border-top: 1px solid var(--line); }
.sheet .ft { display: flex; gap: 8px; padding: 10px 14px 16px; border-top: 1px solid var(--line); }
.sheet .ft .btn { flex: 1; }
.sheet .ft .btn.main { flex: 2; }
.snack { position: absolute; left: 12px; right: 12px; bottom: 76px; z-index: 7; display: flex; align-items: center; gap: 10px; height: 44px; padding: 0 12px; border-radius: 8px; background: var(--surf); box-shadow: 0 0 0 1px var(--line2), 0 6px 18px rgba(0,0,0,.45); font: 400 12.5px/1.3 Inter; }
.snack i { color: var(--ok); font-size: 17px; }
.snack span { flex: 1; }
.toast { position: absolute; left: 50%; transform: translateX(-50%); bottom: 130px; z-index: 7; padding: 9px 14px; border-radius: 8px; background: var(--surf); box-shadow: 0 0 0 1px var(--line2); font: 400 12.5px Inter; white-space: nowrap; max-width: 90%; overflow: hidden; text-overflow: ellipsis; }
.prog { height: 6px; border-radius: 3px; background: var(--surf2); overflow: hidden; }
.prog div { height: 6px; background: var(--acc); transition: width .12s linear; }
.pad3 { display: grid; grid-template-columns: repeat(3, 68px); gap: 9px; justify-content: center; }
.pad3 button { height: 52px; border-radius: 10px; background: var(--surf); border: 1px solid var(--line); color: var(--tx); font: 400 20px/1 Inter; }
.dots { display: flex; justify-content: center; gap: 10px; }
.dots span { width: 11px; height: 11px; border-radius: 6px; border: 1px solid var(--line2); }
.dots span.on { background: var(--acc); }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 0 14px; }
.tile { padding: 12px; border-radius: 8px; background: var(--surf); box-shadow: 0 0 0 1px var(--line); }
.tile .k { font: 400 10.5px/1.2 Inter; color: var(--sub); }
.tile .v { margin-top: 6px; font: 500 21px/1 Inter; }
.tile .of { font: 400 11px/1 Inter; color: var(--sub); margin-left: 6px; }
.tile.wide { grid-column: span 2; }
.attn { margin: 0 12px 8px; padding: 11px 12px; border-radius: 8px; background: var(--surf); box-shadow: 0 0 0 1px var(--line); }
.attn .k { display: flex; align-items: center; gap: 7px; font: 500 10.5px/1 Inter; text-transform: uppercase; letter-spacing: .05em; }
.feeditem { padding: 11px 12px; border-bottom: 1px solid var(--line); }
.feeditem .meta1 { display: flex; align-items: center; gap: 6px; font: 400 11.5px/1 Inter; color: var(--sub); }
.feeditem .dot { width: 6px; height: 6px; border-radius: 3px; background: var(--acc); }
.feeditem .subj { margin: 6px 0 0; font: 400 13.5px/1.3 Inter; cursor: pointer; }
.feeditem .acts { display: flex; gap: 14px; margin-top: 10px; font: 400 12px/1 Inter; }
.split { display: grid; grid-template-columns: 404px 1fr; min-height: 0; flex: 1; }
.split > .left { border-right: 1px solid var(--line); overflow-y: auto; }
.split > .right { overflow-y: auto; }
