/* chatd — чёрный минимализм. Ноль внешних ресурсов, ноль картинок. */

:root {
  --bg: #000;
  --panel: #0a0a0a;
  --chip: #111;
  --border: #1d1d1d;
  --border2: #333;
  --text: #eaeaea;
  --muted: #6e6e6e;
  --dim: #4a4a4a;
  --danger: #ff5f56;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.screen { height: 100dvh; animation: fade .18s ease-out; }
.center { display: flex; align-items: center; justify-content: center; padding: 16px; }

@keyframes fade { from { opacity: 0 } to { opacity: 1 } }

.muted { color: var(--muted); margin: 0; }
.small { font-size: 12px; }
.error { color: var(--danger); font-size: 13px; }

/* ------------------------------- вход ---------------------------------- */

#login-form {
  width: min(90vw, 350px);
  display: flex; flex-direction: column; gap: 10px;
}
#login-form .label {
  margin: 0 0 12px;
  font-size: 11px;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--muted);
}

input, textarea {
  width: 100%;
  padding: 11px 12px;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  outline: none;
  transition: border-color .12s ease;
}
input:focus, textarea:focus { border-color: var(--border2); }
::placeholder { color: var(--dim); }

#key-input {
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  letter-spacing: .08em;
}

button {
  cursor: pointer;
  border: 0;
  border-radius: 10px;
  padding: 11px 14px;
  font: inherit;
  transition: background .12s ease, color .12s ease, border-color .12s ease;
}
button.primary { background: #fff; color: #000; font-weight: 600; }
button.primary:hover { background: #d7d7d7; }
button.primary:active { background: #c4c4c4; }
button.ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12.5px;
}
button.ghost:hover { color: var(--text); border-color: var(--border2); }

/* ------------------------------- чат ----------------------------------- */

#chat-screen { display: flex; flex-direction: column; }
#chat-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
#chat-title {
  font-size: 11px;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--muted);
}
#chat-layout { flex: 1; display: flex; min-height: 0; }

#rooms-pane {
  width: 240px;
  display: flex; flex-direction: column;
  border-right: 1px solid var(--border);
  min-height: 0;
}
#rooms-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px 8px;
  font-size: 11px; letter-spacing: .18em; text-transform: uppercase;
  color: var(--muted);
}
#new-client-box {
  margin: 0 10px 8px; padding: 10px;
  display: flex; flex-direction: column; gap: 8px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
}
#new-client-key {
  display: block;
  padding: 9px 10px;
  background: #050505;
  border: 1px solid var(--border);
  border-radius: 8px;
  word-break: break-all;
  user-select: all;
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 12px;
  color: var(--text);
}
#rooms-list { flex: 1; overflow-y: auto; padding: 2px 6px 10px; }

.room {
  display: flex; flex-direction: column; gap: 2px;
  width: 100%; text-align: left;
  background: transparent; color: var(--text);
  border-radius: 9px;
  padding: 9px 10px;
  margin-bottom: 1px;
}
.room:hover { background: #0d0d0d; }
.room.active { background: #141414; }
.room-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.room-name { font-size: 14px; font-weight: 560; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.room-meta { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge {
  min-width: 17px; height: 17px; padding: 0 5px;
  display: inline-flex; align-items: center; justify-content: center;
  background: #fff; color: #000;
  font-size: 10px; font-weight: 700;
  border-radius: 999px;
}
.rooms-empty { padding: 2px 8px; color: var(--muted); font-size: 12px; }

#chat-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
#messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px;
  display: flex; flex-direction: column; gap: 6px;
}
.empty-hint { margin: auto; color: var(--dim); font-size: 13px; user-select: none; }

.msg {
  max-width: min(70%, 620px);
  padding: 9px 12px 8px;
  background: var(--chip);
  border: 1px solid #171717;
  border-radius: 12px;
  align-self: flex-start;
  animation: fade .15s ease-out;
}
.msg.mine {
  background: #f2f2f2;
  color: #050505;
  border: 0;
  align-self: flex-end;
}
.msg .meta { font-size: 10.5px; color: var(--muted); margin-bottom: 2px; }
.msg.mine .meta { color: #8f8f8f; text-align: right; }
.msg .body { white-space: pre-wrap; overflow-wrap: anywhere; }

#send-form {
  display: flex; gap: 8px; align-items: flex-end;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}
#send-form textarea { resize: none; flex: 1; width: auto; }
#send-btn {
  flex-shrink: 0;
  width: 42px; height: 42px;
  padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 17px; line-height: 1;
}
#chat-note { padding: 0 16px 10px; min-height: 16px; color: var(--muted); }

/* --------------------------- скроллбары -------------------------------- */

* { scrollbar-width: thin; scrollbar-color: #222 transparent; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #1f1f1f; border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: #2e2e2e; }

@media (max-width: 760px) {
  #rooms-pane { width: 168px; }
  .msg { max-width: 86%; }
  #messages { padding: 14px 12px; }
}
