:root {
  --bg: #0f1720;
  --panel: #17212b;
  --panel-2: #202b36;
  --hover: #2b3947;
  --text: #f1f5f9;
  --muted: #8b9aaa;
  --accent: #5aa9e6;
  --own: #2b5278;
  --border: rgba(255,255,255,.07);
  color-scheme: dark;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); overflow: hidden; }
button, input { font: inherit; }
button { color: inherit; cursor: pointer; }
button:disabled { opacity: .45; cursor: default; }
.boot { height: 100vh; display: grid; place-content: center; text-align: center; padding: 24px; }
.boot-logo, .brand-mark { background: linear-gradient(135deg, #64b5f6, #3778c2); color: white; font-weight: 800; }
.boot-logo { width: 72px; height: 72px; border-radius: 24px; display: grid; place-items: center; margin: auto; font-size: 25px; }
.boot h1 { font-size: 22px; margin-bottom: 6px; }
.boot p, .muted { color: var(--muted); }
#app { height: 100vh; display: flex; flex-direction: column; }
.topbar { height: 58px; flex: 0 0 58px; padding: 0 14px; display: flex; align-items: center; gap: 14px; background: var(--panel); border-bottom: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; }
.brand-mark { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; font-size: 12px; }
.stats { margin-left: auto; color: var(--muted); font-size: 12px; }
.icon-button { width: 38px; height: 38px; border: 0; border-radius: 11px; background: transparent; font-size: 21px; display: grid; place-items: center; }
.icon-button:hover { background: var(--hover); }
.workspace { display: grid; grid-template-columns: 330px minmax(320px, 1fr); min-height: 0; flex: 1; }
.workspace.with-media { grid-template-columns: 300px minmax(300px, 1fr) 320px; }
.chats-pane { min-width: 0; background: var(--panel); border-right: 1px solid var(--border); display: flex; flex-direction: column; }
.pane-heading { padding: 18px 18px 10px; display: flex; justify-content: space-between; }
.pane-heading h2, .conversation-title h2, .media-header h2 { font-size: 18px; margin: 0 0 3px; }
.pane-heading .muted { font-size: 12px; }
.search { margin: 4px 12px 10px; padding: 0 12px; height: 40px; border-radius: 12px; background: var(--panel-2); display: flex; align-items: center; gap: 8px; color: var(--muted); }
.search input { width: 100%; border: 0; outline: 0; background: transparent; color: var(--text); }
.chats-list, .media-list { overflow-y: auto; min-height: 0; }
.chats-list { flex: 1; padding: 0 7px 10px; }
.chat-item { width: 100%; display: grid; grid-template-columns: 46px minmax(0,1fr); gap: 11px; padding: 11px; border: 0; border-radius: 13px; background: transparent; text-align: left; }
.chat-item:hover, .chat-item.active { background: var(--hover); }
.avatar { grid-row: span 2; width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; background: #426384; font-weight: 700; font-size: 17px; }
.chat-line { display: flex; min-width: 0; align-items: center; justify-content: space-between; gap: 8px; }
.chat-name, .chat-preview { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-name { font-weight: 600; }
.chat-time { color: var(--muted); font-size: 11px; flex-shrink: 0; }
.chat-preview { color: var(--muted); font-size: 13px; margin-top: 5px; }
.chat-pane { min-width: 0; position: relative; display: flex; flex-direction: column; background: #0e1621; }
.chat-pane.empty { display: grid; place-items: center; }
.welcome { max-width: 390px; padding: 30px; text-align: center; color: var(--muted); }
.welcome h2 { color: var(--text); }
.welcome-icon { font-size: 44px; }
.conversation-header { height: 64px; flex: 0 0 64px; padding: 0 12px; display: flex; align-items: center; gap: 8px; background: var(--panel); border-bottom: 1px solid var(--border); }
.conversation-title { min-width: 0; flex: 1; }
.conversation-title h2 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conversation-title .muted { font-size: 12px; }
.messages-wrap { flex: 1; overflow-y: auto; padding: 12px max(14px, calc((100% - 850px)/2)); }
.messages { display: flex; flex-direction: column; gap: 7px; }
.older, .load-more { border: 0; background: var(--panel-2); color: var(--accent); border-radius: 10px; padding: 10px 14px; }
.older { display: block; margin: 0 auto 15px; }
.load-more { margin: 10px 12px; }
.message { align-self: flex-start; max-width: min(78%, 600px); padding: 8px 11px; border-radius: 7px 16px 16px 16px; background: var(--panel); box-shadow: 0 1px 1px rgba(0,0,0,.14); }
.message.own { align-self: flex-end; border-radius: 16px 7px 16px 16px; background: var(--own); }
.message-meta { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; margin-bottom: 4px; color: var(--accent); font-size: 11px; }
.message-time { margin-left: auto; color: var(--muted); }
.deleted-badge { color: #f3b66b; }
.message-text { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; line-height: 1.42; }
.media-button { margin-top: 7px; border: 0; padding: 9px 11px; border-radius: 10px; background: rgba(0,0,0,.2); text-align: left; max-width: 100%; }
.media-preview { display: block; max-width: 340px; max-height: 300px; margin-top: 7px; border-radius: 11px; cursor: pointer; object-fit: cover; }
.no-local { color: #f3b66b; font-size: 11px; margin-top: 5px; }
.media-pane { min-width: 0; display: flex; flex-direction: column; background: var(--panel); border-left: 1px solid var(--border); }
.media-header { height: 64px; flex: 0 0 64px; display: flex; align-items: center; justify-content: space-between; padding: 0 12px 0 18px; }
.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin: 0 12px 12px; padding: 4px; background: var(--panel-2); border-radius: 11px; }
.tab { border: 0; border-radius: 8px; background: transparent; padding: 8px; color: var(--muted); font-size: 12px; }
.tab.active { background: var(--hover); color: var(--text); }
.media-list { flex: 1; padding: 0 8px; }
.media-item { width: 100%; border: 0; background: transparent; border-radius: 11px; padding: 11px; text-align: left; display: grid; grid-template-columns: 36px minmax(0,1fr); gap: 9px; }
.media-item:hover { background: var(--hover); }
.media-icon { width: 36px; height: 36px; border-radius: 10px; background: #365572; display: grid; place-items: center; }
.media-title { font-size: 13px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.media-subtitle { color: var(--muted); font-size: 11px; margin-top: 4px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.empty-list { padding: 28px 16px; color: var(--muted); text-align: center; font-size: 13px; }
.viewer { position: fixed; inset: 0; z-index: 20; background: rgba(5,10,15,.98); display: flex; flex-direction: column; }
.viewer header { height: 58px; flex: 0 0 58px; display: flex; align-items: center; gap: 8px; padding: 0 12px; background: var(--panel); }
.viewer-content { flex: 1; min-height: 0; overflow: auto; display: grid; place-items: center; padding: 20px; }
.viewer-content img, .viewer-content video { max-width: 100%; max-height: calc(100vh - 110px); border-radius: 8px; }
.viewer-content audio { width: min(500px, 100%); }
.download-card { max-width: 420px; text-align: center; background: var(--panel); border-radius: 18px; padding: 30px; }
.download-card a { display: inline-block; margin-top: 16px; padding: 11px 20px; border-radius: 10px; background: var(--accent); color: #07131e; text-decoration: none; font-weight: 650; }
.toast { position: fixed; z-index: 30; bottom: 24px; left: 50%; transform: translateX(-50%); max-width: min(520px, calc(100% - 30px)); background: #343f4b; padding: 11px 17px; border-radius: 11px; box-shadow: 0 5px 24px rgba(0,0,0,.35); font-size: 13px; }
.mobile-only { display: none; }
@media (max-width: 980px) {
  .workspace.with-media { grid-template-columns: 280px minmax(300px,1fr); }
  .with-media .media-pane { position: fixed; z-index: 10; right: 0; top: 58px; bottom: 0; width: min(340px, 90vw); box-shadow: -8px 0 30px rgba(0,0,0,.35); }
}
@media (max-width: 700px) {
  .workspace, .workspace.with-media { display: block; }
  .chats-pane, .chat-pane { height: 100%; }
  .chat-pane { display: none; }
  #app.conversation-open .chats-pane { display: none; }
  #app.conversation-open .chat-pane { display: flex; }
  #app.conversation-open .chat-pane.empty { display: none; }
  .mobile-only { display: grid; }
  .stats { display: none; }
  .message { max-width: 88%; }
  .messages-wrap { padding: 10px 8px; }
  .with-media .media-pane { top: 58px; width: 100vw; }
  .topbar { height: 54px; flex-basis: 54px; }
  .with-media .media-pane { top: 54px; }
}

