:root {
  color-scheme: light;
  --blue: #3390ec;
  --blue-dark: #2481d7;
  --conv-active: #3390ec;
  --ink: #17212b;
  --muted: #82909e;
  --line: #e7ebef;
  --surface: #fff;
  --surface-soft: #f4f6f8;
  --chat-wall: #dcebcf;
  --incoming: #fff;
  --outgoing: #e2ffc7;
  --message-name: #145b99;
  --outgoing-name: #28613d;
  --danger: #e25454;
  --shadow: 0 8px 28px rgb(28 45 61 / 12%);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  color: var(--ink);
  background: var(--surface-soft);
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --conv-active: #1769aa;
  --ink: #e5eaf0;
  --muted: #93a0ad;
  --line: #293542;
  --surface: #17212b;
  --surface-soft: #101820;
  --chat-wall: #182a2d;
  --incoming: #202e3a;
  --outgoing: #2b5278;
  --message-name: #a6d9ff;
  --outgoing-name: #d1efff;
  --shadow: 0 8px 28px rgb(0 0 0 / 30%);
}

* { box-sizing: border-box; }
html, body, #app { width: 100%; height: 100%; margin: 0; }
body { min-width: 320px; overflow: hidden; background: var(--surface-soft); }
button, input, textarea, select { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}
[hidden] { display: none !important; }
a { color: var(--blue-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
.icon { display: inline-block; flex: 0 0 auto; vertical-align: middle; }
.icon-settings {
  width: 18px;
  height: 18px;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M19.14 12.94a7.49 7.49 0 0 0 .05-.94 7.49 7.49 0 0 0-.05-.94l2.03-1.58a.5.5 0 0 0 .12-.64l-1.92-3.32a.5.5 0 0 0-.61-.22l-2.39.96a7.28 7.28 0 0 0-1.63-.95l-.36-2.54A.49.49 0 0 0 13.88 2h-3.76a.49.49 0 0 0-.49.42L9.27 4.96a7.28 7.28 0 0 0-1.63.95l-2.39-.96a.5.5 0 0 0-.61.22L2.72 8.49a.5.5 0 0 0 .12.64l2.03 1.58a7.49 7.49 0 0 0-.05.94 7.49 7.49 0 0 0 .05.94l-2.03 1.58a.5.5 0 0 0-.12.64l1.92 3.32a.5.5 0 0 0 .61.22l2.39-.96c.5.39 1.05.71 1.63.95l.36 2.54a.49.49 0 0 0 .49.42h3.76a.49.49 0 0 0 .49-.42l.36-2.54c.58-.24 1.13-.56 1.63-.95l2.39.96a.5.5 0 0 0 .61-.22l1.92-3.32a.5.5 0 0 0-.12-.64l-2.03-1.58ZM12 15.5a3.5 3.5 0 1 1 0-7 3.5 3.5 0 0 1 0 7Z'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M19.14 12.94a7.49 7.49 0 0 0 .05-.94 7.49 7.49 0 0 0-.05-.94l2.03-1.58a.5.5 0 0 0 .12-.64l-1.92-3.32a.5.5 0 0 0-.61-.22l-2.39.96a7.28 7.28 0 0 0-1.63-.95l-.36-2.54A.49.49 0 0 0 13.88 2h-3.76a.49.49 0 0 0-.49.42L9.27 4.96a7.28 7.28 0 0 0-1.63.95l-2.39-.96a.5.5 0 0 0-.61.22L2.72 8.49a.5.5 0 0 0 .12.64l2.03 1.58a7.49 7.49 0 0 0-.05.94 7.49 7.49 0 0 0 .05.94l-2.03 1.58a.5.5 0 0 0-.12.64l1.92 3.32a.5.5 0 0 0 .61.22l2.39-.96c.5.39 1.05.71 1.63.95l.36 2.54a.49.49 0 0 0 .49.42h3.76a.49.49 0 0 0 .49-.42l.36-2.54c.58-.24 1.13-.56 1.63-.95l2.39.96a.5.5 0 0 0 .61-.22l1.92-3.32a.5.5 0 0 0-.12-.64l-2.03-1.58ZM12 15.5a3.5 3.5 0 1 1 0-7 3.5 3.5 0 0 1 0 7Z'/%3E%3C/svg%3E") center / contain no-repeat;
}
.muted { color: var(--muted); }
.small { font-size: 12px; }
.pad { padding: 16px; }
.center { text-align: center; }
.right { text-align: right; }
.grow { flex: 1; }
.row { display: flex; align-items: center; gap: 8px; }
.row.end { justify-content: flex-end; }
.stack { display: flex; flex-direction: column; gap: 14px; }

/* Main Telegram-style three-panel frame */
.chat-shell { width: 100%; height: 100%; }
.app {
  display: grid;
  grid-template-columns: minmax(328px, 378px) minmax(0, 1fr);
  width: 100%;
  height: 100%;
  max-width: 1680px;
  margin: 0 auto;
  overflow: hidden;
  background: var(--surface);
  box-shadow: 0 0 36px rgb(31 45 61 / 10%);
}
.shop-rail { display: none; }
.shop-card {
  display: flex;
  flex-direction: column;
  gap: 7px;
  width: 100%;
  max-width: 260px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface);
  box-shadow: 0 4px 16px rgb(0 0 0 / 7%);
}
.shop-image { display: block; width: 100%; height: 150px; border-radius: 8px; background: var(--surface-soft); object-fit: contain; }
.shop-card h3 { margin: 2px 0 0; font-size: 16px; overflow-wrap: anywhere; }
.shop-price { color: var(--blue-dark); font-size: 15px; overflow-wrap: anywhere; }
.shop-quantity { color: var(--ink); font-size: 14px; font-weight: 600; }
.shop-description { margin: 0; color: var(--ink); font-size: 14px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
@media (min-width: 1280px) {
  .chat-shell { display: grid; grid-template-columns: minmax(200px, 1fr) minmax(0, 1680px) minmax(200px, 1fr); }
  .chat-shell > .app { grid-column: 2; margin: 0; }
  .shop-rail { display: flex; min-width: 0; align-items: center; flex-direction: column; gap: 12px; padding: 16px 8px; overflow: auto; scrollbar-width: thin; }
  .shop-rail-left { grid-column: 1; grid-row: 1; }
  .shop-rail-right { grid-column: 3; grid-row: 1; }
}
.sidebar {
  z-index: 2;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  background: var(--surface);
  border-right: 1px solid var(--line);
}
.side-head {
  min-height: 64px;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
}
.avatar {
  position: relative;
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: #fff;
  font-weight: 600;
  letter-spacing: .02em;
  user-select: none;
  overflow: hidden;
}
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: inherit; object-fit: cover; }
.avatar-action { display: inline-flex; flex: 0 0 auto; border-radius: 50%; }
.user-display-name { display: inline-flex; min-width: 0; align-items: center; gap: 4px; vertical-align: middle; }
.verified-badge {
  display: inline-flex;
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: #1877f2;
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  line-height: 1;
}
.me, .head-text { display: flex; flex: 1; min-width: 0; flex-direction: column; gap: 3px; }
.me strong, .title { min-width: 0; overflow: hidden; font-size: 14px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.side-actions { display: flex; align-items: center; gap: 2px; }
.icon-btn {
  display: inline-flex;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: color .15s, background .15s;
}
.icon-btn:hover { color: var(--blue); background: rgb(51 144 236 / 10%); }
.search { position: relative; display: flex; align-items: center; padding: 10px 12px; color: var(--muted); }
.search > .icon { position: absolute; left: 26px; pointer-events: none; }
.search input, input[type="search"] {
  width: 100%;
  min-width: 0;
  height: 40px;
  padding: 0 14px 0 40px;
  border: 1px solid transparent;
  border-radius: 22px;
  background: var(--surface-soft);
  color: var(--ink);
  outline: 0;
}
.search input:focus, input[type="search"]:focus { border-color: rgb(51 144 236 / 45%); background: var(--surface); }
.conv-list { flex: 1; min-height: 0; overflow: auto; padding: 4px 7px 10px; scrollbar-width: thin; }
.payment-card {
  flex: 0 0 auto;
  display: flex;
  max-height: 38%;
  flex-direction: column;
  gap: 7px;
  margin: 0 10px 10px;
  padding: 11px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-soft);
}
.payment-card h3 { margin: 0; font-size: 14px; }
.payment-qr-trigger { position: relative; display: block; max-width: 100%; align-self: center; padding: 0; border: 0; border-radius: 8px; background: transparent; cursor: zoom-in; }
.payment-qr { display: block; width: auto; max-width: min(100%, 170px); max-height: 155px; border-radius: 8px; background: #fff; object-fit: contain; }
.payment-qr-hover-preview { position: fixed; z-index: 19; top: 50%; left: 50%; display: none; max-width: calc(100vw - 24px); max-height: calc(100vh - 24px); padding: 10px; transform: translate(-50%, -50%); border: 1px solid var(--line); border-radius: 12px; background: var(--surface); box-shadow: var(--shadow); pointer-events: none; }
.payment-qr-hover-preview img { display: block; width: auto; height: auto; max-width: calc(100vw - 44px); max-height: calc(100vh - 44px); object-fit: contain; }
.payment-qr-trigger:hover .payment-qr-hover-preview, .payment-qr-trigger:focus-visible .payment-qr-hover-preview { display: block; }
.payment-detail { display: flex; min-width: 0; flex-direction: column; gap: 4px; font-size: 13px; }
.payment-detail strong { color: var(--ink); font-size: 13px; font-weight: 650; }
.payment-value { display: flex; min-width: 0; align-items: center; gap: 5px; }
.payment-value code { flex: 1; min-width: 0; overflow-wrap: anywhere; color: var(--ink); font: 600 13px/1.5 ui-monospace, Consolas, monospace; }
.payment-copy { display: inline-flex; width: 30px; height: 30px; flex: 0 0 auto; align-items: center; justify-content: center; border: 0; border-radius: 7px; background: transparent; color: var(--muted); cursor: pointer; }
.payment-copy:hover { background: var(--surface); color: var(--blue); }
.payment-alert { margin: 2px 0 0; padding: 8px 9px; border: 1px solid rgb(226 84 84 / 35%); border-radius: 8px; background: rgb(226 84 84 / 10%); color: var(--danger); font-size: 13px; font-weight: 750; line-height: 1.4; }
.payment-warning { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.35; }
.conv-row { display: flex; min-width: 0; align-items: center; gap: 2px; }
.conv {
  display: flex;
  width: auto;
  min-width: 0;
  min-height: 72px;
  flex: 1;
  align-items: center;
  gap: 11px;
  padding: 10px 11px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  text-align: left;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.conv-row:hover .conv { background: var(--surface-soft); }
.conv:hover { background: var(--surface-soft); }
.conv.active { background: var(--conv-active); color: #fff; }
.conv.active .muted, .conv.active time, .conv.active .conv-bot, .conv.active .preview { color: #fff; }
.conv-delete { width: 34px; height: 34px; opacity: 0; pointer-events: none; }
.conv.active + .conv-delete { color: #fff; }
.conv-delete:hover { color: var(--danger); }
.conv-row:hover .conv-delete, .conv-row:focus-within .conv-delete { opacity: 1; pointer-events: auto; }
.av-wrap { position: relative; display: inline-flex; flex: 0 0 auto; }
.dot {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 11px;
  height: 11px;
  border: 2px solid var(--surface);
  border-radius: 50%;
  background: #48c78e;
}
.conv.active .dot { border-color: var(--blue); }
.dot.inline { position: static; display: inline-block; width: 9px; height: 9px; border: 0; }
.conv-main { display: flex; flex: 1; min-width: 0; flex-direction: column; gap: 5px; }
.conv-top, .conv-bot { display: flex; min-width: 0; align-items: center; justify-content: space-between; gap: 8px; }
.conv-top strong { overflow: hidden; font-size: 14px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.conv-top time { flex: 0 0 auto; color: var(--muted); font-size: 11px; }
.preview { overflow: hidden; color: var(--muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
@media (hover: none) { .conv-delete { opacity: 1; pointer-events: auto; } }
.badge, .count {
  display: inline-flex;
  min-width: 19px;
  height: 19px;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
  border-radius: 12px;
  background: var(--blue);
  color: white;
  font-size: 11px;
  font-weight: 600;
}
.conv.active .badge { background: rgb(255 255 255 / 25%); }

.chat { position: relative; display: flex; min-width: 0; min-height: 0; flex-direction: column; overflow: hidden; background: var(--chat-wall); }
.app.show-info { grid-template-columns: minmax(290px, 340px) minmax(0, 1fr) 310px; }
.chat-body { display: flex; position: relative; flex: 1; min-height: 0; flex-direction: column; overflow: hidden; }
.chat-head {
  z-index: 1;
  display: flex;
  min-height: 62px;
  align-items: center;
  gap: 12px;
  padding: 8px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  box-shadow: 0 1px 4px rgb(0 0 0 / 4%);
}
.h-avatar { display: flex; flex: 0 0 auto; }
.head-text { gap: 4px; }
.head-text .muted { font-size: 12px; }
.info-trigger { padding: 5px 7px; border: 0; border-radius: 8px; background: transparent; color: inherit; text-align: left; cursor: pointer; }
.info-trigger:hover { background: var(--surface-soft); }
.back { display: none; }
.banner { padding: 8px 14px; background: #fff2d5; color: #88631d; text-align: center; font-size: 13px; }
.pinbar {
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  color: var(--blue);
}
.pin-text { display: flex; flex: 1; min-width: 0; flex-direction: column; gap: 3px; border: 0; background: none; color: var(--ink); text-align: left; cursor: pointer; }
.pin-text span { overflow: hidden; color: var(--muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.link { padding: 2px 4px; border: 0; background: transparent; color: var(--blue-dark); cursor: pointer; }
.list-wrap {
  position: relative;
  display: flex;
  flex: 1;
  min-height: 0;
  flex-direction: column;
  overflow: hidden;
  background-color: var(--chat-wall);
  background-image:
    radial-gradient(ellipse at 20% 20%, rgb(255 255 255 / 12%) 0 2px, transparent 3px),
    radial-gradient(ellipse at 75% 65%, rgb(81 128 73 / 9%) 0 2px, transparent 3px),
    radial-gradient(ellipse at 40% 85%, rgb(255 255 255 / 10%) 0 1px, transparent 2px);
  background-size: 37px 41px, 53px 47px, 29px 31px;
}
.messages {
  display: flex;
  flex: 1;
  min-height: 0;
  flex-direction: column;
  gap: 7px;
  overflow: auto;
  padding: 22px clamp(16px, 5vw, 72px) 20px;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgb(85 113 85 / 25%) transparent;
}
.msg { position: relative; display: grid; width: fit-content; max-width: min(78%, 720px); grid-template-columns: 36px minmax(0, 1fr); align-items: end; gap: 7px; }
.msg.compact { margin-top: -3px; }
.msg.own { align-self: flex-end; grid-template-columns: minmax(0, 1fr); }
.gutter { display: flex; align-items: flex-end; justify-content: center; }
.gutter-time { padding-bottom: 5px; color: var(--muted); font-size: 10px; }
.content {
  min-width: 0;
  padding: 8px 11px 7px;
  border-radius: 13px 13px 13px 4px;
  background: var(--incoming);
  box-shadow: 0 1px 1px rgb(23 33 43 / 8%);
  overflow-wrap: anywhere;
}
.msg.own .content { border-radius: 13px 13px 4px 13px; background: var(--outgoing); }
.msg.compact .content { border-radius: 10px; }
.meta { display: flex; align-items: center; gap: 7px; margin-bottom: 3px; color: var(--blue-dark); font-size: 12px; }
.meta strong { font-weight: 600; }
.meta .sender-name { color: var(--message-name); font-size: 14px; font-weight: 700; }
.meta time { margin-left: auto; color: var(--muted); font-size: 10px; white-space: nowrap; }
.msg.own .meta { color: var(--muted); }
.msg.own .meta .sender-name { color: var(--outgoing-name); }
.body { color: var(--ink); font-size: 14px; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; }
.body a { text-decoration: underline; }
.deleted-text { color: var(--muted); font-style: italic; }
.edited { color: var(--muted); font-size: 10px; }
.pin-badge { display: inline-flex; margin-left: auto; color: var(--blue); }
.tools {
  position: absolute;
  top: -34px;
  right: 0;
  display: none;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.msg:hover .tools, .msg.show-tools .tools { display: flex; }
.tool { display: inline-flex; width: 30px; height: 30px; align-items: center; justify-content: center; border: 0; border-radius: 50%; background: transparent; color: var(--muted); cursor: pointer; }
.tool:hover { color: var(--blue); background: var(--surface-soft); }
.message-menu { min-width: 176px; padding: 4px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); box-shadow: var(--shadow); }
.message-menu-action { display: flex; width: 100%; align-items: center; gap: 9px; padding: 9px 10px; border: 0; border-radius: 7px; background: transparent; color: var(--ink); text-align: left; cursor: pointer; }
.message-menu-action:hover { background: var(--surface-soft); }
.message-menu-action.danger { color: var(--danger); }
.day { align-self: center; margin: 5px 0; }
.day span, .unread-divider span { display: inline-block; padding: 5px 12px; border-radius: 15px; background: rgb(79 122 68 / 60%); color: #fff; font-size: 11px; box-shadow: 0 1px 2px rgb(0 0 0 / 10%); }
.unread-divider { align-self: center; margin: 6px 0; }
.unread-divider span { background: var(--blue); }
.load-more { align-self: center; padding: 8px 14px; border: 0; border-radius: 20px; background: var(--surface); color: var(--blue); cursor: pointer; }
.search-status { margin: 0; }
.message-search-results { display: flex; max-height: min(55vh, 520px); flex-direction: column; gap: 6px; overflow: auto; }
.message-search-result { display: flex; flex-direction: column; gap: 5px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink); text-align: left; cursor: pointer; }
.message-search-result:hover { border-color: var(--blue); background: var(--surface-soft); }
.message-search-meta { display: flex; align-items: center; justify-content: space-between; gap: 10px; color: var(--muted); font-size: 11px; }
.message-search-meta strong { color: var(--ink); font-size: 12px; }
.message-search-meta time { white-space: nowrap; }
.message-search-preview { overflow-wrap: anywhere; font-size: 13px; line-height: 1.4; }
.reactions { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 7px; }
.chip { padding: 3px 8px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); cursor: pointer; }
.chip.mine { border-color: var(--blue); background: rgb(51 144 236 / 10%); }
.atts { display: flex; flex-direction: column; gap: 7px; margin-top: 6px; }
.att-img { display: block; max-width: min(420px, 55vw); padding: 0; overflow: hidden; border: 0; border-radius: 9px; background: transparent; cursor: zoom-in; }
.att-img img { display: block; max-width: 100%; max-height: 360px; object-fit: contain; }
.att-media video { display: block; max-width: min(420px, 55vw); max-height: 360px; border-radius: 9px; }
.att-audio { min-width: 220px; }
.att-audio audio { width: 100%; height: 38px; }
.file-card { display: flex; min-width: 220px; align-items: center; gap: 10px; padding: 9px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.file-ic { color: var(--blue); }
.file-meta, .up-meta { display: flex; flex: 1; min-width: 0; flex-direction: column; gap: 3px; }
.file-meta strong, .up-meta strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-name { margin-bottom: 4px; font-size: 12px; }
.send-error { margin-top: 6px; color: var(--danger); font-size: 12px; }
.editor { display: flex; flex-direction: column; gap: 7px; }
.edit-input { min-width: 240px; padding: 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); resize: vertical; }
.typing { min-height: 20px; padding: 0 24px; color: var(--blue-dark); font-size: 12px; }
.composer {
  z-index: 1;
  padding: 9px clamp(12px, 4vw, 58px) 13px;
  background: linear-gradient(transparent, rgb(255 255 255 / 10%));
}
.composer-row {
  display: flex;
  min-height: 48px;
  align-items: flex-end;
  gap: 5px;
  padding: 5px 7px;
  border: 1px solid rgb(90 110 90 / 14%);
  border-radius: 25px;
  background: var(--surface);
  box-shadow: 0 2px 8px rgb(20 35 20 / 9%);
}
.composer-row .icon-btn { width: 36px; height: 36px; }
.composer textarea {
  flex: 1;
  min-width: 0;
  max-height: 160px;
  padding: 9px 5px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  line-height: 1.4;
  resize: none;
}
.composer textarea:focus { outline: 0; }
.send { display: inline-flex; width: 36px; height: 36px; flex: 0 0 auto; align-items: center; justify-content: center; border: 0; border-radius: 50%; background: var(--blue); color: #fff; cursor: pointer; }
.send:hover { background: var(--blue-dark); }
.chips { display: flex; flex-wrap: wrap; gap: 7px; padding-bottom: 8px; }
.upload { display: flex; width: min(280px, 100%); align-items: center; gap: 8px; padding: 7px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); }
.upload > img { width: 38px; height: 38px; border-radius: 5px; object-fit: cover; }
.upload.error { border-color: var(--danger); }
.chip-ic { display: flex; align-items: center; color: var(--blue); }
.bar { display: block; height: 3px; overflow: hidden; border-radius: 3px; background: var(--line); }
.bar i { display: block; height: 100%; background: var(--blue); }
.drop-hint { position: absolute; z-index: 5; inset: 15px; display: grid; place-items: center; border: 2px dashed var(--blue); border-radius: 16px; background: rgb(255 255 255 / 82%); color: var(--blue-dark); font-size: 20px; pointer-events: none; }
.jump { position: absolute; z-index: 2; right: 25px; bottom: 22px; display: flex; align-items: center; gap: 6px; padding: 9px 14px; border: 0; border-radius: 22px; background: var(--surface); color: var(--blue); box-shadow: var(--shadow); cursor: pointer; }
.empty { display: grid; flex: 1; place-content: center; justify-items: center; gap: 12px; padding: 28px; color: var(--muted); text-align: center; }
.empty > .icon { width: 56px; height: 56px; padding: 15px; border-radius: 50%; background: rgb(51 144 236 / 10%); color: var(--blue); }
.empty h2 { margin: 0; color: var(--ink); font-size: 20px; font-weight: 500; }
.empty p { margin: 0; }

/* Pinned-message panel */
.drawer {
  position: absolute;
  z-index: 4;
  top: 0;
  right: 0;
  bottom: 0;
  display: flex;
  width: min(340px, 88%);
  flex-direction: column;
  border-left: 1px solid var(--line);
  background: var(--surface);
  box-shadow: -8px 0 24px rgb(0 0 0 / 12%);
  transform: translateX(105%);
  transition: transform .2s ease;
}
.drawer.open { transform: translateX(0); }
.drawer-head { display: flex; min-height: 58px; align-items: center; justify-content: space-between; padding: 8px 14px; border-bottom: 1px solid var(--line); }
.drawer-body { flex: 1; overflow: auto; padding: 12px; }
.pin-card { display: flex; flex-direction: column; gap: 9px; margin-bottom: 10px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-soft); }
.pin-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.pin-snippet { overflow-wrap: anywhere; }
.info-panel { z-index: 3; display: flex; min-width: 0; flex-direction: column; overflow: auto; border-left: 1px solid var(--line); background: var(--surface); }
.info-head { display: flex; min-height: 58px; align-items: center; justify-content: space-between; padding: 8px 13px; border-bottom: 1px solid var(--line); }
.info-profile { display: flex; align-items: center; flex-direction: column; gap: 7px; padding: 27px 15px 22px; border-bottom: 1px solid var(--line); text-align: center; }
.info-profile > strong { margin-top: 5px; font-size: 16px; }
.info-avatar .avatar { box-shadow: 0 2px 8px rgb(0 0 0 / 10%); }
.info-section { padding: 17px 13px; }
.info-section h3 { margin: 0 0 11px; font-size: 13px; }
.info-members { display: flex; flex-direction: column; gap: 3px; }
.info-member { display: flex; min-width: 0; align-items: center; gap: 10px; padding: 8px 4px; }
.info-member > span:not(.avatar) { display: flex; flex: 1; min-width: 0; flex-direction: column; gap: 3px; }
.info-member strong { overflow: hidden; font-size: 13px; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }

/* Authentication, dialogs, pickers, notifications */
.auth-wrap { display: grid; min-height: 100%; place-items: center; padding: 24px; background: radial-gradient(circle at 20% 15%, rgb(51 144 236 / 12%), transparent 35%), var(--surface-soft); }
.welcome-screen {
  position: relative;
  display: grid;
  width: 100%;
  min-height: 100%;
  place-items: center;
  overflow: hidden;
  isolation: isolate;
  background:
    radial-gradient(ellipse at 50% 45%, rgb(255 255 255 / 88%), transparent 42%),
    linear-gradient(135deg, #edf7ff 0%, #f7f4ff 48%, #edf9f4 100%);
}
:root[data-theme="dark"] .welcome-screen {
  background:
    radial-gradient(ellipse at 50% 45%, rgb(46 70 99 / 42%), transparent 45%),
    linear-gradient(135deg, #101c29 0%, #191827 52%, #10231f 100%);
}
.welcome-screen::before, .welcome-screen::after {
  position: absolute;
  z-index: -1;
  width: min(72vw, 700px);
  aspect-ratio: 1;
  border: 1px solid rgb(51 144 236 / 10%);
  border-radius: 50%;
  content: "";
}
.welcome-screen::after { width: min(54vw, 520px); border-color: rgb(130 107 214 / 10%); }
.welcome-glow {
  position: absolute;
  z-index: -1;
  width: min(42vw, 440px);
  aspect-ratio: 1;
  border-radius: 50%;
  background: linear-gradient(135deg, rgb(51 144 236 / 16%), rgb(152 115 235 / 12%) 55%, rgb(91 203 163 / 15%));
  filter: blur(44px);
  animation: welcome-breathe 7s ease-in-out infinite alternate;
}
.welcome-content { display: grid; justify-items: center; gap: 22px; padding: 30px; text-align: center; animation: welcome-arrive .8s cubic-bezier(.2,.7,.2,1) both; }
.welcome-emblem {
  display: grid;
  width: clamp(76px, 10vw, 108px);
  aspect-ratio: 1;
  place-items: center;
  border: 1px solid rgb(255 255 255 / 72%);
  border-radius: 32%;
  background: linear-gradient(145deg, #fff, #e6f2ff 55%, #ece8ff);
  box-shadow: 0 18px 55px rgb(67 102 170 / 18%), inset 0 1px 0 #fff;
  transform: rotate(-8deg);
}
:root[data-theme="dark"] .welcome-emblem { border-color: rgb(255 255 255 / 12%); background: linear-gradient(145deg, #283d54, #23364c 55%, #36334f); }
.welcome-emblem span { width: 31%; aspect-ratio: 1; border-radius: 50%; background: linear-gradient(145deg, #43a6f5, #8270e8); box-shadow: 0 8px 24px rgb(81 120 226 / 35%); }
.welcome-content h1 {
  margin: 0;
  background: linear-gradient(100deg, #287fd0, #7662d8 55%, #30a982);
  background-clip: text;
  color: transparent;
  font-size: clamp(3.5rem, 10vw, 7.5rem);
  font-weight: 700;
  letter-spacing: -.075em;
  line-height: 1;
  text-shadow: 0 12px 44px rgb(93 117 198 / 13%);
}
.public-data-page { width: 100%; height: 100vh; height: 100dvh; overflow: hidden; padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); background: var(--surface); }
.public-data-workspace { display: grid; min-height: 0; grid-template-columns: 42px minmax(0, 1fr); overflow: hidden; background: var(--surface); }
.public-data-workspace { width: 100%; height: 100%; }
.public-data-lines { overflow: hidden; padding: 10px 8px 10px 0; border-right: 1px solid var(--line); color: var(--muted); font: 14px/21px Consolas, "Courier New", monospace; text-align: right; user-select: none; }
.public-data-editor { display: block; width: 100%; height: 100%; min-width: 0; min-height: 0; resize: none; padding: 10px 12px; border: 0; border-radius: 0; outline: 0; background: var(--surface); color: var(--ink); caret-color: var(--blue); font: 14px/21px Consolas, "Courier New", monospace; tab-size: 4; white-space: pre; overflow: auto; overscroll-behavior: contain; }
.public-data-editor:focus { outline: 0; }
@media (max-width: 640px) {
  .public-data-workspace { grid-template-columns: 34px minmax(0, 1fr); }
  .public-data-lines { padding: 12px 6px 12px 0; font-size: 16px; line-height: 24px; }
  .public-data-editor { padding: 12px 9px; font-size: 16px; line-height: 24px; -webkit-overflow-scrolling: touch; }
}
.welcome-orbit { position: absolute; z-index: -1; width: 10px; height: 10px; border-radius: 50%; background: #51a7e9; box-shadow: 0 0 0 7px rgb(81 167 233 / 10%), 0 5px 18px rgb(81 167 233 / 35%); }
.orbit-one { top: 27%; left: 28%; }
.orbit-two { right: 27%; bottom: 26%; width: 7px; height: 7px; background: #8a76df; box-shadow: 0 0 0 6px rgb(138 118 223 / 11%), 0 5px 18px rgb(138 118 223 / 35%); }
.welcome-spark { position: absolute; width: 7px; height: 7px; border: 1.5px solid #5ea9e5; border-radius: 2px; opacity: .58; transform: rotate(45deg); }
.spark-one { top: 34%; right: 34%; }
.spark-two { bottom: 33%; left: 34%; width: 5px; height: 5px; border-color: #8875dc; }
.spark-three { top: 22%; right: 23%; width: 4px; height: 4px; border-color: #55b99b; }
@keyframes welcome-breathe { from { transform: scale(.92); opacity: .7; } to { transform: scale(1.08); opacity: 1; } }
@keyframes welcome-arrive { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: translateY(0) scale(1); } }
.auth-card { width: min(100%, 420px); padding: 32px; border: 1px solid var(--line); border-radius: 20px; background: var(--surface); box-shadow: var(--shadow); }
.brand { display: flex; align-items: center; gap: 9px; margin-bottom: 26px; color: var(--blue); font-size: 17px; font-weight: 700; }
.auth-card h1 { margin: 0 0 9px; font-size: 24px; }
.auth-card > .muted { margin: 0 0 22px; line-height: 1.55; }
.auth-card label, .settings label { display: flex; flex-direction: column; gap: 7px; color: var(--ink); font-size: 13px; font-weight: 500; }
.auth-card input, .modal input:not([type="checkbox"]), .modal textarea, .modal select, .settings input, .settings textarea {
  width: 100%;
  min-height: 42px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  color: var(--ink);
}
.auth-card input:focus, .modal input:focus, .modal textarea:focus, .modal select:focus { border-color: var(--blue); outline: 2px solid rgb(51 144 236 / 12%); }
.form-error { min-height: 0; color: var(--danger); font-size: 13px; }
.form-error:not(:empty) { padding: 9px 11px; border-radius: 8px; background: rgb(226 84 84 / 9%); }
.form-warn { color: #9d6c20; font-size: 12px; line-height: 1.5; }
.meter { display: flex; gap: 5px; }
.meter span { height: 4px; flex: 1; border-radius: 4px; background: var(--line); }
.meter span.on { background: #f0aa37; }
.meter span.on.s3, .meter span.on.s4 { background: #48b978; }
.btn {
  display: inline-flex;
  min-height: 36px;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 13px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.btn:hover { border-color: #bac7d3; background: var(--surface-soft); }
.btn.primary { border-color: var(--blue); background: var(--blue); color: #fff; }
.btn.primary:hover { border-color: var(--blue-dark); background: var(--blue-dark); }
.btn.danger { border-color: var(--danger); background: var(--danger); color: #fff; }
.btn.small { min-height: 29px; padding: 4px 9px; font-size: 12px; }
.btn.block { width: 100%; min-height: 44px; border-radius: 11px; font-weight: 600; }
.btn:disabled { opacity: .6; cursor: wait; }
.overlay { position: fixed; z-index: 20; inset: 0; display: grid; place-items: center; padding: 18px; background: rgb(13 26 38 / 45%); backdrop-filter: blur(2px); }
.modal { width: min(100%, 500px); max-height: min(90vh, 800px); overflow: auto; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); box-shadow: var(--shadow); }
.modal.wide { width: min(100%, 900px); }
.modal-head { position: sticky; top: 0; z-index: 1; display: flex; min-height: 58px; align-items: center; justify-content: space-between; padding: 8px 14px 8px 20px; border-bottom: 1px solid var(--line); background: var(--surface); }
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-body { padding: 18px 20px 22px; }
.popover { position: fixed; z-index: 30; max-width: calc(100vw - 16px); border: 1px solid var(--line); border-radius: 14px; background: var(--surface); box-shadow: var(--shadow); }
.picker { max-width: 320px; padding: 9px; }
.quick { display: flex; justify-content: space-around; padding-bottom: 7px; border-bottom: 1px solid var(--line); }
.emoji-grid { display: grid; max-height: 230px; grid-template-columns: repeat(8, 1fr); gap: 3px; overflow: auto; padding-top: 7px; }
.emoji-btn { width: 34px; height: 34px; padding: 0; border: 0; border-radius: 8px; background: transparent; font-size: 20px; cursor: pointer; }
.emoji-btn:hover { background: var(--surface-soft); }
.menu { min-width: 220px; padding: 5px; }
.menu-item { display: block; width: 100%; padding: 10px; border: 0; border-radius: 7px; background: transparent; color: var(--ink); text-align: left; cursor: pointer; }
.menu-item:hover { background: var(--surface-soft); }
.account-menu { min-width: 220px; }
.account-menu-item { display: flex; min-height: 42px; align-items: center; gap: 10px; }
.account-menu-item .icon { color: var(--muted); }
.menu-item.danger { color: var(--danger); }
.lightbox { display: grid; gap: 12px; justify-items: center; }
.lightbox img { max-width: 100%; max-height: 72vh; object-fit: contain; }
#toasts { position: fixed; z-index: 50; right: 20px; bottom: 20px; display: flex; width: min(360px, calc(100vw - 40px)); flex-direction: column; gap: 8px; }
.toast { padding: 12px 15px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface); box-shadow: var(--shadow); font-size: 13px; animation: toast-in .18s ease-out; }
.toast.error { border-color: rgb(226 84 84 / 40%); color: var(--danger); }
.toast.ok { border-color: rgb(72 185 120 / 40%); color: #24834c; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* Admin */
.admin { display: flex; width: 100%; height: 100%; flex-direction: column; overflow: hidden; background: var(--surface-soft); }
.admin-head { display: flex; min-height: 64px; align-items: center; gap: 12px; padding: 10px 20px; border-bottom: 1px solid var(--line); background: var(--surface); }
.admin-head h2 { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 18px; }
.tabs { display: flex; align-items: center; gap: 6px; }
.admin-tabs { flex: 0 0 auto; padding: 10px 20px 0; overflow-x: auto; border-bottom: 1px solid var(--line); background: var(--surface); }
.tab { position: relative; min-height: 42px; padding: 8px 13px; border: 0; border-radius: 8px 8px 0 0; background: transparent; color: var(--muted); white-space: nowrap; cursor: pointer; }
.tab:hover { color: var(--blue); background: rgb(51 144 236 / 6%); }
.tab.on { color: var(--blue); font-weight: 600; }
.tab.on::after { position: absolute; right: 8px; bottom: 0; left: 8px; height: 2px; background: var(--blue); content: ""; }
.admin-content { flex: 1; min-height: 0; overflow: auto; padding: 20px; }
.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.toolbar input[type="search"] { max-width: 420px; padding-left: 14px; }
.table-wrap { width: 100%; overflow: auto; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .table td { padding: 11px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.table th { position: sticky; top: 0; background: var(--surface-soft); color: var(--muted); font-size: 11px; font-weight: 600; white-space: nowrap; }
.table tr:last-child td { border-bottom: 0; }
.user-cell { display: flex; min-width: 160px; align-items: center; gap: 9px; }
.pill { display: inline-flex; align-items: center; padding: 4px 8px; border-radius: 12px; background: var(--surface-soft); font-size: 11px; white-space: nowrap; }
.pill.ok { background: rgb(72 185 120 / 13%); color: #25824b; }
.pill.warn { background: rgb(240 170 55 / 15%); color: #a36c11; }
.pill.bad { background: rgb(226 84 84 / 12%); color: var(--danger); }
.pill.info { background: rgb(51 144 236 / 12%); color: var(--blue); }
.online { color: #2da76b; white-space: nowrap; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 24px; }
.stat { padding: 16px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface); }
.stat-v { font-size: 26px; font-weight: 700; }
.stat-l { margin-top: 4px; font-size: 13px; }
.stat .muted { margin-top: 5px; font-size: 11px; }
.admin-content h3 { margin: 8px 0 14px; font-size: 16px; }
.admin-content h4 { margin: 0; }
.ua, .meta-cell { max-width: 300px; overflow-wrap: anywhere; }
.monitor { display: grid; min-height: 420px; grid-template-columns: minmax(220px, 320px) minmax(0, 1fr); overflow: hidden; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.monitor-list { overflow: auto; border-right: 1px solid var(--line); }
.conv:not(.active) .conv-bot { color: var(--muted); }
.monitor-view { min-width: 0; overflow: auto; padding: 15px; }
.mon-msg { max-width: 78%; margin: 10px 0; padding: 10px 12px; border-radius: 12px; background: var(--surface-soft); }
.mon-msg .meta { justify-content: space-between; }
.mon-msg .body { font-size: 13px; }
.mon-msg.deleted { opacity: .65; }
.settings { max-width: 880px; }
.settings section { padding: 17px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.settings .payment-qr-upload { display: flex; max-width: 420px; flex-direction: column; gap: 7px; font-size: 13px; }
.payment-qr-preview { display: block; max-width: min(100%, 240px); max-height: 240px; border: 1px solid var(--line); border-radius: 10px; background: #fff; object-fit: contain; }
.ad-products-list { display: flex; flex-direction: column; gap: 12px; }
.ad-product-editor { display: flex; flex-direction: column; gap: 11px; padding: 13px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-soft); }
.ad-product-editor-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.ad-image-upload { display: flex; max-width: 440px; flex-direction: column; gap: 7px; font-size: 13px; }
.ad-editor-image { display: block; max-width: min(100%, 220px); max-height: 220px; border-radius: 8px; background: var(--surface); object-fit: contain; }
.profile-settings { gap: 12px; }
.profile-setting-section { display: flex; flex-direction: column; gap: 10px; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.profile-setting-section h4, .profile-setting-section p { margin: 0; }
.profile-setting-section label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.profile-setting-section input { width: 100%; min-height: 40px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-soft); color: var(--ink); }
.profile-avatar-row { display: flex; align-items: center; gap: 14px; }
.profile-avatar-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.check { flex-direction: row !important; align-items: center; }
.check input, .user-row input { width: auto; min-height: auto; }
.copy-row { display: flex; gap: 8px; }
.copy-row input { flex: 1; min-width: 0; }
.user-pick { display: flex; max-height: 300px; flex-direction: column; gap: 5px; overflow: auto; }
.user-row { display: flex; align-items: center; gap: 9px; padding: 9px; border-radius: 9px; cursor: pointer; }
.user-row:hover { background: var(--surface-soft); }

@media (min-width: 1500px) {
  .app { grid-template-columns: minmax(338px, 398px) minmax(0, 1fr); }
}
@media (max-width: 900px) {
  .app { grid-template-columns: minmax(313px, calc(32vw + 38px)) minmax(0, 1fr); }
  .app.show-info { grid-template-columns: minmax(313px, calc(32vw + 38px)) minmax(0, 1fr) 270px; }
  .messages { padding-right: 20px; padding-left: 20px; }
  .msg { max-width: 88%; }
}
@media (max-width: 640px) {
  .app { position: relative; display: block; }
  .sidebar, .chat { position: absolute; inset: 0; width: 100%; height: 100%; }
  .info-panel { position: absolute; inset: 0; }
  .app.show-info .chat { visibility: hidden; }
  .sidebar { transform: translateX(0); transition: transform .2s ease; }
  .chat { visibility: hidden; transform: translateX(100%); transition: transform .2s ease; }
  .app.show-chat .sidebar { transform: translateX(-100%); }
  .app.show-chat .chat { visibility: visible; transform: translateX(0); }
  .back { display: inline-flex; }
  .chat-head { min-height: 58px; gap: 8px; padding: 7px 9px; }
  .chat-head > .icon-btn { width: 34px; height: 34px; }
  .messages { gap: 6px; padding: 16px 10px; }
  .msg { max-width: 92%; grid-template-columns: 30px minmax(0, 1fr); gap: 5px; }
  .msg.own { grid-template-columns: minmax(0, 1fr); }
  .composer { padding: 7px 8px max(9px, env(safe-area-inset-bottom)); }
  .composer-row { min-height: 44px; gap: 1px; padding: 4px; }
  .composer-row .icon-btn { width: 32px; height: 32px; }
  .composer textarea { padding: 7px 3px; font-size: 16px; }
  .admin-head { gap: 7px; padding: 8px 10px; }
  .admin-head h2 { font-size: 15px; }
  .admin-content { padding: 12px; }
  .admin-tabs { padding-right: 10px; padding-left: 10px; }
  .monitor { grid-template-columns: minmax(130px, 38%) minmax(0, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
  .auth-card { padding: 24px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
