:root {
  --bg: #0e1116;
  --panel: #171b22;
  --panel2: #1f2530;
  --accent: #3b82f6;
  --accent2: #2563eb;
  --danger: #dc2626;
  --text: #e6e9ef;
  --muted: #8b94a3;
  --bubble-mine: #2563eb;
  --bubble-other: #272d39;
}

* { box-sizing: border-box; }

/* Атрибут hidden должен скрывать элемент, даже если ниже задан display:flex
   через id/class-селекторы (иначе #login/#chat/.overlay висят всегда). */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.view { height: 100%; }

/* ---- Логин ---- */
#login {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.card {
  background: var(--panel);
  border: 1px solid #2a3140;
  border-radius: 14px;
  padding: 28px;
  width: 100%;
  max-width: 380px;
  text-align: center;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
}

.card h1 { margin: 0 0 8px; font-size: 22px; }
.muted { color: var(--muted); font-size: 14px; }
.error { color: #f87171; font-size: 14px; margin: 10px 0 0; }

input[type="password"], input[type="text"] {
  width: 100%;
  margin-top: 14px;
  padding: 12px 14px;
  background: var(--panel2);
  border: 1px solid #313846;
  border-radius: 10px;
  color: var(--text);
  font-size: 15px;
  outline: none;
}
input:focus { border-color: var(--accent); }

button {
  margin-top: 14px;
  padding: 12px 18px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  cursor: pointer;
  transition: background 0.15s;
}
button:hover { background: var(--accent2); }
button.danger { background: var(--danger); margin: 0; padding: 8px 14px; font-size: 13px; }
button.danger:hover { background: #b91c1c; }

/* ---- Чат ---- */
#chat { display: flex; flex-direction: column; }

.bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--panel);
  border-bottom: 1px solid #2a3140;
}
.badge {
  background: var(--panel2);
  border: 1px solid #313846;
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.5px;
}
.bar .muted { flex: 1; }

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.msg { max-width: 78%; display: flex; flex-direction: column; }
.msg.mine { align-self: flex-end; align-items: flex-end; }
.who { font-size: 11px; color: var(--muted); margin: 0 4px 2px; }
.bubble {
  background: var(--bubble-other);
  padding: 9px 13px;
  border-radius: 14px;
  font-size: 15px;
  word-break: break-word;
  white-space: pre-wrap;
}
.msg.mine .bubble { background: var(--bubble-mine); }
.photo { max-width: 100%; max-height: 320px; border-radius: 10px; display: block; }
.caption { margin-top: 6px; font-size: 14px; }

.system {
  align-self: center;
  color: var(--muted);
  font-size: 12px;
  padding: 2px 10px;
}

.composer {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--panel);
  border-top: 1px solid #2a3140;
}
.composer input[type="text"] { margin-top: 0; flex: 1; }
.composer button { margin-top: 0; }
.icon-btn {
  cursor: pointer;
  font-size: 22px;
  user-select: none;
  padding: 4px;
}

/* ---- Оверлей завершения ---- */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
