/* MOBILE-UX 10.10.2026: доработки мобильной веб-версии (только ≤860px). Откат: убрать ссылку из index.html */
@media (max-width: 860px) {
  /* 1. Свайпы по диалогам */
  #chats { position: relative; }
  #chats .mux-acts { position: absolute; left: 0; right: 0; display: flex; justify-content: flex-end; align-items: stretch; pointer-events: none; z-index: 0; }
  #chats .mux-acts.l { justify-content: flex-start; }
  #chats .mux-acts button { pointer-events: auto; border: 0; min-width: 76px; color: #fff; font: 600 12px/1.2 var(--font); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; }
  #chats .mux-acts button svg { width: 22px; height: 22px; }
  #chats .mux-acts .del { background: #ef4444; }
  #chats .mux-acts .read { background: var(--accent); color: var(--on-accent, #fff); }
  #chats .row { touch-action: pan-y; }
  #chats .row.mux-sw { position: relative; z-index: 1; background: var(--sidebar); }
  #chats .row.mux-anim { transition: transform .22s cubic-bezier(.2,.8,.25,1); }
  body.mux-silent .pin-menu, body.mux-silent .p5-backdrop { visibility: hidden !important; }

  /* 2. Мини-плеер */
  #mux-mini { position: fixed; left: 8px; right: 8px; z-index: 60; bottom: calc(var(--mux-rail, 64px) + 6px); display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 12px; border-radius: 14px; background: var(--panel-2); border: 1px solid var(--line-2); box-shadow: 0 6px 20px rgba(0,0,0,.28); color: var(--text); animation: mux-up .2s ease-out; }
  #mux-mini[hidden] { display: none; }
  #mux-mini .mm-ico { width: 34px; height: 34px; border-radius: 9px; background: rgba(var(--accent-rgb), .16); color: var(--accent); display: grid; place-items: center; flex: none; }
  #mux-mini .mm-m { flex: 1; min-width: 0; display: flex; flex-direction: column; }
  #mux-mini .mm-m b { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  #mux-mini .mm-m small { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  #mux-mini .mm-pp { width: 38px; height: 38px; border-radius: 50%; border: 0; background: var(--accent); color: var(--on-accent, #fff); display: grid; place-items: center; flex: none; }
  #mux-mini .mm-pp svg { width: 20px; height: 20px; }
  html.kb-open #mux-mini { display: none; }
  /* MUSICFIX 15.10.2026: in an open chat - compact bar at the top under the chat header instead of hiding */
  .shell.chat-open ~ #mux-mini { bottom: auto; top: calc(env(safe-area-inset-top, 0px) + 62px); padding: 5px 6px 5px 10px; }
  @keyframes mux-up { from { opacity: 0; transform: translateY(10px); } }

  /* 3. Кнопка «вниз» */
  #mux-down { position: absolute; right: 12px; bottom: 84px; z-index: 30; width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line-2); background: var(--panel-2); color: var(--text); display: grid; place-items: center; box-shadow: 0 4px 14px rgba(0,0,0,.3); transition: opacity .18s, transform .18s; }
  #mux-down[hidden] { display: grid; opacity: 0; transform: translateY(10px) scale(.9); pointer-events: none; }
  #mux-down svg { width: 22px; height: 22px; }
  #mux-down i { position: absolute; top: -6px; right: -4px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px; background: var(--accent); color: var(--on-accent, #fff); font: 700 11px/20px var(--font); font-style: normal; text-align: center; }
  #mux-down i:empty { display: none; }

  /* 4. Отклик на нажатия */
  #chats .row, .rail-item, .adv-ov button, .pin-menu button, .composer button, #thread header button, .icon-btn { -webkit-tap-highlight-color: transparent; }
  #chats .row:active, .pin-menu button:active, .adv-ov .adv-item:active { background: var(--selected) !important; }
  .rail-item:active, .composer button:active, #thread header button:active, #mux-mini .mm-pp:active, #mux-down:active, .icon-btn:active { transform: scale(.92); transition: transform .08s; }

  /* 6. Заготовки списка чатов */
  .mux-skel { display: flex; align-items: center; gap: 12px; padding: 10px 14px; }
  .mux-skel span, .mux-skel em { display: block; background: var(--panel-2); border-radius: 8px; animation: mux-pulse 1.2s ease-in-out infinite; }
  .mux-skel span { width: 52px; height: 52px; border-radius: 50%; flex: none; }
  .mux-skel div { flex: 1; display: flex; flex-direction: column; gap: 8px; }
  .mux-skel em { height: 12px; width: 55%; } .mux-skel em + em { width: 80%; opacity: .7; }
  @keyframes mux-pulse { 50% { opacity: .45; } }

  /* 7. Единый стиль иконок */
  .rail .rail-item svg, #chats-pane .pane-head svg, #thread header svg, .pin-menu button svg { width: 24px; height: 24px; }
  .pin-menu button svg { width: 22px; height: 22px; }
  .rail .rail-item svg [stroke], .rail .rail-item svg[stroke], #thread header svg [stroke], .pin-menu svg [stroke], #chats-pane .pane-head svg [stroke] { stroke-width: 2; }
  .rail .rail-item svg g[stroke], #thread header svg g[stroke], .pin-menu svg g[stroke] { stroke-width: 2; }

  /* 8. Переход список → чат: полный сдвиг справа */
  .shell.chat-open .stage { animation: p5-slide-in .26s cubic-bezier(.2,.8,.25,1); }

  /* 9. Пустые экраны */
  .list-empty, .cl-empty, .fv-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 10px; padding: 48px 24px; color: var(--muted); font-size: 14.5px; line-height: 1.45; }
  .list-empty svg, .cl-empty-ico svg, .fv-empty svg { width: 56px; height: 56px; opacity: .55; }
  .list-empty b, .cl-empty b, .fv-empty b { color: var(--text); font-size: 16px; }
  .mux-ehint { font-size: 13px; color: var(--muted-2, var(--muted)); }

  /* 10. Пузыри сообщений */
  .msg .bubble { position: relative; }
  .msg .bubble .foot { font-size: 11px; opacity: .72; gap: 3px; margin-top: 2px; }
  .msg .bubble .foot svg { width: 14px; height: 14px; }
  .msg:not(.media) > .bubble:not(.media):not(.upd)::after { content: ""; position: absolute; bottom: 0; width: 10px; height: 14px; background: inherit; }
  .msg.me > .bubble:not(.media):not(.upd) { border-bottom-right-radius: 5px; }
  .msg.me > .bubble:not(.media):not(.upd)::after { right: -5px; clip-path: polygon(0 0, 0 100%, 100% 100%); border-bottom-left-radius: 3px; }
  .msg.them:not(.grp) > .bubble:not(.media):not(.upd), .msg.grp.first > .bubble:not(.media) { border-bottom-left-radius: 5px; }
  .msg.them > .bubble:not(.media):not(.upd)::after { left: -5px; clip-path: polygon(100% 0, 0 100%, 100% 100%); }

  /* 5. Светлая тема */
  html.mux-light {
    color-scheme: light;
    --bg: #f3f5f9; --rail: #ffffff; --sidebar: #ffffff; --panel: #ffffff; --panel-2: #eef1f6;
    --line: rgba(15,23,42,.08); --line-2: rgba(15,23,42,.13);
    --bubble-in: #ffffff; --bubble-out: #d7e8ff;
    --text: #111827; --muted: #5b6474; --muted-2: #7b8494;
    --input: #eef1f6; --hover: #f1f4f8; --selected: #e6eefb;
  }
  html.mux-light body, html.mux-light .shell, html.mux-light .sidebar, html.mux-light .pane, html.mux-light .stage, html.mux-light .thread { background: var(--bg); color: var(--text); }
  html.mux-light #chats-pane, html.mux-light #chats, html.mux-light #chats .row, html.mux-light .pane-head { background: var(--sidebar) !important; color: var(--text); }
  html.mux-light .rail { background: rgba(255,255,255,.97) !important; border-color: var(--line) !important; }
  html.mux-light .rail .rail-item { color: #5b6474; }
  html.mux-light .rail .rail-item.on, html.mux-light .rail .rail-item.on svg { color: var(--accent); }
  html.mux-light #thread header, html.mux-light .thread > header, html.mux-light .composer { background: #ffffff !important; border-color: var(--line) !important; color: var(--text); }
  html.mux-light .log { background-color: #e9eef5; }
  html.mux-light .bubble { color: #111827; box-shadow: 0 1px 1px rgba(15,23,42,.06); }
  html.mux-light .msg.me .bubble { background: var(--bubble-out) !important; color: #0b1b33; }
  html.mux-light .msg.them .bubble { background: var(--bubble-in) !important; }
  html.mux-light .preview, html.mux-light #chats time { color: var(--muted); }
  html.mux-light input, html.mux-light textarea, html.mux-light select { background: var(--input); color: var(--text); border-color: var(--line-2); }
  html.mux-light .adv-ov, html.mux-light .adv-card, html.mux-light .pin-menu, html.mux-light .modal, html.mux-light .sheet, html.mux-light [role="dialog"] { background: #ffffff !important; color: var(--text) !important; border-color: var(--line) !important; }
  html.mux-light .adv-ov { background: var(--bg) !important; }
  html.mux-light .p5-backdrop { background: rgba(15,23,42,.35); }
  html.mux-light .so-skel .so-ring, html.mux-light .so-skel small, html.mux-light .rd-skel-block { background: #e3e8ef !important; }
  html.mux-light .so-stories small, html.mux-light .so-stories span { color: #374151 !important; }
  html.mux-light #mux-mini, html.mux-light #mux-down { box-shadow: 0 4px 14px rgba(15,23,42,.15); }
  html.mux-light .list-empty, html.mux-light .cl-empty, html.mux-light .fv-empty { color: var(--muted); }

  /* переключатель темы в «Чаты и оформление» */
  .mux-seg { display: flex; gap: 6px; margin-top: 8px; }
  .mux-seg button { flex: 1; padding: 9px 6px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--panel-2); color: var(--text); font: 500 14px var(--font); }
  .mux-seg button.on { background: var(--accent); border-color: var(--accent); color: var(--on-accent, #fff); }
}
@media (max-width: 860px) and (prefers-reduced-motion: reduce) {
  .shell.chat-open .stage, #mux-mini, .mux-skel span, .mux-skel em { animation: none !important; }
  #chats .row.mux-anim, #mux-down { transition: none; }
}

/* DESKTOP-UX 10.10.2026: то же для ПК (>860px) — тема, заготовки, пустые экраны, «вниз», мини-плеер, действия при наведении. Мобильная часть выше не тронута */
@media (min-width: 861px) {
  /* 5. Светлая тема */
  html.mux-light {
    color-scheme: light;
    --bg: #f3f5f9; --rail: #ffffff; --sidebar: #ffffff; --panel: #ffffff; --panel-2: #eef1f6;
    --line: rgba(15,23,42,.08); --line-2: rgba(15,23,42,.13);
    --bubble-in: #ffffff; --bubble-out: #d7e8ff;
    --text: #111827; --muted: #5b6474; --muted-2: #7b8494;
    --input: #eef1f6; --hover: #f1f4f8; --selected: #e6eefb;
  }
  html.mux-light body, html.mux-light .shell, html.mux-light .sidebar, html.mux-light .pane, html.mux-light .stage, html.mux-light .thread { background: var(--bg); color: var(--text); }
  html.mux-light #chats-pane, html.mux-light #chats, html.mux-light #chats .row, html.mux-light .pane-head { background: var(--sidebar) !important; color: var(--text); }
  html.mux-light .rail { background: rgba(255,255,255,.97) !important; border-color: var(--line) !important; }
  html.mux-light .rail .rail-item { color: #5b6474; }
  html.mux-light .rail .rail-item.on, html.mux-light .rail .rail-item.on svg { color: var(--accent); }
  html.mux-light #thread header, html.mux-light .thread > header, html.mux-light .composer { background: #ffffff !important; border-color: var(--line) !important; color: var(--text); }
  html.mux-light .log { background-color: #e9eef5; }
  html.mux-light .bubble { color: #111827; box-shadow: 0 1px 1px rgba(15,23,42,.06); }
  html.mux-light .msg.me .bubble { background: var(--bubble-out) !important; color: #0b1b33; }
  html.mux-light .msg.them .bubble { background: var(--bubble-in) !important; }
  html.mux-light .preview, html.mux-light #chats time { color: var(--muted); }
  html.mux-light input, html.mux-light textarea, html.mux-light select { background: var(--input); color: var(--text); border-color: var(--line-2); }
  html.mux-light .adv-ov, html.mux-light .adv-card, html.mux-light .pin-menu, html.mux-light .modal, html.mux-light .sheet, html.mux-light [role="dialog"] { background: #ffffff !important; color: var(--text) !important; border-color: var(--line) !important; }
  html.mux-light .adv-ov { background: var(--bg) !important; }
  html.mux-light .p5-backdrop { background: rgba(15,23,42,.35); }
  html.mux-light .so-skel .so-ring, html.mux-light .so-skel small, html.mux-light .rd-skel-block { background: #e3e8ef !important; }
  html.mux-light .so-stories small, html.mux-light .so-stories span { color: #374151 !important; }
  html.mux-light #mux-mini, html.mux-light #mux-down { box-shadow: 0 4px 14px rgba(15,23,42,.15); }
  html.mux-light .list-empty, html.mux-light .cl-empty, html.mux-light .fv-empty { color: var(--muted); }

  /* переключатель темы в «Чаты и оформление» */
  .mux-seg { display: flex; gap: 6px; margin-top: 8px; }
  .mux-seg button { flex: 1; padding: 9px 6px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--panel-2); color: var(--text); font: 500 14px var(--font); }
  .mux-seg button.on { background: var(--accent); border-color: var(--accent); color: var(--on-accent, #fff); }
  /* 6. Заготовки списка чатов */
  .mux-skel { display: flex; align-items: center; gap: 12px; padding: 10px 14px; }
  .mux-skel span, .mux-skel em { display: block; background: var(--panel-2); border-radius: 8px; animation: mux-pulse 1.2s ease-in-out infinite; }
  .mux-skel span { width: 52px; height: 52px; border-radius: 50%; flex: none; }
  .mux-skel div { flex: 1; display: flex; flex-direction: column; gap: 8px; }
  .mux-skel em { height: 12px; width: 55%; } .mux-skel em + em { width: 80%; opacity: .7; }
  @keyframes mux-pulse { 50% { opacity: .45; } }

  /* 9. Пустые экраны */
  .list-empty, .cl-empty, .fv-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 10px; padding: 48px 24px; color: var(--muted); font-size: 14.5px; line-height: 1.45; }
  .list-empty svg, .cl-empty-ico svg, .fv-empty svg { width: 56px; height: 56px; opacity: .55; }
  .list-empty b, .cl-empty b, .fv-empty b { color: var(--text); font-size: 16px; }
  .mux-ehint { font-size: 13px; color: var(--muted-2, var(--muted)); }

  body.mux-silent .pin-menu, body.mux-silent .p5-backdrop { visibility: hidden !important; }
  html.mux-light .ia-rail { background: #eef1f6 !important; }
  html.mux-light .ia-item, html.mux-light .ia-item svg { color: #4b5563; }
  html.mux-light .ia-item:hover, html.mux-light .ia-item:hover svg { color: var(--accent); }
  html.mux-light .rail .rail-item:hover { background: var(--hover); }
  html.mux-light .mp-bar { background: #ffffff; }
  html.mux-light .mp-menu { background: #ffffff; color: var(--text); }

  /* кнопка «вниз» с числом непрочитанных */
  #mux-down { position: absolute; right: 22px; bottom: 92px; z-index: 30; width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--line-2); background: var(--panel-2); color: var(--text); display: grid; place-items: center; box-shadow: 0 4px 14px rgba(0,0,0,.3); cursor: pointer; transition: opacity .18s, transform .18s, background .15s; }
  #mux-down:hover { background: var(--hover); }
  #mux-down[hidden] { display: grid; opacity: 0; transform: translateY(10px) scale(.9); pointer-events: none; }
  #mux-down svg { width: 22px; height: 22px; }
  #mux-down i { position: absolute; top: -6px; right: -4px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px; background: var(--accent); color: var(--on-accent, #fff); font: 700 11px/20px var(--font); font-style: normal; text-align: center; }
  #mux-down i:empty { display: none; }

  /* мини-плеер: карточка в правом нижнем углу, пока раздел «Музыка» закрыт */
  #mux-mini { position: fixed; right: 20px; bottom: 20px; z-index: 1800; width: 340px; display: flex; align-items: center; gap: 10px; padding: 8px 10px 8px 8px; border-radius: 16px; background: var(--panel-2); border: 1px solid var(--line-2); box-shadow: 0 14px 40px rgba(0,0,0,.4); color: var(--text); cursor: pointer; animation: mux-up .2s ease-out; }
  #mux-mini[hidden] { display: none; }
  #mux-mini:hover { border-color: rgba(var(--accent-rgb), .5); }
  #mux-mini .mm-ico { width: 48px; height: 48px; border-radius: 10px; overflow: hidden; background: rgba(var(--accent-rgb), .16); color: var(--accent); display: grid; place-items: center; flex: none; }
  #mux-mini .mm-ico img { width: 100%; height: 100%; object-fit: cover; display: block; }
  #mux-mini .mm-m { flex: 1; min-width: 0; display: flex; flex-direction: column; }
  #mux-mini .mm-m b { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  #mux-mini .mm-m small { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  #mux-mini button { border: 0; display: grid; place-items: center; flex: none; cursor: pointer; }
  #mux-mini .mm-nb { width: 32px; height: 32px; border-radius: 50%; background: transparent; color: var(--muted); }
  #mux-mini .mm-nb:hover { background: var(--hover); color: var(--text); }
  #mux-mini .mm-pp { width: 38px; height: 38px; border-radius: 50%; background: var(--accent); color: var(--on-accent, #fff); }
  #mux-mini .mm-pp:hover { filter: brightness(1.1); }
  #mux-mini svg { width: 18px; height: 18px; } #mux-mini .mm-pp svg { width: 20px; height: 20px; }
  @keyframes mux-up { from { opacity: 0; transform: translateY(10px); } }

  /* действия при наведении на строку чата */
  #chats { position: relative; }
  #chats .mux-hov { position: absolute; right: 10px; z-index: 5; transform: translateY(-50%); display: flex; gap: 4px; padding: 3px; border-radius: 10px; background: var(--panel-2); border: 1px solid var(--line-2); box-shadow: 0 4px 12px rgba(0,0,0,.25); }
  #chats .mux-hov[hidden] { display: none; }
  #chats .mux-hov button { width: 30px; height: 30px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); display: grid; place-items: center; cursor: pointer; }
  #chats .mux-hov button[hidden] { display: none; }
  #chats .mux-hov button svg { width: 17px; height: 17px; }
  #chats .mux-hov .read:hover { background: rgba(var(--accent-rgb), .16); color: var(--accent); }
  #chats .mux-hov .del:hover { background: rgba(239,68,68,.16); color: #ef4444; }
}
@media (min-width: 861px) and (prefers-reduced-motion: reduce) {
  #mux-mini, .mux-skel span, .mux-skel em { animation: none !important; }
  #mux-down { transition: none; }
}
@media (max-width: 860px) { #mux-mini .mm-nb { display: none !important; } }
