:root { --bg:#0f1416; --panel:#151d20; --panel2:#1b2529; --line:#26343a; --text:#e5eeec; --dim:#8aa09b; --accent:#2fae95; --accent2:#1f6e60; --danger:#b3483f; --warn:#e0b15c; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
button { font: inherit; color: inherit; border: 0; border-radius: 10px; padding: 9px 14px; background: var(--panel2); cursor: pointer; }
button.ok, button.accent { background: var(--accent); color: #fff; }
button.danger { background: var(--danger); color: #fff; }
button:disabled { opacity: .45; cursor: default; }
button.icon, label.icon { width: 42px; height: 42px; padding: 0; display: inline-flex; align-items: center; justify-content: center; font-size: 20px; border-radius: 50%; background: transparent; cursor: pointer; flex: none; }
button.icon.accent { background: var(--accent); }
input, textarea, select { font: inherit; color: var(--text); background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; width: 100%; }
textarea { resize: none; }
.hint { color: var(--dim); padding: 16px; font-size: 15px; }
.center { text-align: center; }
.row { display: flex; gap: 8px; align-items: center; }
.row.end { justify-content: flex-end; flex-wrap: wrap; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--danger); flex: none; }
.dot.on { background: var(--accent); }

#app { display: flex; height: 100%; height: 100dvh; }
#list { width: 340px; border-right: 1px solid var(--line); display: flex; flex-direction: column; background: var(--panel); }
#chat { flex: 1; display: flex; flex-direction: column; min-width: 0; position: relative; }
.bar { display: flex; align-items: center; gap: 6px; padding: 8px 10px; padding-top: max(8px, env(safe-area-inset-top)); border-bottom: 1px solid var(--line); background: var(--panel); min-height: 58px; }
.bar h1 { font-size: 20px; margin: 0 6px; flex: 1; color: var(--accent); }
.bar .title { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.bar .title b, .bar .title small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar .title small { color: var(--dim); }
#rooms { overflow-y: auto; flex: 1; }
.room { display: flex; gap: 10px; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--line); cursor: pointer; }
.room:hover, .room.active { background: var(--panel2); }
.avatar { width: 44px; height: 44px; border-radius: 50%; background: var(--accent2); display: flex; align-items: center; justify-content: center; font-weight: 700; flex: none; }
.room .info { flex: 1; min-width: 0; }
.room .info div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.room .preview { color: var(--dim); font-size: 14px; }
.badge { background: var(--accent); color: #fff; border-radius: 12px; padding: 1px 8px; font-size: 13px; }

#msgs { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 6px; }
.msg { max-width: 78%; padding: 8px 12px; border-radius: 16px; background: var(--panel2); align-self: flex-start; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.mine { align-self: flex-end; background: var(--accent2); }
.msg .who { font-size: 13px; color: var(--accent); font-weight: 600; }
.msg .meta { font-size: 12px; color: var(--dim); text-align: right; margin-top: 2px; }
.msg img, .msg video { max-width: 100%; max-height: 340px; border-radius: 10px; display: block; margin-top: 4px; }
.msg audio { width: 240px; max-width: 100%; margin-top: 4px; }
.msg .file { display: flex; gap: 8px; align-items: center; }
.msg .file a { color: var(--text); }
.sys { align-self: center; color: var(--dim); font-size: 13px; text-align: center; padding: 2px 8px; }
progress { width: 180px; }

#composer { display: flex; gap: 6px; align-items: flex-end; padding: 8px; padding-bottom: max(8px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--panel); }
#composer textarea { max-height: 140px; }
#callBar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 8px 12px; background: #183a33; border-bottom: 1px solid var(--line); }
#callBar[hidden] { display: none; }
#callText { flex: 1; }
#nochat { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: var(--bg); }
#nochat[hidden] { display: none; }

#modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 10; }
#modal[hidden] { display: none; }
#modal .box { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 18px; width: 100%; max-width: 440px; max-height: 90vh; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
#modal h2 { margin: 0; font-size: 19px; }
#modalBody { display: flex; flex-direction: column; gap: 10px; }
#modalBody label { color: var(--dim); font-size: 14px; }
.choice { display: flex; gap: 8px; flex-wrap: wrap; }
.choice button.sel { background: var(--accent); color: #fff; }
#toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); background: #263236; padding: 10px 16px; border-radius: 12px; z-index: 20; max-width: 90%; }

@media (max-width: 760px) {
  #list { width: 100%; border: 0; }
  #chat { display: none; }
  body.in-chat #list { display: none; }
  body.in-chat #chat { display: flex; }
}
@media (min-width: 761px) { #btnBack { display: none; } }

#lock { position: fixed; inset: 0; background: var(--bg); z-index: 30; display: flex; align-items: center; justify-content: center; padding: 20px; }
#lock[hidden] { display: none; }
#lock .box { width: 100%; max-width: 320px; display: flex; flex-direction: column; gap: 12px; text-align: center; }
#lock .biglock { font-size: 54px; }
#lock h2 { margin: 0; font-size: 20px; }
#lock input { text-align: center; font-size: 22px; letter-spacing: 4px; }
.warn { color: var(--warn); font-size: 14px; min-height: 18px; }
.members { display: flex; flex-direction: column; gap: 10px; }
.members code, .mycode { display: block; font-size: 18px; letter-spacing: 1px; color: var(--accent); }
.member { border-top: 1px solid var(--line); padding-top: 10px; display: flex; flex-direction: column; gap: 6px; }
