:root {
  --bg: #071116;
  --bg-2: #0d1b22;
  --panel: rgba(13, 23, 31, 0.76);
  --panel-strong: rgba(17, 31, 40, 0.92);
  --line: rgba(140, 185, 201, 0.14);
  --line-strong: rgba(140, 185, 201, 0.28);
  --text: #ecf6f8;
  --muted: #93a9b2;
  --accent: #2ce3c6;
  --accent-2: #86ffe0;
  --accent-soft: rgba(44, 227, 198, 0.12);
  --danger: #ff7b7b;
  --shadow: 0 30px 80px rgba(0, 0, 0, 0.42);
  --radius: 24px;
  --radius-sm: 16px;
  font-family: "Noto Sans SC", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 15% 20%, rgba(44, 227, 198, 0.18), transparent 24%),
    radial-gradient(circle at 85% 18%, rgba(96, 146, 255, 0.18), transparent 22%),
    linear-gradient(160deg, var(--bg) 0%, var(--bg-2) 45%, #09131a 100%);
  overflow-x: hidden;
  overflow-y: auto;
}

body, button, input, textarea {
  font-family: "Noto Sans SC", system-ui, sans-serif;
}

.bg-grid,
.bg-glow {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

.bg-grid {
  background-image:
    linear-gradient(rgba(255,255,255,0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.04) 1px, transparent 1px);
  background-size: 32px 32px;
  mask-image: linear-gradient(to bottom, rgba(0,0,0,0.6), transparent 80%);
  opacity: 0.22;
}

.bg-glow {
  filter: blur(80px);
  opacity: 0.6;
}

.glow-a {
  background: radial-gradient(circle at 20% 20%, rgba(44, 227, 198, 0.18), transparent 24%);
}

.glow-b {
  background: radial-gradient(circle at 80% 28%, rgba(120, 130, 255, 0.16), transparent 22%);
}

.app-shell {
  width: min(1240px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 32px;
  display: grid;
  place-items: center;
  position: relative;
  z-index: 1;
}

.glass-card {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
}

.join-panel,
.chat-panel {
  width: 100%;
  border-radius: var(--radius);
  overflow: hidden;
}

.join-panel {
  max-width: 1200px;
  padding: clamp(24px, 4vw, 42px);
}

.join-layout {
  display: grid;
  grid-template-columns: 1.15fr 0.95fr;
  gap: 28px;
  align-items: stretch;
}

.join-copy,
.join-console {
  min-width: 0;
}

.brand-row {
  display: flex;
  gap: 18px;
  align-items: center;
}

.brand-mark {
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  background: linear-gradient(145deg, rgba(44, 227, 198, 0.18), rgba(44, 227, 198, 0.05));
  border: 1px solid rgba(134, 255, 224, 0.26);
  color: var(--accent-2);
  font-family: "JetBrains Mono", monospace;
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: 0.05em;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent-2);
  font-family: "JetBrains Mono", monospace;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

h1, h2 {
  margin: 0;
  letter-spacing: -0.03em;
}

h1 {
  font-size: clamp(2.7rem, 6vw, 5.4rem);
  line-height: 0.94;
}

h2 {
  font-size: clamp(1.35rem, 2.8vw, 2rem);
}

.lead {
  max-width: 60ch;
  margin: 24px 0 28px;
  color: var(--muted);
  font-size: 1.02rem;
  line-height: 1.9;
}

.feature-stack {
  display: grid;
  gap: 14px;
}

.feature-card,
.security-notes div {
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: var(--radius-sm);
  padding: 16px 18px;
}

.feature-card strong,
.security-notes strong {
  display: block;
  font-size: 0.96rem;
  color: var(--text);
}

.feature-card span,
.security-notes span {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  line-height: 1.6;
  font-size: 0.92rem;
}

.join-console {
  background: var(--panel-strong);
  border: 1px solid var(--line-strong);
  border-radius: 28px;
  padding: 18px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.04);
}

.console-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 4px 18px;
}

.console-dot {
  width: 11px;
  height: 11px;
  border-radius: 999px;
  display: inline-block;
}

.console-dot.red { background: #ff6a6a; }
.console-dot.yellow { background: #ffd15b; }
.console-dot.green { background: #53e8a8; }

.console-title {
  margin-left: 8px;
  color: var(--muted);
  font-family: "JetBrains Mono", monospace;
  font-size: 0.82rem;
}

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

label {
  display: grid;
  gap: 8px;
  min-width: 0;
}

label span {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
}

input,
textarea,
button {
  font: inherit;
}

input,
textarea {
  width: 100%;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 16px;
  background: rgba(255,255,255,0.03);
  color: var(--text);
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

input::placeholder,
textarea::placeholder {
  color: rgba(236,246,248,0.28);
}

input {
  height: 48px;
  padding: 0 15px;
}

textarea {
  min-height: 54px;
  max-height: 180px;
  resize: none;
  padding: 14px 15px;
  line-height: 1.5;
}

input:focus,
textarea:focus {
  border-color: rgba(44, 227, 198, 0.45);
  background: rgba(255,255,255,0.05);
  box-shadow: 0 0 0 4px rgba(44, 227, 198, 0.12);
}

.primary-button,
.send-button,
.ghost-button,
.icon-button {
  border-radius: 16px;
  border: 1px solid transparent;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.16s ease, background 0.2s ease, border-color 0.2s ease;
}

.primary-button,
.send-button {
  background: linear-gradient(135deg, #2ce3c6, #13bfa3);
  color: #032118;
}

.primary-button:hover,
.send-button:hover {
  transform: translateY(-1px);
  background: linear-gradient(135deg, #53ecd2, #20ceb1);
}

.primary-button {
  height: 52px;
  margin-top: 4px;
}

.security-notes {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.chat-panel {
  height: min(900px, calc(100vh - 64px));
  display: grid;
  grid-template-rows: auto auto auto 1fr auto;
}

.hidden { display: none; }

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 22px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,0.02);
}

.room-meta {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.voice-status {
  margin: 6px 0 0;
  color: var(--accent-2);
  font-size: 0.86rem;
}

.video-status {
  margin: 6px 0 0;
  color: #9ec7ff;
  font-size: 0.84rem;
}

.voice-participant-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
}

.voice-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.04);
  color: var(--text);
  font-size: 0.82rem;
  line-height: 1;
}

.voice-pill.muted {
  color: var(--muted);
  border-color: rgba(255, 123, 123, 0.24);
  background: rgba(255, 123, 123, 0.08);
}

.voice-pill.speaking {
  border-color: rgba(44, 227, 198, 0.36);
  background: rgba(44, 227, 198, 0.14);
  box-shadow: 0 0 0 1px rgba(44, 227, 198, 0.12) inset;
}

.media-stage {
  padding: 14px 22px 0;
}

.media-stage.hidden {
  display: none !important;
}

.media-video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
}

.video-tile {
  position: relative;
  min-height: 160px;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.035);
}

.video-tile video {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  background: #050b0f;
}

.video-placeholder {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-weight: 800;
  text-align: center;
  padding: 18px;
}

.video-tile.camera-off video {
  display: none;
}

.video-meta {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 10px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(0,0,0,0.5);
  color: var(--text);
  font-size: 0.8rem;
  backdrop-filter: blur(10px);
}

.video-meta span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.icon-button,
.ghost-button {
  height: 44px;
  background: rgba(255,255,255,0.04);
  border-color: rgba(255,255,255,0.08);
  color: var(--text);
}

.icon-button {
  width: 44px;
  display: grid;
  place-items: center;
}

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

.icon-button:hover,
.ghost-button:hover {
  transform: translateY(-1px);
  background: rgba(44, 227, 198, 0.10);
  border-color: rgba(44, 227, 198, 0.22);
}

.ghost-button {
  padding: 0 14px;
}

.file-button {
  position: relative;
  cursor: pointer;
}

.file-button input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.status-bar {
  min-height: 34px;
  padding: 10px 22px 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.status-bar.error {
  color: var(--danger);
}

.message-list {
  min-height: 0;
  margin: 0;
  padding: 18px 22px 22px;
  list-style: none;
  overflow-y: auto;
}

.message {
  display: flex;
  margin: 12px 0;
}

.message.own {
  justify-content: flex-end;
}

.message-bubble {
  max-width: min(700px, 86%);
  border-radius: 20px;
  border: 1px solid rgba(255,255,255,0.06);
  background: rgba(255,255,255,0.04);
  padding: 12px 14px;
}

.message.own .message-bubble {
  background: linear-gradient(135deg, rgba(44, 227, 198, 0.22), rgba(44, 227, 198, 0.08));
  border-color: rgba(44, 227, 198, 0.18);
}

.message.system .message-bubble {
  max-width: 100%;
  width: 100%;
  background: rgba(255,255,255,0.02);
  border-style: dashed;
}

.message-head {
  display: flex;
  gap: 12px;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 6px;
}

.message-name {
  font-weight: 800;
  overflow-wrap: anywhere;
}

.message-time {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 0.76rem;
  font-family: "JetBrains Mono", monospace;
}

.message-text {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.6;
}

.message-attachment {
  margin-top: 10px;
  display: grid;
  gap: 10px;
}

.attachment-image {
  width: min(320px, 100%);
  max-height: 260px;
  object-fit: cover;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.03);
}

.attachment-download {
  color: var(--accent-2);
  text-decoration: none;
  font-weight: 700;
}

.attachment-download:hover {
  text-decoration: underline;
}

.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: end;
  padding: 16px 22px 22px;
  border-top: 1px solid var(--line);
  background: rgba(255,255,255,0.02);
  transition: background 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.composer.dragover {
  background: rgba(44, 227, 198, 0.08);
  box-shadow: inset 0 0 0 1px rgba(44, 227, 198, 0.24);
}

.composer-main {
  display: grid;
  gap: 10px;
}

.composer-tools {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.attach-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 14px;
  background: rgba(255,255,255,0.04);
  color: var(--text);
  cursor: pointer;
}

.attach-button:hover {
  background: rgba(44, 227, 198, 0.10);
  border-color: rgba(44, 227, 198, 0.22);
}

.attach-button svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.attach-button input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.attachment-meta {
  color: var(--muted);
  font-size: 0.85rem;
}

.send-button {
  min-width: 92px;
  height: 52px;
  padding: 0 20px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

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

  .security-notes {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .app-shell {
    padding: 0;
    place-items: stretch;
  }

  .join-panel,
  .chat-panel {
    min-height: 100vh;
    border-radius: 0;
  }

  .join-panel {
    padding: 20px;
  }

  .chat-panel {
    min-height: 100vh;
    height: auto;
    overflow: visible;
  }

  .chat-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .header-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .voice-participant-list {
    width: 100%;
    justify-content: flex-start;
  }

  .ghost-button {
    margin-left: 0;
  }

  .media-stage {
    padding-inline: 14px;
  }

  .video-frame {
    min-height: 56vh;
    height: 56vh;
  }

  .media-video-grid {
    grid-template-columns: 1fr;
  }

  .message-bubble {
    max-width: 94%;
  }

  .message-list {
    max-height: none;
    overflow-y: visible;
  }

  .composer {
    grid-template-columns: 1fr;
  }

  .send-button {
    width: 100%;
  }
}
