/* 0.15.2 — договор «Настройки → Интерфейс» v1.2 (§7, 002-З-1445): правша/левша на всех экранах, платформа android/apple,
   раскладки telegram и wechat как экранные формы оригиналов (без чужих логотипов, значков и фирменных цветов),
   мини-кнопки, выделение, лента combined, кнопки звонка, плашка «Идёт запись», знак кобрендинга. */

:root { --w152-reach: 40vh; }

/* ================================================================ мини-кнопки у сообщений и строк звонков (§7.3) */
.w152-q { display: inline-flex; align-items: center; gap: 2px; flex: none; align-self: center; }
.w152-qb { width: 40px; height: 40px; min-width: 40px; border-radius: 50%; display: grid; place-items: center; color: var(--ink-2);
  background: color-mix(in srgb, var(--bg) 72%, transparent); transition: opacity .12s, background .12s; }
.w152-qb:hover, .w152-qb:focus-visible { background: var(--bg-2); color: var(--brand); }
.w152-qb.on { background: var(--brand-soft); color: var(--brand); }
.bubble-row:has(.w152-q) { max-width: min(820px, 94%); }
.bubble-row:has(.w152-q) > .bubble { min-width: 0; flex: 0 1 auto; }
/* мышь — при наведении; касание — всегда */
@media (hover: hover) and (pointer: fine) {
  .w152-q { opacity: 0; }
  .msg:hover .w152-q, .room:hover .w152-q, .w152-q:focus-within, .w152-selmode .w152-q { opacity: 1; }
}
@media (max-width: 760px) {
  .bubble-row:has(.w152-q) { max-width: 100%; }
  .w152-q { gap: 0; }
}
.call-row .w152-q { margin-inline: 2px; }
.call-row .col.grow { min-width: 0; }
.call-row .col.grow .name, .call-row .col.grow .call-line { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* выделение */
.msg.w152-picked .bubble { outline: 2px solid var(--brand); outline-offset: 1px; }
.msg.w152-picked { background: color-mix(in srgb, var(--brand) 8%, transparent); border-radius: 8px; }
.w152-selmode .bubble { cursor: pointer; }
.w152-selbar { display: flex; align-items: center; gap: 6px; padding: 6px 10px; min-height: 52px; background: var(--bg-2); border-top: 1px solid var(--line); }
.w152-selbar .icon { min-width: 44px; min-height: 44px; }
.w152-selbar .link { min-height: 44px; padding-inline: 10px; }

/* ================================================================ лента combined (§7.4) */
.w152-feed-call .avatar { opacity: .9; }
.w152-feed-call[data-kind="missed"] .name { color: var(--danger); }

/* ================================================================ кнопки звонка, плашка записи, результат (§7.5) */
.w152-callbtns.call { display: contents; }
.w152-callbtns.chat { display: inline-flex; gap: 2px; }
.w152-cb { position: relative; }
.w152-cb.rec { background: #C62828 !important; color: #fff !important; }
.w152-cb .w152-rec-time { position: absolute; bottom: -16px; left: 50%; transform: translateX(-50%); font-size: 11px; color: inherit; font-variant-numeric: tabular-nums; white-space: nowrap; }
.cv-controls .w152-cb .w152-rec-time { color: #fff; }
.w152-rec-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: #FF5252; animation: w152-blink 1s steps(2, start) infinite; flex: none; }
.w152-cb .w152-rec-dot { position: absolute; top: 4px; inset-inline-end: 4px; }
@keyframes w152-blink { to { visibility: hidden; } }
@media (prefers-reduced-motion: reduce) { .w152-rec-dot { animation: none; } }
.w152-recbanner { display: flex; align-items: center; gap: 8px; padding: 6px 12px; background: #B71C1C; color: #fff; font-size: 13.5px; font-weight: 600; }
.cv-top .w152-recbanner, .gc-top .w152-recbanner { border-radius: 999px; padding: 4px 12px; flex-basis: auto; }
.call-card .w152-recbanner { border-radius: 999px; }
.w152-chatcall { display: flex; align-items: center; gap: 8px; padding-block: 4px 4px; padding-inline: 12px 6px; background: color-mix(in srgb, var(--brand) 10%, var(--bg)); border-top: 1px solid var(--line); color: var(--ink); min-height: 48px; }
.w152-chatcall > .ic { color: var(--ok); }
.w152-rec-notice span { display: inline-flex; align-items: center; gap: 6px; }
.w152-result { position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 80; display: flex; align-items: center; gap: 10px; padding-block: 8px 8px; padding-inline: 14px 8px;
  background: var(--bg); color: var(--ink); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); width: max-content; max-width: calc(100vw - 24px); }
.w152-result .col { min-width: 0; }
.w152-result small { color: var(--ink-2); max-width: 46vw; }
.w152-result .primary { min-height: 40px; white-space: nowrap; }
.w152-sheet h3 { margin: 0; }
.w152-conf-url { display: block; padding: 10px; background: var(--bg-2); border-radius: 10px; word-break: break-all; font-size: 13px; user-select: all; }
@media (max-width: 600px) {
  .w152-sheet-bg { place-items: end stretch; padding: 0; }
  .w152-sheet { width: 100%; border-radius: 22px 22px 0 0; }
}

/* ================================================================ знак кобрендинга (§7.1) */
.w152-cobrand { flex: none; display: block; }
.w151-brand .w152-cobrand, .w151-a1bar .w152-cobrand { margin-inline-end: 2px; }
.w151-brand { gap: 12px; }

/* ================================================================ «Быстрые кнопки» */
.w152-qchip { display: inline-flex; align-items: center; gap: 4px; padding-block: 2px 2px; padding-inline: 10px 2px; border: 1px solid var(--line); border-radius: 999px; background: var(--bg); min-height: 44px; }
.w152-qchip .icon.sm { width: 36px; height: 36px; }
.w152-qside { display: flex; flex-direction: column; gap: 6px; }
.w152-callq-row { align-items: center; min-height: 48px; }
.w152-callq-row label { align-items: center; min-height: 44px; }
.w152-qpv { display: flex; flex-direction: column; gap: 6px; padding: 10px; background: var(--chat-bg); border-radius: 12px; }
.w152-qpv-row { display: flex; align-items: center; gap: 3px; }
.w152-qpv-row.own { justify-content: flex-end; }
.w152-pv-bubble { width: 110px; height: 26px; border-radius: 10px; background: var(--other); box-shadow: 0 1px 1.5px rgba(16, 32, 56, .1); }
.w152-pv-bubble.own { background: var(--own); }
.w152-pv-b { width: 22px; height: 22px; border-radius: 50%; background: var(--bg); display: grid; place-items: center; color: var(--ink-2); }

/* ================================================================ раскладки: экранные формы (§7.1) */
.w152-edit, .w152-search-btn, .w152-compose, .w152-menu-call { display: none; }
.w152-fab-alibry { display: none; }
.side { position: relative; }
.w151-drawer-me { width: 100%; text-align: start; align-items: flex-start; }
.w151-drawer-sep { border: 0; border-top: 1px solid var(--line); margin: 6px 0; }

/* ---- telegram (обе платформы) */
:root[data-layout="telegram"] .w152-menu-call { display: flex; }
:root[data-layout="telegram"] .chat-head :is(.head-video, .head-call) { display: none; }
:root[data-layout="telegram"] .comp-cam { display: none !important; }
:root[data-layout="telegram"] .tab-head .cam-btn { display: none; }
/* telegram + android: «≡», название, поиск справа; вкладки папок; «карандаш» снизу справа; нижней панели нет */
:root[data-layout="telegram"][data-platform="android"] .tab-head .w152-search-btn { display: inline-grid; }
:root[data-layout="telegram"][data-platform="android"] .side .panel:not(.w152-searching) > .search { display: none; }
/* telegram + apple: «Изм.» слева, «Чаты» по центру, «новое сообщение» справа; поиск под шапкой; снизу Контакты/Звонки/Чаты/Настройки */
:root[data-layout="telegram"][data-platform="apple"] .tab-head .menu-left { display: none; }
:root[data-layout="telegram"][data-platform="apple"] .tab-head :is(.w152-edit, .w152-compose) { display: inline-grid; }
:root[data-layout="telegram"][data-platform="apple"] .tab-head .w152-edit { display: inline-flex; align-items: center; min-height: 44px; padding-inline: 4px; color: var(--brand); font-weight: 500; }
:root[data-layout="telegram"][data-platform="apple"] .side .panel > .tab-head { position: relative; justify-content: space-between; }
:root[data-layout="telegram"][data-platform="apple"] .side .panel > .tab-head h1 { position: absolute; left: 50%; transform: translateX(-50%); font-size: 17px; font-weight: 600; }
:root[data-layout="telegram"][data-platform="apple"]:not([data-hand]) .tabs { display: flex; }
:root[data-layout="telegram"][data-platform="apple"] .w151-fab { display: none; }
@media (min-width: 761px) {
  :root[data-layout="telegram"][data-platform="apple"]:not([data-hand]) .side .tabs { display: flex; background: var(--bg-2); border-top: 1px solid var(--line); }
  :root[data-layout="telegram"][data-platform="apple"] .tab { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0 8px; font-size: 12px; color: var(--ink-2); }
  :root[data-layout="telegram"][data-platform="apple"] .tab-ic { position: relative; width: 52px; height: 30px; border-radius: 999px; display: grid; place-items: center; }
  :root[data-layout="telegram"][data-platform="apple"] .tab.on { color: var(--brand); }
}
/* «Изм.»: выбор чатов */
.w152-check { flex: none; width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--ink-3); display: grid; place-items: center; }
.w152-check.on { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.w152-editing .room .row-more { display: none; }

/* ---- wechat: название по центру, справа поиск и «⊕»; без вкладок папок; снизу Чаты/Контакты/Открыть/Я */
:root[data-layout="wechat"] .side .panel > .tab-head { position: relative; justify-content: flex-end; }
:root[data-layout="wechat"] .tab-head :is(.menu-left, .cam-btn) { display: none; }
:root[data-layout="wechat"] .tab-head .w152-search-btn { display: inline-grid; }
:root[data-layout="wechat"] .tab-head .plus-btn { border: 1.8px solid currentColor; border-radius: 50%; width: 30px; height: 30px; min-width: 30px; margin: 9px; }
:root[data-layout="wechat"] .side .panel:not(.w152-searching) > .search { display: none; }
:root[data-layout="wechat"] .side .panel > .filters { display: none; }
/* чат wechat: снизу «голос/клавиатура», поле, «смайлик» и «⊕» */
:root[data-layout="wechat"] .comp-pill .comp-emoji { order: 2; }
:root[data-layout="wechat"] .comp-pill textarea { order: 1; }
:root[data-layout="wechat"] .comp-pill .comp-attach { order: 3; }
.w152-vk { flex: none; }
.w152-hold { min-height: 42px; border: 1px solid var(--line); border-radius: var(--r-field, 10px); background: var(--bg); font-weight: 600; color: var(--ink); }
.popup.w152-tiles { position: fixed; inset-inline-start: 0 !important; inset-inline-end: 0; top: auto !important; bottom: 0; width: 100%; max-width: 100%; min-width: 0;
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; padding: 14px 10px calc(14px + env(safe-area-inset-bottom)); border-radius: 18px 18px 0 0; }
.popup.w152-tiles > button { flex-direction: column; justify-content: center; text-align: center; gap: 6px; font-size: 12px; padding: 10px 2px; min-height: 76px; }
.popup.w152-tiles .att-ic { width: 52px; height: 52px; border-radius: 14px; }
@media (min-width: 761px) { .popup.w152-tiles { inset-inline-start: auto !important; inset-inline-end: 16px; bottom: 80px; width: 380px; border-radius: 18px; } }

/* ================================================================ платформа (§7.2) */
/* ---- android: Material 3 — плавающая кнопка, нижние листы, переключатели Material */
:root[data-platform="android"] .switch { width: 52px !important; height: 32px !important; background: var(--bg-3); box-shadow: inset 0 0 0 2px var(--ink-3) !important; }
:root[data-platform="android"] .switch::after { top: 8px; inset-inline-start: 8px; width: 16px; height: 16px; background: var(--ink-2); box-shadow: none; transition: all .15s; }
:root[data-platform="android"] .switch:checked { background: var(--brand); box-shadow: none !important; }
:root[data-platform="android"] .switch:checked::after { top: 4px; inset-inline-start: 24px; width: 24px; height: 24px; background: var(--brand-ink); }
@media (max-width: 760px) {
  :root[data-platform="android"]:not([data-layout]):not([data-hand]) .w152-fab-alibry { display: grid; bottom: 74px; inset-inline-end: 16px; }
  :root[data-platform="android"]:not([data-layout]):not([data-hand]):not([data-bars]) .side .tab-head .plus-btn { display: none; }
  :root[data-platform="android"] .popup:not(.picker-pop):not(.mention-pop):not(.w152-tiles) { inset-inline-start: 0 !important; inset-inline-end: 0; top: auto !important; bottom: 0; width: 100%; max-width: 100%;
    max-height: 72vh; overflow-y: auto; border-radius: 28px 28px 0 0; padding: 22px 8px calc(10px + env(safe-area-inset-bottom)); animation: w152-up .16s ease-out; }
  :root[data-platform="android"] .popup:not(.picker-pop):not(.mention-pop):not(.w152-tiles)::before { content: ""; position: absolute; top: 8px; left: 50%; width: 32px; height: 4px; margin-inline-start: -16px; border-radius: 2px; background: var(--ink-3); opacity: .5; }
  :root[data-platform="android"] .popup > button { min-height: 52px; }
  :root[data-platform="android"] .popup-bg { background: rgb(0 0 0 / 32%); }
}
@keyframes w152-up { from { transform: translateY(24px); opacity: .4; } }

/* ---- apple: iOS — нижняя таб-панель, крупный заголовок, «‹ Назад» с подписью, листы действий, переключатели iOS */
:root[data-platform="apple"] .switch { width: 51px !important; height: 31px !important; background: color-mix(in srgb, var(--ink) 16%, var(--bg)); }
:root[data-platform="apple"] .switch::after { top: 2px; inset-inline-start: 2px; width: 27px; height: 27px; box-shadow: 0 3px 8px rgb(0 0 0 / 15%), 0 1px 1px rgb(0 0 0 / 16%); }
:root[data-platform="apple"] .switch:checked { background: #248A3D; }
:root[data-platform="apple"] .switch:checked::after { inset-inline-start: 22px; }
/* «‹ Назад» с подписью (iOS): шеврон и текст вместо стрелки */
:root[data-platform="apple"] button[data-label] { grid-auto-flow: column; align-items: center; gap: 2px; width: auto; padding-inline: 2px 8px; color: var(--brand); }
:root[data-platform="apple"] button[data-label] .ic[data-ic="back"] { display: none; }
:root[data-platform="apple"] button[data-label]::before { content: "‹"; font-size: 34px; line-height: 1; margin-top: -4px; }
:root[data-platform="apple"] button[data-label]::after { content: attr(data-label); font-size: 16px; }
:root[data-platform="apple"]:not([data-layout]) .side .panel > .tab-head { flex-wrap: wrap; row-gap: 0; padding-bottom: 4px; }
:root[data-platform="apple"]:not([data-layout]) .side .panel > .tab-head h1 { order: 20; flex-basis: 100%; font-size: 32px; font-weight: 800; letter-spacing: -.01em; }
:root[data-platform="apple"] .tabs { -webkit-backdrop-filter: saturate(180%) blur(18px); backdrop-filter: saturate(180%) blur(18px); background: color-mix(in srgb, var(--bg) 86%, transparent); }
:root[data-platform="apple"] .tabs .tab.on { color: var(--brand); }
:root[data-platform="apple"] .tabs .tab.on .tab-ic { background: none; }
:root[data-platform="apple"] .popup.msg-menu { border-radius: 14px; -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px); background: color-mix(in srgb, var(--bg) 88%, transparent); }
@media (max-width: 760px) {
  :root[data-platform="apple"] .popup:not(.picker-pop):not(.mention-pop):not(.w152-tiles):not(.msg-menu) { inset-inline-start: 8px !important; inset-inline-end: 8px; top: auto !important; bottom: 8px; width: auto; max-width: none;
    max-height: 70vh; overflow-y: auto; border-radius: 14px; padding: 4px; animation: w152-up .18s ease-out; }
  :root[data-platform="apple"] .popup:not(.picker-pop):not(.mention-pop):not(.w152-tiles):not(.msg-menu) > button { justify-content: center; min-height: 52px; font-size: 17px; color: var(--brand); border-bottom: 1px solid var(--line); border-radius: 0; }
  :root[data-platform="apple"] .popup:not(.picker-pop):not(.mention-pop):not(.w152-tiles):not(.msg-menu) > button:last-child { border-bottom: 0; }
  :root[data-platform="apple"] .popup > button.danger { color: var(--danger); }
  :root[data-platform="apple"] .popup-bg { background: rgb(0 0 0 / 28%); }
}
/* свайпы по строке (apple) */
.w152-swipe { position: relative; height: 0; z-index: 0; }
.w152-swipe > button { position: absolute; top: 0; height: 68px; width: 80px; color: #fff; font-size: 12.5px; font-weight: 600; padding: 0 6px; white-space: normal; line-height: 1.15; text-align: center; overflow: hidden; }
.w152-swipe.l > .w152-sw-pin { inset-inline-end: 80px; background: #E65100; }
.w152-swipe.l > .w152-sw-arch { inset-inline-end: 0; background: #546E7A; }
.w152-swipe.r > .w152-sw-read { inset-inline-start: 0; width: 100px; background: #1565C0; }
.room[style*="translateX"] { position: relative; z-index: 1; background: var(--bg); transition: transform .15s; }

/* ================================================================ правша / левша: всё нажимаемое — внизу, на всех экранах (§7.1) */
.w152-reach-title, .w152-you-h1 { display: none; }
/* шапки и полосы панелей — вниз (список, звонки, вкладки, настройки, профиль, сведения) */
:root[data-hand] .panel > .panel-head { order: 90; border-top: 1px solid var(--line); }
:root[data-hand] .panel > :is(.search, .filters, .banner, .w9a-bars, .recovery, .search-kinds, .w152-selbar, .chat-search) { order: 80; }
:root[data-hand] .side .tab-head .menu-left { order: 0; }
/* экран чата: заголовок-текст сверху; шапка с действиями, закреплённое, поиск — над полем ввода */
:root[data-hand] .chat > * { order: 50; }
:root[data-hand] .chat > .w152-reach-title { order: 0; }
:root[data-hand] .chat > .chat-body { order: 10; }
:root[data-hand] .chat > .chat-head { order: 60; border-top: 1px solid var(--line); border-bottom: 0; }
:root[data-hand] .chat > :is(footer, .composer, .w15-channel-foot) { order: 70; }
:root[data-hand] .chat > .w152-reach-title { display: block; padding: 10px 16px; text-align: center; font-weight: 700; font-size: 17px; color: var(--ink);
  background: var(--bg); border-bottom: 1px solid var(--line); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; pointer-events: none; }
/* ручка сегмента в нижнем углу не закрывает кнопки нижних полос */
:root[data-hand="right"] .panel > .panel-head, :root[data-hand="right"] .chat > .chat-head, :root[data-hand="right"] .w152-selbar { padding-inline-end: 84px; }
:root[data-hand="left"] .panel > .panel-head, :root[data-hand="left"] .chat > .chat-head, :root[data-hand="left"] .w152-selbar { padding-inline-start: 84px; }
/* звонок: карточка и кнопки — у нижнего края */
:root[data-hand] .call-overlay:not(.video):not(.gc) { place-items: end center; }
:root[data-hand] .call-overlay .cv-controls { bottom: 18px; }
@media (max-width: 600px) {
  /* телефон: верхние 40% — только крупный заголовок-текст (как «зона досягаемости»); содержимое и кнопки — ниже */
  :root[data-hand] .panel { padding-top: var(--w152-reach); }
  :root[data-hand] .panel > .panel-head h1, :root[data-hand] .panel > .panel-head .w152-you-h1 { display: flex; position: absolute; top: 0; inset-inline: 0; inset-inline-start: 0; transform: none;
    height: var(--w152-reach); align-items: flex-end; padding: 0 20px 14px; margin: 0; font-size: 30px; font-weight: 800; pointer-events: none; z-index: 1;
    background: linear-gradient(180deg, color-mix(in srgb, var(--brand) 7%, var(--bg)), var(--bg)); border-bottom: 1px solid var(--line); }
  :root[data-hand] .panel.w152-scrolled { padding-top: 56px; }
  :root[data-hand] .panel.w152-scrolled > .panel-head h1, :root[data-hand] .panel.w152-scrolled > .panel-head .w152-you-h1 { height: 56px; font-size: 19px; padding-bottom: 14px; }
  /* «Сведения» (aside.info) и вложенные страницы — так же */
  :root[data-hand] .chat-head .back { display: inline-grid; }
}

/* кнопка «Чат» в звонке: свёрнутый звонок — полоска «Вернуться к звонку» */
.w152-callpill { position: fixed; left: 50%; top: 10px; transform: translateX(-50%); z-index: 46; display: flex; align-items: center; gap: 8px; max-width: calc(100vw - 24px);
  min-height: 44px; padding: 6px 16px; border-radius: 999px; background: #1B5E20; color: #fff; font-weight: 600; box-shadow: var(--shadow); }
:root[data-hand] .w152-callpill { top: auto; bottom: 150px; }
