:root {
  --bg: #ececec;
  --panel: #ffffff;
  --border: #b9b9b9;
  --text: #202020;
  --muted: #6a6a6a;
  --accent: #6d4c78;
  --accent-dark: #563b60;
  --online: #36a269;
  --danger: #a33a3a;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--text);
  background: var(--bg);
}

button, input, textarea { font: inherit; }

.center-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  box-shadow: 0 5px 20px rgba(0,0,0,.08);
}

.landing-card {
  width: min(430px, 100%);
  padding: 34px;
}

.brand {
  text-align: center;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 4px;
}

.tagline {
  text-align: center;
  color: var(--muted);
  line-height: 1.5;
  margin: 8px 0 28px;
}

label {
  display: block;
  margin: 16px 0 7px;
  font-weight: 700;
  font-size: 14px;
}

input, textarea {
  width: 100%;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  outline: none;
}

input {
  height: 42px;
  padding: 0 12px;
}

textarea {
  resize: none;
  padding: 10px 12px;
  min-height: 42px;
}

input:focus, textarea:focus {
  border-color: var(--accent);
}

.primary, .danger, .button-link {
  border: 0;
  cursor: pointer;
  color: #fff;
  background: var(--accent);
  font-weight: 700;
  letter-spacing: .4px;
}

.primary:hover { background: var(--accent-dark); }

.landing-card .primary {
  width: 100%;
  height: 44px;
  margin-top: 24px;
}

.button-link {
  display: block;
  text-decoration: none;
  text-align: center;
  padding: 13px;
  margin-top: 24px;
}

.error {
  min-height: 20px;
  color: #a33a3a;
  font-size: 13px;
  margin: 12px 0 0;
}

.fineprint {
  color: var(--muted);
  font-size: 12px;
  text-align: center;
  line-height: 1.5;
  margin: 20px 0 0;
}

.link-button {
  display: block;
  margin: 18px auto 0;
  border: 0;
  background: none;
  color: var(--accent);
  cursor: pointer;
}

.chat-page {
  min-height: 100vh;
  padding: 18px;
}

.chat-shell {
  width: min(1200px, 100%);
  height: calc(100vh - 36px);
  min-height: 540px;
  margin: auto;
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid var(--border);
}

.chat-header {
  height: 54px;
  flex: 0 0 54px;
  padding: 0 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
  background: #f7f7f7;
}

.muted { color: var(--muted); margin-left: 8px; font-size: 13px; }
.online-count { font-size: 13px; color: var(--online); font-weight: 700; }

.chat-layout {
  min-height: 0;
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 240px;
}

.conversation {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  background: #fff;
}

.message {
  margin-bottom: 14px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.message strong { font-size: 14px; }
.message .time { color: #888; font-family: monospace; font-size: 12px; }
.message div { margin-left: 49px; }

.system-message {
  color: #777;
  font-size: 12px;
  margin: 10px 0;
}

.composer {
  position: relative;
  display: grid;
  grid-template-columns: 44px 1fr 76px;
  gap: 0;
  border-top: 1px solid var(--border);
  padding: 8px;
}

.emoji-button {
  border: 1px solid var(--border);
  background: #f7f7f7;
  cursor: pointer;
}

.send-button {
  min-width: 70px;
}

.emoji-panel {
  position: absolute;
  left: 8px;
  bottom: 58px;
  width: 230px;
  padding: 8px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  background: #fff;
  border: 1px solid var(--border);
  box-shadow: 0 5px 20px rgba(0,0,0,.15);
}

.emoji-panel button {
  border: 0;
  background: #f3f3f3;
  padding: 8px;
  cursor: pointer;
}

.users-panel {
  position: relative;
  border-left: 1px solid var(--border);
  background: #f8f8f8;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.panel-title {
  padding: 14px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .8px;
  border-bottom: 1px solid var(--border);
}

.user-row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.user-row:hover { background: #e9e9e9; }

.online-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--online);
  flex: 0 0 auto;
}

.exit-wrap {
  margin-top: auto;
  padding: 12px;
  border-top: 1px solid var(--border);
}

.danger {
  width: 100%;
  height: 38px;
  background: var(--danger);
}

.private-container {
  position: fixed;
  right: 18px;
  bottom: 18px;
  display: flex;
  gap: 12px;
  align-items: flex-end;
  max-width: calc(100vw - 36px);
}

.private-window {
  width: 320px;
  height: 390px;
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid var(--border);
  box-shadow: 0 8px 30px rgba(0,0,0,.18);
}

.private-window header {
  height: 42px;
  flex: 0 0 42px;
  display: flex;
  align-items: center;
  padding: 0 10px;
  background: #f3f3f3;
  border-bottom: 1px solid var(--border);
}

.private-window header span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.private-window .close {
  margin-left: auto;
  border: 0;
  background: transparent;
  font-size: 22px;
  cursor: pointer;
}

.private-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}

.private-message {
  margin-bottom: 10px;
  font-size: 13px;
}

.private-message.mine {
  text-align: right;
}

.private-message div {
  margin-top: 3px;
  overflow-wrap: anywhere;
}

.private-composer {
  display: grid;
  grid-template-columns: 1fr 65px;
  border-top: 1px solid var(--border);
}

.private-composer input {
  border: 0;
  min-width: 0;
}

.private-composer button {
  border: 0;
}

@media (max-width: 720px) {
  .chat-page { padding: 0; }
  .chat-shell {
    height: 100vh;
    min-height: 0;
    border-left: 0;
    border-right: 0;
  }

  .chat-layout { grid-template-columns: 1fr; }

  .users-panel {
    display: none;
  }

  .private-container {
    left: 0;
    right: 0;
    bottom: 0;
    max-width: none;
  }

  .private-window {
    width: 100vw;
    height: 100vh;
    border: 0;
  }

  .private-window:not(:last-child) { display: none; }
}

@media (max-width: 420px) {
  .landing-card { padding: 24px; }
  .composer { grid-template-columns: 42px 1fr 68px; }
  .chat-header { padding: 0 10px; }
}
