#meeting-actions, .guest-actions, .meeting-head, .meeting-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}
#meeting-actions { margin: 0 0 14px; }
#meeting-actions .primary, .guest-actions .primary, #meeting-chat button {
  width: auto;
  flex: none;
  padding-inline: 14px;
  margin: 0;
}
#meeting-presence { font-size: 14px; font-weight: 650; color: var(--pine); }
.meeting-head > :first-child { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.meeting-head h2 { font-size: 20px; letter-spacing: -.6px; }
.meeting-head small { color: var(--muted); font-weight: 600; }
#meeting-clock, #guest-time { font-variant-numeric: tabular-nums; }
#meeting {
  width: min(1500px, 96vw);
  height: 94dvh;
  max-width: none;
  max-height: none;
  overflow: hidden;
  padding: 0;
  border-radius: 20px;
}
.meeting-shell { display: flex; flex-direction: column; height: 100%; }
.meeting-head { padding: 16px 20px; }
.meeting-content {
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(285px, 30%, 330px);
  flex: 1;
  min-height: 0;
  border-block: 1px solid var(--line);
}
#meeting-grid {
  overflow: auto;
  background: var(--map-bg);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(210px, 100%), 1fr));
  grid-auto-rows: max-content;
  gap: 12px;
  padding: 16px;
  align-content: safe center;
  justify-items: center;
}
#meeting-grid:has(.presenting) { align-content: start; }
.meeting-tile.presenting { align-self: start; }
.meeting-tile {
  position: relative;
  align-self: center;
  display: grid;
  place-items: center;
  width: min(100%, 46vh);
  aspect-ratio: 1;
  background: #40574e;
  border: 1px solid #ffffff24;
  border-radius: 16px;
  overflow: hidden;
  isolation: isolate;
  color: white;
}
.meeting-tile canvas, .meeting-tile video { position: absolute; width: 100%; height: 100%; object-fit: cover; }
.meeting-tile canvas { width: 82%; height: 82%; top: 4%; }
.meeting-tile span {
  position: absolute;
  bottom: 10px;
  left: 10px;
  max-width: calc(100% - 20px);
  background: #12231ede;
  padding: 6px 10px;
  border-radius: 9px;
  font-size: 13px;
  overflow-wrap: anywhere;
}
.meeting-tile.name-only span { position: static; background: none; font-size: 18px; text-align: center; }
.meeting-tile.presenting {
  grid-column: 1 / -1;
  order: -1;
  width: 100%;
  aspect-ratio: 16/9;
  background: #0d1613;
}
.meeting-tile.presenting video { object-fit: contain; }
.meeting-tile.speaking::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 0 3px #91edbc, inset 0 0 22px #58e7a047;
  pointer-events: none;
}
.speaker-mark { display: none; }
.speaking .speaker-mark, #meeting-speakers {
  display: flex;
  align-items: center;
  position: absolute;
  left: 12px;
  top: 12px;
  border-radius: 18px;
  background: #91edbc;
  color: #0b3828;
  padding: 8px;
  font-size: 14px;
  font-weight: 700;
  pointer-events: none;
}
.speaking:has(.raised-hand:not([hidden])) .speaker-mark { left: 54px; }
.speaker-mark::before, #meeting-speakers::before {
  content: '';
  flex: none;
  width: 18px;
  height: 18px;
  background: currentColor;
  clip-path: polygon(0 35%, 15% 35%, 15% 65%, 0 65%, 0 35%, 29% 35%, 29% 10%, 43% 10%, 43% 90%, 29% 90%, 29% 35%, 57% 35%, 57% 21%, 71% 21%, 71% 79%, 57% 79%, 57% 35%, 85% 35%, 85% 65%, 100% 65%, 100% 35%);
}
.expanded-share .speaker-mark { display: none; }
#meeting-speakers { gap: 7px; max-width: calc(100% - 80px); padding-inline: 12px; overflow-wrap: anywhere; }
#meeting-chat { display: flex; flex-direction: column; min-height: 0; padding: 16px; gap: 12px; }
#meeting-chat h3 { font-size: 16px; }
#meeting-log { flex: 1; overflow: auto; overflow-wrap: anywhere; font-size: 14px; }
#meeting-log p { margin-bottom: 14px; white-space: pre-wrap; }
#meeting-log strong { display: block; color: var(--pine); font-size: 13px; margin-bottom: 3px; }
#meeting-chat form { display: flex; align-items: center; gap: 6px; }
#meeting-chat input { min-width: 0; margin: 0; }
#meeting-status:not(:empty) { padding: 10px 16px 0; color: var(--danger); text-align: center; }
.meeting-controls { justify-content: center; padding: 14px; }
#meeting button {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: none;
  padding: 0;
  border-radius: 50%;
}
#meeting button .icon { width: 21px; height: 21px; }
#meeting-chat #meeting-attach, #meeting-chat #meeting-remove { width: 36px; height: 36px; min-height: 36px; }
#meeting #meeting-chat #meeting-send { padding: 0; }
#meeting-draft { display: flex; align-items: center; gap: 8px; background: var(--subtle); border-radius: 10px; padding: 6px; }
#meeting-draft img { max-width: 68px; max-height: 44px; border-radius: 6px; }
#meeting-draft span { flex: 1; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#meeting #meeting-log .meeting-image {
  display: block;
  width: fit-content;
  height: auto;
  max-width: 100%;
  margin-top: 5px;
  border-radius: 9px;
  background: var(--subtle);
  overflow: hidden;
  font-size: 13px;
}
.meeting-image img { display: block; max-width: 100%; }
#meeting-image-viewer { width: fit-content; max-width: 96vw; padding: 0; }
#meeting-image-viewer img { display: block; max-width: 95vw; max-height: 78dvh; object-fit: contain; }
#meeting-image-viewer .meeting-head { padding: 10px 14px; }
@media (max-width: 760px) {
  #meeting-chat:has(#meeting-draft:not([hidden])) h3 { display: none; }
}
.meeting-controls button {
  background: var(--accent-soft);
  color: var(--pine);
  border: 1px solid var(--accent-line);
}
.meeting-controls button[aria-pressed="true"] {
  background: var(--primary-bg);
  color: var(--primary-ink);
  border-color: var(--primary-line);
}
.meeting-controls button:hover { filter: brightness(.94); }
#meeting-end { background: #a53e32; border-color: #a53e32; color: white; }
#meeting-hand[aria-pressed="true"], #meeting-hands > div { background: #ffdf95; color: #503406; border-color: #e7bb61; }
.raised-hand {
  position: absolute;
  z-index: 2;
  top: 12px;
  left: 12px;
  color: #ffdf95;
  width: 26px;
  height: 26px;
}
.meeting-tile:has(.raised-hand:not([hidden])) { box-shadow: inset 0 0 0 3px #ffdf95; border-color: #ffdf95; }
.meeting-tile:has(.raised-hand:not([hidden]))::before {
  content: '';
  position: absolute;
  z-index: 1;
  top: 5px;
  left: 5px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #12231eeb;
}
.expand-share {
  position: absolute;
  top: 10px;
  right: 10px;
  background: #12231ee8;
  color: white;
  border: 1px solid #ffffff55;
}
.expand-share:hover { background: #304d39; }
#meeting.expanded-share {
  width: 100vw;
  height: 100dvh;
  border: 0;
  border-radius: 0;
  background: #0d1613;
}
.expanded-share .meeting-head, .expanded-share #meeting-chat, #meeting-bubbles { display: none; }
.expanded-share .meeting-content { display: block; position: relative; border: 0; }
.expanded-share #meeting-grid { display: block; height: 100%; padding: 0; overflow: hidden; }
.expanded-share .meeting-tile.presenting { height: 100%; aspect-ratio: auto; border: 0; border-radius: 0; }
.expanded-share .meeting-controls { background: var(--paper); }
.expanded-share #meeting-status:not(:empty) { color: #ffe2c4; }
.expanded-share #meeting-bubbles {
  position: absolute;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 8px;
  bottom: 14px;
  right: 14px;
  width: min(330px, calc(100% - 28px));
  max-height: calc(100% - 76px);
  pointer-events: none;
}
#meeting-hands, #meeting-messages { display: grid; grid-template-columns: minmax(0, 1fr); justify-items: end; gap: 6px; overflow: auto; pointer-events: auto; }
#meeting-hands > div, #meeting #meeting-messages button {
  display: flex;
  gap: 8px;
  align-items: center;
  text-align: left;
  height: auto;
  min-height: 38px;
  border: 0;
  border-radius: 15px;
  padding: 10px 14px;
  width: fit-content;
  max-width: 100%;
  overflow-wrap: anywhere;
  font-size: 14px;
  font-weight: 650;
}
#meeting #meeting-messages button {
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  color: #fff;
  background: #192c25f5;
  border: 1px solid #ffffff42;
  font-weight: 400;
}
#meeting-messages strong { color: #c7e6b6; }
#meeting-messages span { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
#guest-invite { width: min(450px, 94vw); }
#guest-invite .meeting-head { padding: 0; }
#guest-invite p, #guest-entry p { line-height: 1.5; color: var(--muted); font-size: 14px; margin: 14px 0; }
#guest-invite #guest-revoke { color: var(--danger); }
.guest-page { display: grid; place-items: center; padding: 16px; background: var(--accent-soft); }
#guest-entry { width: min(420px, 100%); background: var(--paper); padding: 32px; border-radius: 20px; box-shadow: 0 12px 60px #14271a14; }
#guest-entry h1 { margin-top: 12px; font-size: 28px; }
#guest-entry button, #guest-create { width: 100%; }
@media (max-width: 760px) {
  #meeting { width: 100vw; height: 100dvh; border: 0; border-radius: 0; }
  .meeting-head, .meeting-controls { gap: 6px; padding: 10px; }
  .meeting-head h2 { font-size: 17px; }
  .meeting-content { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) minmax(126px, 34%); }
  #meeting-grid { grid-template-columns: repeat(auto-fit, minmax(min(130px, 100%), 1fr)); gap: 7px; padding: 8px; }
  #meeting-chat { padding: 8px 12px; gap: 5px; }
  #meeting .meeting-controls button { width: 40px; height: 40px; }
}
