:root {
  --bg: #f6f7f8;
  --panel: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --border: #e5e7eb;
  --accent: #2f80ed;
  --bubble-me: #e6f6ff;
  --bubble-client: #f3f4f6;
  --icon-gap: 10px;
  --header-bg: #292929;
  --header-text: #ffffff;
  --menu-bg: var(--header-bg);
  --menu-text: rgba(255,255,255,0.72);
  --menu-active: #ffffff;
  --menu-active-bg: rgba(255,255,255,0.18);
  --menu-width: 73px;
  --menu-mobile-height: 68px;
}
.ui-icon { width: 16px; height: 16px; display: block; }
* { box-sizing: border-box; }
html, body { height: 100%; touch-action: manipulation; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 -apple-system, Segoe UI, Roboto, Inter, system-ui, sans-serif; overflow: hidden; overscroll-behavior: none; -webkit-text-size-adjust: 100%; }
#app { display: flex; height: 100vh; height: 100dvh; width: 100%; box-sizing: border-box; transition: padding-left 0.2s ease; }
.menu-open #app { padding-left: var(--menu-width); }

#side-menu { width: var(--menu-width); background: var(--menu-bg); border-right: 1px solid rgba(255,255,255,0.12); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 12px 4px; position: fixed; top: 0; left: 0; height: 100vh; height: 100dvh; transform: translateX(-100%); transition: transform 0.2s ease; z-index: 70; }
.menu-item { width: 100%; border: none; background: transparent; padding: 8px 2px; border-radius: 12px; display: flex; flex-direction: column; align-items: center; gap: 4px; color: var(--menu-text); font-size: 9px; font-weight: 600; cursor: pointer; text-align: center; line-height: 1.1; text-decoration: none; }
.menu-item:hover { background: rgba(255,255,255,0.12); color: #ffffff; }
.menu-item[aria-current="page"] { background: var(--menu-active-bg); color: var(--menu-active); }
.menu-open #side-menu { transform: translateX(0); }
.menu-icon { width: 40px; height: 40px; display: block; }
.menu-item .menu-icon { color: #ffffff; }
.menu-icon-img { width: 40px; height: 40px; display: block; filter: invert(1) grayscale(1) brightness(1.6); object-fit: contain; }
.menu-icon-orders { width: 110px; height: 110px; margin-top: -32px; margin-bottom: -34px; display: block; }
.menu-label { display: block; max-width: 100%; white-space: nowrap; }

#channels, #dialog { transition: none; }

#channels { width: 400px; border-right: 1px solid var(--border); background: var(--panel); display: flex; flex-direction: column; }
#channels .header, #dialog .header { padding: 12px 16px; border-bottom: 1px solid var(--border); font-weight: 600; background: var(--header-bg); color: var(--header-text); height: 56px; box-sizing: border-box; }
#channels .channel-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.channel-header-left { display: flex; align-items: center; gap: 8px; min-width: 0; }
.menu-toggle { border: none; background: transparent; color: inherit; width: 34px; height: 34px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; position: relative; z-index: 80; transition: transform 0.2s ease; overflow: visible; transform: translateX(-10px); }
.menu-toggle:hover { background: rgba(255,255,255,0.16); }
.menu-toggle .ui-icon { width: 27px; height: 27px; }
.menu-toggle .ui-icon path { transition: transform 0.2s ease, opacity 0.2s ease; transform-box: fill-box; transform-origin: center; }
.menu-open .menu-toggle { transform: translateX(calc(0px - var(--menu-width))); }
.menu-open .menu-toggle .ui-icon path:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.menu-open .menu-toggle .ui-icon path:nth-child(2) { opacity: 0; }
.menu-open .menu-toggle .ui-icon path:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }
.channel-header-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.channel-header-action { background: transparent; border: none; color: #ffffff; width: 30px; height: 30px; }
.channel-header-action:hover { background: rgba(255,255,255,0.12); }
.channel-header-actions { display: inline-flex; align-items: center; gap: 6px; }
.channel-header-action.is-active { color: #f59e0b; background: rgba(245, 158, 11, 0.18); }
.channel-search-panel { max-height: 0; opacity: 0; overflow: hidden; padding: 0 12px; transition: max-height 0.2s ease, opacity 0.2s ease, padding 0.2s ease; }
.channel-search-panel.open { max-height: 52px; opacity: 1; padding: 8px 12px; }
.channel-search-field { display: flex; align-items: center; gap: 8px; background: #ffffff; border: 1px solid var(--border); border-radius: 10px; padding: 6px 8px; }
#channel-search-input { flex: 1; border: none; outline: none; font-size: 14px; min-width: 0; }
.channel-search-count { font-size: 12px; color: #64748b; background: #f1f5f9; border-radius: 999px; padding: 2px 6px; min-width: 22px; text-align: center; }
.channel-search-count.is-loading { color: #94a3b8; background: #eef2f7; }
.channel-search-clear { border: none; background: transparent; color: #6b7280; font-size: 14px; width: 24px; height: 24px; border-radius: 6px; cursor: pointer; }
.channel-search-clear:hover { background: rgba(15,23,42,0.06); }
.channel-search-clear.hidden { display: none; }
#dialog .header { display: flex; align-items: center; gap: 12px; }
.dialog-header-info { flex: 1; display: flex; align-items: center; gap: 12px; min-width: 0; }
.dialog-item-image { width: 40px; height: 40px; border-radius: 10px; object-fit: cover; flex-shrink: 0; background: rgba(255,255,255,0.08); }
.dialog-header-text { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.dialog-title-row { display: flex; align-items: center; gap: 8px; min-width: 0; }
.dialog-account-avatar { width: 26px; height: 26px; border-radius: 50%; overflow: hidden; background: #d1d5db; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center; font-weight: 600; color: #fff; text-transform: uppercase; }
.dialog-account-avatar.dialog-account-avatar--ai { border-radius: 8px; }
.dialog-account-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.dialog-account-avatar.placeholder { background: #9ca3af; }
.dialog-account-avatar.avatar-zoom-lr-rest img { transform: scale(1.6); transform-origin: center; }
#dialog-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; color: inherit; text-decoration: none; display: block; }
#dialog-title.dialog-title-link { cursor: pointer; }
#dialog-title.dialog-title-link:hover { text-decoration: underline; }
.dialog-item-price { font-size: 12px; color: rgba(255,255,255,0.78); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dialog-header-actions { position: relative; flex-shrink: 0; display: flex; align-items: center; }
.dialog-status-button { border: none; background: #ffff99; color: #111827; padding: 0 10px; height: 32px; border-radius: 10px; font-weight: 700; font-size: 12px; line-height: 1; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; max-width: min(420px, 60vw); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dialog-status-button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.dialog-status-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.dialog-status-schedule { font-weight: 600; font-size: 11px; opacity: 0.85; flex-shrink: 0; }
.dialog-status-caret { opacity: 0.7; flex-shrink: 0; }
.dialog-status-menu { position: absolute; right: 0; bottom: calc(100% + 8px); top: auto; background: #ffffff; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; box-shadow: 0 18px 40px rgba(15,23,42,0.22); min-width: 240px; max-height: min(560px, 80vh); overflow-y: auto; z-index: 30; }
.dialog-status-item { width: 100%; border: none; padding: 10px 12px; cursor: pointer; text-align: left; font-weight: 600; font-size: 13px; color: #111827; display: flex; align-items: center; justify-content: flex-start; gap: 12px; }
.dialog-status-item:hover { filter: brightness(0.98); }
.dialog-status-item.selected::after { content: '✓'; font-weight: 800; color: rgba(17,24,39,0.7); margin-left: auto; }
.dialog-status-item-left { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.dialog-status-icon { width: 16px; height: 16px; display: inline-flex; align-items: center; justify-content: center; color: rgba(17,24,39,0.8); flex-shrink: 0; }
.dialog-status-icon svg { width: 16px; height: 16px; stroke: currentColor; }
.dialog-status-button .dialog-status-icon { color: rgba(17,24,39,0.85); }
.dialog-status-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.back-button { border: none; background: transparent; color: #ffffff; font-size: 20px; cursor: pointer; padding: 4px 8px; border-radius: 8px; display: none; }
.back-button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
#channel-list { overflow-y: auto; flex: 1; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; touch-action: pan-y; }
.channel-list-loader { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 10px 12px; border-top: 1px solid var(--border); background: #ffffff; color: var(--muted); font-size: 12px; }
.channel-list-loader.hidden { display: none; }
.channel-list-loader-spinner { width: 16px; height: 16px; border: 2px solid rgba(148,163,184,0.35); border-top-color: rgba(71,85,105,0.8); border-radius: 50%; animation: messages-spin 0.8s linear infinite; }
.messages-loading { display: flex; align-items: center; justify-content: center; }
.messages-loading-card { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 18px 22px; border: 1px solid var(--border); border-radius: 12px; background: #ffffff; box-shadow: 0 10px 24px rgba(15,23,42,0.08); color: var(--muted); font-size: 13px; }
.messages-loading-card--error { color: #b42318; border-color: rgba(180,35,24,0.25); background: #fff5f5; }
.messages-loading-spinner { width: 26px; height: 26px; border: 3px solid rgba(148,163,184,0.35); border-top-color: rgba(71,85,105,0.75); border-radius: 50%; animation: messages-spin 0.8s linear infinite; }
.messages-loading-text { text-align: center; }
@keyframes messages-spin { to { transform: rotate(360deg); } }
.channel { padding: 10px 26px 10px 12px; cursor: pointer; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 12px; position: relative; text-decoration: none; color: inherit; overflow: hidden; }
.channel.is-favorite .channel-fav-action { border-color: #f59e0b; color: #f59e0b; background: rgba(245, 158, 11, 0.12); }
.channel-fav-action {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%) translateX(22px);
  opacity: 0;
  pointer-events: none;
  width: 44px;
  height: 44px;
  z-index: 2;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 14px rgba(15,23,42,0.12);
  transition: transform 0.18s ease, opacity 0.18s ease;
  color: #64748b;
}
.channel-fav-action svg { width: 36px; height: 36px; }
.channel-delete-action {
  position: absolute;
  right: 56px;
  top: 50%;
  transform: translateY(-50%) translateX(22px);
  opacity: 0;
  pointer-events: none;
  width: 44px;
  height: 44px;
  z-index: 2;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 14px rgba(15,23,42,0.12);
  transition: transform 0.18s ease, opacity 0.18s ease;
  color: #64748b;
}
.channel-delete-action svg { width: 30px; height: 30px; }
.channel--fav-open .channel-fav-action {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(-50%) translateX(0);
}
.channel--fav-open .channel-delete-action {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(-50%) translateX(0);
}
.channel::before { content: ''; position: absolute; right: 0; top: 0; bottom: 0; width: 4px; background: var(--channel-status-color, transparent); pointer-events: none; }
body.mobile-list .channel::before,
body.mobile-dialog .channel::before { width: 8px; }
.channel.needs-reply { background: #e6f6ff; }
.channel:hover:not(.needs-reply) { background: #f2f5f9; }
.channel.active::after { content: ''; position: absolute; right: 10px; top: 50%; transform: translateY(-50%); width: 0; height: 0; border-top: 7px solid transparent; border-bottom: 7px solid transparent; border-left: 9px solid var(--accent); }

body.mobile-list .channel.active:not(.needs-reply),
body.mobile-dialog .channel.active:not(.needs-reply) { background: transparent; }
body.mobile-list .channel.active::after,
body.mobile-dialog .channel.active::after { content: none; }
body.mobile-list .channel.channel--fav-open,
body.mobile-dialog .channel.channel--fav-open,
body.mobile-list .channel.is-favorite,
body.mobile-dialog .channel.is-favorite {
  padding-right: 108px;
}
body.mobile-list .channel.is-favorite .channel-fav-action,
body.mobile-dialog .channel.is-favorite .channel-fav-action {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(-50%) translateX(0);
}
body.mobile-list .channel.is-favorite .channel-delete-action,
body.mobile-dialog .channel.is-favorite .channel-delete-action,
body.mobile-list .channel.channel--fav-open .channel-delete-action,
body.mobile-dialog .channel.channel--fav-open .channel-delete-action {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(-50%) translateX(0);
}
body.mobile-list .channel:hover:not(.needs-reply),
body.mobile-dialog .channel:hover:not(.needs-reply) { background: transparent; }
body.mobile-list .channel:active:not(.needs-reply),
body.mobile-dialog .channel:active:not(.needs-reply) { background: #f2f5f9; }
.push-control,
body.mobile-list .push-control,
body.mobile-dialog .push-control { display: none !important; }
body.mobile-list .channel-head .name .channel-name-text,
body.mobile-dialog .channel-head .name .channel-name-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.channel-avatar-stack { --avatar-size: 40px; --item-size: 52px; width: var(--item-size); height: var(--item-size); position: relative; flex-shrink: 0; display: grid; place-items: center; overflow: visible; }
.channel-item-image { position: absolute; inset: 0; width: var(--item-size); height: var(--item-size); border-radius: 10px; overflow: hidden; background: #e6ebf2; box-shadow: 0 6px 14px rgba(15, 23, 42, 0.12); transform: translate(-8px, -11px); z-index: 1; }
.channel-item-image img { width: 100%; height: 100%; object-fit: cover; display: block; }
.channel-avatar { width: var(--avatar-size, 40px); height: var(--avatar-size, 40px); border-radius: 50%; overflow: hidden; background: #d1d5db; display: flex; align-items: center; justify-content: center; font-weight: 600; color: #fff; text-transform: uppercase; position: relative; box-shadow: 0 0 0 2px var(--panel); transform: translate(8px, 15px); z-index: 2; }
.channel-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.channel-avatar.placeholder { background: #9ca3af; }
.channel-avatar.avatar-zoom-lr-rest img { transform: scale(1.6); transform-origin: center; }
.channel-avatar.channel-avatar--wa { transform: none; }
.channel-avatar.channel-avatar--tg { transform: none; background: #64a9dc; }
.channel-avatar.channel-avatar--ai { transform: none; width: calc(var(--avatar-size, 40px) + 5px); height: calc(var(--avatar-size, 40px) + 5px); border-radius: 8px; }
.ws-dot { position: absolute; right: 2px; bottom: 2px; width: 10px; height: 10px; border-radius: 999px; border: 2px solid var(--panel); pointer-events: none; }
.ws-dot--ok { background: #22c55e; }
.ws-dot--bad { background: #ef4444; }
.channel-info { flex: 1; min-width: 0; }
.channel-head { display: flex; align-items: baseline; gap: 10px; }
.channel-head .name { flex: 1; min-width: 0; font-weight: 600; color: var(--text); display: flex; align-items: center; gap: 6px; }
.channel-head .name.name--wa { flex-direction: column; align-items: flex-start; gap: 2px; }
.wa-name-row { display: flex; align-items: center; gap: 6px; min-width: 0; }
.wa-name-row .channel-name-text { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wa-phone { font-size: 12px; color: var(--muted); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.channel-name-text { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.channel.post-merged { border-top: 1px solid var(--border); margin-top: 15px; }
.channel-group-wrap .channel.post-merged { border-top: none; margin-top: 0; }
.wa-link-toggle { border: none; background: transparent; color: #b7bdc7; font-size: 12px; line-height: 1; cursor: pointer; padding: 0 2px; }
.wa-link-toggle:hover { color: #8892a0; }
.channel-time { font-size: 12px; color: var(--muted); white-space: nowrap; flex-shrink: 0; }
.channel-group-title { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); padding: 10px 12px 4px; }
.channel-group-wrap { margin: 0 0 6px 23px; border: 1px solid var(--border); border-right: none; border-radius: 12px 0 0 12px; background: rgba(255,255,255,0.6); overflow: hidden; }
.channel-group-wrap .channel { border-bottom: 1px solid var(--border); border-radius: 0; margin: 0; }
.channel-group-wrap .channel:last-child { border-bottom: none; }
.channel-topic { color: var(--muted); font-size: 12px; margin-top: 2px; display: grid; grid-template-columns: minmax(0, 1fr) max-content; column-gap: 8px; align-items: center; min-width: 0; }
.channel-topic-title { min-width: 0; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.channel-topic-price { color: var(--text); font-weight: 600; white-space: nowrap; justify-self: end; }
.wa-merge-menu { position: fixed; z-index: 1200; background: #ffffff; border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 8px 24px rgba(15,23,42,0.12); min-width: 220px; padding: 6px 0; }
.wa-merge-title { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); padding: 6px 12px; }
.channel--tg .channel-topic { color: #1e293b; }
.channel--tg .channel-name-text { color: #0f172a; }
.channel--disabled { cursor: default; opacity: 0.85; }
.tg-auth-card { border: 1px dashed #cbd5e1; background: #f8fafc; border-radius: 12px; padding: 10px 12px; margin: 10px 12px; display: grid; gap: 6px; }
.tg-auth-head { display: flex; align-items: center; gap: 8px; font-weight: 700; color: #0f172a; }
.tg-auth-icon { width: 28px; height: 28px; border-radius: 50%; background: #64a9dc; color: #ffffff; display: grid; place-items: center; font-weight: 800; }
.tg-auth-note { font-size: 12px; color: #475569; }
.tg-auth-btn { border: none; background: #0ea5e9; color: #fff; padding: 8px 10px; border-radius: 10px; font-weight: 700; cursor: pointer; width: fit-content; }
.tg-auth-btn:hover { filter: brightness(0.97); }
.wa-merge-unlink { display: block; width: 100%; text-align: left; background: transparent; border: none; padding: 8px 12px; font-size: 12px; cursor: pointer; color: #b42318; }
.wa-merge-unlink:hover { background: #fff1f2; }
.wa-merge-divider { height: 1px; background: var(--border); margin: 4px 0; }
.wa-merge-list { max-height: 280px; overflow-y: auto; }
.wa-merge-item { display: block; width: 100%; text-align: left; background: transparent; border: none; padding: 8px 12px; font-size: 12px; cursor: pointer; color: var(--text); }
.wa-merge-item:hover { background: #f2f5f9; }
.wa-merge-item.active { font-weight: 600; }
.wa-merge-empty { padding: 8px 12px; font-size: 12px; color: var(--muted); }
.channel .subtitle { color: var(--muted); font-size: 12px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

#dialog { flex: 1; display: flex; flex-direction: column; background: var(--panel); }
#messages { flex: 1; overflow-y: auto; padding: 16px 20px; display: flex; flex-direction: column; gap: 8px; background: var(--panel); -webkit-overflow-scrolling: touch; overscroll-behavior: contain; touch-action: pan-y; }
.msg-row { display: flex; align-items: flex-end; gap: 8px; width: 100%; }
.msg-row.me { justify-content: flex-end; }
.msg-row.client { justify-content: flex-start; }
.msg-row .msg { align-self: auto; }
.msg-avatar { width: 56px; height: 56px; border-radius: 50%; overflow: hidden; border: 1px solid var(--border); background: #ffffff; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.msg-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.msg-avatar--icon img { width: 70%; height: 70%; object-fit: contain; }
.msg-avatar--avito.msg-avatar--icon img { width: 100%; height: 100%; object-fit: cover; transform: scale(1.6); transform-origin: center; }
.msg-avatar--system-internal img { transform: scale(0.9); transform-origin: center; }
.msg-avatar--wa { background: #e7f9f0; border-color: rgba(5, 150, 105, 0.3); }
.msg-avatar--avito { background: #e7f9ee; border-color: rgba(16, 185, 129, 0.35); }
.msg-avatar--system-internal { border-color: #d6c6ff; }
.msg-avatar.msg-avatar--ai { border-radius: 8px; }
.msg { max-width: 72%; padding: 10px 12px; border-radius: 14px; word-wrap: break-word; border: 1px solid var(--border); box-shadow: 0 1px 1px rgba(17, 24, 39, 0.04); }
.msg.me { background: var(--bubble-me); border-color: #c7e8ff; }
.msg.client { background: var(--bubble-client); }
.msg.system { background: #e9f8ef; border-color: #bfe8cd; }
.msg.system .meta { color: #3c6f54; }
.msg.system.system-internal { background: #f2eaff; border-color: #d6c6ff; }
.msg.system.system-internal .meta { color: #6c4aa5; }
.msg .body { display: flex; flex-direction: column; gap: 6px; }
.msg .text { white-space: pre-wrap; }
.msg .photo { max-width: min(320px, 60vw); }
.msg .photo img { width: 100%; border-radius: 10px; display: block; height: auto; box-shadow: 0 2px 6px rgba(17,24,39,0.12); cursor: zoom-in; }
.msg.pending { position: relative; }
.msg.pending .photo { position: relative; overflow: hidden; }
.msg.pending .photo img { filter: saturate(0.92); }
.msg.pending .video { position: relative; overflow: hidden; }
.msg.pending .video video { width: 100%; border-radius: 10px; display: block; background: #000; }
.msg.pending .upload-overlay { position: absolute; left: 8px; right: 8px; bottom: 8px; padding: 6px 8px; border-radius: 10px; background: rgba(15,23,42,0.65); color: #fff; display: flex; flex-direction: column; gap: 6px; }
.msg.pending .upload-label-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 11px; line-height: 1.2; }
.msg.pending .upload-label { font-weight: 600; }
.msg.pending .upload-progress { position: relative; height: 4px; background: rgba(255,255,255,0.3); border-radius: 999px; overflow: hidden; }
.msg.pending .upload-progress-bar { position: absolute; top: 0; left: 0; height: 100%; width: 0%; background: #22c55e; transition: width 0.2s ease; }
.msg.pending .upload-progress-bar.indeterminate { width: 40%; animation: uploadIndeterminate 1.6s linear infinite; }
.msg.pending-failed .upload-overlay { background: rgba(185,28,28,0.75); }
.msg.pending-failed .upload-progress-bar { background: #fecaca; }
.msg.pending .upload-error { display: flex; align-items: flex-start; gap: 6px; font-size: 11px; color: #b91c1c; }
.msg.pending .upload-error-icon { width: 16px; height: 16px; border-radius: 50%; border: 1px solid #b91c1c; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 11px; line-height: 1; }
.msg.pending .upload-error-text { flex: 1; min-width: 0; }
.msg.pending .upload-retry { border: 1px solid rgba(185,28,28,0.5); background: #fff; color: #b91c1c; border-radius: 999px; padding: 2px 8px; font-size: 11px; line-height: 1.3; cursor: pointer; margin-left: 4px; }
.msg.pending .upload-retry:active { transform: translateY(1px); }
.msg.pending-failed.pending-retry { cursor: pointer; }
.msg.pending-failed.pending-retry:hover { filter: brightness(0.98); }
.msg .photo-fallback { max-width: min(320px, 60vw); padding: 12px; border-radius: 10px; border: 1px dashed var(--border); background: rgba(17,24,39,0.04); font-size: 13px; color: var(--muted); }
.msg .video { max-width: min(360px, 65vw); position: relative; }
.msg .video iframe { width: 100%; min-height: 220px; border: none; border-radius: 10px; display: block; box-shadow: 0 6px 18px rgba(15,23,42,0.25); background: #000; }
.msg .video video { width: 100%; border-radius: 10px; display: block; background: #000; }
.msg .video .video-duration { position: absolute; right: 12px; bottom: 12px; background: rgba(0,0,0,0.65); color: #fff; font-size: 12px; padding: 2px 8px; border-radius: 999px; }
.msg .video-thumb { position: relative; display: block; max-width: min(360px, 65vw); border-radius: 10px; overflow: hidden; box-shadow: 0 6px 18px rgba(15,23,42,0.25); }
.msg .video-thumb img { width: 100%; display: block; height: auto; }
.msg .video-thumb::before { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0,0,0,0) 40%, rgba(0,0,0,0.6) 100%); }
.msg .video-thumb::after { content: ''; position: absolute; left: 50%; top: 50%; transform: translate(-40%, -50%); width: 0; height: 0; border-left: 18px solid rgba(255,255,255,0.95); border-top: 12px solid transparent; border-bottom: 12px solid transparent; filter: drop-shadow(0 4px 8px rgba(0,0,0,0.4)); }
.msg .video-thumb__duration { position: absolute; right: 12px; bottom: 10px; color: #fff; font-size: 12px; padding: 2px 8px; border-radius: 999px; background: rgba(0,0,0,0.6); }
.msg .video-fallback { max-width: min(360px, 65vw); padding: 12px; border-radius: 10px; border: 1px dashed var(--border); background: rgba(17,24,39,0.04); font-size: 13px; color: var(--muted); }
.msg .voice { max-width: min(360px, 65vw); display: flex; flex-direction: column; gap: 6px; }
.msg .voice audio { width: 100%; }
.msg .voice.voice--tg { flex-direction: row; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 14px; background: rgba(15,23,42,0.06); width: 100%; max-width: 100%; box-sizing: border-box; }
@media (min-width: 980px) {
  .msg .voice.voice--tg { max-width: 300px; }
}
.msg.me .voice.voice--tg { background: rgba(47,128,237,0.14); }
.msg .voice.voice--tg audio { display: none; }
.voice-play { width: 36px; height: 36px; border-radius: 50%; border: none; background: #ffffff; color: var(--accent); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0; box-shadow: 0 4px 10px rgba(15,23,42,0.12); }
.msg.me .voice-play { background: #ffffff; color: var(--accent); }
.voice-play:active { transform: scale(0.98); }
.voice-icon { display: inline-flex; align-items: center; justify-content: center; }
.voice-icon--play { width: 0; height: 0; border-left: 10px solid currentColor; border-top: 7px solid transparent; border-bottom: 7px solid transparent; margin-left: 2px; }
.voice-icon--pause { display: none; width: 14px; height: 14px; position: relative; }
.voice-icon--pause::before,
.voice-icon--pause::after { content: ''; position: absolute; top: 0; bottom: 0; width: 4px; background: currentColor; border-radius: 1px; }
.voice-icon--pause::before { left: 0; }
.voice-icon--pause::after { right: 0; }
.voice.is-playing .voice-icon--play { display: none; }
.voice.is-playing .voice-icon--pause { display: inline-flex; }
.voice-wave { flex: 1; min-width: 0; height: 28px; position: relative; display: flex; align-items: center; }
.voice-bars { position: absolute; left: 0; right: 0; top: 0; bottom: 0; display: flex; align-items: center; justify-content: space-between; gap: 0; padding: 0 2px; }
.voice-bars--base { z-index: 1; }
.voice-progress { position: absolute; left: 0; right: 0; top: 0; bottom: 0; overflow: hidden; z-index: 2; --voice-progress: 0%; clip-path: inset(0 calc(100% - var(--voice-progress)) 0 0); }
.voice-bars--active { z-index: 2; }
.voice-bar { width: 2px; flex: 0 0 auto; border-radius: 999px; background: rgba(15,23,42,0.3); }
.voice-bars--active .voice-bar { background: var(--accent); }
.voice-time { font-size: 12px; color: var(--muted); min-width: 48px; text-align: right; }
.msg .voice-duration { font-size: 12px; color: var(--muted); text-align: right; }
.msg .voice-transcript { margin-top: 6px; font-size: 13px; color: var(--text); line-height: 1.4; white-space: pre-wrap; }
.msg .voice-fallback { padding: 8px 12px; border-radius: 8px; background: rgba(15,23,42,0.05); border: 1px solid var(--border); font-size: 13px; color: var(--muted); }
.msg .link-previews { display: flex; flex-direction: column; gap: 8px; }
.msg .link-preview-card { position: relative; display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: rgba(255,255,255,0.95); color: #0f172a; text-decoration: none; box-shadow: 0 2px 6px rgba(15,23,42,0.12); }
.msg .link-preview-card:hover { filter: brightness(1.02); }
.msg .link-preview-thumb { width: 100%; height: 220px; flex-shrink: 0; background: rgba(148,163,184,0.2); display: flex; align-items: center; justify-content: center; overflow: hidden; }
.msg .link-preview-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.msg .link-preview-info { flex: 1; min-width: 0; padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; }
.msg .link-preview-title { font-size: 14px; font-weight: 700; line-height: 1.4; color: #0f172a; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.msg .link-preview-meta { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.msg .link-preview-price { font-weight: 600; font-size: 12px; color: #047857; }
.msg .link-preview-domain { font-size: 11px; text-transform: lowercase; opacity: 0.8; }
.msg .link-preview-refresh { position: absolute; top: 6px; right: 6px; width: 28px; height: 28px; border: none; border-radius: 8px; background: rgba(15,23,42,0.06); color: #475569; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; padding: 0; }
.msg .link-preview-refresh:hover { background: rgba(15,23,42,0.1); }
.msg .link-preview-refresh:disabled { opacity: 0.5; cursor: default; }
@media (min-width: 1025px) {
  .msg .link-previews { max-width: 360px; }
  .msg .link-preview-card { width: 100%; }
}
.lightbox { position: fixed; inset: 0; background: rgba(10, 12, 18, 0.92); z-index: 80; display: flex; align-items: center; justify-content: center; overflow: hidden; cursor: zoom-out; }
.lightbox-inner { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left)); box-sizing: border-box; }
.lightbox-image { width: 100%; height: 100%; max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 0; box-shadow: none; background: #111; cursor: default; touch-action: pan-x pan-y pinch-zoom; }
.lightbox-close { position: fixed; top: 14px; right: 14px; width: 36px; height: 36px; border-radius: 999px; background: rgba(15,23,42,0.72); color: #fff; border: 1px solid rgba(255,255,255,0.2); display: inline-flex; align-items: center; justify-content: center; font-size: 18px; cursor: pointer; z-index: 1; }
.lightbox-close:hover { background: rgba(15,23,42,0.88); }
body.lightbox-open { overflow: hidden; }
.examples-panel { position: fixed; inset: 0; background: rgba(15,23,42,0.5); display: flex; align-items: center; justify-content: center; z-index: 80; padding: 16px; }
.examples-panel.hidden { display: none; }
.examples-card { width: min(720px, 100%); max-height: min(80vh, 720px); background: #ffffff; border-radius: 16px; border: 1px solid var(--border); box-shadow: 0 20px 48px rgba(15,23,42,0.25); display: flex; flex-direction: column; overflow: hidden; }
.examples-header { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.examples-title { font-weight: 700; }
.examples-close { border: none; background: transparent; font-size: 18px; cursor: pointer; }
.examples-body { padding: 12px 16px 16px; overflow: hidden; display: flex; flex-direction: column; gap: 12px; flex: 1; }
.examples-search input { width: 100%; border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; font-size: 14px; }
.examples-group-list { display: flex; flex-direction: column; gap: 8px; overflow-y: auto; max-height: 52vh; }
.examples-group-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: #f9fafb; cursor: pointer; }
.examples-group-item:hover { background: #f1f5f9; }
.examples-group-name { font-weight: 600; font-size: 13px; }
.examples-group-count { font-size: 12px; color: var(--muted); }
.examples-photo-header { display: flex; align-items: center; gap: 12px; }
.examples-back { border: 1px solid var(--border); background: #ffffff; padding: 6px 10px; border-radius: 8px; cursor: pointer; font-size: 12px; }
.examples-selected-title { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.examples-photo-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.examples-select-all { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); cursor: pointer; }
.examples-select-all-checkbox { position: absolute; opacity: 0; pointer-events: none; }
.examples-select-all-mark { width: 18px; height: 18px; border-radius: 6px; border: 1px solid rgba(15,23,42,0.25); background: rgba(255,255,255,0.95); display: inline-flex; align-items: center; justify-content: center; transition: all 0.15s ease; box-shadow: 0 1px 2px rgba(15,23,42,0.1); position: relative; line-height: 1; }
.examples-select-all-mark::after { content: '✓'; font-size: 12px; color: #fff; font-weight: 700; opacity: 0; position: absolute; left: 50%; top: 50%; transform: translate(-50%, -55%); transition: opacity 0.15s ease; }
.examples-select-all-checkbox:checked + .examples-select-all-mark { background: var(--accent); border-color: var(--accent); }
.examples-select-all-checkbox:checked + .examples-select-all-mark::after { opacity: 1; }
.examples-select-all-label { font-size: 12px; }
.examples-send { border: none; background: var(--accent); color: #ffffff; border-radius: 8px; padding: 7px 14px; cursor: pointer; font-size: 12px; font-weight: 600; position: relative; overflow: hidden; }
.examples-send:disabled { opacity: 0.75; cursor: not-allowed; }
.examples-send.is-sending::after { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: var(--send-progress, 0%); background: rgba(255,255,255,0.2); pointer-events: none; }
.examples-photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(95px, 1fr)); gap: 10px; overflow-y: auto; max-height: 50vh; }
.examples-photo-card { position: relative; width: 95px; height: 95px; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: #f3f4f6; }
.examples-photo-card img { width: 100%; height: 100%; object-fit: cover; display: block; }
.examples-photo-card--video::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0,0,0,0.1), rgba(0,0,0,0.25)); pointer-events: none; }
.examples-photo-kind { position: absolute; right: 8px; top: 8px; width: 31px; height: 31px; border-radius: 50%; background: rgba(0,0,0,0.6); color: #fff; display: inline-flex; align-items: center; justify-content: center; z-index: 2; }
.examples-photo-kind svg { width: 17px; height: 17px; }
.examples-photo-duration { position: absolute; left: 50%; bottom: 8px; transform: translateX(-50%); background: rgba(0,0,0,0.75); color: #fff; font-size: 11px; padding: 2px 6px; border-radius: 6px; z-index: 2; }
.examples-photo-check { position: absolute; top: 6px; left: 6px; width: 18px; height: 18px; display: inline-flex; align-items: center; justify-content: center; line-height: 0; }
.examples-photo-checkbox { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.examples-photo-checkmark { width: 18px; height: 18px; border-radius: 6px; border: 1px solid rgba(15,23,42,0.25); background: rgba(255,255,255,0.95); display: inline-flex; align-items: center; justify-content: center; transition: all 0.15s ease; box-shadow: 0 1px 2px rgba(15,23,42,0.1); position: relative; line-height: 1; }
.examples-photo-checkbox:checked + .examples-photo-checkmark { background: var(--accent); border-color: var(--accent); }
.examples-photo-checkmark::after { content: '✓'; font-size: 12px; color: #fff; font-weight: 700; opacity: 0; position: absolute; left: 50%; top: 50%; transform: translate(-50%, -55%); transition: opacity 0.15s ease; }
.examples-photo-checkbox:checked + .examples-photo-checkmark::after { opacity: 1; }
.examples-step.hidden { display: none; }
@media (max-width: 720px) {
  .examples-card { width: 100%; max-height: 90vh; }
  .examples-photo-grid { max-height: 50vh; }
}
.msg .quote { border-left: 3px solid rgba(15,23,42,0.22); padding: 6px 8px; border-radius: 10px; background: rgba(15,23,42,0.05); }
.msg.me .quote { border-left-color: rgba(14,165,233,0.6); background: rgba(14,165,233,0.06); }
.msg .quote-head { font-size: 11px; color: var(--muted); font-weight: 600; margin-bottom: 2px; }
.msg .quote-text { font-size: 12px; color: var(--muted); white-space: pre-wrap; }
.msg .quote-media { width: 132px; height: 92px; border-radius: 10px; overflow: hidden; background: rgba(15,23,42,0.08); margin: 2px 0 6px; }
.msg .quote-media img { width: 100%; height: 100%; object-fit: cover; display: block; }
.msg .meta { font-size: 11px; color: var(--muted); margin-top: 6px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.msg .meta-text { flex: 1; min-width: 0; display: inline-flex; align-items: center; gap: 6px; }
.msg .meta-status { font-size: 12px; color: var(--muted); display: inline-flex; align-items: center; gap: 0; flex-shrink: 0; margin-left: 2px; }
.msg .meta-status .meta-check { display: inline-block; line-height: 1; }
.msg .meta-status .meta-check--second { margin-left: -6px; }
.msg .meta-status--read { color: #0ea5e9; }
.msg .meta-actions { display: flex; gap: 6px; flex-shrink: 0; }
.msg .meta-action { appearance: none; border: none; background: transparent; color: var(--muted); font-size: 11px; padding: 2px 6px; border-radius: 8px; cursor: pointer; }
.msg .meta-action-icon { width: 26px; height: 26px; padding: 0; display: inline-flex; align-items: center; justify-content: center; }
.msg .meta-action-icon .ui-icon { width: 16px; height: 16px; display: block; }
.msg .meta-action:active { background: rgba(15,23,42,0.07); }
.msg .meta-action-danger { color: #b91c1c; }
.msg .meta-action-danger:active { background: rgba(185,28,28,0.12); }
.msg .meta-action-emoji { font-size: 14px; }
.msg .message-reaction { align-self: flex-start; font-size: 12px; background: rgba(15,23,42,0.08); padding: 2px 6px; border-radius: 999px; width: fit-content; }
.msg.me .message-reaction { align-self: flex-end; background: rgba(14,165,233,0.12); }
.reaction-menu { position: absolute; z-index: 2000; display: flex; gap: 4px; padding: 4px 6px; background: #fff; border: 1px solid var(--border); border-radius: 999px; box-shadow: 0 6px 16px rgba(15,23,42,0.18); }
.reaction-menu-item { appearance: none; border: none; background: transparent; cursor: pointer; font-size: 16px; line-height: 1; padding: 2px 4px; border-radius: 6px; }
.reaction-menu-item:hover { background: rgba(15,23,42,0.06); transform: translateY(-1px); }
.msg.deleted { background: #f8fafc; border-style: dashed; opacity: 0.85; }
.msg.deleted .body { opacity: 0.95; }
.msg.deleted .meta { color: #9ca3af; }
.msg .text.deleted-text { color: #9ca3af; font-style: italic; }
.msg.reply-highlight { box-shadow: 0 0 0 2px rgba(47,128,237,0.35); }
.msg.reply-highlight-temp { animation: replyFlash 1.2s linear forwards; }
.msg .quote.quote-clickable { cursor: pointer; transition: filter 0.2s ease, background 0.2s ease; }
@media (hover: hover) {
  .msg .quote.quote-clickable:hover { filter: brightness(0.96); }
}
@keyframes replyFlash {
  0%, 8% { box-shadow: 0 0 0 3px rgba(255,200,0,0.95), 0 0 12px rgba(255,200,0,0.7); }
  10%, 18% { box-shadow: none; }
  20%, 28% { box-shadow: 0 0 0 3px rgba(255,200,0,0.95), 0 0 12px rgba(255,200,0,0.7); }
  30%, 38% { box-shadow: none; }
  40%, 48% { box-shadow: 0 0 0 3px rgba(255,200,0,0.95), 0 0 12px rgba(255,200,0,0.7); }
  50%, 58% { box-shadow: none; }
  60%, 68% { box-shadow: 0 0 0 3px rgba(255,200,0,0.95), 0 0 12px rgba(255,200,0,0.7); }
  70%, 78% { box-shadow: none; }
  80%, 88% { box-shadow: 0 0 0 3px rgba(255,200,0,0.95), 0 0 12px rgba(255,200,0,0.7); }
  90%, 100% { box-shadow: none; }
}
@keyframes uploadIndeterminate {
  0% { left: -40%; }
  100% { left: 100%; }
}

.reply-banner { flex: 1; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--border); background: rgba(15,23,42,0.04); width: 100%; }
.reply-banner-text { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.reply-banner-title { font-size: 11px; color: var(--muted); }
.reply-banner-preview { font-size: 12px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 520px; }
.reply-banner-cancel { appearance: none; border: none; background: transparent; color: var(--muted); font-size: 16px; line-height: 1; padding: 2px 6px; border-radius: 8px; cursor: pointer; }
.reply-banner-cancel:active { background: rgba(15,23,42,0.07); }

#composer-actions { display: flex; flex-direction: column; gap: 6px; padding: 6px 12px calc(10px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--border); background: var(--panel); }
#composer-actions.note-preview-visible { padding-bottom: calc(10px + 12px + env(safe-area-inset-bottom, 0px)); }
.composer-actions-row { display: flex; gap: 8px; align-items: center; justify-content: space-between; }
.composer-tools { display: flex; gap: var(--icon-gap); align-items: center; flex-wrap: nowrap; flex: 1; min-width: 0; }
.dialog-status-control { margin-left: auto; align-self: center; }
.action-control { position: relative; display: flex; align-items: center; gap: 4px; min-width: 0; }
.note-control { position: relative; flex: 0 0 32px; align-items: center; justify-content: center; gap: 0; }
.icon-button { border: 1px solid var(--border); background: #f9fafb; border-radius: 8px; width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center; font-size: 16px; cursor: pointer; color: #111827; transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.icon-button:hover { background: #eef2f7; }
.icon-button--primary { background: var(--accent); border-color: transparent; color: #fff; }
.icon-button--primary:hover { background: #1f6ed4; }
.icon-button--danger { border-color: var(--border); color: #111827; background: #f9fafb; }
.icon-button--danger:hover { background: #eef2f7; }
.icon-button .ui-icon { width: 18px; height: 18px; }
.icon-button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.icon-button:disabled { opacity: 0.45; cursor: default; }
.spellcheck-control { display: none; }
.note-preview { position: absolute; left: 2px; top: calc(100% + 10px); font-size: 12px; line-height: 1.2; color: var(--text); max-width: 220px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-left: 30px; }
.note-preview::before { content: ''; position: absolute; left: 13px; top: -1px; width: 9px; height: 8px; border-left: 2px solid var(--muted); border-bottom: 2px solid var(--muted); border-bottom-left-radius: 2px; }
.note-preview::after { content: ''; position: absolute; left: 20px; top: 5px; width: 4px; height: 4px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(-45deg); }
.note-preview.muted { color: var(--muted); opacity: 0; pointer-events: none; }
.note-preview.muted::before,
.note-preview.muted::after { display: none; }
body.ai-dialog .note-control,
body.ai-dialog .review-request-control,
body.ai-dialog .no-reply-control,
body.ai-dialog .dialog-status-control {
  display: none;
}
body.ai-dialog #quick-replies-toggle,
body.ai-dialog #quick-replies-panel {
  display: none;
}
body.ai-dialog .quick-replies-control {
  display: inline-flex;
  align-items: center;
}
body.ai-dialog .note-preview,
body.ai-dialog #note-panel,
body.ai-dialog #dialog-status-menu {
  display: none;
}
.note-panel { position: absolute; left: 0; bottom: calc(100% + 8px); top: auto; background: #fff; border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 18px 40px rgba(15,23,42,0.18); padding: 10px; z-index: 20; width: min(320px, 80vw); }
#note-input { width: 100%; min-height: 90px; border: 1px solid var(--border); border-radius: 8px; padding: 8px; font-size: 13px; resize: vertical; }
#note-input:focus { border-color: #c7d2fe; box-shadow: 0 0 0 2px rgba(59,130,246,0.15); outline: none; }
.push-control { display: none; }
.push-panel-row { display: flex; gap: 8px; align-items: center; justify-content: flex-start; }
.push-action { padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px; background: #ffffff; color: var(--text); font-weight: 700; cursor: pointer; font-size: 12px; }
.push-action:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.push-action--primary { background: var(--accent); color: #ffffff; border-color: transparent; }
.push-action--secondary { background: #f8fafc; }
.push-debug { font-size: 12px; line-height: 1.4; white-space: pre-wrap; }
.quick-replies-panel { position: absolute; left: 50%; bottom: calc(100% + 23px); top: auto; transform: translateX(calc(-50% + 100px)); background: #fff; border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 18px 40px rgba(15,23,42,0.18); width: min(360px, 85vw); padding: 10px; display: flex; flex-direction: column; gap: 8px; z-index: 20; max-height: min(70vh, 420px); overflow-y: auto; }
#quick-replies-search { width: 100%; border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; font-size: 13px; }
#quick-replies-search:focus { border-color: #c7d2fe; box-shadow: 0 0 0 2px rgba(59,130,246,0.15); outline: none; }
.quick-replies-list { flex: 1 1 auto; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
.quick-reply-item { border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; text-align: left; background: #f8fafc; cursor: pointer; font-size: 13px; appearance: none; }
.quick-reply-item:hover { background: #eef2f7; }
.quick-reply-item:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.quick-reply-item-title { font-weight: 600; margin-bottom: 4px; color: var(--text); }
.quick-reply-item-body { font-size: 12px; color: var(--muted); white-space: pre-wrap; }
.quick-replies-empty { font-size: 12px; color: var(--muted); padding: 4px 0; }
#no-reply-button { width: 32px; height: 32px; padding: 0; border-radius: 8px; justify-content: center; gap: 0; }
#no-reply-button:disabled { opacity: 0.4; cursor: default; }
.no-reply-icon { display: inline-flex; align-items: center; justify-content: center; }
.no-reply-icon .ui-icon { width: 18px; height: 18px; }
.no-reply-control { margin-left: 0; }
.quick-actions-cluster { display: inline-flex; align-items: center; gap: var(--icon-gap); }
.attachment-control { position: relative; display: inline-flex; }
#attachment-button { width: 32px; height: 32px; padding: 0; }
#attachment-button .ui-icon { width: 18px; height: 18px; }
.attachment-menu { position: absolute; bottom: calc(100% + 8px); left: 0; top: auto; transform: none; display: flex; flex-direction: column; background: #fff; border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 12px 24px rgba(15,23,42,0.15); overflow: hidden; min-width: 210px; z-index: 25; }
.attachment-menu button { border: none; background: transparent; padding: 10px 16px; cursor: pointer; text-align: left; display: flex; gap: 8px; align-items: center; font-size: 14px; white-space: nowrap; }
.attachment-menu button:hover { background: #f2f5f9; }
.attachment-menu .ui-icon { width: 25px; height: 25px; }

#composer { position: relative; display: flex; gap: 6px; align-items: center; padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px)) 12px; background: var(--panel); }
#composer-input { flex: 1; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border); background: #fff; color: var(--text); outline: none; resize: none; min-height: 42px; max-height: 200px; font-size: 12px; line-height: 1.4; font-family: inherit; }
#composer-input[readonly] { background: #f8fafc; color: #475569; }
#composer.draft-locked #composer-input { border-color: rgba(234, 179, 8, 0.45); box-shadow: 0 0 0 2px rgba(234, 179, 8, 0.12); }
.draft-actions { display: inline-flex; align-items: center; gap: 6px; }
.draft-actions.hidden { display: none; }
.draft-action { width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--border); background: #fff; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; color: #475569; padding: 0; }
.draft-action .ui-icon { width: 16px; height: 16px; }
.draft-action--approve { color: #0f766e; border-color: rgba(15, 118, 110, 0.25); }
.draft-action--reject { color: #b42318; border-color: rgba(180, 35, 24, 0.25); }
.draft-action--edit { color: #334155; }
.draft-action:disabled { opacity: 0.45; cursor: not-allowed; }
#composer-input:focus { border-color: #c7d2fe; box-shadow: 0 0 0 3px rgba(59,130,246,0.15); }
#composer-send { width: 36px; height: 36px; border-radius: 10px; border: none; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; background: var(--accent); color: #fff; }
#composer-send .ui-icon { width: 18px; height: 18px; }
#composer-send:hover { filter: brightness(1.08); }
#file-input { display: none; }
.hidden { display: none !important; }
.muted { color: var(--muted); }

@media (max-width: 640px) {
  .composer-actions-row { flex-direction: column; align-items: stretch; gap: 6px; }
  .composer-tools { min-width: 100%; flex-wrap: nowrap; gap: var(--icon-gap); }
  body.mobile-dialog #composer-actions { padding: 4px 12px 4px; gap: 4px; }
  body.mobile-dialog #composer-actions.note-preview-visible { padding-bottom: 4px; }
  body.mobile-dialog #composer { padding-top: 6px; }
  .no-reply-control { align-self: flex-end; }
  .quick-replies-panel {
    position: fixed;
    left: 12px;
    right: 12px;
    top: auto;
    bottom: calc(120px + env(safe-area-inset-bottom, 0px));
    width: auto;
    max-width: none;
    transform: none;
  }
  .attachment-menu {
    left: 12px;
    right: 12px;
    position: fixed;
    bottom: calc(120px + env(safe-area-inset-bottom, 0px));
    top: auto;
    min-width: auto;
  }
}

.auth-overlay { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: 24px; background: rgba(15, 23, 42, 0.55); z-index: 50; }
.pull-refresh { position: fixed; top: 0; left: 0; right: 0; height: 0; opacity: 0; overflow: hidden; display: flex; align-items: center; justify-content: center; gap: 8px; background: rgba(15, 23, 42, 0.78); color: #e2e8f0; z-index: 60; transition: height 0.18s ease, opacity 0.18s ease; pointer-events: none; }
.pull-refresh.active { opacity: 1; }
.pull-refresh span { font-size: 13px; font-weight: 600; letter-spacing: 0.2px; }
.auth-card { width: min(420px, 92vw); background: var(--panel); border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 24px 60px rgba(15, 23, 42, 0.35); padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.auth-title { font-size: 18px; font-weight: 700; color: var(--text); }
.auth-field { display: flex; flex-direction: column; gap: 6px; }
.auth-label { font-size: 12px; color: var(--muted); }
.auth-input { width: 100%; padding: 12px 12px; border-radius: 10px; border: 1px solid var(--border); background: #fff; color: var(--text); outline: none; font-size: 16px; }
.auth-input:focus { border-color: #c7d2fe; box-shadow: 0 0 0 3px rgba(59,130,246,0.15); }
.auth-submit { padding: 12px 14px; background: var(--accent); color: #fff; border: none; border-radius: 10px; cursor: pointer; font-weight: 700; }
.auth-submit:disabled { opacity: 0.75; cursor: default; }
.auth-error { color: #b91c1c; font-size: 13px; }
.password-wrap { position: relative; display: flex; align-items: center; }
.password-wrap input { padding-right: 44px; }
.password-toggle { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); border: none; background: transparent; color: #94a3b8; padding: 4px; cursor: pointer; display: grid; place-items: center; }
.password-toggle svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.password-toggle.is-active { color: #0f172a; }
.schedule-card { gap: 10px; width: min(560px, 100%); }
.schedule-title { font-size: 16px; font-weight: 700; color: var(--text); }
.schedule-actions { display: flex; justify-content: flex-end; gap: 8px; }
.schedule-cancel { padding: 12px 14px; border-radius: 10px; border: 1px solid var(--border); background: #fff; color: var(--text); cursor: pointer; }
.schedule-cancel:hover { background: #f3f4f6; }
.schedule-input { font-size: 16px; }
.schedule-input[readonly] { background: #f8fafc; cursor: default; }
.schedule-picker { border: 1px solid var(--border); border-radius: 12px; padding: 12px; background: #ffffff; display: flex; flex-direction: column; gap: 10px; }
.schedule-picker-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.schedule-month-label { font-size: 16px; font-weight: 700; color: #0f172a; text-transform: capitalize; }
.schedule-nav { border: none; background: #eef2f7; color: #0f172a; width: 34px; height: 34px; border-radius: 10px; cursor: pointer; font-size: 18px; display: inline-flex; align-items: center; justify-content: center; }
.schedule-nav:hover { background: #e2e8f0; }
.schedule-weekdays { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; font-size: 12px; font-weight: 600; text-transform: uppercase; color: #64748b; text-align: center; }
.schedule-days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.schedule-day { border: none; background: #f8fafc; color: #0f172a; font-size: 14px; font-weight: 600; height: 38px; border-radius: 10px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.schedule-day:hover { background: #e2e8f0; }
.schedule-day.is-outside { opacity: 0.35; }
.schedule-day.is-today { box-shadow: inset 0 0 0 2px rgba(148,163,184,0.8); }
.schedule-day.is-selected { background: #0ea5e9; color: #fff; }
.schedule-day.is-selected:hover { background: #0284c7; }
.schedule-day.is-disabled { opacity: 0.25; cursor: not-allowed; background: #f1f5f9; }
.schedule-time { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.schedule-time-label { font-size: 13px; font-weight: 700; color: #0f172a; }
.schedule-time-controls { display: inline-flex; align-items: center; gap: 8px; }
.schedule-time-select { border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; font-size: 16px; background: #fff; color: #0f172a; }
.schedule-time-sep { font-weight: 700; font-size: 16px; color: #64748b; }

@media (max-width: 1024px), (hover: none) and (pointer: coarse) {
  #app { flex-direction: column; height: 100vh; height: 100dvh; }
  #channels { width: 100%; height: 100vh; height: 100dvh; border-right: none; display: flex !important; }
  #dialog { width: 100%; height: 100vh; height: 100dvh; display: none !important; }
  .back-button { display: inline-flex; align-items: center; justify-content: center; }
body.mobile-dialog .dialog-status-button { height: 32px; padding: 0 10px; justify-content: center; max-width: none; }
body.mobile-dialog .dialog-status-label { display: inline; }
body.mobile-dialog .dialog-status-schedule { display: none; }
body.mobile-dialog .dialog-status-caret { font-size: 14px; opacity: 0.85; }
  body.mobile-dialog #dialog { display: flex !important; }
  body.mobile-dialog #channels { display: none !important; }
  body.mobile-list #dialog { display: none !important; }
  body.mobile-list #channels { display: flex !important; }
  body.mobile-dialog #composer-input { font-size: 16px; }
  body.mobile-dialog #note-input { font-size: 16px; }
body.mobile-dialog #quick-replies-search { font-size: 16px; }
body.mobile-dialog #channel-search-input { font-size: 16px; }
body.mobile-list #channel-search-input { font-size: 16px; }
  body.mobile-dialog .no-reply-control { align-self: center; }
  body.mobile-dialog .note-preview { display: none; }
  body.mobile-dialog .note-control { flex-direction: row; align-items: center; }
}

@media (max-width: 1024px), (hover: none) and (pointer: coarse) {
  .menu-label { display: none; }
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}
