/* Раздел «Сообщения»: тёмное золото, расположение и поведение по утверждённому макету.
   Все классы с приставкой ib-, чтобы не задевать остальные разделы. */

#ib, .ib-pop {
  --ib-panel: #0c0d10; --ib-in: #17181d; --ib-gold: #e5ac45; --ib-gold-b: #f4bf5c; --ib-gold-l: #ffd785;
  --ib-line: rgba(229, 172, 69, 0.2); --ib-hair: rgba(255, 255, 255, 0.07);
  --ib-text: #f1f1f2; --ib-text2: #a1a6af; --ib-muted: #80858f; --ib-on-gold: #17130d; --ib-ok: #34d399; --ib-err: #ff8c9b;
  --ib-grad: linear-gradient(180deg, #ffd785 0%, #f4bf5c 35%, #e5ac45 70%, #a8722e 100%);
  color: var(--ib-text);
  color-scheme: dark;
  font: 400 14px/1.45 Inter, Manrope, system-ui, -apple-system, "Segoe UI", sans-serif;
}

/* ---------- Экран на всю высоту под шапкой ---------- */
body.inbox-view { overflow: hidden; }
body.inbox-view #app-screen { display: flex; flex-direction: column; height: 100vh; height: 100dvh; min-height: 0; overflow: hidden; }
body.inbox-view #app-screen.hidden { display: none; }
body.inbox-view #app-screen .header { flex: none; }
body.inbox-view #app-screen .content { flex: 1; min-height: 0; width: 100%; max-width: none; margin: 0; padding: 0; display: flex; }
body.inbox-view #tab-inbox { flex: 1; min-width: 0; min-height: 0; display: flex; animation: none; }
body.inbox-view #tab-inbox.hidden { display: none; }

#ib { flex: 1; min-width: 0; min-height: 0; display: grid; grid-template-columns: 340px minmax(0, 1fr) 300px; grid-template-rows: minmax(0, 1fr); font-variant-numeric: tabular-nums; }
#ib.no-card { grid-template-columns: 340px minmax(0, 1fr); }
#ib.no-card .ib-info { display: none; }
:where(#ib, .ib-pop) button { display: inline-block; justify-content: normal; align-items: normal; gap: normal; padding: 0; margin: 0; border: 0; border-radius: 0; background: none; box-shadow: none; color: inherit; font: inherit; line-height: inherit; text-align: center; cursor: pointer; transition: background-color 0.15s, color 0.15s, border-color 0.15s; }
:where(#ib, .ib-pop) input, :where(#ib) textarea { font: inherit; color: inherit; }
:where(#ib, .ib-pop) :focus-visible, .modal.modal-ib :focus-visible { outline: 2px solid var(--ib-gold-l, #ffd785); outline-offset: -2px; }
.ib-i { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
#ib ::-webkit-scrollbar, .ib-pop ::-webkit-scrollbar { width: 7px; height: 7px; }
#ib ::-webkit-scrollbar-thumb, .ib-pop ::-webkit-scrollbar-thumb { background: rgba(229, 172, 69, 0.22); border-radius: 9px; }

/* ---------- Список чатов ---------- */
.ib-list { display: flex; flex-direction: column; min-height: 0; min-width: 0; border-right: 1px solid var(--ib-hair); background: var(--ib-panel); }
.ib-top { padding: 10px 10px 0; }
.ib-sline { display: flex; gap: 8px; align-items: center; }
.ib-search { display: flex; flex: 1; min-width: 0; align-items: center; gap: 9px; height: 40px; padding: 0 13px; margin: 0; border-radius: 99px; background: #17181d; color: var(--ib-muted); border: 1px solid transparent; }
.ib-search:focus-within { border-color: var(--ib-gold-b); }
:where(#ib, .ib-pop) .ib-search input, .modal.modal-gold.modal-ib .modal-body .ib-search input { flex: 1; width: auto; min-width: 0; min-height: 0; height: auto; margin: 0; padding: 0; background: none; border: 0; border-radius: 0; outline: 0; box-shadow: none; color: var(--ib-text, #f1f1f2); }
.ib-search input::-webkit-search-cancel-button { filter: invert(0.6); }
#ib .ib-bell { width: 40px; height: 40px; flex: none; display: grid; place-items: center; border-radius: 50%; border: 1px solid var(--ib-hair); color: var(--ib-muted); }
#ib .ib-bell:hover { color: var(--ib-gold-l); border-color: var(--ib-line); }
#ib .ib-bell.active { color: var(--ib-gold-b); border-color: var(--ib-line); }

#ib .ib-acc { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 48px; margin-top: 8px; padding: 6px 10px 6px 8px; border-radius: 14px; border: 1px solid var(--ib-line); background: #101115; text-align: left; }
#ib .ib-acc:hover { border-color: rgba(244, 191, 92, 0.55); }
.ib-acc .t, .ib-am .t { flex: 1; min-width: 0; }
.ib-acc b, .ib-am b { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 13.5px; font-weight: 600; line-height: 1.3; }
.ib-acc small, .ib-am small { display: block; color: var(--ib-muted); font-size: 12px; line-height: 1.3; }
.ib-acc > .ib-i { color: var(--ib-gold-b); }
.ib-stack { display: flex; flex: none; padding-left: 8px; }
.ib-stack .ib-av { margin-left: -8px; border: 2px solid #101115; }

.ib-tabs-wrap { display: flex; align-items: center; margin-top: 4px; border-bottom: 1px solid var(--ib-hair); }
.ib-tabs { flex: 1; min-width: 0; display: flex; padding: 12px 12px; overflow-x: auto; scrollbar-width: none; }
.ib-tabs::-webkit-scrollbar { display: none; }
.ib-tabs.more { -webkit-mask-image: linear-gradient(90deg, #000 82%, transparent); mask-image: linear-gradient(90deg, #000 82%, transparent); }
#ib .ib-tabs button { flex: 1 0 auto; position: relative; display: flex; justify-content: center; gap: 5px; align-items: center; min-height: 40px; padding: 9px 10px 10px; color: var(--ib-text2); font-size: 13px; font-weight: 600; white-space: nowrap; user-select: none; -webkit-touch-callout: none; }
#ib .ib-tabs button:hover { color: var(--ib-text); }
#ib .ib-tabs button.on { color: var(--ib-gold-l); }
.ib-tabs button.on::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: 0; height: 2px; border-radius: 2px; background: var(--ib-gold-b); }
.ib-tabs button .ib-i { width: 13px; height: 13px; }
#ib .ib-tab-add { width: 34px; height: 30px; flex: none; display: grid; place-items: center; margin-left: 2px; border-radius: 9px; color: var(--ib-gold-b); border: 1px solid var(--ib-line); }
#ib .ib-tab-add:hover { background: rgba(229, 172, 69, 0.12); }
.ib-tab-add .ib-i { width: 16px; height: 16px; }

.ib-badge { display: inline-flex; flex: none; align-items: center; justify-content: center; min-width: 19px; height: 19px; padding: 0 5px; border-radius: 99px; background: var(--ib-gold-b, #f4bf5c); color: var(--ib-on-gold, #17130d); font-size: 11px; font-weight: 700; line-height: 1; }
.ib-badge.mute { background: #34363d; color: #b9bcc3; }

.ib-rows { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 4px 6px 12px; }
button.ib-row, button.ib-arch { display: flex; justify-content: flex-start; margin: 0; gap: 11px; align-items: center; width: 100%; padding: 8px 9px; border: 0; border-radius: 12px; background: none; box-shadow: none; color: var(--ib-text, #f1f1f2); font-size: 14px; font-weight: 400; line-height: 1.45; text-align: left; user-select: none; -webkit-touch-callout: none; }
#ib .ib-row:hover, #ib .ib-arch:hover { background: rgba(255, 255, 255, 0.035); }
#ib .ib-row.on { background: linear-gradient(90deg, rgba(229, 172, 69, 0.2), rgba(229, 172, 69, 0.07)); }
.ib-av { position: relative; flex: none; width: 50px; height: 50px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 17px; color: #fff4dc; background: var(--c, #3a2f1d); }
.ib-av img { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.ib-av img.wait { opacity: 0; }
.ib-av.online::after { content: ""; position: absolute; right: 1px; bottom: 1px; z-index: 1; width: 12px; height: 12px; border-radius: 50%; background: var(--ib-ok, #34d399); border: 2.5px solid #0c0d10; }
.ib-av.sm { width: 32px; height: 32px; font-size: 12.5px; }
.ib-av.xs { width: 30px; height: 30px; font-size: 11.5px; }
.ib-av-all { background: #26272d; color: var(--ib-gold-l, #ffd785); }
.ib-r-body { flex: 1; min-width: 0; display: block; }
.ib-r-l { display: flex; align-items: center; gap: 6px; min-width: 0; }
.ib-r-name { flex: 1; min-width: 0; display: flex; align-items: center; gap: 5px; font-weight: 600; font-size: 14.5px; }
.ib-r-name b { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-weight: 600; }
.ib-r-name .ib-i { width: 13px; height: 13px; color: var(--ib-muted); }
.ib-r-name .ib-star { color: var(--ib-gold-b); fill: var(--ib-gold-b); stroke: var(--ib-gold-b); }
.ib-r-time { display: flex; flex: none; align-items: center; gap: 3px; color: var(--ib-muted, #80858f); font-size: 12px; }
.ib-r-prev { flex: 1; min-width: 0; display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; color: var(--ib-text2, #a1a6af); font-size: 13.5px; font-weight: 400; }
.ib-r-prev em { font-style: normal; color: var(--ib-text, #f1f1f2); }
.ib-r-prev.typing { color: var(--ib-gold-b, #f4bf5c); }
.ib-r-acc { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 11.5px; color: #a68a55; line-height: 20px; }
.ib-pin { display: flex; color: var(--ib-muted); }
.ib-pin .ib-i { width: 15px; height: 15px; }
.ib-tick { width: 15px; height: 15px; color: var(--ib-gold-b, #f4bf5c); stroke-width: 2.2; }
.ib-tick.sent { color: var(--ib-muted, #80858f); }
#ib .ib-arch { color: var(--ib-text2); }
.ib-arch .ib-av { background: #26272d; color: var(--ib-text2); }
.ib-arch .ib-r-name { display: block; }
.ib-empty { padding: 40px 20px; text-align: center; color: var(--ib-muted, #80858f); }
#ib .ib-btn { height: 40px; margin-top: 14px; padding: 0 17px; border-radius: 11px; border: 1px solid var(--ib-line); font-weight: 600; color: var(--ib-text); }
#ib .ib-btn:hover { border-color: rgba(244, 191, 92, 0.55); color: var(--ib-gold-l); }
.ib-more { display: block; width: 100%; padding: 12px; text-align: center; color: var(--ib-muted, #80858f); font-size: 12.5px; }
#ib .ib-link { color: var(--ib-gold-b); }
.ib-skel i { display: block; position: relative; height: 66px; overflow: hidden; }
.ib-skel i::before { content: ""; position: absolute; left: 9px; top: 8px; width: 50px; height: 50px; border-radius: 50%; background: #17181d; }
.ib-skel i::after { content: ""; position: absolute; left: 70px; top: 18px; width: 52%; height: 10px; border-radius: 6px; background: #17181d; box-shadow: 0 20px 0 -1px #131419; }

/* ---------- Переписка ---------- */
.ib-chat { position: relative; display: flex; flex-direction: column; min-height: 0; min-width: 0;
  background: radial-gradient(900px 500px at 80% -10%, rgba(229, 172, 69, 0.09), transparent 60%), radial-gradient(700px 500px at 0% 110%, rgba(168, 114, 46, 0.07), transparent 60%), #07080a; }
.ib-chead { flex: none; display: flex; align-items: center; gap: 12px; height: 62px; padding: 0 14px; border-bottom: 1px solid var(--ib-hair); background: var(--ib-panel); }
.ib-chead .ib-av { width: 40px; height: 40px; font-size: 14px; }
#ib .ib-who { flex: 1; min-width: 0; text-align: left; }
/* style.css задаёт этому имени градиент старого оформления */
#ib #chat-header-name { display: block; font-size: 15px; font-weight: 600; letter-spacing: normal; background: none; -webkit-text-fill-color: currentColor; color: var(--ib-text); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.ib-who small { display: block; color: var(--ib-muted); font-size: 12.5px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.ib-who .live { color: var(--ib-ok); }
.ib-who .type { color: var(--ib-gold-b); }
#ib .ib-ic { width: 40px; height: 40px; flex: none; display: grid; place-items: center; border-radius: 50%; color: var(--ib-text2); }
#ib .ib-ic:hover { background: rgba(255, 255, 255, 0.05); color: var(--ib-gold-l); }
#ib .ib-ic.on { color: var(--ib-gold-b); }
#ib .ib-back { display: none; }
.ib-msgs { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 12px max(14px, calc((100% - 780px) / 2)); display: flex; flex-direction: column; gap: 3px; }
.ib-msgs > * { flex: none; }
.ib-msgs > :first-child { margin-top: auto; }
.ib-day { align-self: center; position: sticky; top: 0; z-index: 3; margin: 10px 0 7px; padding: 3px 12px; border-radius: 99px; background: rgba(20, 21, 26, 0.88); color: var(--ib-text2); font-size: 12px; font-weight: 600; }
.ib-pick { margin: auto; max-width: calc(100% - 28px); padding: 7px 15px; border-radius: 99px; background: rgba(20, 21, 26, 0.9); color: var(--ib-text2); font-weight: 500; text-align: center; }
.ib-msgs > .ib-pick:first-child { margin: auto; }
.ib-m { position: relative; align-self: flex-start; max-width: min(76%, 520px); min-width: 74px; padding: 7px 12px 6px; border-radius: 16px 16px 16px 5px; background: var(--ib-in); border: 1px solid rgba(255, 255, 255, 0.05); margin-bottom: 2px; }
.ib-m::after { content: ""; display: block; clear: both; }
.ib-m.out { align-self: flex-end; border-radius: 16px 16px 5px 16px; background: linear-gradient(180deg, #3a2d14, #2c2210); border-color: rgba(244, 191, 92, 0.22); }
.ib-m.pending { opacity: 0.75; }
.ib-tx { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14.5px; }
.ib-tx a { color: var(--ib-gold-l); text-decoration: underline; text-underline-offset: 2px; }
.ib-meta { float: right; display: inline-flex; align-items: center; gap: 3px; margin: 6px 0 -2px 12px; color: var(--ib-muted); font-size: 11px; line-height: 1; }
.ib-m.out .ib-meta { color: #b9a273; }
.ib-m.out .ib-meta .ib-tick:not(.sent) { color: var(--ib-gold-b); }
#ib .ib-quote { display: block; width: 100%; text-align: left; margin: 1px 0 5px; padding: 3px 9px; border-left: 3px solid var(--ib-gold-b); border-radius: 5px; background: rgba(229, 172, 69, 0.1); font-size: 12.5px; }
.ib-quote b { display: block; color: var(--ib-gold-l); font-size: 12px; }
.ib-quote span { display: block; color: var(--ib-text2); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; max-width: 340px; }
.ib-fwd { color: var(--ib-gold-b); font-size: 12px; font-weight: 600; margin-bottom: 2px; }
.ib-note { color: var(--ib-text2); font-size: 14px; overflow-wrap: anywhere; }
.ib-m.has-photo { width: 332px; padding: 5px 12px 6px; }
#ib .ib-photo { position: relative; display: block; width: calc(100% + 14px); border-radius: 12px; overflow: hidden; margin: 0 -7px 4px; background: #101115; }
.ib-photo img, .ib-thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transition: opacity 0.2s; }
.ib-photo img.wait, .ib-thumb img.wait, .ib-sticker img.wait { opacity: 0; }
.ib-fail { display: none; position: absolute; inset: 0; align-items: center; justify-content: center; padding: 12px; color: var(--ib-text2); font-size: 12.5px; text-align: center; }
.ib-pop .failed > img, #ib .failed > img { display: none; }
#ib .failed > .ib-fail { display: flex; }
.ib-sticker { position: relative; display: flex; align-items: center; justify-content: center; width: 140px; height: 140px; }
.ib-sticker img, .ib-sticker video, .ib-st-anim { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
.ib-st-anim svg { display: block; }
/* эмодзи стикера — пока грузится и если показать нельзя */
.ib-st-emoji { font-size: 64px; line-height: 1; opacity: 1; transition: opacity .2s; }
.ib-sticker.wait .ib-st-emoji { opacity: .35; }
.ib-sticker.ready .ib-st-emoji { opacity: 0; }
/* стикер без подписи — без «пузыря», как в Telegram; время — плашкой */
.ib-m:has(> .ib-sticker):not(:has(.ib-tx, .ib-quote, .ib-fwd)) { background: none; border-color: transparent; padding: 0; }
.ib-m:has(> .ib-sticker):not(:has(.ib-tx, .ib-quote, .ib-fwd)) .ib-meta { padding: 2px 8px; border-radius: 10px; background: rgba(0, 0, 0, 0.55); color: #d8d8dc; }
.ib-voice { display: flex; align-items: center; gap: 10px; width: 260px; max-width: 100%; padding: 2px 0; }
.ib-voice > div { min-width: 0; }
.ib-voice b { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 13px; font-weight: 600; }
#ib .ib-play { width: 42px; height: 42px; flex: none; border-radius: 50%; display: grid; place-items: center; background: var(--ib-grad); color: var(--ib-on-gold); }
.ib-play svg { width: 18px; height: 18px; fill: currentColor; }
.ib-wave { display: flex; align-items: center; gap: 2px; height: 26px; cursor: pointer; }
.ib-wave i { width: 3px; flex: none; border-radius: 2px; background: rgba(255, 255, 255, 0.25); }
.ib-wave i.p { background: var(--ib-gold-b); }
.ib-voice small { display: block; color: var(--ib-muted); font-size: 11.5px; }
#ib .ib-file { display: flex; align-items: center; gap: 11px; max-width: 100%; padding: 2px 0; text-align: left; }
.ib-file > span:last-child { min-width: 0; }
.ib-f-ic { width: 44px; height: 44px; flex: none; border-radius: 12px; display: grid; place-items: center; background: rgba(229, 172, 69, 0.15); color: var(--ib-gold-b); }
.ib-file b { display: block; font-size: 13.5px; font-weight: 600; overflow-wrap: anywhere; }
.ib-file small { display: block; color: var(--ib-muted); font-size: 12px; }
.ib-m.hit { animation: ib-hit 1.4s; }
@keyframes ib-hit { 0%, 40% { box-shadow: 0 0 0 3px #f4bf5c; } 100% { box-shadow: 0 0 0 3px transparent; } }
#ib .ib-m-more { position: absolute; top: 3px; right: -30px; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; color: var(--ib-muted); opacity: 0; }
#ib .ib-m.out .ib-m-more { right: auto; left: -30px; }
/* Прозрачная полоска, чтобы мышь доходила от пузыря до кнопки */
.ib-m-more::before { content: ""; position: absolute; inset: -4px -8px; }
#ib .ib-m:hover .ib-m-more, #ib .ib-m-more:focus-visible { opacity: 1; }
#ib .ib-m-more:hover { color: var(--ib-gold-l); background: rgba(255, 255, 255, 0.05); }
#ib .ib-down { position: absolute; right: 18px; bottom: 100px; z-index: 4; width: 42px; height: 42px; border-radius: 50%; background: #1b1c21; border: 1px solid var(--ib-line); display: grid; place-items: center; color: var(--ib-gold-b); }

/* ---------- Поле ввода ---------- */
.ib-compose { flex: none; padding: 8px max(14px, calc((100% - 780px) / 2)) 12px; }
.ib-bar { display: flex; align-items: center; gap: 10px; padding: 7px 8px 7px 14px; background: #15161b; border: 1px solid var(--ib-hair); border-bottom: 0; color: var(--ib-gold-b); }
.ib-bar:first-child { border-radius: 14px 14px 0 0; }
.ib-bar > div { flex: 1; min-width: 0; border-left: 3px solid var(--ib-gold-b); padding-left: 9px; }
.ib-bar b { display: block; font-size: 12.5px; font-weight: 600; }
.ib-bar span { display: block; color: var(--ib-text2); font-size: 12.5px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.ib-line { display: flex; align-items: flex-end; gap: 8px; }
.ib-box { flex: 1; min-width: 0; display: flex; align-items: flex-end; gap: 2px; min-height: 48px; padding: 3px 6px 3px 3px; border-radius: 24px; background: #15161b; border: 1px solid var(--ib-hair); }
#chat-bar:not(.hidden) + .ib-line .ib-box { border-radius: 0 0 22px 22px; }
.ib-box:focus-within { border-color: rgba(244, 191, 92, 0.55); }
#ib .ib-box textarea { flex: 1; width: auto; min-width: 0; min-height: 0; margin: 0; resize: none; border: 0; border-radius: 0; outline: 0; box-shadow: none; background: none; padding: 10px 4px; max-height: 160px; line-height: 20px; height: 40px; color: var(--ib-text); }
#ib .ib-send { width: 48px; height: 48px; flex: none; border-radius: 50%; display: grid; place-items: center; background: var(--ib-grad); color: var(--ib-on-gold); box-shadow: 0 6px 18px rgba(229, 172, 69, 0.22); }
#ib .ib-send:hover { filter: brightness(1.07); }
.ib-from { margin: 6px 0 0 14px; color: var(--ib-muted); font-size: 12px; }
.ib-from b { color: #c9a864; font-weight: 600; }

/* ---------- Карточка клиента ---------- */
.ib-info { display: flex; flex-direction: column; min-height: 0; min-width: 0; overflow-y: auto; border-left: 1px solid var(--ib-hair); background: var(--ib-panel); padding: 22px 16px; }
.ib-info > * { flex: none; }
.ib-info .ib-av.big { width: 88px; height: 88px; font-size: 30px; margin: 0 auto 12px; }
.ib-info h3 { text-align: center; font-size: 17px; font-weight: 700; overflow-wrap: anywhere; }
.ib-sub { min-height: 19px; text-align: center; color: var(--ib-muted); font-size: 13px; margin-bottom: 18px; }
.ib-ibox { padding: 11px 13px; border-radius: 13px; border: 1px solid var(--ib-hair); background: rgba(255, 255, 255, 0.02); margin-bottom: 10px; }
.ib-ibox small { display: block; color: var(--ib-muted); font-size: 12px; }
.ib-ibox b { font-weight: 600; font-size: 14px; overflow-wrap: anywhere; }
.ib-i-acts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 18px; }
#ib .ib-i-acts button { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 2px; border-radius: 12px; border: 1px solid var(--ib-line); font-size: 12px; color: var(--ib-text2); }
#ib .ib-i-acts button:hover { color: var(--ib-gold-l); border-color: rgba(244, 191, 92, 0.55); }
#ib .ib-i-acts button.on { background: rgba(229, 172, 69, 0.14); color: var(--ib-gold-l); }
.ib-info h4 { font-size: 13px; font-weight: 700; margin: 8px 0; color: var(--ib-text2); }
.ib-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; margin-bottom: 12px; }
#ib .ib-thumb { position: relative; aspect-ratio: 1; border-radius: 8px; overflow: hidden; background: #17181d; }
.ib-info .ib-file { margin-bottom: 6px; }

/* ---------- Меню, выбор аккаунта, фото ---------- */
.ib-menu { position: fixed; z-index: 1200; min-width: 232px; max-width: calc(100vw - 16px); max-height: calc(100vh - 16px); overflow-y: auto; padding: 6px; border-radius: 14px; background: rgba(18, 19, 23, 0.98); border: 1px solid var(--ib-line); box-shadow: 0 20px 45px rgba(0, 0, 0, 0.65); }
.ib-menu.ib-menu button { width: 100%; display: flex; justify-content: flex-start; gap: 11px; align-items: center; min-height: 38px; padding: 8px 11px; border-radius: 9px; text-align: left; font-weight: 500; }
.ib-menu.ib-menu button:hover { background: rgba(229, 172, 69, 0.11); color: var(--ib-gold-l); }
.ib-menu button .ib-i { color: var(--ib-gold-b); width: 17px; height: 17px; }
.ib-menu hr { border: 0; border-top: 1px solid var(--ib-hair); margin: 5px 4px; }
.ib-menu.ib-menu .danger, .ib-menu.ib-menu .danger .ib-i { color: var(--ib-err); }
.ib-menu.ib-am { width: 320px; background: #121317; overflow: visible; }
.ib-am .ib-am-q { flex: none; margin-bottom: 6px; height: 38px; border-radius: 11px; background: #08090b; border-color: rgba(255, 255, 255, 0.1); }
.ib-am .ib-am-q:focus-within { border-color: var(--ib-gold-b); }
.ib-am-list { max-height: min(330px, 52vh); overflow-y: auto; }
.ib-am-list .ib-empty { padding: 22px 10px; }
.ib-menu.ib-menu.ib-am button { padding: 8px 10px; }
.ib-menu.ib-menu.ib-am button.on { background: rgba(229, 172, 69, 0.12); }
.ib-am-list button > .ib-i { width: 17px; height: 17px; }
.ib-am .ph { width: 17px; flex: none; }
.ib-viewer { position: fixed; inset: 0; z-index: 1300; display: grid; grid-template: minmax(0, 1fr) / minmax(0, 1fr); place-items: center; padding: 18px; background: rgba(0, 0, 0, 0.92); cursor: zoom-out; }
.ib-viewer img { max-width: 100%; max-height: 100%; min-height: 0; object-fit: contain; }
.ib-viewer button { position: absolute; top: 14px; right: 14px; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; background: rgba(255, 255, 255, 0.08); }

/* ---------- Окна раздела (на основе общих окон) ---------- */
.modal.modal-gold.modal-ib { --ib-text: #f1f1f2; --ib-muted: #80858f; --ib-text2: #a1a6af; --ib-gold-b: #f4bf5c; --ib-gold-l: #ffd785; --ib-on-gold: #17130d; max-width: 400px; font-variant-numeric: tabular-nums; }
/* Как в макете: заголовок без крестика и разделителей; закрывают «Отмена», Esc и нажатие мимо окна */
.modal.modal-gold.modal-ib .modal-header { padding: 22px 22px 0; border: 0; }
.modal.modal-gold.modal-ib .modal-header h3 { font-size: 18px; letter-spacing: normal; overflow-wrap: anywhere; }
.modal.modal-gold.modal-ib .modal-close { display: none; }
.modal.modal-gold.modal-ib .modal-body { padding: 10px 22px 0; }
.modal.modal-gold.modal-ib .ac-lead { margin-bottom: 14px; font-size: 14px; }
.modal.modal-gold.modal-ib .modal-footer { flex-wrap: wrap; justify-content: flex-end; gap: 9px; padding: 14px 22px 22px; border: 0; }
.modal.modal-gold.modal-ib .modal-footer button { min-width: 0; min-height: 40px; height: 40px; padding: 0 17px; }
.modal.modal-gold.modal-ib .modal-body input.ib-in { width: 100%; height: 44px; margin: 0 0 10px; padding: 0 13px; border-radius: 11px; background: #08090b; border: 1px solid rgba(255, 255, 255, 0.1); outline: 0; text-transform: none; }
.modal.modal-gold.modal-ib .modal-body input.ib-in:focus { border-color: #f4bf5c; box-shadow: none; }
.modal.modal-gold.modal-ib .modal-body label.ib-f-q { display: flex; margin: 0; text-transform: none; letter-spacing: 0; font-size: 14px; font-weight: 400; background: #08090b; border-radius: 11px; border: 1px solid rgba(255, 255, 255, 0.1); }
.modal.modal-gold.modal-ib .modal-body label.ib-f-q:focus-within { border-color: #f4bf5c; }
.ib-f-list { height: min(290px, 34vh); overflow-y: auto; margin-top: 8px; }
.modal.modal-ib .ib-f-list .ib-row { justify-content: flex-start; padding: 6px 8px; min-height: 0; cursor: pointer; }
.modal.modal-ib .ib-f-list .ib-row:hover { background: rgba(255, 255, 255, 0.045); }
.modal.modal-ib .ib-f-list .ib-row.busy { opacity: 0.5; }
.ib-f-list .ib-av { width: 38px; height: 38px; font-size: 13px; }
.ib-f-list .ib-r-name { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.ib-f-list .ib-r-acc { line-height: 1.35; }
.ib-box-c { width: 22px; height: 22px; flex: none; display: grid; place-items: center; border-radius: 7px; border: 1.5px solid #50535b; }
.ib-box-c .ib-i { width: 15px; height: 15px; opacity: 0; stroke-width: 3; }
.ib-row.sel .ib-box-c { background: #f4bf5c; border-color: #f4bf5c; color: #17130d; }
.ib-row.sel .ib-box-c .ib-i { opacity: 1; }
.modal.modal-gold.modal-ib .modal-body label.ib-check { display: flex; gap: 10px; align-items: center; margin: 0; padding: 12px; border-radius: 12px; border: 1px solid rgba(255, 255, 255, 0.08); cursor: pointer; color: #f1f1f2; font-size: 14px; font-weight: 500; text-transform: none; letter-spacing: 0; }
.modal.modal-gold.modal-ib .modal-body label.ib-check input { width: 18px; height: 18px; flex: none; margin: 0; padding: 0; accent-color: #f4bf5c; }
.ib-check span { overflow-wrap: anywhere; }
.modal.modal-gold.modal-ib .modal-footer .ib-del-folder { margin-right: auto; min-width: 0; padding: 0 6px; border-color: transparent; background: none; color: #ff8c9b; }

/* Всплывающее сообщение лежит над полем ввода и не должно перехватывать нажатия */
body.inbox-view .ac-toast { pointer-events: none; }

/* ---------- Окно перевода ---------- */
.ib-tr-source { max-height: min(110px, 18vh); overflow-y: auto; padding: 3px 0 3px 10px; border-left: 3px solid rgba(244, 191, 92, 0.45); color: #a1a6af; font-size: 13.5px; white-space: pre-wrap; overflow-wrap: anywhere; }
.modal.modal-gold.modal-ib .modal-body label.ib-tr-lang { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 14px 0 10px; color: #80858f; font-size: 13px; font-weight: 500; text-transform: none; letter-spacing: 0; }
.modal.modal-gold.modal-ib .modal-body label.ib-tr-lang select { width: auto; min-height: 36px; height: 36px; margin: 0; padding: 0 34px 0 12px; font-size: 13.5px; color: #f1f1f2; }
.ib-tr-text { min-height: 66px; max-height: min(260px, 34vh); overflow-y: auto; padding: 11px 13px; border-radius: 12px; border: 1px solid rgba(255, 255, 255, 0.08); background: rgba(255, 255, 255, 0.025); color: #f1f1f2; font-size: 14.5px; white-space: pre-wrap; overflow-wrap: anywhere; user-select: text; }
.ib-tr-text.wait { color: #80858f; }
.ib-tr-text.err { color: #ff8c9b; border-color: rgba(245, 87, 108, 0.3); }

/* ---------- Узкий экран: карточки нет ---------- */
@media (max-width: 1180px) {
  #ib, #ib.no-card { grid-template-columns: 320px minmax(0, 1fr); }
  #ib .ib-info, #ib .ib-card-btn { display: none; }
}

/* Палец вместо мыши: кнопки «⋯» нет, меню по долгому нажатию */
@media (pointer: coarse) {
  .ib-m, .ib-row { user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
  #ib .ib-m-more { display: none; }
}

/* ---------- Телефон: список и чат отдельными экранами ---------- */
@media (max-width: 760px) {
  #ib, #ib.no-card { grid-template-columns: minmax(0, 1fr); }
  #ib .ib-list { border-right: 0; }
  #ib .ib-chat { display: none; }
  body.ib-in-chat #ib .ib-list, body.inbox-view.ib-in-chat #app-screen .header, body.inbox-view.ib-in-chat #app-screen .mobile-nav-menu { display: none; }
  body.ib-in-chat #ib .ib-chat { display: flex; }
  #ib .ib-back { display: grid; }
  .ib-chead { padding: 0 6px; gap: 8px; }
  .ib-msgs { padding: 10px; }
  .ib-m { max-width: 86%; }
  .ib-compose { padding: 6px 8px 10px; padding-bottom: max(10px, env(safe-area-inset-bottom)); }
  #ib .ib-m-more { display: none; }
  .ib-m.has-photo { width: 272px; }
  #ib .ib-box textarea, #ib .ib-search input { font-size: 16px; }
  #ib .ib-down { bottom: 92px; }
}

@media (prefers-reduced-motion: reduce) {
  .ib-m.hit { animation: none; outline: 2px solid #f4bf5c; }
  .ib-photo img, .ib-thumb img { transition: none; }
}

/* Выбор нескольких чатов */
.ib-tools { display: flex; align-items: center; gap: 14px; min-height: 38px; padding: 4px 4px 2px; font-size: 13px; }
.ib-tools span { color: #a1a6af; white-space: nowrap; }
#ib .ib-tools button { min-height: 0; margin: 0; padding: 5px 0; border: 0; border-radius: 6px; background: none; box-shadow: none; transform: none; color: var(--ib-gold-b); font: inherit; font-weight: 600; white-space: nowrap; cursor: pointer; }
#ib .ib-tools button:hover { color: #ffd785; }
#ib .ib-tools .ib-tools-end { margin-left: auto; }
.ib-sel-box { display: grid; place-items: center; width: 20px; height: 20px; flex: none; border-radius: 6px; border: 1.5px solid rgba(244, 191, 92, 0.55); }
.ib-sel-box .ib-i { width: 14px; height: 14px; opacity: 0; }
.ib-row.sel .ib-sel-box { background: #f4bf5c; border-color: #f4bf5c; color: #17130d; }
.ib-row.sel .ib-sel-box .ib-i { opacity: 1; }
#ib .ib-row.sel { background: rgba(229, 172, 69, 0.13); }
.ib-bulk { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px; border-top: 1px solid var(--ib-line); }
.ib-bulk[hidden] { display: none; }
#ib .ib-bulk button { flex: 1 1 auto; min-height: 0; height: 34px; margin: 0; padding: 0 11px; border-radius: 9px; border: 1px solid var(--ib-line); background: rgba(255, 255, 255, 0.045); box-shadow: none; transform: none; color: #f1f1f2; font: inherit; font-size: 13px; font-weight: 600; white-space: nowrap; cursor: pointer; }
#ib .ib-bulk button:hover:not(:disabled) { border-color: rgba(244, 191, 92, 0.55); color: #ffd785; }
#ib .ib-bulk button:disabled { opacity: 0.45; cursor: default; }
