/* ═══════════════════════════ RESET & BASE ═══ */

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --blue: #0071e3;
  --black: #1d1d1f;
  --white: #ffffff;
  --g1: #f5f5f7;
  --g2: #e8e8ed;
  --g3: #86868b;
  --border: rgba(0, 0, 0, 0.08);
  --r-tile: 16px;

  /*
    flat: 거의 선처럼 보이는 상태
    cue: 입 주변만 보이는 상태
    open: speaker처럼 전체가 보이는 상태
  */
  --flat-clip: inset(48% 0 48% 0 round var(--r-tile));
  --cue-clip: inset(54% 0 14% 0 round var(--r-tile));
  --open-clip: inset(0 0 0 0 round var(--r-tile));

  font-family: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  -webkit-font-smoothing: antialiased;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #fff;
  color: var(--black);
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

/* ═══════════════════════════ JOIN SCREEN ═══ */

#join-screen {
  width: 100vw;
  height: 100vh;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  height: 52px;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 0.5px solid var(--border);
}

.logo {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.nav-r {
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-tag {
  font-size: 0.72rem;
  font-weight: 400;
  color: var(--g3);
  background: var(--g1);
  border-radius: 6px;
  padding: 4px 10px;
}

.nav-link-plain {
  font-size: 0.8rem;
  font-weight: 400;
  color: #555;
  text-decoration: none;
  padding: 6px 12px;
  border-radius: 8px;
  transition: background 0.15s;
}

.nav-link-plain:hover {
  background: var(--g1);
  color: var(--black);
}

.btn-nav-plain,
.btn-join-hero,
.btn-join {
  background: var(--blue);
  color: #fff;
  border-radius: 999px;
  font-weight: 500;
  letter-spacing: -0.01em;
  transition: background 0.2s, transform 0.15s;
}

.btn-nav-plain {
  padding: 7px 18px;
  font-size: 0.8rem;
}

.btn-nav-plain:hover,
.btn-join-hero:hover,
.btn-join:hover {
  background: #0077ed;
}

.join-center {
  position: relative;
  z-index: 10;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.join-eyebrow {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--blue);
  margin-bottom: 10px;
  letter-spacing: 0.01em;
}

.join-title {
  font-size: clamp(2.4rem, 4vw, 3.6rem);
  font-weight: 600;
  line-height: 1.07;
  letter-spacing: -0.04em;
  margin-bottom: 12px;
}

.join-sub {
  font-size: 0.95rem;
  font-weight: 400;
  color: var(--g3);
  line-height: 1.6;
  max-width: 320px;
  margin-bottom: 28px;
  text-align: center;
}

.hero-btns {
  display: flex;
  gap: 10px;
  align-items: center;
}

.btn-join-hero {
  padding: 13px 26px;
  font-size: 0.88rem;
}

.btn-join-hero:hover {
  transform: scale(1.02);
}

.btn-learn {
  padding: 13px 22px;
  background: var(--g1);
  color: var(--black);
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 500;
  transition: background 0.2s;
  letter-spacing: -0.01em;
}

.btn-learn:hover {
  background: var(--g2);
}

/* Landing bubbles */
.bubble {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.bcircle {
  border-radius: 50%;
  overflow: hidden;
  position: relative;
  flex-shrink: 0;
}

.bcircle svg {
  display: block;
  width: 100%;
  height: 100%;
}

.bpill {
  background: #fff;
  border-radius: 999px;
  padding: 4px 11px;
  font-size: 0.62rem;
  font-weight: 500;
  color: var(--black);
  white-space: nowrap;
  letter-spacing: -0.01em;
  box-shadow:
    0 2px 8px rgba(0, 0, 0, 0.09),
    0 0 0 0.5px rgba(0, 0, 0, 0.05);
}

.you-pill {
  background: var(--black);
  color: #fff;
}

/* SVG avatar colors */
.bw1 .av-bg { fill: #eef3ff; }
.bw1 .av-head,
.bw1 .av-body { fill: #b8cef7; }

.bw2 .av-bg { fill: #f3eeff; }
.bw2 .av-head,
.bw2 .av-body { fill: #c8a8f0; }

.bw3 .av-bg { fill: #edfaf3; }
.bw3 .av-head,
.bw3 .av-body { fill: #80d4a8; }

.bw4 .av-bg { fill: #fdf8ee; }
.bw4 .av-head,
.bw4 .av-body { fill: #e8c060; }

.bw5 .av-bg { fill: #fff0f5; }
.bw5 .av-head,
.bw5 .av-body { fill: #f0a0c0; }

.bw6 .av-bg { fill: #edfbff; }
.bw6 .av-head,
.bw6 .av-body { fill: #60cce0; }

.bw-you .av-bg { fill: #f0f0f0; }
.bw-you .av-head,
.bw-you .av-body { fill: #888; }

.bw1 {
  top: 10%;
  left: 6%;
  opacity: 0;
  animation:
    bIn 0.55s cubic-bezier(0.34, 1.4, 0.64, 1) 0.5s forwards,
    flt1 8s ease-in-out 1.3s infinite;
}

.bw1 .bcircle {
  width: 114px;
  height: 114px;
  background: #eef3ff;
  box-shadow: 0 10px 32px rgba(80, 120, 255, 0.1);
}

.bw2 {
  top: 6%;
  right: 13%;
  opacity: 0;
  animation:
    bIn 0.55s cubic-bezier(0.34, 1.4, 0.64, 1) 0.63s forwards,
    flt2 9s ease-in-out 1.7s infinite;
}

.bw2 .bcircle {
  width: 88px;
  height: 88px;
  background: #f3eeff;
  box-shadow: 0 8px 24px rgba(130, 80, 255, 0.09);
}

.bw3 {
  top: 44%;
  left: 3%;
  opacity: 0;
  animation:
    bIn 0.55s cubic-bezier(0.34, 1.4, 0.64, 1) 0.76s forwards,
    flt3 10s ease-in-out 2.1s infinite;
}

.bw3 .bcircle {
  width: 104px;
  height: 104px;
  background: #edfaf3;
  box-shadow: 0 8px 28px rgba(40, 180, 100, 0.09);
}

.bw4 {
  top: 57%;
  right: 7%;
  opacity: 0;
  animation:
    bIn 0.55s cubic-bezier(0.34, 1.4, 0.64, 1) 0.84s forwards,
    flt4 7s ease-in-out 1.1s infinite;
}

.bw4 .bcircle {
  width: 80px;
  height: 80px;
  background: #fdf8ee;
  box-shadow: 0 6px 20px rgba(210, 160, 30, 0.1);
}

.bw5 {
  bottom: 12%;
  left: 11%;
  opacity: 0;
  animation:
    bIn 0.55s cubic-bezier(0.34, 1.4, 0.64, 1) 0.92s forwards,
    flt5 9s ease-in-out 1.9s infinite;
}

.bw5 .bcircle {
  width: 92px;
  height: 92px;
  background: #fff0f5;
  box-shadow: 0 7px 24px rgba(220, 70, 110, 0.08);
}

.bw6 {
  bottom: 8%;
  right: 16%;
  opacity: 0;
  animation:
    bIn 0.55s cubic-bezier(0.34, 1.4, 0.64, 1) 0.98s forwards,
    flt2 8s ease-in-out 2.3s infinite;
}

.bw6 .bcircle {
  width: 84px;
  height: 84px;
  background: #edfbff;
  box-shadow: 0 6px 22px rgba(20, 170, 210, 0.09);
}

.bw-you {
  top: 10%;
  right: 24%;
  z-index: 5;
  opacity: 0;
  animation:
    bIn 0.65s cubic-bezier(0.34, 1.4, 0.64, 1) 0.57s forwards,
    flt3 10s ease-in-out 2s infinite;
}

.bw-you .bcircle {
  width: 148px;
  height: 148px;
  background: #fff;
  box-shadow:
    0 24px 60px rgba(0, 0, 0, 0.12),
    0 4px 16px rgba(0, 0, 0, 0.05);
  outline: 1.5px solid var(--black);
}

/* Landing chips */
.chips {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 4px;

  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);

  border: 0.5px solid rgba(0, 0, 0, 0.08);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.06);

  z-index: 30;
}

.chip {
  display: flex;
  align-items: center;
  gap: 5px;

  padding: 4px 8px;
  border-radius: 999px;

  font-size: 0.64rem;
  font-weight: 500;
  color: #86868b;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.chip + .chip {
  border-left: 0.5px solid rgba(0, 0, 0, 0.07);
  border-radius: 0;
}

.cd {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.you-rings {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  pointer-events: none;
  z-index: -1;
}

.wring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.06);
  opacity: 0;
  animation: wave 3.2s ease-out infinite;
}

.wring:nth-child(2) {
  animation-delay: 1.07s;
}

.wring:nth-child(3) {
  animation-delay: 2.13s;
}

@keyframes wave {
  0% {
    transform: scale(1);
    opacity: 0.5;
  }
  100% {
    transform: scale(1.9);
    opacity: 0;
  }
}

@keyframes flt1 {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

@keyframes flt2 {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-13px); }
}

@keyframes flt3 {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

@keyframes flt4 {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-11px); }
}

@keyframes flt5 {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-9px); }
}

@keyframes bIn {
  from {
    opacity: 0;
    transform: scale(0.75) translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* ═══════════════════════════ MODAL ═══ */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0.25);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.modal-card {
  background: #fff;
  border-radius: 20px;
  width: 360px;
  box-shadow:
    0 32px 80px rgba(0, 0, 0, 0.16),
    0 4px 20px rgba(0, 0, 0, 0.07);
  transform: scale(0.93) translateY(12px);
  transition: transform 0.3s cubic-bezier(0.34, 1.35, 0.64, 1);
  overflow: hidden;
}

.modal-overlay.open .modal-card {
  transform: scale(1) translateY(0);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 20px 0;
}

.modal-title {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.modal-close {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--g1);
  color: var(--g3);
  font-size: 1.1rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

.modal-close:hover {
  background: var(--g2);
}

.modal-body {
  padding: 16px 20px 22px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.field-label {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--g3);
  letter-spacing: 0.01em;
}

.modal-body input {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--g2);
  border-radius: 10px;
  font-family: inherit;
  font-size: 0.9rem;
  color: var(--black);
  background: #fff;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.modal-body input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.1);
}

.modal-body input::placeholder {
  color: #c0c0c5;
}

.btn-join {
  width: 100%;
  padding: 13px;
  margin-top: 2px;
  font-size: 0.88rem;
}

.btn-join:active {
  transform: scale(0.98);
}

.btn-join:disabled {
  opacity: 0.5;
  cursor: default;
  transform: none;
}

.join-error {
  font-size: 0.74rem;
  color: #ff3b30;
  min-height: 0.8em;
  text-align: center;
}

/* ═══════════════════════════ MEETING SCREEN ═══ */

#meeting-screen {
  width: 100vw;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: #fff;
}

.topbar {
  height: 52px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 0.5px solid var(--border);
  position: relative;
  z-index: 20;
}

.tb-left,
.tb-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.tb-center {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

.meeting-name,
.participant-count {
  font-size: 0.72rem;
  font-weight: 400;
  color: var(--g3);
  background: var(--g1);
  border-radius: 6px;
  padding: 4px 10px;
}

.mode-pill {
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(16px);
  border: 0.5px solid var(--border);
  border-radius: 999px;
  padding: 4px;
  display: flex;
  gap: 2px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.mode-btn {
  font-size: 0.72rem;
  font-weight: 500;
  padding: 5px 14px;
  border-radius: 999px;
  color: var(--g3);
  transition: background 0.2s, color 0.2s;
}

.mode-btn.sel {
  background: #fff;
  color: var(--black);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}

.tb-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  background: var(--g1);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 0.76rem;
  font-weight: 500;
  color: var(--g3);
  transition: background 0.2s;
}

.tb-btn:hover {
  background: var(--g2);
}

/* ═══════════════════════════ TILE CONTAINER ═══ */

#tiles-container {
  flex: 1;
  display: grid;
  gap: clamp(18px, 2.1vw, 34px);
  padding: clamp(18px, 2.2vw, 36px);
  perspective: 1200px;
  perspective-origin: 50% 52%;
  overflow: hidden;
  position: relative;
  transition: background 0.4s;

  align-items: center;
  justify-items: center;
  align-content: center;
  justify-content: center;
}

#tiles-container.n1 {
  grid-template-columns: minmax(320px, min(78vw, 1100px));
}

#tiles-container.n2 {
  grid-template-columns: repeat(2, minmax(300px, min(42vw, 620px)));
}

#tiles-container.n3 {
  grid-template-columns: repeat(3, minmax(240px, min(30vw, 480px)));
}

#tiles-container.n4 {
  grid-template-columns: repeat(2, minmax(280px, min(38vw, 540px)));
}

#tiles-container.n5,
#tiles-container.n6 {
  grid-template-columns: repeat(3, minmax(230px, min(29vw, 430px)));
}

#tiles-container.n7,
#tiles-container.n8,
#tiles-container.n9 {
  grid-template-columns: repeat(3, minmax(210px, min(28vw, 380px)));
}

#tiles-container.n10,
#tiles-container.n11,
#tiles-container.n12 {
  grid-template-columns: repeat(4, minmax(170px, min(22vw, 310px)));
}

#tiles-container.nmax {
  grid-template-columns: repeat(5, minmax(140px, min(18vw, 240px)));
}

#tiles-container.circle-mode {
  display: block;
  background: #fff;
  perspective: none;
}

/* ═══════════════════════════ TILE BASE ═══ */

.tile {
  --tile-ar: 16 / 9;
  --cue-pull-x: 0;
  --cue-pull-y: 0;

  width: 100%;
  aspect-ratio: var(--tile-ar, 16 / 9);

  background: var(--g1);
  border-radius: var(--r-tile);
  border: 1.5px solid transparent;
  overflow: hidden;
  position: relative;

  display: flex;
  align-items: center;
  justify-content: center;

  min-width: 0;
  min-height: 0;

  clip-path: var(--flat-clip);
  transform: perspective(900px) rotateX(62deg);
  transform-origin: center center;

  transition:
    clip-path 0.48s cubic-bezier(0.18, 0.92, 0.2, 1),
    transform 0.48s cubic-bezier(0.18, 0.92, 0.2, 1),
    border-color 0.26s ease,
    box-shadow 0.26s ease,
    background 0.26s ease;

  will-change: transform, clip-path;
}

#tiles-container.n1 .tile {
  width: min(78vw, 1120px);
  max-height: calc(100vh - 170px);
}

#tiles-container:not(.n1):not(.circle-mode) .tile {
  max-height: calc((100vh - 170px) / 2.15);
}

.video-wrap {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: inherit;
}

.tile-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
  background: #ddd;
  position: absolute;
  inset: 0;
}

.tile-video.mirrored {
  transform: scaleX(-1);
}

/* ═══════════════════════════ CENTER REVEAL ═══ */

.tile.center-expand {
  clip-path: var(--cue-clip);
  transform: perspective(900px) rotateX(0deg);
  z-index: 5;
}

.tile.speaker {
  clip-path: var(--open-clip);
  transform: perspective(900px) rotateX(0deg);
  z-index: 6;
}

.tile.expand-pulse {
  border-color: rgba(0, 113, 227, 0.32);
}

.tile.pre-gaze {
  border-color: rgba(168, 190, 238, 0.52);
}

.tile.pre-lean {
  border-color: rgba(29, 29, 31, 0.42);
}

.tile.pre-gaze.center-expand {
  transform:
    translate(
      calc(var(--cue-pull-x, 0) * 6px),
      calc(var(--cue-pull-y, 0) * 6px)
    )
    perspective(900px)
    rotateX(0deg);
}

.tile.pre-lean.center-expand {
  transform:
    perspective(900px)
    rotateX(0deg)
    translateY(-3px);
}

.tile.mouth-open:not(.center-expand):not(.speaker) {
  border-color: rgba(209, 209, 214, 0.5);
}

.tile.leaning,
.tile.gaze-pull {
  transform: perspective(900px) rotateX(62deg);
  box-shadow: none;
}

/* ═══════════════════════════ SPEAKER ═══ */

.tile.speaker {
  border-color: var(--blue);
  background: #fff;
  box-shadow: none;
}

.tile.held-speaker {
  clip-path: var(--open-clip);
  transform: perspective(900px) rotateX(0deg);
  border-color: rgba(0, 113, 227, 0.24);
  background: #fff;
  box-shadow: none;
}

.speaker-ring {
  display: none !important;
}

/* ═══════════════════════════ TILE UI ═══ */

.tile-name {
  position: absolute;
  bottom: 10px;
  left: 10px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(8px);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 0.58rem;
  font-weight: 500;
  color: var(--black);
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.09);
  white-space: nowrap;
  max-width: calc(100% - 20px);
  overflow: hidden;
  text-overflow: ellipsis;
  z-index: 8;
}

.tile.speaker .tile-name {
  background: var(--blue);
  color: #fff;
}

.tile-cam-off {
  position: absolute;
  inset: 0;
  background: var(--g1);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 8px;
  z-index: 6;
}

.tile-cam-off svg {
  opacity: 0.3;
}

.tile-cam-off span {
  font-size: 0.65rem;
  color: var(--g3);
}

.mute-badge {
  position: absolute;
  bottom: 10px;
  right: 10px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(255, 59, 48, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9;
}

.cue-dots {
  position: absolute;
  bottom: 10px;
  right: 10px;
  display: flex;
  gap: 4px;
  align-items: center;
  z-index: 10;
}

.cue-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.13);
  transition:
    background 0.2s,
    transform 0.2s,
    box-shadow 0.2s;
}

.cue-dot:nth-child(1).active {
  background: #d1d1d6;
  transform: scale(1.35);
}

.cue-dot:nth-child(2).active {
  background: #a8beee;
  transform: scale(1.35);
}

.cue-dot:nth-child(3).active {
  background: #1d1d1f;
  transform: scale(1.35);
}

.tile.speaker .cue-dots {
  display: flex;
}

/* ═══════════════════════════ CIRCLE MODE ═══ */

.circle-mode .tile {
  position: absolute !important;
  border-radius: 50% !important;
  width: var(--circle-size) !important;
  height: var(--circle-size) !important;
  aspect-ratio: 1 / 1 !important;

  clip-path: inset(0 0 0 0 round 50%) !important;
  transform: none !important;

  border-color: transparent !important;
  box-shadow: 0 6px 26px rgba(0, 0, 0, 0.08) !important;

  transition:
    left 0.58s cubic-bezier(0.22, 0.9, 0.26, 1),
    top 0.58s cubic-bezier(0.22, 0.9, 0.26, 1),
    width 0.34s ease,
    height 0.34s ease !important;
}

.circle-mode .tile.outer-ring {
  z-index: 3;
}

.circle-mode .tile.inner-ring {
  z-index: 2;
}

.circle-mode .tile-name {
  bottom: 6%;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.52rem;
  padding: 2px 8px;
}

.circle-mode .cue-dots {
  display: none;
}

/* ═══════════════════════════ LEFT MESSAGE ═══ */

.left-msg {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: #fff;
  z-index: 50;
}

.left-msg p {
  font-size: 1.2rem;
  font-weight: 500;
  color: var(--black);
}

.left-msg a {
  font-size: 0.85rem;
  color: var(--blue);
  text-decoration: none;
}

/* ═══════════════════════════ BOTTOM BAR ═══ */

.bottombar {
  height: 72px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: saturate(180%) blur(20px);
  border-top: 0.5px solid var(--border);
  position: relative;
  z-index: 30;
}

.ctrl {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 10px;
  transition: background 0.15s;
}

.ctrl:hover {
  background: var(--g1);
}

.ctrl-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--g1);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.ctrl-icon.on {
  background: var(--black);
}

.ctrl-icon.red {
  background: #ff3b30;
}

.ctrl-icon.circle-active {
  background: var(--blue);
}

.ctrl-label {
  font-size: 0.58rem;
  font-weight: 500;
  color: var(--g3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.ctrl-label.red {
  color: #ff3b30;
}

.ctrl-div {
  width: 0.5px;
  height: 28px;
  background: var(--border);
  margin: 0 2px;
}

/* ═══════════════════════════ TOAST ═══ */

.toast {
  position: fixed;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--black);
  color: #fff;
  border-radius: 10px;
  padding: 8px 16px;
  font-size: 0.78rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
  z-index: 100;
}

.toast.show {
  opacity: 1;
}

/* ═══════════════════════════ RESPONSIVE ═══ */

@media (max-width: 900px) {
  #tiles-container.n2,
  #tiles-container.n3,
  #tiles-container.n4,
  #tiles-container.n5,
  #tiles-container.n6,
  #tiles-container.n7,
  #tiles-container.n8,
  #tiles-container.n9,
  #tiles-container.n10,
  #tiles-container.n11,
  #tiles-container.n12,
  #tiles-container.nmax {
    grid-template-columns: repeat(2, minmax(150px, 1fr));
  }
}

@media (max-width: 600px) {
  .topbar {
    padding: 0 12px;
  }

  .tb-center {
    display: none;
  }

  #tiles-container {
    gap: 14px;
    padding: 14px;
  }

  #tiles-container.n2,
  #tiles-container.n3,
  #tiles-container.n4,
  #tiles-container.n5,
  #tiles-container.n6,
  #tiles-container.n7,
  #tiles-container.n8,
  #tiles-container.n9,
  #tiles-container.n10,
  #tiles-container.n11,
  #tiles-container.n12,
  #tiles-container.nmax {
    grid-template-columns: 1fr;
  }

  .bottombar {
    height: 66px;
  }

  .ctrl-icon {
    width: 36px;
    height: 36px;
  }
}

/* ═══════════════════════════ NAME FIXED / VIDEO ONLY FOLDS ═══ */

/*
  핵심:
  .tile 전체를 접지 않고,
  .video-wrap만 flat / cue / open 상태로 접고 펼침.
  그래서 .tile-name은 항상 펼쳐진 사각형 기준 bottom-left 위치에 고정됨.
*/

.tile {
  clip-path: none !important;
  transform: none !important;
  overflow: visible !important;
  background: transparent !important;
  border-color: transparent !important;
}

/* 비디오 면만 접히는 실제 surface */
.tile .video-wrap {
  border-radius: var(--r-tile);
  border: 1.5px solid transparent;
  background: var(--g1);
  overflow: hidden;

  clip-path: var(--flat-clip);
  transform: perspective(900px) rotateX(62deg);
  transform-origin: center center;

  transition:
    clip-path 0.48s cubic-bezier(0.18, 0.92, 0.2, 1),
    transform 0.48s cubic-bezier(0.18, 0.92, 0.2, 1),
    border-color 0.26s ease,
    box-shadow 0.26s ease,
    background 0.26s ease;

  will-change: transform, clip-path;
}

/* cue 상태: 입 주변만 열림 */
.tile.center-expand .video-wrap {
  clip-path: var(--cue-clip);
  transform: perspective(900px) rotateX(0deg);
}

/* speaker 상태: 전체 화면 열림 */
.tile.speaker .video-wrap {
  clip-path: var(--open-clip);
  transform: perspective(900px) rotateX(0deg);
  border-color: var(--blue);
  background: #fff;
  box-shadow: none;
}

/* held speaker도 전체 열린 상태 */
.tile.held-speaker .video-wrap {
  clip-path: var(--open-clip);
  transform: perspective(900px) rotateX(0deg);
  border-color: rgba(0, 113, 227, 0.24);
  background: #fff;
  box-shadow: none;
}

/* lip + gaze */
.tile.pre-gaze .video-wrap {
  border-color: rgba(168, 190, 238, 0.52);
}

.tile.pre-gaze.center-expand .video-wrap {
  transform:
    translate(
      calc(var(--cue-pull-x, 0) * 6px),
      calc(var(--cue-pull-y, 0) * 6px)
    )
    perspective(900px)
    rotateX(0deg);
}

/* lip + leaning */
.tile.pre-lean .video-wrap {
  border-color: rgba(29, 29, 31, 0.42);
}

.tile.pre-lean.center-expand .video-wrap {
  transform:
    perspective(900px)
    rotateX(0deg)
    translateY(-3px);
}

/* 이름은 항상 펼쳐진 사각형 기준 위치에 고정 */
.tile-name {
  position: absolute;
  left: 10px !important;
  bottom: 10px !important;
  top: auto !important;
  transform: none !important;
  z-index: 20;
}

/* speaker일 때 이름 색상 유지 */
.tile.speaker .tile-name {
  background: var(--blue);
  color: #fff;
}

/* flat 상태에서도 이름이 잘리지 않게 */
.tile:not(.speaker) .tile-name {
  background: rgba(255, 255, 255, 0.9);
  color: var(--black);
}

/* cue dots도 이름처럼 타일 바깥 기준 위치 유지 */
.cue-dots {
  z-index: 21;
}

/* circle mode에서는 다시 원형 비디오로 */
.circle-mode .tile {
  border-radius: 50% !important;
  overflow: visible !important;
  transform: none !important;
  clip-path: none !important;
}

.circle-mode .tile .video-wrap {
  border-radius: 50% !important;
  clip-path: inset(0 0 0 0 round 50%) !important;
  transform: none !important;
  border-color: transparent !important;
}

.circle-mode .tile-name {
  top: auto !important;
  bottom: 6% !important;
  left: 50% !important;
  transform: translateX(-50%) !important;
  font-size: 0.52rem;
  padding: 2px 8px;
}