* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f3f5f9;
  color: #18202a;
}

button,
input,
textarea {
  font: inherit;
}

.page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 320px 1fr;
}

.sidebar {
  padding: 16px;
  background: #0f1722;
  color: #f8fbff;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  padding: 16px;
}

.card h1 {
  margin: 0 0 8px;
  font-size: 24px;
}

.muted {
  margin: 8px 0 0;
  color: #bdd0ea;
  font-size: 14px;
  line-height: 1.5;
}

label,
.room-meta,
.online-header {
  display: block;
  margin-bottom: 8px;
  font-size: 14px;
  color: #dce8f7;
}

input,
textarea {
  width: 100%;
  border: 1px solid #cad6e2;
  border-radius: 12px;
  padding: 12px 14px;
  background: #ffffff;
  color: #18202a;
}

textarea {
  resize: vertical;
  min-height: 96px;
}

.composer-tip {
  margin: 10px 0 0;
  color: #66788a;
  font-size: 13px;
}

.button-row,
.invite-box,
.composer-actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

button,
.file-button {
  border: none;
  border-radius: 12px;
  padding: 12px 14px;
  background: #2a7fff;
  color: #ffffff;
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.15s ease;
  text-align: center;
}

button:hover,
.file-button:hover {
  opacity: 0.92;
  transform: translateY(-1px);
}

button.secondary {
  background: #334155;
}

.invite-box {
  flex-direction: column;
}

.online-header,
.room-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.user-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.user-list li {
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.1);
  font-size: 14px;
}

.chat-panel {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.message-list {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.message {
  max-width: 760px;
  background: #ffffff;
  border: 1px solid #dde5ef;
  border-radius: 16px;
  padding: 14px 16px;
  box-shadow: 0 4px 18px rgba(15, 23, 34, 0.05);
}

.message.system {
  background: #eaf2ff;
  border-color: #bfd5ff;
}

.message.self {
  align-self: flex-end;
  background: #2a7fff;
  border-color: #2a7fff;
  color: #ffffff;
}

.message.self .message-time,
.message.self .message-author {
  color: #ffffff;
}

.message.other {
  align-self: flex-start;
}

.message.recalled {
  opacity: 0.72;
}

.message.recalled .message-body {
  font-style: italic;
}

.message-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.message-author {
  font-size: 15px;
}

.message-time {
  font-size: 12px;
  color: #66788a;
  white-space: nowrap;
}

.message-body {
  word-break: break-word;
  line-height: 1.6;
}

.message-body img {
  max-width: min(100%, 360px);
  width: auto;
  border-radius: 12px;
  margin-top: 8px;
  display: block;
  cursor: zoom-in;
}

.message-actions {
  margin-top: 10px;
  display: flex;
  justify-content: flex-end;
}

.message-recall-button {
  display: none;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  background: rgba(15, 23, 34, 0.08);
  color: inherit;
}

.message.self .message-recall-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.16);
}

.message.system .message-recall-button,
.message.recalled .message-recall-button {
  display: none;
}

.composer {
  padding: 16px 20px 20px;
  border-top: 1px solid #dde5ef;
  background: #ffffff;
}

.composer-actions {
  justify-content: space-between;
  align-items: center;
}

.composer-actions button,
.composer-actions .file-button {
  min-width: 120px;
}

.image-viewer {
  position: fixed;
  inset: 0;
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.image-viewer[hidden] {
  display: none;
}

.image-viewer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 34, 0.84);
}

.image-viewer-panel {
  position: relative;
  z-index: 1;
  width: min(96vw, 1100px);
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.image-viewer-toolbar {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.image-viewer-stage {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 16px;
  min-height: 60vh;
  max-height: calc(92vh - 64px);
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.image-viewer-image {
  max-width: none;
  max-height: none;
  transform-origin: center center;
  transition: transform 0.08s linear;
  user-select: none;
}

@media (max-width: 900px) {
  .page {
    grid-template-columns: 1fr;
  }

  .chat-panel {
    min-height: auto;
  }

  .message-list {
    min-height: 50vh;
  }
}

@media (max-width: 520px) {
  .sidebar,
  .composer,
  .message-list {
    padding: 14px;
  }

  .button-row,
  .composer-actions {
    flex-direction: column;
  }

  .composer-actions button,
  .composer-actions .file-button {
    width: 100%;
  }

  .image-viewer-toolbar {
    flex-wrap: wrap;
  }
}
