:root { color-scheme: dark; --bg: #0f1419; --surface: #18212b; --surface2: #223040; --teal: #14b8a6; --tealdark: #0f766e; --muted: #9aa7b4; --danger: #f87171; }
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: #fff; font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
[hidden] { display: none !important; }
a { color: var(--teal); }
button { font: inherit; cursor: pointer; border: 0; border-radius: 10px; padding: 9px 14px; background: var(--surface2); color: var(--teal); font-weight: 600; }
button.primary { background: var(--tealdark); color: #fff; }
button.link { background: none; padding: 4px 8px; }
button:focus-visible, input:focus-visible, textarea:focus-visible { outline: 2px solid var(--teal); outline-offset: 1px; }
input, textarea { font: inherit; color: #fff; background: var(--surface); border: 1px solid var(--surface2); border-radius: 10px; padding: 10px 12px; width: 100%; }
.mono { font-family: ui-monospace, Consolas, monospace; letter-spacing: .08em; text-transform: uppercase; }
.muted { color: var(--muted); } .small { font-size: 13px; } .bold { font-weight: 700; } .big { font-size: 18px; }
.err { color: var(--danger); min-height: 1.4em; font-size: 14px; }
.center { display: flex; align-items: center; justify-content: center; text-align: center; }
.screen.center { min-height: 100%; padding: 24px; }
.box { width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 10px; text-align: center; }
.logo { width: 68px; height: 68px; border-radius: 20px; background: var(--tealdark); display: grid; place-items: center; font: 700 26px system-ui; margin: 0 auto; }
h1 { margin: 4px 0; font-size: 24px; }

#app { display: grid; grid-template-columns: 320px 1fr; height: 100vh; }
aside { background: var(--surface); display: flex; flex-direction: column; min-height: 0; border-right: 1px solid #0b1015; }
aside header, main header { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; min-height: 64px; background: var(--surface); }
main header { border-bottom: 1px solid #0b1015; }
aside footer { padding: 10px 16px; }
.notify { margin: 0 12px 8px; text-align: left; }
#chats { flex: 1; overflow-y: auto; }
.chat { width: 100%; display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: 0; background: none; color: #fff; font-weight: 400; text-align: left; }
.chat:hover { background: #1d2833; } .chat.on { background: #1f2d3a; }
.chat .mid { flex: 1; min-width: 0; } .chat .title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } .chat .sub { color: var(--muted); font-size: 13px; }
.badge { background: var(--teal); color: #04201d; border-radius: 12px; padding: 1px 8px; font-size: 12px; font-weight: 700; }
.avatar { border-radius: 50%; display: grid; place-items: center; font-weight: 700; color: #fff; flex: none; overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }

main { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
#empty { flex: 1; }
#chat { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.pin { padding: 8px 16px; background: var(--surface2); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#msgs { flex: 1; overflow-y: auto; padding: 12px 16px; }
.day { text-align: center; color: var(--muted); font-size: 12px; margin: 14px 0 8px; }
.row { display: flex; margin: 3px 0; } .row.mine { justify-content: flex-end; }
.bubble { position: relative; max-width: min(620px, 75%); background: var(--surface2); border-radius: 16px; padding: 8px 12px 6px; overflow-wrap: anywhere; }
.bubble.mine { background: var(--tealdark); }
.who { color: var(--teal); font-size: 12px; font-weight: 700; }
.text { white-space: pre-wrap; } .text.big { font-size: 38px; line-height: 1.2; }
.gone { color: var(--muted); font-style: italic; }
.meta { color: #ffffffb3; font-size: 11px; text-align: right; margin-top: 2px; }
.quote { border-left: 3px solid var(--teal); background: #00000033; border-radius: 8px; padding: 5px 9px; margin: 2px 0 5px; font-size: 13px; cursor: pointer; }
.quote b { color: var(--teal); display: block; font-size: 12px; } .quote div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 420px; }
.media .photo { display: block; max-width: 320px; max-height: 320px; border-radius: 10px; margin: 4px 0; cursor: zoom-in; }
.media video { max-width: 420px; border-radius: 10px; } .media audio { width: 280px; }
.file { background: #00000033; color: #fff; margin: 4px 0; }
.card { display: block; text-decoration: none; color: #fff; background: #00000033; border-radius: 10px; overflow: hidden; margin-top: 6px; max-width: 320px; }
.card img { width: 100%; max-height: 170px; object-fit: cover; display: block; }
.card .site { color: var(--muted); font-size: 12px; padding: 6px 10px 0; } .card .ptitle { font-weight: 700; padding: 2px 10px; } .card .pdesc { font-size: 13px; color: #ffffffcc; padding: 0 10px 8px; }
.reacts { display: flex; gap: 4px; margin-top: 4px; } .reacts span { background: var(--surface); border-radius: 10px; padding: 1px 7px; font-size: 13px; }
.tools { position: absolute; top: -14px; right: 8px; display: none; gap: 2px; background: var(--surface); border-radius: 10px; padding: 2px; box-shadow: 0 2px 8px #0008; }
.bubble:hover .tools, .bubble:focus-within .tools { display: flex; }
.tools button { background: none; padding: 3px 6px; font-size: 15px; }
.reply { display: flex; align-items: center; justify-content: space-between; padding: 6px 16px; background: var(--surface); color: var(--muted); font-size: 13px; border-top: 1px solid #0b1015; }
#composer { display: flex; gap: 8px; padding: 10px 16px 14px; background: var(--surface); align-items: flex-end; }
#composer textarea { resize: none; max-height: 160px; }
#attach { font-size: 22px; padding: 6px 14px; }
#readonly { padding: 14px; background: var(--surface); }
#callBtns button { background: none; font-size: 20px; padding: 6px 10px; }
#call { position: fixed; inset: 0; background: #0b1a1f; z-index: 50; display: flex; flex-direction: column; align-items: center; justify-content: center; }
#remoteVideo { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #000; }
#localVideo { position: absolute; top: 20px; right: 20px; width: 220px; border-radius: 12px; background: #000; z-index: 2; transform: scaleX(-1); }
#callInfo { position: relative; z-index: 2; text-align: center; font-size: 26px; display: flex; flex-direction: column; gap: 6px; }
#callStatus { font-size: 16px; }
#callButtons { position: absolute; bottom: 40px; display: flex; gap: 18px; z-index: 2; }
#callButtons button { width: 68px; height: 68px; border-radius: 50%; font-size: 24px; background: #ffffff33; color: #fff; }
#callButtons button.red { background: #dc2626; } #callButtons button.green { background: #16a34a; } #callButtons button.on { background: #ffffffaa; }
@media (max-width: 720px) { #app { grid-template-columns: 1fr; } aside { display: none; } }
