:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #101418;
  color: #f8fafc;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(16, 185, 129, 0.2), transparent 34%),
    linear-gradient(315deg, rgba(14, 165, 233, 0.18), transparent 30%),
    #101418;
}

button,
input {
  font: inherit;
}

input[type="file"] {
  min-height: auto;
  padding: 10px;
}

.avatar-preview {
  align-items: center;
  background: #334155 center / cover no-repeat;
  border: 1px solid #475569;
  border-radius: 50%;
  color: #e2e8f0;
  display: flex;
  font-weight: 800;
  height: 64px;
  justify-content: center;
  width: 64px;
}

button {
  border: 0;
  border-radius: 8px;
  background: #22c55e;
  color: #052e16;
  cursor: pointer;
  font-weight: 700;
  min-height: 44px;
  padding: 0 16px;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.secondary {
  background: #334155;
  color: #e2e8f0;
}

.app {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 16px;
}

.setup,
.chat {
  background: rgba(15, 23, 42, 0.84);
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 8px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.28);
  width: min(720px, 100%);
}

.setup {
  display: grid;
  gap: 16px;
  padding: 24px;
}

.brand {
  align-items: center;
  display: flex;
  gap: 12px;
}

.mark {
  align-items: center;
  background: #f8fafc;
  border-radius: 8px;
  color: #111827;
  display: inline-flex;
  font-weight: 900;
  height: 44px;
  justify-content: center;
  width: 44px;
}

h1 {
  font-size: 24px;
  line-height: 1.1;
  margin: 0;
}

label {
  color: #cbd5e1;
  display: grid;
  gap: 8px;
}

input {
  background: #020617;
  border: 1px solid #334155;
  border-radius: 8px;
  color: #f8fafc;
  min-height: 46px;
  padding: 0 14px;
  width: 100%;
}

.note {
  color: #94a3b8;
  font-size: 14px;
  line-height: 1.45;
  margin: 0;
}

.error {
  background: rgba(239, 68, 68, 0.14);
  border: 1px solid rgba(248, 113, 113, 0.4);
  border-radius: 8px;
  color: #fecaca;
  font-size: 14px;
  line-height: 1.45;
  margin: 0;
  padding: 10px 12px;
}

.hidden {
  display: none;
}

.chat {
  display: grid;
  grid-template-rows: auto minmax(360px, 65vh) auto;
  overflow: hidden;
  position: relative;
}

.chat.hidden {
  display: none;
}

header,
.composer {
  align-items: center;
  display: flex;
  gap: 12px;
  padding: 14px;
}

header {
  border-bottom: 1px solid rgba(148, 163, 184, 0.18);
  justify-content: space-between;
}

header div {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

#roomTitle {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#statusText {
  color: #94a3b8;
  font-size: 13px;
}

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

.panel {
  background: #0f172a;
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 8px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.34);
  display: grid;
  gap: 14px;
  padding: 16px;
  position: absolute;
  right: 14px;
  top: 70px;
  width: min(320px, calc(100% - 28px));
  z-index: 10;
}

.panel.hidden {
  display: none;
}

.panel-header {
  align-items: center;
  display: flex;
  justify-content: space-between;
}

.users-list {
  display: grid;
  gap: 10px;
}

.user-row {
  align-items: center;
  display: flex;
  gap: 10px;
}

.message-row {
  align-items: flex-end;
  display: flex;
  gap: 8px;
  max-width: 86%;
}

.message-row.mine {
  align-self: flex-end;
}

.message-row.theirs {
  align-self: flex-start;
}

.avatar {
  align-items: center;
  background: #475569 center / cover no-repeat;
  border: 1px solid rgba(226, 232, 240, 0.16);
  border-radius: 50%;
  color: #e2e8f0;
  display: flex;
  flex: 0 0 34px;
  font-size: 13px;
  font-weight: 800;
  height: 34px;
  justify-content: center;
  width: 34px;
}

.message {
  border-radius: 8px;
  line-height: 1.4;
  min-width: 120px;
  padding: 10px 12px;
  position: relative;
  word-break: break-word;
}

.author {
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 4px;
}

.author-cyan {
  color: #67e8f9;
}

.author-red {
  color: #f87171;
}

.message-text {
  color: #f8fafc;
}

.message-row.mine .message-text {
  color: #052e16;
}

.photo {
  border-radius: 8px;
  display: block;
  max-height: 360px;
  max-width: min(100%, 360px);
  object-fit: contain;
}

.message-row.mine .message {
  align-self: flex-end;
  background: #22c55e;
  color: #052e16;
}

.message-row.theirs .message {
  align-self: flex-start;
  background: #1f2937;
}

.message-tools {
  display: flex;
  justify-content: flex-end;
  margin-top: 6px;
  position: relative;
}

.message-menu-button {
  background: rgba(15, 23, 42, 0.18);
  border-radius: 999px;
  color: currentColor;
  font-size: 16px;
  letter-spacing: 0;
  line-height: 1;
  min-height: 26px;
  min-width: 34px;
  padding: 0 8px 4px;
}

.message-menu {
  background: #020617;
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 8px;
  bottom: 30px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.34);
  display: grid;
  min-width: 136px;
  overflow: hidden;
  position: absolute;
  right: 0;
  z-index: 20;
}

.message-menu.hidden {
  display: none;
}

.message-menu button {
  background: transparent;
  border-radius: 0;
  color: #e2e8f0;
  font-size: 14px;
  font-weight: 700;
  justify-content: flex-start;
  min-height: 38px;
  padding: 0 12px;
  text-align: left;
}

.message-menu button:hover {
  background: #1f2937;
}

.edited-label {
  color: currentColor;
  display: block;
  font-size: 11px;
  margin-top: 5px;
  opacity: 0.55;
}

.system {
  align-self: center;
  background: transparent;
  color: #94a3b8;
  font-size: 13px;
  max-width: 100%;
  padding: 2px;
}

.composer {
  border-top: 1px solid rgba(148, 163, 184, 0.18);
}

.composer input {
  flex: 1;
}

.file-input {
  display: none;
}

@media (max-width: 560px) {
  .app {
    padding: 0;
  }

  .setup,
  .chat {
    border: 0;
    border-radius: 0;
    min-height: 100vh;
  }

  .chat {
    grid-template-rows: auto 1fr auto;
  }

  .composer {
    align-items: stretch;
    flex-direction: column;
  }

  .message {
    max-width: 92%;
  }

  .message-row {
    max-width: 100%;
  }
}
