:root {
  color-scheme: dark;
  font-family:
    Inter, "Segoe UI", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  --bg: #0b1016;
  --surface: #131b24;
  --surface-2: #1b2632;
  --line: #2c3a49;
  --text: #f2f6f9;
  --muted: #9fb0c0;
  --accent: #20c997;
  --accent-strong: #12a97d;
  --danger: #ed5f65;
  --warning: #f3b64d;
  background: var(--bg);
  color: var(--text);
}

* {
  box-sizing: border-box;
}

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

body {
  min-height: 100vh;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 12% 8%, rgba(32, 201, 151, 0.12), transparent 32rem),
    linear-gradient(145deg, #0b1016 0%, #0e1720 50%, #111923 100%);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

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

[hidden] {
  display: none !important;
}

.join-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.join-panel {
  width: min(100%, 440px);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(19, 27, 36, 0.94);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.34);
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 28px;
}

.brand-mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--accent);
  color: #06251c;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.06em;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 22px;
  font-weight: 750;
}

.brand-lockup p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 14px;
}

.join-form {
  display: grid;
  gap: 18px;
}

.join-form label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

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

.join-form input {
  min-height: 48px;
  padding: 0 14px;
}

.join-form input:focus,
.chat-form input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(32, 201, 151, 0.13);
}

.join-form button,
.chat-form button {
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #06251c;
  font-weight: 800;
}

.join-form button {
  min-height: 48px;
  margin-top: 2px;
}

.join-form button:hover,
.chat-form button:hover {
  background: var(--accent-strong);
}

.form-error {
  min-height: 20px;
  color: #ff8b90;
  font-size: 13px;
}

.meeting-view {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
}

.meeting-header {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(11, 16, 22, 0.88);
  backdrop-filter: blur(12px);
}

.meeting-label {
  display: block;
  margin-bottom: 2px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

#current-room {
  display: block;
  max-width: min(52vw, 680px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.meeting-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.connection-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--warning);
  font-size: 13px;
  font-weight: 700;
}

.connection-status::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.connection-status.connected {
  color: var(--accent);
}

.connection-status.disconnected {
  color: var(--danger);
}

.secondary-button {
  min-height: 38px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
}

.secondary-button:hover {
  border-color: #4b6075;
}

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

.stage {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  padding: 16px;
  gap: 14px;
}

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

.video-tile {
  position: relative;
  min-width: 0;
  min-height: 220px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #070b10;
}

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

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

.video-placeholder {
  position: absolute;
  inset: 0;
  display: none;
  place-items: center;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.video-tile.audio-only .video-placeholder {
  display: grid;
}

.video-tile footer {
  position: absolute;
  right: 10px;
  bottom: 10px;
  left: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 9px;
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 6px;
  background: rgba(4, 8, 12, 0.72);
  backdrop-filter: blur(8px);
  font-size: 12px;
}

.video-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 750;
}

.video-state {
  flex: 0 0 auto;
  color: var(--muted);
}

.call-controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 9px;
}

.control-button {
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.control-button.active {
  border-color: rgba(32, 201, 151, 0.62);
  background: rgba(32, 201, 151, 0.14);
  color: #6ee7bd;
}

.control-button.danger {
  border-color: rgba(237, 95, 101, 0.55);
  color: #ff989c;
}

.side-panel {
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  border-left: 1px solid var(--line);
  background: rgba(19, 27, 36, 0.86);
}

.participant-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 15px 16px 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.participant-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 16px 14px;
  border-bottom: 1px solid var(--line);
}

.participant-chip {
  max-width: 100%;
  overflow: hidden;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.participant-chip.self {
  border-color: rgba(32, 201, 151, 0.48);
  color: #70e5be;
}

.chat-panel {
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.chat-panel header {
  padding: 14px 16px 10px;
}

.chat-panel h2 {
  font-size: 14px;
}

.chat-messages {
  min-height: 0;
  overflow-y: auto;
  padding: 0 16px 12px;
  scrollbar-color: #405265 transparent;
}

.chat-empty {
  padding: 18px 0;
  color: var(--muted);
  font-size: 13px;
}

.chat-message {
  padding: 8px 0;
  border-top: 1px solid rgba(44, 58, 73, 0.7);
}

.chat-message:first-child {
  border-top: 0;
}

.chat-message header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 0;
  margin-bottom: 4px;
}

.chat-message strong {
  overflow: hidden;
  color: #c7d4df;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-message time {
  flex: 0 0 auto;
  color: #74879a;
  font-size: 10px;
}

.chat-message p {
  color: var(--text);
  font-size: 13px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

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

.chat-form input {
  min-height: 40px;
  padding: 0 11px;
}

.chat-form button {
  min-width: 64px;
  padding: 0 12px;
}

@media (max-width: 980px) {
  .meeting-layout {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr) minmax(280px, 42vh);
  }

  .side-panel {
    border-top: 1px solid var(--line);
    border-left: 0;
  }
}

@media (max-width: 640px) {
  .meeting-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .meeting-actions {
    width: 100%;
    justify-content: space-between;
  }

  .stage {
    padding: 10px;
  }

  .video-grid {
    grid-template-columns: 1fr;
    grid-auto-rows: minmax(200px, 1fr);
  }

  .call-controls {
    justify-content: stretch;
  }

  .control-button {
    flex: 1 1 calc(50% - 9px);
  }
}
