:root {
  color-scheme: light;
  --bg: #f4f7fb;
  --panel: #ffffff;
  --text: #172033;
  --muted: #63708a;
  --line: #dbe3ef;
  --accent: #1672f3;
  --accent-strong: #0f5ed0;
  --bubble: #edf4ff;
  --shadow: 0 18px 50px rgba(23, 32, 51, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

button,
input,
textarea {
  font: inherit;
}

.chat-shell {
  width: min(820px, 100%);
  min-height: 100dvh;
  margin: 0 auto;
  display: grid;
  grid-template-rows: auto 1fr auto;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: calc(18px + env(safe-area-inset-top)) 18px 16px;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 4px;
  font-size: 12px;
  color: var(--muted);
}

h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.15;
  letter-spacing: 0;
}

.status {
  flex: 0 0 auto;
  min-width: 86px;
  padding: 7px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.status.online {
  border-color: #a9d8be;
  color: #176b39;
  background: #edf9f1;
}

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

.empty {
  margin: auto;
  color: var(--muted);
  text-align: center;
}

.message {
  width: fit-content;
  max-width: min(620px, 92%);
  padding: 12px 14px;
  border: 1px solid #cfe0f8;
  border-radius: 8px;
  background: var(--bubble);
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
}

.author {
  font-weight: 700;
  color: var(--text);
}

.message-text {
  margin: 0;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  line-height: 1.45;
}

.message-text a {
  color: var(--accent-strong);
  font-weight: 700;
}

.composer {
  display: grid;
  grid-template-columns: minmax(120px, 180px) 1fr auto;
  gap: 10px;
  padding: 14px 18px calc(14px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: #fbfdff;
}

label {
  display: grid;
  gap: 6px;
}

label span {
  color: var(--muted);
  font-size: 12px;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: var(--panel);
  outline: none;
}

input {
  min-height: 46px;
  padding: 0 12px;
}

textarea {
  min-height: 46px;
  max-height: 160px;
  padding: 11px 12px;
  resize: vertical;
}

input:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(22, 114, 243, 0.12);
}

button {
  align-self: end;
  min-height: 46px;
  padding: 0 18px;
  border: 0;
  border-radius: 8px;
  color: #ffffff;
  background: var(--accent);
  font-weight: 700;
  cursor: pointer;
}

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

@media (max-width: 680px) {
  .chat-shell {
    box-shadow: none;
  }

  .topbar {
    align-items: flex-start;
  }

  .composer {
    grid-template-columns: 1fr;
  }

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