/* The call fills the screen; home keeps its own warm, spacious composition. */
body.in-call {
  overflow: hidden;
  --call-bottom: max(90px, calc(env(safe-area-inset-bottom) + 80px));
}
body.in-call .toast {
  bottom: calc(var(--call-bottom) + 20px);
}
.call {
  position: fixed;
  inset: 0;
  z-index: 5;
  width: 100%;
  height: 100dvh;
  max-width: none;
  margin: 0;
  padding: 0;
  overflow: hidden;
}
.call .call-body {
  position: absolute;
  inset: 0;
  display: block;
  width: auto;
  height: auto;
  min-height: 0;
  max-height: none;
  transition: right 0.3s ease;
}
.call .stage {
  width: 100%;
  height: 100%;
  border-radius: 0;
  box-shadow: none;
}
.call.has-remote .stage {
  background: #111612;
}
.call .call-heading {
  position: absolute;
  z-index: 6;
  top: 0;
  left: 0;
  right: 0;
  margin: 0;
  padding: max(14px, env(safe-area-inset-top))
    max(18px, env(safe-area-inset-right)) 35px
    max(18px, env(safe-area-inset-left));
  align-items: center;
  gap: 12px;
  pointer-events: none;
  background: linear-gradient(#e9e9dce8, #e9e9dc00);
  transition: right 0.3s ease;
}
.call .call-heading > div:first-child {
  min-width: 0;
}
.call .call-heading h1 {
  max-width: min(65vw, 780px);
  font-size: 17px;
  line-height: 1.25;
  letter-spacing: -0.3px;
}
.call .call-heading .eyebrow {
  margin-bottom: 5px;
  font-size: 8px;
  letter-spacing: 1px;
}
.call .call-heading-actions {
  gap: 12px;
}
.call .call-heading button {
  pointer-events: auto;
  min-height: 40px;
  padding: 9px 12px;
  font-size: 11px;
  white-space: nowrap;
}
.call.has-remote .call-heading {
  color: #fff;
  background: linear-gradient(#111612ad, #11161200);
}
.call.has-remote .call-heading .eyebrow,
.call.has-remote .time-left {
  color: #e2e6d5;
}
.call.has-remote .call-heading .soft-button {
  background: #1b231bcc;
  color: #fff;
  border-color: #ffffff26;
  backdrop-filter: blur(12px);
}
.call .tiles {
  grid-template-columns: 1fr;
  grid-auto-rows: minmax(0, 1fr);
  gap: 8px;
  padding: 0;
}
.call .tiles .tile {
  border-radius: 0;
}
.call .tiles[data-remote-count="1"] .tile video {
  object-fit: contain;
  background: #111612;
}
.call .tiles[data-remote-count="2"],
.call .tiles[data-remote-count="3"],
.call .tiles[data-remote-count="4"] {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.call .tiles[data-remote-count="3"] .tile.first-remote {
  grid-column: 1 / -1;
}
.call .tiles[data-remote-count="5"],
.call .tiles[data-remote-count="6"],
.call .tiles[data-remote-count="7"] {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.call.has-remote .tile .tile-label {
  left: max(18px, env(safe-area-inset-left));
  bottom: var(--call-bottom);
}
.call .enable-sound,
.call .call-banner {
  top: auto;
  bottom: var(--call-bottom);
  max-width: calc(100% - 32px);
}
.call .enable-sound {
  min-height: 44px;
}
.call:has(.enable-sound:not([hidden])) .call-banner {
  bottom: calc(var(--call-bottom) + 64px);
}
.call .call-bottom {
  position: absolute;
  z-index: 7;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 7px;
  min-height: 0;
  margin: 0;
  padding: 12px 12px max(12px, env(safe-area-inset-bottom));
  pointer-events: none;
  transition: right 0.3s ease;
}
.call .call-controls {
  pointer-events: auto;
  padding: 5px;
  gap: 2px;
  border-radius: 20px;
  background: #faf8efd9;
  backdrop-filter: blur(18px);
  box-shadow: 0 4px 25px #0002;
}
.call .control {
  min-width: 46px;
  min-height: 48px;
  padding: 6px 7px;
  gap: 4px;
}
.call .control-label {
  font-size: 9px;
}
.call .control-divider {
  margin: 0 2px;
}
.call .bell-wrap {
  position: static;
  pointer-events: auto;
}
.call .bell-wrap > span {
  display: none;
}
.call .bell {
  width: 44px;
  height: 54px;
}
.call .waiting {
  padding: 95px 20px 130px;
}
.call .waiting img {
  height: clamp(160px, 28vh, 290px);
  max-height: 48%;
}
.call .self-view {
  visibility: hidden;
  position: absolute;
  z-index: 8;
  top: 0;
  left: 0;
  width: clamp(104px, 24vw, 160px);
  aspect-ratio: 4 / 3;
  border: 1px solid #ffffff60;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 4px 22px #0005;
  touch-action: none;
  user-select: none;
  cursor: grab;
  transition:
    transform 280ms cubic-bezier(0.2, 0.8, 0.2, 1),
    width 280ms ease;
}
.call .self-view.positioned {
  visibility: visible;
}
.call .self-view.dragging {
  cursor: grabbing;
  transition: none;
}
.call .self-view:focus-visible {
  outline: 3px solid #c5dda1;
  outline-offset: 3px;
}
.call .self-view .tile {
  width: 100%;
  height: 100%;
  border-radius: 0;
  animation: none;
}
.call .self-view video {
  transform: none;
}
.call .self-view .mirrored video {
  transform: scaleX(-1);
}
.call .self-view .tile .tile-label {
  left: 7px;
  right: 7px;
  bottom: 7px;
  flex-direction: row;
  align-items: center;
  gap: 4px;
  pointer-events: none;
}
.call .self-view .name {
  font-size: 10px;
  padding: 3px 7px;
}
.call .self-view .attention {
  font-size: 9px;
  padding: 3px 5px;
}
.call .self-view .buddy img {
  max-height: 68%;
}
.call .tile video {
  transition: opacity 180ms ease;
}
.call .chat {
  display: none;
  position: absolute;
  z-index: 12;
  inset: auto auto var(--call-bottom) max(12px, env(safe-area-inset-left));
  width: min(360px, calc(var(--visible-width, 100vw) - 24px));
  height: min(360px, 44dvh);
  max-height: calc(var(--visible-height, 100dvh) - 130px);
  min-height: 0;
  color: #f6f8f0;
  background: #18251ebd;
  border: 1px solid #ffffff36;
  border-radius: 20px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 8px 32px #0003;
  transform: none;
  visibility: visible;
}
.call .chat.open {
  display: flex;
  animation: chat-appear 150ms ease-out;
}
.call #chat-button,
.call #close-chat {
  display: flex;
}
.call .chat-heading {
  padding: 9px 12px 9px 16px;
  border-color: #ffffff1f;
  min-height: 46px;
}
.call .chat-heading h2 {
  color: #fff;
}
.call .chat-heading .icon-button {
  color: #fff;
  width: 36px;
  height: 36px;
  min-height: 36px;
}
.call .messages {
  padding: 12px;
  scrollbar-color: #ffffff70 transparent;
}
.call .chat-empty {
  color: #f1f5e9c9;
  padding-top: 8px;
}
.call .message {
  margin-bottom: 10px;
}
.call .message-meta {
  color: #e8f0dfb5;
}
.call .message-body {
  background: #ffffff1f;
  color: #fff;
}
.call .message.mine .message-body {
  background: #72895980;
  color: #fff;
}
.call .chat-form {
  margin: 0 10px 8px;
  border-color: #ffffff45;
  background: #0e181dc2;
}
.call .chat-form textarea {
  font-size: 16px;
  color: #fff;
}
.call .chat-form textarea::placeholder {
  color: #e6ecdeba;
}
.call .chat-form:focus-within {
  border-color: #c4dda2;
}
.call .chat-footnote {
  color: #e6ecdeb5;
  margin: 0 6px 9px;
}
.call:has(.chat.open) .stage {
  filter: none;
}
.call.keyboard-open .chat {
  bottom: calc(var(--keyboard-inset) + 8px);
  height: min(280px, calc(var(--visible-height) * 0.7));
  max-height: calc(var(--visible-height) - 20px);
}
.call.keyboard-open .chat-footnote {
  display: none;
}
.call .chat-peek {
  position: absolute;
  z-index: 9;
  left: max(12px, env(safe-area-inset-left));
  bottom: calc(var(--call-bottom) + 8px);
  width: min(320px, calc(100% - 24px));
  display: flex;
  flex-direction: column;
  gap: 7px;
  pointer-events: none;
}
.call .chat-notice {
  display: block;
  width: 100%;
  min-height: 44px;
  padding: 10px 13px;
  border: 1px solid #ffffff2e;
  border-radius: 15px;
  background: #18251ea8;
  color: white;
  text-align: left;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  pointer-events: auto;
  animation: chat-appear 150ms ease-out;
}
.call .chat-notice-name {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: #e0edcc;
  margin-bottom: 3px;
}
.call .chat-notice-body {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  font-size: 14px;
  line-height: 1.4;
}
.call .control[aria-busy="true"] .control-icon {
  opacity: 0.45;
}
@keyframes chat-appear {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
@media (orientation: portrait) and (max-width: 760px) {
  .call .self-view {
    aspect-ratio: 3 / 4;
  }
}
@media (max-width: 760px) {
  .call .call-heading {
    padding-left: max(14px, env(safe-area-inset-left));
    padding-right: max(14px, env(safe-area-inset-right));
  }
  .call .call-heading h1 {
    max-width: calc(100vw - 140px);
    font-size: 15px;
  }
  .call .call-heading-actions {
    gap: 0;
  }
  .call .control {
    min-width: 43px;
    padding: 6px;
  }
  .call .control-icon {
    width: 20px;
    height: 20px;
  }
  .call .tiles[data-remote-count="2"] {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 380px) {
  .call .call-bottom {
    gap: 3px;
    padding-left: 5px;
    padding-right: 5px;
  }
  .call .call-controls {
    gap: 0;
    padding: 4px;
  }
  .call .control {
    width: 40px;
    min-width: 40px;
    padding: 5px 3px;
  }
  .call .control-label {
    font-size: 8px;
  }
  .call .control-divider {
    display: none;
  }
  .call .bell {
    width: 40px;
  }
}
@media (max-height: 500px) and (min-width: 600px) {
  body.in-call {
    --call-bottom: 80px;
  }
  .call .call-heading .eyebrow {
    display: none;
  }
  .call .waiting {
    padding: 65px 20px 80px;
  }
  .call .waiting img {
    height: 170px;
    max-height: 100%;
  }
}
@media (prefers-reduced-motion: reduce) {
  .call :is(.call-body, .call-heading, .call-bottom, .self-view, .tile video) {
    transition: none;
  }
}

.call.entering :is(.call-bottom, .call-heading-actions) {
  visibility: hidden;
}

/* The last-minute reminder stays with the heading, above the call controls. */
.call.ending-soon .call-heading {
  flex-wrap: wrap;
}
.call .call-countdown {
  flex: 0 0 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  color: #37432d;
  background: #f7f5e9f5;
  border: 1px solid #9aab773d;
  border-radius: 16px;
  box-shadow: 0 4px 18px #11161212;
  backdrop-filter: blur(12px);
}
.call .countdown-copy {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 8px;
  font-size: 11px;
}
.call .countdown-copy strong {
  font-size: 22px;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.5px;
  line-height: 1;
}
.call .call-countdown #extend-button {
  flex: 0 0 auto;
  min-height: 44px;
  color: #344329;
  background: #e5eccf;
  border-color: #a4b77a5c;
}
.call .countdown-note {
  max-width: 120px;
  font-size: 10px;
  line-height: 1.35;
  text-align: right;
}
@media (max-width: 380px) {
  .call .call-countdown {
    gap: 8px;
    padding: 8px 10px;
  }
  .call .countdown-copy {
    max-width: 105px;
  }
}
