:root {
  color-scheme: light;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #172033;
  background: #f2f5fa;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 280px;
  min-height: 100vh;
  margin: 0;
  display: grid;
  place-items: center;
  padding: 1.25rem;
}

.app {
  width: min(100%, 42rem);
}

.panel {
  padding: clamp(1.5rem, 6vw, 2.5rem);
  border: 1px solid #dce3ee;
  border-radius: 1rem;
  background: #fff;
  box-shadow: 0 1rem 2.5rem rgb(24 43 77 / 8%);
}

h1 {
  margin: 0;
  font-size: 1.8rem;
}

.intro {
  margin: 0.5rem 0 1.75rem;
  color: #5e6a7e;
}

form {
  display: grid;
  gap: 0.65rem;
}

label {
  font-weight: 650;
}

input,
button {
  width: 100%;
  min-height: 2.9rem;
  border-radius: 0.55rem;
  font: inherit;
}

input {
  padding: 0.65rem 0.8rem;
  border: 1px solid #aeb9ca;
  color: inherit;
}

input:focus-visible,
button:focus-visible {
  outline: 3px solid #8bb6ff;
  outline-offset: 2px;
}

button {
  margin-top: 0.25rem;
  padding: 0.65rem 1rem;
  border: 0;
  background: #2459c4;
  color: #fff;
  font-weight: 650;
  cursor: pointer;
}

button:hover {
  background: #1948a6;
}

button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.connection-status {
  margin: 0 0 0.75rem;
  color: #b42318;
  font-weight: 650;
}

.reconnect-button {
  margin: 0 0 0.75rem;
  background: #5e6a7e;
}

.message-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  max-height: min(55vh, 32rem);
  min-height: 12rem;
  overflow-y: auto;
  margin: 0 0 1rem;
  padding: 1rem;
  border: 1px solid #dce3ee;
  border-radius: 0.65rem;
  background: #f8faff;
  list-style: none;
}

.message {
  align-self: flex-start;
  max-width: 85%;
  padding: 0.65rem 0.8rem;
  border-radius: 0.75rem 0.75rem 0.75rem 0.2rem;
  background: #e8eef8;
  overflow-wrap: anywhere;
}

.message-own {
  align-self: flex-end;
  border-radius: 0.75rem 0.75rem 0.2rem 0.75rem;
  background: #dce9ff;
}

.message-system {
  align-self: center;
  max-width: 100%;
  padding: 0.2rem 0.6rem;
  background: transparent;
  color: #68758a;
  font-size: 0.875rem;
  font-style: italic;
  text-align: center;
}

.message-heading {
  display: flex;
  justify-content: space-between;
  gap: 1.5rem;
  margin-bottom: 0.2rem;
  font-size: 0.8rem;
}

.message-username {
  font-weight: 700;
}

.message-time {
  color: #68758a;
  font-variant-numeric: tabular-nums;
}

.message-text {
  margin: 0;
  white-space: pre-wrap;
}

.message-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.65rem;
}

.message-form button {
  width: auto;
  margin: 0;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  clip-path: inset(50%);
}

.error {
  min-height: 1.25em;
  margin: 0;
  color: #b42318;
  font-size: 0.9rem;
}

[hidden] {
  display: none !important;
}
