:root {
  --bg: #f6f8fb;
  --ink: #111827;
  --muted: #687386;
  --line: #dce3ec;
  --panel: #ffffff;
  --panel-strong: #f9fbfd;
  --canvas: #101820;
  --canvas-soft: #172330;
  --tile: #1e2b38;
  --teal: #22c7b8;
  --teal-strong: #10998d;
  --coral: #ff7a59;
  --coral-strong: #f0522f;
  --danger: #e5484d;
  --shadow: 0 18px 50px rgba(12, 22, 35, 0.14);
  --radius: 8px;
  --dock-height: 86px;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  color: var(--ink);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background:
    linear-gradient(135deg, rgba(34, 199, 184, 0.08), transparent 32%),
    linear-gradient(315deg, rgba(255, 122, 89, 0.09), transparent 30%),
    var(--bg);
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.app-shell {
  min-height: 100vh;
}

.is-hidden {
  display: none !important;
}

.prejoin-view {
  display: grid;
  grid-template-columns: minmax(300px, 420px) minmax(360px, 680px);
  align-items: center;
  justify-content: center;
  gap: clamp(28px, 5vw, 72px);
  min-height: 100vh;
  padding: clamp(22px, 4vw, 56px);
}

.brand-strip {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  flex: 0 0 auto;
  border-radius: 8px;
  background: var(--canvas);
  color: var(--teal);
  font-size: 16px;
  font-weight: 800;
  box-shadow: 0 12px 24px rgba(16, 24, 32, 0.18);
}

.brand-mark.small {
  width: 42px;
  height: 42px;
  font-size: 12px;
  box-shadow: none;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(36px, 5vw, 64px);
  line-height: 0.95;
  letter-spacing: 0;
}

.brand-strip p,
.room-label {
  color: var(--muted);
}

.join-panel {
  width: 100%;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.86);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.join-panel label {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.join-panel input,
.chat-form input {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  outline: none;
  transition:
    border-color 150ms ease,
    box-shadow 150ms ease;
}

.join-panel input {
  height: 48px;
  padding: 0 14px;
  font-size: 16px;
}

.join-panel input:focus,
.chat-form input:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 4px rgba(34, 199, 184, 0.16);
}

.join-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 8px;
}

.primary-action,
.secondary-action,
.ghost-button,
.mini-control,
.dock-button,
.chat-form button,
.drawer-tab {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
}

.primary-action {
  background: var(--teal);
  color: #06221f;
}

.secondary-action {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

.preview-tile {
  position: relative;
  min-height: min(58vh, 520px);
  overflow: hidden;
  border-radius: var(--radius);
  background:
    radial-gradient(circle at 30% 20%, rgba(34, 199, 184, 0.3), transparent 34%),
    linear-gradient(135deg, #1b2a38, #111820 68%);
  box-shadow: var(--shadow);
}

.preview-tile video {
  width: 100%;
  height: 100%;
  min-height: min(58vh, 520px);
  object-fit: cover;
  transform: scaleX(-1);
}

.preview-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #eef7f6;
  font-size: clamp(52px, 10vw, 96px);
  font-weight: 900;
}

.preview-empty.is-hidden {
  display: none;
}

.preview-controls {
  position: absolute;
  right: 16px;
  bottom: 16px;
  display: flex;
  gap: 10px;
}

.mini-control,
.ghost-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 14px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(16, 24, 32, 0.72);
  color: #f8fafc;
}

.mini-control.is-off,
.dock-button.is-off {
  background: rgba(229, 72, 77, 0.14);
  color: #ffd7d8;
}

.meeting-view {
  display: grid;
  grid-template-rows: 72px minmax(0, 1fr) var(--dock-height);
  min-height: 100vh;
  background: var(--canvas);
  color: #f8fafc;
}

.meeting-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(16, 24, 32, 0.96);
}

.room-meta,
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.room-meta h2 {
  max-width: min(44vw, 560px);
  overflow: hidden;
  font-size: 18px;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.room-label {
  font-size: 12px;
  font-weight: 800;
}

.meeting-status {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 12px;
  border-radius: 8px;
  background: rgba(34, 199, 184, 0.12);
  color: #aef2eb;
  font-size: 12px;
  font-weight: 800;
}

.meeting-stage {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  min-height: 0;
}

.video-region {
  min-width: 0;
  min-height: 0;
  padding: 18px;
}

.video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
  grid-auto-rows: minmax(190px, 1fr);
  gap: 12px;
  height: 100%;
}

.video-grid.count-1 {
  grid-template-columns: minmax(0, 1fr);
}

.video-grid.count-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.video-grid.count-3,
.video-grid.count-4 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.video-tile {
  position: relative;
  min-height: 190px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius);
  background:
    radial-gradient(circle at 70% 20%, rgba(255, 122, 89, 0.22), transparent 30%),
    linear-gradient(145deg, #213344, #111820);
}

.video-tile.is-speaking {
  border-color: var(--teal);
  box-shadow: 0 0 0 2px rgba(34, 199, 184, 0.25);
}

.video-tile video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: transparent;
}

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

.video-tile.has-video .avatar {
  display: none;
}

.video-tile:not(.has-video) video {
  display: none;
}

.avatar {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #ecfeff;
  font-size: clamp(34px, 8vw, 82px);
  font-weight: 900;
}

.tile-shade {
  position: absolute;
  inset: auto 0 0;
  height: 42%;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.58));
  pointer-events: none;
}

.tile-footer {
  position: absolute;
  right: 12px;
  bottom: 12px;
  left: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
  color: #fff;
  font-size: 13px;
  font-weight: 800;
}

.tile-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tile-state {
  color: #b8c5d6;
  font-size: 12px;
  white-space: nowrap;
}

.side-drawer {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
  border-left: 1px solid rgba(255, 255, 255, 0.08);
  background: #f8fafc;
  color: var(--ink);
}

.drawer-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
}

.drawer-tab {
  background: transparent;
  color: var(--muted);
}

.drawer-tab.is-active {
  background: var(--canvas);
  color: #fff;
}

.drawer-panel {
  min-height: 0;
}

#chatPanel {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
}

.chat-list,
.participant-list {
  min-height: 0;
  overflow: auto;
  padding: 14px;
}

.chat-message {
  display: grid;
  gap: 4px;
  margin-bottom: 12px;
}

.chat-message strong,
.participant-name {
  font-size: 13px;
}

.chat-message p {
  width: fit-content;
  max-width: 88%;
  padding: 10px 12px;
  border-radius: 8px;
  background: #edf2f7;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.35;
}

.chat-message.is-self {
  justify-items: end;
}

.chat-message.is-self p {
  background: rgba(34, 199, 184, 0.18);
}

.chat-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 46px;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--line);
}

.chat-form input {
  height: 44px;
  padding: 0 12px;
}

.chat-form button {
  display: grid;
  place-items: center;
  background: var(--teal);
  color: #06221f;
}

.participant-row {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.participant-avatar {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: var(--canvas);
  color: var(--teal);
  font-size: 12px;
  font-weight: 900;
}

.participant-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.participant-state {
  color: var(--muted);
  font-size: 12px;
}

.control-dock {
  display: grid;
  grid-template-columns: repeat(7, minmax(76px, 112px));
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(16, 24, 32, 0.98);
}

.dock-button {
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 6px;
  height: 64px;
  padding: 6px;
  background: transparent;
  color: #d9e4ef;
}

.dock-button:hover,
.dock-button.is-active {
  background: rgba(255, 255, 255, 0.08);
}

.dock-button.leave {
  background: var(--danger);
  color: #fff;
}

.icon {
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
}

.icon svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.toast-region {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 30;
  display: grid;
  gap: 10px;
  width: min(360px, calc(100vw - 36px));
}

.toast {
  padding: 12px 14px;
  border: 1px solid rgba(16, 24, 32, 0.12);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  box-shadow: var(--shadow);
  font-size: 14px;
  font-weight: 700;
}

@media (max-width: 980px) {
  .prejoin-view {
    grid-template-columns: 1fr;
    align-content: start;
    padding-top: 32px;
  }

  .preview-tile {
    min-height: 360px;
  }

  .preview-tile video {
    min-height: 360px;
  }

  .meeting-view {
    grid-template-rows: 66px minmax(0, 1fr) 92px;
  }

  .meeting-stage {
    grid-template-columns: 1fr;
  }

  .side-drawer {
    position: fixed;
    right: 10px;
    bottom: 104px;
    z-index: 20;
    width: min(420px, calc(100vw - 20px));
    height: min(520px, calc(100vh - 190px));
    border: 1px solid rgba(16, 24, 32, 0.12);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
  }

  .side-drawer:not(.is-open) {
    display: none;
  }

  .control-dock {
    grid-template-columns: repeat(7, minmax(52px, 1fr));
    overflow-x: auto;
    justify-content: start;
  }

  .dock-button {
    min-width: 62px;
    font-size: 11px;
  }
}

@media (max-width: 680px) {
  .join-actions {
    grid-template-columns: 1fr;
  }

  .meeting-topbar {
    padding: 10px;
  }

  .room-meta h2 {
    max-width: 46vw;
    font-size: 15px;
  }

  .topbar-actions .ghost-button span:last-child {
    display: none;
  }

  .meeting-status {
    display: none;
  }

  .video-region {
    padding: 10px;
  }

  .video-grid,
  .video-grid.count-2,
  .video-grid.count-3,
  .video-grid.count-4 {
    grid-template-columns: 1fr;
    grid-auto-rows: minmax(180px, 1fr);
  }

  .control-dock {
    grid-template-columns: repeat(7, minmax(42px, 1fr));
    gap: 4px;
    overflow: visible;
    padding: 8px 6px;
  }

  .dock-button {
    min-width: 0;
    height: 56px;
    padding: 6px 2px;
    font-size: 0;
  }

  .dock-button .icon {
    width: 22px;
    height: 22px;
  }

  .dock-button .icon svg {
    width: 22px;
    height: 22px;
  }

  .preview-controls {
    right: 10px;
    bottom: 10px;
    left: 10px;
  }

  .mini-control {
    flex: 1;
  }
}
