* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: #0e1621; color: #f5f5f5; overflow: hidden;
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
.hidden { display: none !important; }
.muted { color: #8c9aa9; }
.grow { flex: 1; }
a { color: #6ab3f3; }
button { font: inherit; color: inherit; cursor: pointer; }
svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- welcome / banned */
.screen { height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 20px; overflow: auto;
  background: radial-gradient(circle at 50% 0%, #2a1520 0%, #0e1621 60%); }
.welcome-card { max-width: 420px; width: 100%; text-align: center; }
.logo { width: 96px; height: 96px; border-radius: 50%; margin: 0 auto 16px; background: #e5484d; display: flex;
  align-items: center; justify-content: center; font-size: 48px; font-weight: 700; box-shadow: 0 10px 40px #e5484d55; }
.logo.ban { background: #3a1d22; box-shadow: none; }
h1 { margin: 0 0 4px; font-size: 30px; }
.lead { margin: 0 0 22px; color: #aab8c5; font-size: 17px; }
.features { list-style: none; padding: 0; margin: 0 0 26px; text-align: left; display: inline-block; }
.features li { padding: 6px 0; }
.big-btn { width: 100%; border: 0; border-radius: 12px; padding: 15px; font-size: 17px; font-weight: 600;
  background: #e5484d; color: #fff; }
.big-btn:hover { background: #f05a5f; }
.big-btn:disabled { opacity: .6; }
.fine { color: #6d7f8f; font-size: 13px; margin: 14px 0 0; }

/* ---------- chat layout */
#chat { height: 100dvh; display: flex; flex-direction: column; max-width: 860px; margin: 0 auto;
  background: #0e1621 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='80'%3E%3Ccircle cx='10' cy='10' r='1.2' fill='%23ffffff08'/%3E%3Ccircle cx='50' cy='45' r='1.2' fill='%23ffffff08'/%3E%3C/svg%3E"); }
@media (min-width: 861px) { #chat { border-left: 1px solid #0b1118; border-right: 1px solid #0b1118; } }
.top { display: flex; align-items: center; gap: 12px; padding: 8px 10px 8px 14px; background: #17212b;
  border-bottom: 1px solid #0b1118; padding-top: max(8px, env(safe-area-inset-top)); position: relative; z-index: 3; }
.avatar { width: 42px; height: 42px; border-radius: 50%; background: #e5484d; display: flex; align-items: center;
  justify-content: center; font-weight: 700; font-size: 20px; flex: none; }
.title { flex: 1; min-width: 0; }
.name { font-weight: 600; }
.status { font-size: 13px; color: #8c9aa9; }
.status.online { color: #6ab3f3; }
.icon-btn { background: none; border: 0; color: #8c9aa9; padding: 8px; border-radius: 50%; display: flex; flex: none; }
.icon-btn:hover { color: #d0dbe5; background: #ffffff0d; }

.menu { position: absolute; top: 62px; right: max(10px, calc(50% - 420px)); z-index: 5; background: #17212b;
  border-radius: 12px; box-shadow: 0 8px 30px #0009; padding: 8px; width: 280px; max-height: 75dvh; overflow: auto;
  display: flex; flex-direction: column; gap: 6px; }
.menu button { width: 100%; border: 0; border-radius: 8px; background: #232e3c; padding: 11px 10px; font-size: 15px;
  text-align: center; box-shadow: 0 1px 0 #0b1118; }
.menu button:hover { background: #2b3949; }

.cmd-chip { display: inline-block; border: 0; border-radius: 8px; background: #2b5278; color: #fff; padding: 2px 9px;
  margin: 1px 0; font-size: 14px; line-height: 1.5; white-space: nowrap; vertical-align: baseline; }
.cmd-chip:hover { background: #33618d; }

#messages { flex: 1; overflow-y: auto; padding: 10px 10px 6px; display: flex; flex-direction: column; gap: 4px;
  overscroll-behavior: contain; }
.older { text-align: center; color: #8c9aa9; font-size: 13px; padding: 6px; }
.day { align-self: center; background: #1e2c3a99; color: #c9d4de; font-size: 13px; padding: 3px 10px;
  border-radius: 12px; margin: 8px 0; }

/* ---------- bubbles */
.msg { display: flex; flex-direction: column; max-width: min(78%, 520px); align-self: flex-start; }
.msg.me { align-self: flex-end; align-items: flex-end; }
.bubble { position: relative; background: #182533; border-radius: 14px 14px 14px 4px; padding: 7px 10px 6px;
  white-space: pre-wrap; overflow-wrap: anywhere; min-width: 60px; }
.msg.me .bubble { background: #2b5278; border-radius: 14px 14px 4px 14px; }
.bubble.media-only { padding: 3px; background: transparent; }
.bubble.media-only .time { position: absolute; right: 8px; bottom: 6px; background: #0008; padding: 1px 6px;
  border-radius: 8px; color: #fff; }
.bubble .text { display: inline; }
.time { float: right; font-size: 11px; color: #8c9aa999; margin: 6px 0 -4px 10px; line-height: 1; user-select: none; }
.msg.me .time { color: #9ec4ea99; }
.bubble blockquote { margin: 4px 0; padding: 2px 8px; border-left: 3px solid #6ab3f3; background: #6ab3f314;
  border-radius: 4px; white-space: pre-wrap; }
.bubble code { background: #0003; padding: 1px 4px; border-radius: 4px; font-size: 14px; }
.bubble pre { background: #0003; padding: 8px; border-radius: 6px; overflow-x: auto; white-space: pre-wrap; }
.big-emoji { font-size: 48px; line-height: 1.1; }
.tg-spoiler { background: #8c9aa9; color: transparent; border-radius: 4px; cursor: pointer; transition: .2s; }
.tg-spoiler.shown { background: transparent; color: inherit; }

.media { display: block; max-width: 100%; border-radius: 11px; margin: -3px -6px 6px; cursor: pointer;
  max-height: 420px; object-fit: cover; background: #0b1118; }
.bubble.media-only .media { margin: 0; }
.media-wrap { position: relative; overflow: hidden; border-radius: 11px; margin: -3px -6px 6px; }
.bubble.media-only .media-wrap { margin: 0; }
.media-wrap .media { margin: 0; }
.media-wrap.spoiler .media { filter: blur(28px) brightness(.7); transform: scale(1.1); }
.media-wrap.spoiler::after { content: "🙈 Нажмите, чтобы открыть"; position: absolute; inset: 0; display: flex;
  align-items: center; justify-content: center; font-size: 14px; color: #fff; text-shadow: 0 1px 4px #000; cursor: pointer; }
.media.round { width: 220px; height: 220px; border-radius: 50%; object-fit: cover; }
.media.sticker { background: transparent; width: 180px; height: auto; cursor: default; }
audio.media { width: 260px; height: 40px; background: transparent; cursor: default; margin: 2px 0 6px; }
.file-link { display: inline-flex; gap: 8px; align-items: center; margin-bottom: 4px; }
.uploading { opacity: .6; }

.ikb { display: flex; flex-direction: column; gap: 3px; margin-top: 3px; width: 100%; min-width: 220px; }
.ikb-row { display: flex; gap: 3px; }
.ikb button, .ikb a { flex: 1; min-width: 0; background: #1e2c3a; border: 0; border-radius: 8px; padding: 9px 8px;
  color: #fff; text-align: center; text-decoration: none; font-size: 14px; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; position: relative; }
.ikb a::after { content: "↗"; position: absolute; top: 2px; right: 5px; font-size: 10px; color: #8c9aa9; }
.ikb button:hover, .ikb a:hover { background: #26384a; }
.ikb button:disabled { opacity: .5; }

/* ---------- composer */
.bottom { background: #17212b; border-top: 1px solid #0b1118; padding-bottom: env(safe-area-inset-bottom); position: relative; }
.composer { display: flex; align-items: flex-end; gap: 4px; padding: 6px 8px; }
#input { flex: 1; resize: none; border: 0; outline: 0; background: transparent; color: #f5f5f5; font: inherit;
  font-size: 16px; padding: 10px 4px; max-height: 160px; line-height: 1.35; }
#input::placeholder { color: #6d7f8f; }
.send-btn { width: 44px; height: 44px; flex: none; border: 0; border-radius: 50%; background: none; color: #6ab3f3;
  display: flex; align-items: center; justify-content: center; }
.send-btn:hover { background: #ffffff0d; }
#send-btn svg, #rec-send svg { fill: currentColor; stroke: none; }
.recording { display: flex; align-items: center; gap: 12px; padding: 6px 8px 6px 18px; }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: #e5484d; animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .2; } }
.text-btn { background: none; border: 0; color: #e5484d; padding: 8px; }

.reply-kb { display: flex; flex-direction: column; gap: 6px; padding: 6px 8px 8px; max-height: 40dvh; overflow: auto; }
.reply-kb .row { display: flex; gap: 6px; }
.reply-kb button { flex: 1; min-width: 0; border: 0; border-radius: 8px; background: #232e3c; padding: 11px 6px;
  font-size: 15px; box-shadow: 0 1px 0 #0b1118; }
.reply-kb button:hover { background: #2b3949; }

/* ---------- overlays */
.viewer { position: fixed; inset: 0; background: #000e; z-index: 20; display: flex; align-items: center;
  justify-content: center; cursor: zoom-out; }
.viewer img, .viewer video { max-width: 100vw; max-height: 100dvh; }
.toast { position: fixed; left: 50%; top: 76px; transform: translateX(-50%); background: #000c; color: #fff;
  padding: 10px 16px; border-radius: 10px; z-index: 30; max-width: 90vw; white-space: pre-wrap; text-align: center; }
.toast.alert { top: 50%; transform: translate(-50%, -50%); background: #17212b; box-shadow: 0 10px 40px #000a;
  padding: 18px 20px 12px; min-width: 260px; }
.toast.alert button { display: block; margin: 14px 0 0 auto; background: none; border: 0; color: #6ab3f3; font-weight: 600; }
