:root{
  --bg:#0b141a;
  --panel:#111b21;
  --panel-2:#0f171d;
  --text:#e9edef;
  --muted:#8696a0;
  --line:rgba(255,255,255,.08);
  --accent:#00a884;
  --accent-2:#cbd5dc;
  --danger:#c0392b;
  --danger-bg:rgba(192,57,43,.14);
  --ok:#00a884;
  --shadow:0 16px 40px rgba(0,0,0,.35);
  --radius:16px;
  --radius-sm:12px;
  --max:920px;
}

*{box-sizing:border-box}
html,body{
  margin:0;
  padding:0;
  height:100%;
  background:var(--bg);
  color:var(--text);
  font-family:Inter,ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;
}
a{color:inherit;text-decoration:none}
button,input,textarea{font:inherit}
textarea{resize:none}

.app{
  max-width:var(--max);
  margin:0 auto;
  padding:22px 18px 60px;
}
.chat-app{
  max-width:860px;
  height:100vh;
  display:flex;
  flex-direction:column;
  padding:14px 12px 16px;
}

.topbar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:14px;
  flex:0 0 auto;
  margin:0 0 14px;
  padding:14px 16px;
  background:rgba(17,27,33,.92);
  backdrop-filter:blur(18px);
  border:1px solid var(--line);
  border-radius:20px;
  box-shadow:var(--shadow);
}

.brand{font-weight:700;letter-spacing:.2px}
.guest,.subtle{color:var(--muted);font-size:.92rem}
.back{
  width:38px;
  height:38px;
  border:1px solid var(--line);
  border-radius:999px;
  display:grid;
  place-items:center;
  background:var(--panel);
  color:var(--text)
}

.panel,.messages,.composer,.dropzone,.room-item,.upload-card{
  border:1px solid var(--line);
  background:linear-gradient(180deg,var(--panel),var(--panel-2));
  box-shadow:var(--shadow);
}

.panel{
  border-radius:var(--radius);
  padding:18px;
  margin:0 0 14px;
}

.panel h1,.panel h2{margin:0 0 10px}
.panel p{margin:0 0 10px;line-height:1.6;color:var(--accent-2)}
.muted{color:var(--muted)!important}
.rules{margin:0;padding-left:18px;color:var(--accent-2);line-height:1.7}

.actions{
  display:flex;
  flex-wrap:wrap;
  gap:10px;
  margin:0 0 14px;
}
.btn,.send{
  border:1px solid var(--line);
  background:#1a202b;
  color:var(--text);
  border-radius:12px;
  padding:11px 14px;
  font-weight:600;
  cursor:pointer;
  transition:.15s ease;
}
.btn:hover,.send:hover,.room-x:hover{transform:translateY(-1px)}
.btn-warn{border-color:rgba(192,57,43,.35);background:var(--danger-bg);color:#ffd7d7}
.btn-ghost{background:transparent}

.room-list{display:flex;flex-direction:column;gap:10px}
.room-item{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  border-radius:14px;
  padding:12px 12px 12px 14px;
}
.room-item a{font-weight:700;color:var(--accent)}
.inline-delete{margin:0}

.room-x{
  width:30px;
  height:30px;
  border-radius:999px;
  border:1px solid rgba(192,57,43,.4);
  background:var(--danger-bg);
  color:#ffb3b3;
  display:grid;
  place-items:center;
  cursor:pointer;
  line-height:1;
  font-size:18px;
}

.messages{
  flex:1 1 auto;
  min-height:0;
  overflow-y:auto;
  overflow-x:hidden;
  border-radius:24px;
  padding:14px 16px;
  margin:0 0 14px;
  display:flex;
  flex-direction:column;
  gap:8px;
}

.message{
  display:flex;
  flex-direction:column;
  max-width:100%;
  margin:0;
}

.message.me{align-items:flex-end}
.message.other{align-items:flex-start}

.meta{
  font-size:.76rem;
  color:var(--muted);
  margin:0 0 2px;
  line-height:1;
}

.bubble{
  display:block;
  width:auto;
  max-width:100%;
  padding:0;
  margin:0;
  border:none;
  background:transparent;
  line-height:1.4;
  white-space:pre-wrap;
  overflow-wrap:anywhere;
  font-size:15px;
  color:var(--text);
}

.upload-card{
  display:inline-flex;
  flex-direction:column;
  gap:6px;
  width:fit-content;
  max-width:100%;
  padding:7px 9px;
  border-radius:14px;
  border:1px solid var(--line);
  background:#171d27;
}

.upload-name{
  font-weight:600;
  margin:0;
}

.upload-card img,
.chat-thumb{
  display:block;
  width:auto;
  height:auto;
  max-width:220px;
  max-height:220px;
  object-fit:contain;
  border-radius:12px;
  cursor:pointer;
  background:#0d1016;
}

.composer{
  flex:0 0 auto;
  border-radius:24px;
  padding:16px;
  display:flex;
  align-items:center;
  gap:10px;
}

.pick,.send{
  width:44px;
  height:44px;
  min-width:44px;
  border-radius:999px;
  display:grid;
  place-items:center;
  padding:0;
}

.pick{
  border:1px solid var(--line);
  background:#1d2532;
  color:var(--text);
  cursor:pointer;
}

.send{
  background:var(--accent);
  border-color:var(--accent);
  color:#fff;
}

.composer-body{
  flex:1;
  min-width:0;
  display:flex;
  flex-direction:column;
  gap:8px;
}

.composer textarea{
  width:100%;
  min-height:52px;
  border-radius:16px;
  border:1px solid var(--line);
  background:#0d1016;
  color:var(--text);
  padding:14px 14px;
  outline:none;
  box-sizing:border-box;
}

.composer textarea:focus,.dropzone.drag{
  border-color:rgba(0,168,132,.55);
  box-shadow:0 0 0 3px rgba(0,168,132,.12);
}

.file-list{
  display:flex;
  flex-wrap:nowrap;
  gap:8px;
  overflow-x:auto;
  overflow-y:hidden;
  margin:0;
  padding-bottom:2px;
  -webkit-overflow-scrolling:touch;
}

.file-pill{
  flex:0 0 auto;
  padding:8px 10px;
  border-radius:999px;
  background:#141923;
  border:1px solid var(--line);
  color:var(--accent-2);
  font-size:.88rem;
  white-space:nowrap;
}

.img-modal{
  position:fixed;
  inset:0;
  background:rgba(0,0,0,.72);
  z-index:99999;
  display:none;
  align-items:center;
  justify-content:center;
  padding:18px;
}

.img-modal.is-open{
  display:flex;
}

.modal-window{
  width:min(96vw, 1200px);
  height:min(92vh, 900px);
  display:flex;
  flex-direction:column;
  overflow:hidden;
  border-radius:18px;
  background:#0f1115;
  border:1px solid rgba(255,255,255,.08);
  box-shadow:0 20px 70px rgba(0,0,0,.55);
}

.modal-image-wrap{
  flex:1 1 auto;
  min-height:0;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:18px;
}

.modal-image{
  display:block;
  width:100%;
  height:100%;
  object-fit:contain;
  background:#0d1016;
  border-radius:10px;
}

.modal-actions{
  flex:0 0 auto;
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:10px;
  padding:14px 16px;
  border-top:1px solid rgba(255,255,255,.06);
  background:rgba(255,255,255,.02);
}

.modal-close{
  width:44px;
  height:44px;
  border-radius:999px;
  border:1px solid rgba(255,255,255,.08);
  background:#1a202b;
  color:#fff;
  display:grid;
  place-items:center;
  cursor:pointer;
  font-size:22px;
  line-height:1;
}

@media (max-width:700px){
  .app{padding:14px 12px 44px}
  .chat-app{
    height:100dvh;
    padding:12px 10px 12px;
  }
  .topbar,.panel,.messages,.composer{border-radius:18px}
  .message{max-width:92%}
  .room-item{align-items:flex-start}
  .upload-card img,.chat-thumb{max-width:180px;max-height:180px}
  .modal-window{
    width:100vw;
    height:100dvh;
    border-radius:0;
  }
}