body {
  margin: 0;
  /* iPad fix: use dynamic viewport height so footer isn't hidden */
  height: 100dvh;
  min-height: 100dvh;

  display: grid;
  grid-template-rows: auto 1fr auto;
  font: 14px/1.45 system-ui, Segoe UI, Arial;
}

header,
footer {
  padding: .6rem .8rem;
  background: #0f1730;
  color: #e8eefc;
}

main {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 0px;
  padding: 0px;
  background: #0b1020;
  color: #e8eefc;

  /* ensure the grid child can shrink and scroll within the 1fr row */
  min-height: 0;
  overflow: auto;
}

#panel {
  background: #0d142b;
  border: 0px solid #223055;
  border-radius: 10px;
  padding: 0px;
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: 10px;
  min-height: 0;
}

input,
button {
  padding: .45rem .6rem;
  border-radius: 8px;
  border: 1px solid #2b3b61;
  background: #122048;
  color: #e8eefc;
}

button.primary {
  background: #17436b;
  border-color: #246ea8;
  font-weight: 700;
}

#micBtn.talking {
  background: #2c5a2c;
  border-color: #3f8f3f;
}

/* Chat area (scrollable) */
#logWrap {
  min-height: 0;
  /* allow child to size */
  background: #0d142b;
  border: 1px solid #223055;
  border-radius: 8px;
  padding: .5rem;
  display: flex;
  flex-direction: column;
}

#log {
  overflow: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Chat bubbles */
.bubble {
  max-width: 78%;
  padding: .5rem .65rem;
  border: 1px solid #223055;
  border-radius: 12px;
  background: #0f1b36;
  color: #e8eefc;
  line-height: 1.4;
  word-break: break-word;
}

.bubble .meta {
  font-size: 12px;
  opacity: .8;
  margin-bottom: 2px;
}

.bubble .name {
  font-weight: 700;
  margin-right: 6px;
}

.bubble.self {
  margin-left: auto;
  background: #13325a;
  border-color: #2b5b9a;
}

.bubble.system {
  margin: 0 auto;
  background: #101a34;
  border-style: dashed;
  color: #cfe2ff;
}

/* Side panels */
#side {
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 10px;
  min-height: 0;
}

.card {
  background: #0d142b;
  border: 1px solid #223055;
  border-radius: 10px;
  padding: 10px;
}

#peerList {
  margin-top: 6px;
  font-family: monospace;
  white-space: pre-wrap;
}