:root {
  --bg: #0f172a;
  --card: #111827;
  --line: #243041;
  --text: #f8fafc;
  --muted: #94a3b8;
  --primary: #2563eb;
  --danger: #dc2626;
  --success: #22c55e;
  --warning: #ef4444;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Inter, Arial, sans-serif;
  background: linear-gradient(180deg, #0b1220, #151922);
  color: var(--text);
}

.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 32px 16px;
}

.container.wide {
  max-width: 1680px;
}

.hidden {
  display: none !important;
}

.card {
  background: rgba(17, 24, 39, 0.96);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 24px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.25);
}

.join-card {
  margin-bottom: 20px;
}

.layout-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 20px;
  align-items: start;
}

.meeting-card {
  min-height: 620px;
  padding-top: 18px;
}

.chat-card {
  min-height: 620px;
  display: flex;
  flex-direction: column;
}

h1 {
  margin-top: 0;
  font-size: 28px;
}

h2 {
  margin-top: 0;
}

.muted {
  color: var(--muted);
  line-height: 1.55;
}

.btn {
  border: 0;
  border-radius: 12px;
  padding: 12px 16px;
  cursor: pointer;
  font-size: 15px;
}

.btn.primary {
  background: var(--primary);
  color: white;
}

.btn.danger {
  background: var(--danger);
  color: white;
}

.btn:disabled,
.icon-btn:disabled,
.toggle-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
}

.gap-top {
  margin-top: 12px;
}

input[type="text"] {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #0b1220;
  color: white;
}

.form-grid {
  display: grid;
  gap: 12px;
  margin: 16px 0;
}

label span {
  display: block;
  margin-bottom: 8px;
}

.status {
  margin: 14px 0 0;
  color: #cbd5e1;
}

.prejoin-media-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.toggle-btn {
  border: 1px solid var(--line);
  background: #111c33;
  color: white;
  border-radius: 14px;
  padding: 12px 14px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  min-height: 48px;
}

.toggle-btn.active {
  border-color: #355cae;
  background: #13274f;
}

.toggle-btn.inactive {
  border-color: #4b5563;
  background: #1f2937;
  color: #cbd5e1;
}

.icon-wrap {
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.icon {
  width: 22px;
  height: 22px;
  display: none;
  object-fit: contain;
}

.toggle-btn.active .icon-mic-on,
.toggle-btn.active .icon-cam-on {
  display: block;
}

.toggle-btn.inactive .icon-mic-off,
.toggle-btn.inactive .icon-cam-off {
  display: block;
}

.meeting-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.meeting-title-wrap {
  min-width: 0;
}

.meeting-title {
  font-size: 18px;
  font-weight: 700;
}

.meeting-room-name {
  color: var(--muted);
  font-size: 14px;
  margin-top: 4px;
  word-break: break-word;
}

.meeting-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.icon-btn {
  width: 50px;
  height: 50px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #1f2937;
  color: white;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.icon-btn .icon {
  display: none;
  width: 22px;
  height: 22px;
  object-fit: contain;
}

.icon-btn:not(.is-off) .icon-mic-on,
.icon-btn:not(.is-off) .icon-cam-on {
  display: block;
}

.icon-btn.is-off .icon-mic-off,
.icon-btn.is-off .icon-cam-off {
  display: block;
}

.icon-btn.is-off {
  border-color: #7f1d1d;
  background: #3a1111;
  color: #fecaca;
}

.meeting-timer {
  min-width: 74px;
  text-align: center;
  font-size: 18px;
  font-weight: 700;
  color: #93c5fd;
  padding: 0 6px;
}

.leave-inline-btn {
  min-height: 50px;
}

.videos {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(460px, 1fr));
  gap: 20px;
}

.video-tile {
  background: #0b1220;
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
  min-height: 420px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.video-tile.speaking {
  border-color: var(--success);
  box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.35);
  transform: translateY(-2px);
}

.video-tile.mic-muted {
  border-color: var(--warning);
  box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.25);
}

.video-label-row {
  padding: 10px 12px;
  font-size: 14px;
  color: #cbd5e1;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.video-label {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.participant-state-icons {
  display: flex;
  align-items: center;
  gap: 8px;
}

.state-icon {
  width: 18px;
  height: 18px;
  display: none;
}

.state-icon img {
  width: 18px;
  height: 18px;
  display: block;
  object-fit: contain;
}

.video-tile.mic-muted .state-mic-off {
  display: block;
}

.video-tile.cam-muted .state-cam-off {
  display: block;
}

.media-slot {
  min-height: 360px;
  height: 560px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #020617;
  position: relative;
  overflow: hidden;
}

.media-slot video {
  width: 100%;
  height: 100%;
  min-height: 360px;
  object-fit: cover;
}

.media-slot .local-video {
  transform: scaleX(-1);
}

.avatar-placeholder {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1d4ed8, #3b82f6);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 44px;
  font-weight: 800;
  letter-spacing: 0.02em;
  user-select: none;
}

.hidden-audio {
  width: 0;
  height: 0;
  opacity: 0;
}

.chat-title {
  margin-bottom: 16px;
}

.chat-messages {
  flex: 1;
  min-height: 260px;
  max-height: 620px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #0b1220;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chat-message {
  background: #111827;
  border: 1px solid #223046;
  border-radius: 12px;
  padding: 10px 12px;
}

.chat-message.own {
  background: #102143;
  border-color: #274b8f;
}

.chat-author {
  font-size: 12px;
  color: #93c5fd;
  margin-bottom: 6px;
  font-weight: 700;
}

.chat-text {
  font-size: 14px;
  line-height: 1.45;
  color: #f8fafc;
  word-break: break-word;
}

.chat-form {
  margin-top: 14px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

@media (max-width: 1200px) {
  .layout-grid {
    grid-template-columns: 1fr;
  }

  .chat-card {
    min-height: auto;
  }

  .chat-messages {
    max-height: 320px;
  }
}

@media (max-width: 900px) {
  .videos {
    grid-template-columns: 1fr;
  }

  .media-slot {
    height: 460px;
    min-height: 320px;
  }

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

@media (max-width: 720px) {
  .container {
    padding: 20px 12px;
  }

  h1 {
    font-size: 24px;
  }

  .chat-form {
    grid-template-columns: 1fr;
  }

  .prejoin-media-row {
    flex-direction: column;
  }

  .toggle-btn {
    width: 100%;
    justify-content: flex-start;
  }

  .meeting-topbar {
    align-items: stretch;
  }

  .meeting-controls {
    width: 100%;
  }

  .meeting-timer {
    order: 10;
    width: 100%;
    text-align: left;
    padding: 6px 0 0;
  }

  .media-slot {
    height: 420px;
    min-height: 300px;
  }

  .video-tile {
    min-height: 340px;
  }
}