:root {
  color-scheme: light;
  --background: #f7f7f4;
  --surface: #ffffff;
  --surface-muted: #ecebe5;
  --border: #d9d6cc;
  --text: #20201d;
  --muted: #69675f;
  --accent: #0f766e;
  --accent-strong: #115e59;
  --sent: #e7f4f1;
  --received: #f2f1eb;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--background);
  color: var(--text);
}

button,
input {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(220px, 280px) minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  display: grid;
  align-content: start;
  gap: 18px;
  padding: 28px;
  border-right: 1px solid var(--border);
  background: var(--surface-muted);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

input {
  width: 100%;
  height: 44px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 12px;
  background: var(--surface);
  color: var(--text);
  outline: none;
}

input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
}

button {
  height: 44px;
  border: 0;
  border-radius: 8px;
  padding: 0 16px;
  background: var(--accent);
  color: #ffffff;
  font-weight: 700;
  cursor: pointer;
}

button:hover {
  background: var(--accent-strong);
}

.status {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.chat-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-width: 0;
  min-height: 100vh;
  background: var(--surface);
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 24px 28px;
  border-bottom: 1px solid var(--border);
}

#count-label {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 14px;
}

.messages {
  display: grid;
  align-content: end;
  gap: 12px;
  min-height: 0;
  margin: 0;
  padding: 28px;
  overflow: auto;
  list-style: none;
}

.message {
  max-width: min(680px, 82%);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  background: var(--received);
}

.message.mine {
  justify-self: end;
  background: var(--sent);
}

.message-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
}

.message-user {
  color: var(--text);
  font-weight: 800;
}

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

.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  padding: 20px 28px 24px;
  border-top: 1px solid var(--border);
  background: #fbfbf8;
}

.composer button {
  min-width: 92px;
}

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

  .sidebar {
    grid-template-columns: 1fr 1fr auto;
    align-items: end;
    padding: 16px;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .status {
    grid-column: 1 / -1;
  }

  .chat-panel {
    min-height: calc(100vh - 165px);
  }

  .chat-header,
  .messages,
  .composer {
    padding-left: 16px;
    padding-right: 16px;
  }

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

@media (max-width: 520px) {
  .sidebar,
  .composer {
    grid-template-columns: 1fr;
  }

  .chat-header {
    align-items: flex-start;
    flex-direction: column;
  }
}
