:root {
  --bg: #0b141a;
  --header: #202c33;
  --panel: #111b21;
  --panel-2: #1c272e;
  --bubble: #005c4b;
  --bubble-alt: #143c36;
  --text: #e9edef;
  --muted: #8696a0;
  --accent: #00a884;
  --line: rgba(255,255,255,0.08);
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font-family: Inter, system-ui, sans-serif; background: #081016; color: var(--text); overflow: hidden; }
button, input, textarea { font: inherit; }
a { color: inherit; text-decoration: none; }
button { -webkit-tap-highlight-color: transparent; }

.app-shell { height: 100vh; display: grid; grid-template-columns: 260px 1fr; background: var(--bg); }
.sidebar { border-right: 1px solid var(--line); background: #111b21; display: flex; flex-direction: column; min-width: 0; }
.compact-head { padding: 8px 10px; }
.sidebar-head { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--line); }
.sidebar-head h1 { margin: 0; font-size: .95rem; }
.subtle { margin: 2px 0 0; color: var(--muted); font-size: .72rem; }
.icon-btn { width: 32px; height: 32px; border-radius: 50%; border: 0; background: #202c33; color: var(--text); cursor: pointer; display: grid; place-items: center; }
.nav-btn { display: none; }
.new-chat-form { display: flex; gap: 6px; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.new-chat-form.hidden { display: none; }
.new-chat-form input, .new-chat-form button { border: 0; border-radius: 9px; padding: 8px 10px; }
.new-chat-form input { flex: 1; background: #202c33; color: var(--text); min-width: 0; }
.new-chat-form button { background: var(--accent); color: #04211b; font-weight: 700; }
.chat-list { padding: 4px 0; overflow-y: auto; }
.chat-row { width: 100%; border: 0; background: transparent; color: var(--text); display: grid; grid-template-columns: 36px 1fr auto; align-items: center; gap: 8px; text-align: left; padding: 7px 10px; cursor: pointer; }
.chat-row:hover { background: rgba(255,255,255,0.05); }
.chat-row.active { background: rgba(0,168,132,0.16); }
.chat-avatar, .avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: linear-gradient(145deg, #2d4652, #172127); font-weight: 700; flex: 0 0 auto; }
.chat-row-main { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.chat-row-top, .chat-row-bottom { display: flex; align-items: center; gap: 6px; min-width: 0; }
.chat-row-top strong, .chat-row-top small, .chat-row-bottom small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-row-top strong { font-size: .83rem; flex: 1; }
.chat-row-top small, .chat-row-bottom small { color: var(--muted); font-size: .69rem; }
.chat-row-bottom small { flex: 1; }
.chat-count { min-width: 18px; height: 18px; border-radius: 999px; display: inline-grid; place-items: center; padding: 0 5px; background: rgba(255,255,255,0.08); color: var(--text); font-size: .66rem; }
.chat-row-delete { width: 24px; height: 24px; border: 0; border-radius: 50%; background: transparent; color: var(--muted); cursor: pointer; }
.chat-row-delete:hover { background: rgba(255,255,255,0.08); color: var(--text); }

.chat-pane { min-width: 0; display: grid; grid-template-rows: auto auto 1fr auto; }
.chat-header { padding: 8px 10px; display: flex; align-items: center; justify-content: space-between; gap: 10px; background: rgba(32,44,51,0.98); border-bottom: 1px solid var(--line); }
.chat-contact { display: flex; align-items: center; gap: 8px; min-width: 0; }
.contact-copy { min-width: 0; }
.chat-contact h2 { margin: 0; font-size: .94rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.header-actions { display: flex; align-items: center; gap: 8px; }
.top-search input { width: min(220px, 34vw); border: 0; outline: none; background: #111b21; color: var(--text); border-radius: 10px; padding: 8px 10px; font-size: .85rem; }
.filter-row { display: flex; gap: 5px; padding: 6px 8px; overflow-x: auto; background: rgba(17,27,33,0.96); border-bottom: 1px solid var(--line); }
.filter-pill { white-space: nowrap; border: 0; background: #182229; color: var(--muted); border-radius: 999px; padding: 5px 8px; cursor: pointer; font-size: .73rem; }
.filter-pill span { color: var(--text); background: rgba(255,255,255,0.08); border-radius: 999px; padding: 1px 5px; margin-left: 3px; }
.filter-pill.active { background: rgba(0,168,132,0.2); color: #d6fff6; }
.message-list { overflow-y: auto; padding: 8px 10px 78px; background: linear-gradient(rgba(11,20,26,.78), rgba(11,20,26,.78)), radial-gradient(rgba(255,255,255,.035) 1px, transparent 1px); background-size: auto, 18px 18px; }
.message { display: flex; justify-content: flex-end; margin: 1px 0 6px; }
.message-bubble { position: relative; max-width: min(72%, 560px); min-width: 90px; background: var(--bubble); border-radius: 7px; border-top-right-radius: 2px; padding: 6px 34px 5px 8px; }
.message-bubble::after { content: ''; position: absolute; top: 0; right: -6px; border-left: 6px solid var(--bubble); border-bottom: 6px solid transparent; }
.type-file, .type-link, .type-video, .type-audio, .type-image { background: var(--bubble-alt); }
.type-file::after, .type-link::after, .type-video::after, .type-audio::after, .type-image::after { border-left-color: var(--bubble-alt); }
.message-actions { position: absolute; top: 4px; right: 4px; display: flex; gap: 3px; opacity: 0; transition: opacity .12s ease; }
.message:hover .message-actions, .message-bubble:focus-within .message-actions { opacity: 1; }
.mini-icon-button { width: 20px; height: 20px; border: 0; border-radius: 50%; background: rgba(0,0,0,.18); color: rgba(255,255,255,.88); display: grid; place-items: center; cursor: pointer; font-size: .76rem; }
.message-title { font-size: .78rem; font-weight: 700; margin: 0 0 3px; }
.message-text { white-space: pre-wrap; word-break: break-word; line-height: 1.28; font-size: .88rem; }
.selectable { user-select: text; -webkit-user-select: text; }
.link-card, .file-card { margin-top: 5px; display: block; background: rgba(0,0,0,.16); border-radius: 6px; padding: 7px 8px; }
.link-card { color: #9ad9ff; overflow-wrap: anywhere; font-size: .82rem; }
.file-card { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.file-main { min-width: 0; }
.file-main strong, .file-main small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-main strong { font-size: .8rem; }
.file-main small { color: var(--muted); margin-top: 2px; font-size: .7rem; }
.file-open { font-size: .74rem; }
.chat-image, .chat-media { width: 100%; max-height: 300px; margin-top: 5px; border-radius: 6px; display: block; background: #000; }
.compact-player { height: 34px; }
.tag-row { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.tag { border-radius: 999px; background: rgba(255,255,255,.09); color: #d4f8f0; padding: 2px 5px; font-size: .66rem; }
.message-meta-bottom { display: flex; justify-content: flex-end; gap: 4px; margin-top: 3px; color: rgba(233,237,239,.72); font-size: .68rem; }
.copy-feedback { color: #c9fff3; }
.empty-chat { display: grid; place-items: center; min-height: 44vh; }
.empty-bubble { max-width: 300px; text-align: center; background: rgba(17,27,33,.92); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.empty-bubble p { margin: 4px 0 0; color: var(--muted); font-size: .84rem; }
.composer-shell { position: sticky; bottom: 0; z-index: 5; padding: 6px 8px; background: linear-gradient(180deg, transparent, rgba(11,20,26,.66) 18%, rgba(17,27,33,.98)); }
.composer-bar { display: flex; align-items: flex-end; gap: 6px; }
.circle-button { width: 38px; height: 38px; border-radius: 50%; border: 0; display: grid; place-items: center; cursor: pointer; }
#attachTrigger, .record-button { background: #202c33; color: var(--text); }
.send-button { background: var(--accent); color: #06231d; font-weight: 700; }
.input-stack { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 5px; background: #202c33; border-radius: 16px; padding: 7px 9px 6px; }
#contentInput { width: 100%; min-height: 24px; max-height: 140px; resize: none; border: 0; outline: none; background: transparent; color: var(--text); line-height: 1.32; padding: 0; font-size: .9rem; }
.hidden-input { display: none; width: 100%; border: 0; outline: none; border-radius: 9px; padding: 7px 9px; background: #152127; color: var(--text); }
.hidden-input.visible { display: block; }
.quick-modes { display: flex; flex-wrap: wrap; gap: 4px; }
.mode-button { border: 0; background: #152127; color: var(--muted); border-radius: 999px; padding: 3px 7px; font-size: .69rem; cursor: pointer; }
.mode-button.active { background: rgba(0,168,132,.18); color: #d6fff6; }
.file-name { color: var(--muted); font-size: .7rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recording-status, .recording-preview, .form-error { margin-left: 44px; }
.recording-status { display: none; align-items: center; gap: 8px; color: #ffd8d8; font-size: .78rem; margin-top: 5px; }
.recording-status.visible { display: flex; }
.recording-dot { width: 8px; height: 8px; border-radius: 50%; background: #ff6b6b; }
.recording-status.is-recording .recording-dot { animation: pulse 1s infinite; }
.recording-preview.visible { margin-top: 5px; }
.form-error { min-height: 18px; color: #ff9f9f; font-size: .78rem; margin-top: 4px; }
.install-button { display: inline-flex; align-items: center; justify-content: center; border: none; border-radius: 999px; padding: .42rem .72rem; background: #25d366; color: #062b14; font-weight: 700; cursor: pointer; white-space: nowrap; font-size: .78rem; }
.install-button[hidden], .mobile-overlay[hidden] { display: none !important; }
.mobile-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.48); z-index: 15; }

@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.35} }

@media (max-width: 860px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: min(84vw, 320px); transform: translateX(-100%); transition: transform .18s ease; z-index: 20; }
  body.sidebar-open .sidebar { transform: translateX(0); }
  .nav-btn { display: grid; }
  .top-search input { width: min(34vw, 128px); }
  .header-actions { min-width: 0; }
  .message-bubble { max-width: 86%; }
}
