:root {
  color: #172033;
  background: #eef4f8;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
}

button,
textarea,
input {
  font: inherit;
}

.hidden {
  display: none !important;
}

.seatApp {
  min-height: 100dvh;
  display: grid;
  padding: max(12px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom));
}

.connectPanel,
.chatShell {
  width: min(100%, 720px);
  margin: auto;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 14px;
  background: #ffffff;
  box-shadow: 0 14px 40px rgba(15, 23, 42, 0.08);
}

.connectPanel {
  display: grid;
  gap: 14px;
  padding: 20px;
}

.connectPanel h1,
.connectPanel p {
  margin: 0;
}

.passwordField {
  display: grid;
  gap: 6px;
}

.passwordField span {
  color: #6b7585;
  font-size: 13px;
}

.passwordField input,
.composer textarea {
  width: 100%;
  border: 1px solid rgba(15, 23, 42, 0.12);
  border-radius: 10px;
  padding: 10px 12px;
  outline: none;
}

.primaryButton {
  min-height: 42px;
  border: 0;
  border-radius: 10px;
  background: #229ed9;
  color: #ffffff;
  font-weight: 700;
}

.secondaryButton {
  min-height: 34px;
  border: 1px solid rgba(15, 23, 42, 0.1);
  border-radius: 8px;
  background: #f7fafc;
  color: #243247;
  padding: 6px 10px;
}

.errorText {
  min-height: 18px;
  margin: 0;
  color: #d92d20;
  font-size: 13px;
}

.chatShell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  height: calc(100dvh - 24px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  min-height: 520px;
  overflow: hidden;
}

.chatHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
}

.chatHeader strong,
.chatHeader span {
  display: block;
}

.chatHeader span {
  margin-top: 2px;
  color: #6b7585;
  font-size: 12px;
}

.messageViewport {
  min-height: 0;
  overflow: auto;
  background: #f5f8fb;
  scrollbar-width: none;
  padding: 10px 0;
}

.messageViewport::-webkit-scrollbar {
  display: none;
}

.loadOlder {
  display: block;
  margin: 0 auto 8px;
  border: 0;
  background: transparent;
  color: #0f6f9c;
  font-size: 13px;
}

.messageList {
  display: grid;
  gap: 8px;
}

.messageRow {
  display: flex;
  padding: 0 12px;
}

.messageRow.mine {
  justify-content: flex-end;
}

.bubble,
.postCard {
  max-width: min(78%, 520px);
  border: 0;
  border-radius: 14px;
  background: #ffffff;
  color: #172033;
  text-align: left;
  padding: 10px 12px;
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.06);
}

.messageRow.mine .bubble {
  background: #229ed9;
  color: #ffffff;
}

.bubble p,
.postCard p {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.5;
}

.mediaGrid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  margin-top: 8px;
  max-width: 260px;
}

.mediaGrid.single {
  grid-template-columns: minmax(0, 180px);
}

.mediaGrid.two,
.mediaGrid.four {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  max-width: 180px;
}

.mediaGrid img,
.mediaGrid video {
  width: 100%;
  border-radius: 8px;
  background: #0f172a;
  object-fit: cover;
}

.mediaGrid img {
  aspect-ratio: 1;
}

.mediaGrid video {
  height: auto;
}

.postCard {
  display: grid;
  gap: 8px;
  width: min(78%, 420px);
}

.postCard strong {
  color: #0f6f9c;
}

.postCard p {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.composer {
  display: grid;
  gap: 8px;
  padding: 10px;
  border-top: 1px solid rgba(15, 23, 42, 0.08);
  background: #ffffff;
}

.toolbar {
  display: flex;
  gap: 8px;
}

.toolButton {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  border: 1px solid rgba(15, 23, 42, 0.1);
  border-radius: 8px;
  background: #f7fafc;
  color: #243247;
  padding: 6px 10px;
  font-size: 13px;
}

.toolButton input {
  position: absolute;
  inset: 0;
  opacity: 0;
}

.composer textarea {
  min-height: 48px;
  max-height: 140px;
  resize: vertical;
}

.attachmentList {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 56px));
  gap: 6px;
}

.attachmentItem {
  position: relative;
  aspect-ratio: 1;
  border-radius: 8px;
  overflow: hidden;
  background: #0f172a;
}

.attachmentItem img,
.attachmentItem video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.attachmentItem button {
  position: absolute;
  top: 4px;
  right: 4px;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
}

.uploadState {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px 10px;
  color: #6b7585;
  font-size: 12px;
}

.uploadState span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.uploadState div {
  grid-column: 1 / -1;
  height: 4px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.08);
}

.uploadState i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: #229ed9;
}

.postModal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 16px;
}

.modalBackdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(15, 23, 42, 0.62);
}

.postPanel {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 14px;
  width: min(92vw, 560px);
  max-height: 88vh;
  overflow: auto;
  border-radius: 14px;
  background: #ffffff;
  padding: 16px;
}

.postPanel header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.postPanel header button {
  border: 0;
  border-radius: 8px;
  background: #f1f5f9;
  padding: 8px 10px;
}

.postPanel p {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.6;
}

.postPanel .mediaGrid {
  max-width: none;
}

@media (max-width: 640px) {
  .seatApp {
    padding: 0;
  }

  .connectPanel,
  .chatShell {
    width: 100%;
    height: 100dvh;
    min-height: 100dvh;
    border: 0;
    border-radius: 0;
  }
}
