@font-face {
  font-family: "Instrument Sans";
  src: url("/instrument-sans.woff2") format("woff2");
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
}

:root {
  color-scheme: light;
  font-family: "Instrument Sans", system-ui, sans-serif;
  color: #24202c;
  background: #f7f5f9;
  --paper: #fff;
  --muted: #61586c;
  --line: #e8e1ee;
  --accent: #6235ac;
  --accent-dark: #4e268f;
  --tint: #f1eaf9;
  --error: #a32947;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
h1, h2, p { margin: 0; }
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.icon-library { position: absolute; width: 0; height: 0; }
.icon {
  width: 1.25rem;
  height: 1.25rem;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.65;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.shell {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  width: min(100%, 83rem);
  height: 100dvh;
  min-height: 28rem;
  margin: auto;
  padding: 1.5rem clamp(1.25rem, 4vw, 3rem) 2rem;
}
.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: none;
  min-height: 2.5rem;
}
.wordmark {
  display: flex;
  align-items: center;
  gap: .65rem;
  font-size: 1.58rem;
  font-weight: 700;
  letter-spacing: -.055em;
}
.wordmark-period { color: var(--accent); }
.brand-mark, .welcome-mark {
  display: grid;
  place-items: center;
  flex: none;
}
.brand-mark {
  width: 2.125rem;
  height: 2.125rem;
  border-radius: .625rem;
  color: white;
  background: var(--accent);
}
.brand-mark .icon { width: 1.5rem; height: 1.5rem; }
.connection {
  display: flex;
  align-items: center;
  gap: .45rem;
  color: var(--muted);
  font-size: .875rem;
}
.connection-dot {
  width: .5rem;
  height: .5rem;
  border-radius: 50%;
  background: #a3692e;
}
.connection[data-live="true"] .connection-dot { background: #20714d; }

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(17.5rem, 34%);
  flex: 1;
  min-height: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 1.375rem;
  background: var(--paper);
  box-shadow: 0 18px 48px #3820510d;
}
.chat {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}
.room-header {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: space-between;
  gap: .875rem;
  padding: 1.25rem clamp(1rem, 3vw, 2rem);
  border-bottom: 1px solid var(--line);
}
.room-header h1 {
  font-size: 1.2rem;
  font-weight: 680;
  letter-spacing: -.035em;
}
.room-header p {
  margin-top: .25rem;
  color: var(--muted);
  font-size: .875rem;
}
.profile, .subtle-button, .copy-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  min-height: 2.75rem;
  padding: .5rem .8rem;
  border: 1px solid var(--line);
  border-radius: .625rem;
  background: var(--paper);
  color: var(--accent-dark);
  font-size: .875rem;
  font-weight: 600;
}
.profile { min-width: 0; max-width: 47%; }
.profile span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.profile .icon, .copy-link .icon { width: 1rem; height: 1rem; }
.profile:hover, .subtle-button:hover { background: var(--tint); }

.join {
  display: grid;
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 1.75rem 1.25rem;
}
.welcome {
  width: min(100%, 22rem);
  margin: auto;
}
.welcome-mark {
  width: 3.375rem;
  height: 3.375rem;
  margin-bottom: 1rem;
  border-radius: 1rem;
  background: var(--tint);
  color: var(--accent);
}
.welcome-mark .icon { width: 1.875rem; height: 1.875rem; }
.welcome h2 {
  font-size: clamp(1.65rem, 3.2vw, 2.2rem);
  font-weight: 690;
  letter-spacing: -.04em;
  line-height: 1.1;
  text-wrap: balance;
}
.welcome p { margin-top: .5rem; color: var(--muted); line-height: 1.5; }
.name-form { display: grid; gap: .5rem; }
.welcome .name-form { margin-top: 1.5rem; }
.name-form label { font-size: .875rem; font-weight: 600; }
.name-form input {
  width: 100%;
  min-height: 3rem;
  padding: .7rem .8rem;
  border: 1px solid #d9cfe2;
  border-radius: .625rem;
  background: var(--paper);
  color: inherit;
}
::placeholder { color: #756b7f; opacity: 1; }
.primary {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: .5rem;
  min-height: 2.75rem;
  padding: .6rem 1rem;
  border: 1px solid transparent;
  border-radius: .625rem;
  background: var(--accent);
  color: #fff;
  font-weight: 625;
}
.primary:hover:not(:disabled) { background: var(--accent-dark); }
.primary:disabled { background: #eae1f1; color: #665773; }
.welcome .primary { margin-top: .25rem; min-height: 3rem; }

.conversation {
  display: flex;
  flex: 1;
  min-height: 0;
  position: relative;
}
.timeline {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: auto;
  overflow-anchor: none;
  overscroll-behavior-y: contain;
  padding: 1.25rem clamp(1rem, 3vw, 2rem);
}
.timeline:focus-visible { outline-offset: -3px; }
.history-controls { text-align: center; margin-bottom: 1.25rem; }
.history-controls .error { margin-top: .5rem; }
.empty {
  margin: auto;
  color: var(--muted);
  text-align: center;
  line-height: 1.5;
}
.message-list {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1rem;
  margin: auto 0 0;
  padding: 0;
  list-style: none;
}
.message-list:empty { display: none; }
.message {
  max-width: min(85%, 30rem);
  min-width: 0;
}
.message[data-own="true"] { align-self: flex-end; }
.message-meta {
  display: flex;
  align-items: baseline;
  gap: .55rem;
  margin: 0 .15rem .25rem;
  color: var(--muted);
  font-size: .8125rem;
}
.message[data-own="true"] .message-meta { justify-content: flex-end; }
.message-meta strong { color: #403448; overflow-wrap: anywhere; }
.message-meta time { flex: none; white-space: nowrap; }
.message-body {
  display: flex;
  flex-direction: column;
  width: fit-content;
  max-width: 100%;
  overflow: hidden;
  border-radius: .875rem .875rem .875rem .25rem;
  background: #f3eff6;
}
.message[data-own="true"] .message-body {
  margin-left: auto;
  border-radius: .875rem .875rem .25rem .875rem;
  background: #eee3fa;
}
.message:has(.message-media) { width: 22rem; }
.message:has(.message-media) .message-body { width: 100%; }
.message-text {
  padding: .625rem .875rem;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  line-height: 1.45;
}
.message-media {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: contain;
  background: #211729;
}
.message-body a:focus-visible { outline-offset: -3px; }
.new-messages {
  position: absolute;
  inset: auto auto .75rem 50%;
  translate: -50% 0;
  white-space: nowrap;
  box-shadow: 0 4px 18px #40304c1a;
}

.composer {
  flex: none;
  padding: .875rem clamp(1rem, 3vw, 2rem);
  border-top: 1px solid var(--line);
}
.composer-row {
  display: flex;
  align-items: flex-end;
  gap: .5rem;
}
.composer textarea {
  flex: 1;
  min-width: 0;
  min-height: 2.875rem;
  max-height: 7.5rem;
  padding: .65rem .75rem;
  resize: none;
  border: 1px solid #d9cfe2;
  border-radius: .625rem;
  background: var(--paper);
  color: inherit;
  line-height: 1.4;
  field-sizing: content;
}
.icon-button {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  border: 0;
  border-radius: .625rem;
  background: transparent;
  color: var(--accent-dark);
}
.icon-button:hover:not(:disabled) { background: var(--tint); }
.attach-button { border: 1px solid var(--line); height: 2.875rem; }
.send-button { min-height: 2.875rem; }
.send-button .icon { width: 1.1rem; height: 1.1rem; }
.attachment {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  max-width: 100%;
  padding: 0 .125rem 0 .65rem;
  margin-bottom: .5rem;
  border-radius: .625rem;
  background: var(--tint);
  color: var(--accent-dark);
  font-size: .875rem;
}
.attachment span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.error { color: var(--error); font-size: .875rem; }
.compose-error { margin-bottom: .5rem; }

.invite {
  display: grid;
  isolation: isolate;
  position: relative;
  overflow: auto;
  padding: 1.5rem;
  border-left: 1px solid #e4d7f2;
  background: #eee4f7;
  color: #342044;
  text-align: center;
}
.invite::before {
  position: absolute;
  inset: 0;
  z-index: -1;
  background: radial-gradient(circle, #8864a636 1px, transparent 1.5px) 0 0 / 16px 16px;
  mask-image: linear-gradient(150deg, #000, transparent 42%, transparent 56%, #000);
  pointer-events: none;
  content: "";
}
.invite-content { margin: auto; width: min(100%, 16.5rem); }
.invite h2 {
  font-size: clamp(1.8rem, 3.3vw, 2.8rem);
  font-weight: 690;
  letter-spacing: -.045em;
  line-height: 1.05;
}
.invite p { margin-top: .5rem; color: #5d4770; line-height: 1.5; }
.qr {
  display: block;
  width: 100%;
  margin: 1.4rem 0 1rem;
  overflow: hidden;
  border: 1px solid #ddcce9;
  border-radius: 1.125rem;
  background: #fff;
  box-shadow: 0 10px 24px #52346613;
}
.qr img { display: block; width: 100%; height: auto; }
.copy-link {
  border-color: #d8c4eb;
  background: #f8f2fc;
}
.copy-link:hover { background: #fff; }

dialog {
  width: min(calc(100% - 2rem), 24rem);
  padding: 1.5rem;
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: var(--paper);
  color: inherit;
  box-shadow: 0 18px 45px #2120232e;
}
dialog::backdrop { background: #2b163960; }
dialog h2 { margin-bottom: .5rem; font-size: 1.35rem; letter-spacing: -.04em; }
.dialog-actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: .5rem; }

@media (max-width: 47rem), (hover: none) and (pointer: coarse) {
  .shell {
    gap: 0;
    height: var(--viewport-height, 100dvh);
    min-height: 0;
    padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
    background: var(--paper);
  }
  .masthead {
    min-height: 3.5rem;
    padding: .5rem 1rem;
    border-bottom: 1px solid var(--line);
  }
  .wordmark { font-size: 1.35rem; }
  .brand-mark { width: 1.875rem; height: 1.875rem; }
  .layout { border: 0; border-radius: 0; box-shadow: none; grid-template-columns: minmax(0, 1fr); }
  .room-header { padding-block: .875rem; }
  .invite { display: none; }
  .composer { padding-block: .625rem; }
}

@media (max-width: 23rem) {
  .send-button { padding-inline: .65rem; }
  .room-header p { font-size: .8125rem; }
}
