/* Тема в духе Telegram (тёмная): шапка чата, пузыри сообщений, поле ввода, нижние вкладки. */
:root {
  --bg: #0e1621; --panel: #17212b; --line: #101921; --text: #f5f5f5; --muted: #6d7f8f;
  --accent: #5288c1; --in: #182533; --out: #2b5278; --card: rgba(255,255,255,.06); --error: #ff6b6b;
  --name1: #f28c52; --name2: #46b3e6; --name3: #a56fe0; --name4: #5fc26a;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 16px/1.35 -apple-system, "Segoe UI", Roboto, system-ui, sans-serif; -webkit-font-smoothing: antialiased; }
.hidden { display: none !important; }
.screen { min-height: 100%; }
button { font: inherit; cursor: pointer; }
input, textarea { font: inherit; }
svg { display: block; }

/* ---------- вход ---------- */
#login { display: flex; align-items: center; justify-content: center; padding: 16px; min-height: 100dvh; }
.card { width: 100%; max-width: 340px; display: flex; flex-direction: column; gap: 14px; text-align: center; }
.card .logo { width: 96px; height: 96px; border-radius: 50%; background: var(--accent); margin: 0 auto 6px; display: flex; align-items: center; justify-content: center; }
.card h1 { margin: 0; font-weight: 600; font-size: 24px; }
.card p.hint { margin: -6px 0 6px; color: var(--muted); font-size: 14px; }
.card label { text-align: left; display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 13px; }
.card input { background: var(--panel); border: 1px solid #243442; border-radius: 10px; padding: 12px; color: var(--text); font-size: 16px; }
.card input:focus { outline: none; border-color: var(--accent); }
.card button { background: var(--accent); color: #fff; border: 0; border-radius: 10px; padding: 13px; font-weight: 600; font-size: 16px; }
.error { color: var(--error); margin: 0; min-height: 1.2em; font-size: 13px; }

/* ---------- каркас ---------- */
#app { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }
header { display: flex; align-items: center; gap: 12px; padding: 8px 12px; padding-top: calc(8px + env(safe-area-inset-top)); background: var(--panel); box-shadow: 0 1px 0 rgba(0,0,0,.35); z-index: 2; }
.avatar { width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 600; color: #fff; background: linear-gradient(135deg, #6ab3f3, #3a7bd5); flex: none; }
.chat-title { flex: 1; min-width: 0; }
.chat-title b { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-title span { display: block; color: var(--muted); font-size: 13px; }
.chat-title #chat-sub { display: flex; gap: 10px; flex-wrap: wrap; }
.member { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.member .mname { color: #c9d3dc; }
.member .mstatus { color: var(--muted); }
.member.online .mstatus { color: #4fc26b; }
.member .dot { width: 7px; height: 7px; border-radius: 50%; background: #556777; }
.member.online .dot { background: #4fc26b; box-shadow: 0 0 5px #4fc26b; }
.icon-btn { background: none; border: 0; color: var(--muted); padding: 8px; border-radius: 50%; }
.icon-btn:active { background: var(--card); }
.bell .bell-on { display: none; }
.bell.on .bell-on { display: block; }
.bell.on .bell-off { display: none; }

main { flex: 1; display: flex; flex-direction: column; min-height: 0; }

/* ---------- лента ---------- */
#messages { flex: 1; overflow-y: auto; padding: 12px 10px; display: flex; flex-direction: column; gap: 4px;
  background: var(--bg);
  background-image: radial-gradient(rgba(255,255,255,.035) 1px, transparent 1px);
  background-size: 22px 22px; }
.msg { position: relative; max-width: min(78%, 560px); background: var(--in); border-radius: 14px; border-bottom-left-radius: 4px; padding: 6px 10px 6px 10px; align-self: flex-start; box-shadow: 0 1px 1px rgba(0,0,0,.25); }
.msg.mine { background: var(--out); align-self: flex-end; border-bottom-left-radius: 14px; border-bottom-right-radius: 4px; }
.msg.model { background: #1f2f3a; border-left: 3px solid var(--accent); }
.msg .author { display: block; font-size: 14px; font-weight: 600; margin-bottom: 1px; color: var(--name2); }
.msg.mine .author { display: none; }
.msg .author.c1 { color: var(--name1); } .msg .author.c2 { color: var(--name2); }
.msg .author.c3 { color: var(--name3); } .msg .author.c4 { color: var(--name4); }
.body { white-space: pre-wrap; word-break: break-word; display: inline; }
.msg .time { float: right; font-size: 11px; color: rgba(255,255,255,.45); margin: 8px 0 0 10px; line-height: 1; }
.msg.mine .time { color: rgba(255,255,255,.6); }
.day { align-self: center; background: rgba(0,0,0,.35); color: #dfe6ee; font-size: 13px; padding: 4px 12px; border-radius: 12px; margin: 8px 0; }

.track-card { display: block; background: var(--card); border-radius: 10px; padding: 8px 10px; margin: 2px 0 4px; min-width: 240px; }
.track-title { font-weight: 600; }
.track-info { color: rgba(255,255,255,.55); font-size: 12px; margin: 1px 0 6px; }
.track-card audio { width: 100%; height: 36px; filter: invert(.9) hue-rotate(180deg); }

/* ---------- ввод ---------- */
.composer { display: flex; gap: 6px; padding: 8px 8px; padding-bottom: max(12px, env(safe-area-inset-bottom)); background: var(--panel); align-items: flex-end; }
.composer textarea { flex: 1; resize: none; background: var(--bg); border: 0; border-radius: 20px; padding: 10px 14px; color: var(--text); max-height: 160px; min-height: 40px; }
.composer textarea:focus { outline: none; }
.composer .send-btn { width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; flex: none; }
.attach { display: flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 50%; cursor: pointer; color: var(--muted); flex: none; }
.attach input { display: none; }
.status { padding: 2px 16px; font-size: 12px; color: var(--muted); background: var(--panel); min-height: 1.2em; }
.status:empty { display: none; }

/* ---------- нижние вкладки ---------- */
#drawer-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 10; }
#drawer { position: fixed; top: 0; left: 0; bottom: 0; width: min(300px, 80vw); background: var(--panel); z-index: 11; display: flex; flex-direction: column; padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom); box-shadow: 4px 0 24px rgba(0,0,0,.5); animation: slide .18s ease-out; }
@keyframes slide { from { transform: translateX(-100%); } }
.drawer-head { padding: 20px 16px 14px; border-bottom: 1px solid rgba(255,255,255,.06); margin-bottom: 6px; }
.drawer-head b { display: block; margin-top: 10px; font-size: 16px; }
.avatar.big { width: 56px; height: 56px; font-size: 22px; background: linear-gradient(135deg, #f8a06a, #e5584b); }
.menu-item { display: flex; align-items: center; gap: 16px; width: 100%; background: none; border: 0; color: var(--text); text-align: left; padding: 13px 18px; font-size: 16px; }
.menu-item svg { color: var(--muted); flex: none; }
.menu-item:active { background: var(--card); }
.menu-item.tab.active { color: var(--accent); }
.menu-item.tab.active svg { color: var(--accent); }
.menu-sep { height: 1px; background: rgba(255,255,255,.06); margin: 6px 0; }
.switch { margin-left: auto; width: 38px; height: 22px; border-radius: 11px; background: #3a4a5a; position: relative; transition: background .15s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: left .15s; }
.bell.on .switch { background: #4fc26b; }
.bell.on .switch::after { left: 19px; }

/* ---------- треки ---------- */
#tab-tracks { overflow: auto; background: var(--panel); }
.track-row { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-bottom: 1px solid rgba(255,255,255,.06); text-decoration: none; color: inherit; }
.track-row .ico { width: 44px; height: 44px; border-radius: 50%; background: var(--accent); display: flex; align-items: center; justify-content: center; color: #fff; flex: none; }
.track-row .main { flex: 1; min-width: 0; }
.track-row .title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.track-row .meta { color: var(--muted); font-size: 13px; }
.track-row .dl { color: var(--muted); padding: 8px; }
.empty { color: var(--muted); text-align: center; padding: 40px 16px; }

@media (min-width: 700px) {
  #app { max-width: 820px; margin: 0 auto; box-shadow: 0 0 0 1px rgba(255,255,255,.06); }
}
