:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --text: #16202a;
  --muted: #6b7a8a;
  --line: #e4e9ef;
  --accent: #1f7aec;
  --accent-soft: #eaf2ff;
  --incoming: #ffffff;
  --outgoing: #dff0ff;
  --danger: #c73333;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--text);
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
  border-radius: 12px;
  background: var(--accent);
  color: white;
  padding: 10px 16px;
  cursor: pointer;
}

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

.hidden {
  display: none !important;
}

.muted {
  color: var(--muted);
  font-size: 13px;
}

.error {
  color: var(--danger);
  min-height: 20px;
}

.brand {
  color: var(--accent);
  font-weight: 800;
  letter-spacing: -0.02em;
}

.login {
  display: grid;
  min-height: 100%;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(420px, 100%);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--panel);
  box-shadow: 0 20px 60px rgb(20 35 55 / 10%);
}

.login-card h1 {
  margin: 12px 0 24px;
}

.login-card label {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
  color: var(--muted);
}

.login-card input,
.composer textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  outline: none;
}

.login-card input:focus,
.composer textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.login-card button {
  width: 100%;
}

.app {
  display: grid;
  height: 100%;
  grid-template-columns: 340px 1fr;
}

.sidebar {
  min-width: 0;
  border-right: 1px solid var(--line);
  background: var(--panel);
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.ghost {
  border: 1px solid var(--line);
  background: white;
  color: var(--muted);
}

.conversation-list {
  height: calc(100vh - 77px);
  overflow: auto;
}

.conversation {
  display: grid;
  gap: 5px;
  width: 100%;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}

.conversation:hover,
.conversation.active {
  background: var(--accent-soft);
}

.conversation-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.conversation-name {
  overflow: hidden;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badge {
  min-width: 22px;
  border-radius: 999px;
  background: var(--accent);
  color: white;
  font-size: 12px;
  line-height: 22px;
  text-align: center;
}

.last-text {
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat {
  display: grid;
  min-width: 0;
  height: 100vh;
  grid-template-rows: auto 1fr auto;
}

.chat-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.chat-header h1 {
  margin: 0 0 4px;
  font-size: 20px;
}

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

.messages.empty {
  display: grid;
  place-items: center;
}

.empty-state {
  color: var(--muted);
}

.message {
  max-width: min(680px, 80%);
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--incoming);
}

.message.outgoing {
  align-self: flex-end;
  border-color: #c4ddf8;
  background: var(--outgoing);
}

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

.message-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.message-meta {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

.delete-message {
  margin-left: 8px;
  border: 0;
  background: transparent;
  color: var(--danger);
  font-size: 12px;
  padding: 0;
}

.attachments {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.attachments img,
.attachments video {
  max-width: 320px;
  border-radius: 12px;
}

.attachment-link {
  color: var(--accent);
}

.composer {
  display: grid;
  gap: 10px;
  padding: 14px;
  border-top: 1px solid var(--line);
  background: var(--panel);
}

.composer-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

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

  .sidebar {
    display: none;
  }

  .message {
    max-width: 92%;
  }
}
