:root {
  --bg: #070b14;
  --bg-elev: rgba(15, 23, 42, 0.72);
  --bg-card: rgba(17, 25, 44, 0.76);
  --bg-input: rgba(9, 14, 27, 0.85);
  --border: rgba(148, 163, 184, 0.16);
  --border-highlight: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(148, 163, 184, 0.34);
  --text: #f8fafc;
  --text-muted: #94a3b8;
  --accent: #6366f1;
  --accent-2: #8b5cf6;
  --accent-hover: #4f46e5;
  --accent-soft: rgba(99, 102, 241, 0.16);
  --success: #10b981;
  --success-soft: rgba(16, 185, 129, 0.16);
  --warning: #f59e0b;
  --warning-soft: rgba(245, 158, 11, 0.16);
  --danger: #ef4444;
  --danger-soft: rgba(239, 68, 68, 0.16);
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 20px 50px rgba(2, 6, 23, 0.55);
  --font-sans: "Inter", "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", "Fira Code", Consolas, monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* Smooth GPU-accelerated ambient background */
.ambient-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
  background: radial-gradient(ellipse at 50% -20%, rgba(79, 70, 229, 0.22), transparent 60%),
    linear-gradient(180deg, #060913 0%, #090e1c 55%, #060a14 100%);
}

.ambient-orb {
  position: absolute;
  border-radius: 50%;
  opacity: 0.55;
  will-change: transform;
  transform: translate3d(0, 0, 0);
}

.orb-1 {
  width: min(65vw, 760px);
  height: min(65vw, 760px);
  top: -18%;
  left: -14%;
  background: radial-gradient(circle, rgba(99, 102, 241, 0.36) 0%, rgba(139, 92, 246, 0.14) 36%, transparent 70%);
  animation: floatOrb1 24s ease-in-out infinite alternate;
}

.orb-2 {
  width: min(56vw, 680px);
  height: min(56vw, 680px);
  top: 18%;
  right: -14%;
  background: radial-gradient(circle, rgba(16, 185, 129, 0.28) 0%, rgba(6, 182, 212, 0.1) 38%, transparent 70%);
  animation: floatOrb2 28s ease-in-out infinite alternate;
}

.orb-3 {
  width: min(54vw, 640px);
  height: min(54vw, 640px);
  bottom: -20%;
  left: 24%;
  background: radial-gradient(circle, rgba(139, 92, 246, 0.28) 0%, rgba(99, 102, 241, 0.08) 38%, transparent 70%);
  animation: floatOrb3 32s ease-in-out infinite alternate;
}

.ambient-grid {
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(148, 163, 184, 0.14) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: radial-gradient(circle at 50% 30%, rgba(0, 0, 0, 0.7), transparent 85%);
  -webkit-mask-image: radial-gradient(circle at 50% 30%, rgba(0, 0, 0, 0.7), transparent 85%);
}

@keyframes floatOrb1 {
  0% { transform: translate3d(0, 0, 0) scale(1); }
  50% { transform: translate3d(6vw, 5vh, 0) scale(1.08); }
  100% { transform: translate3d(2vw, 10vh, 0) scale(0.96); }
}

@keyframes floatOrb2 {
  0% { transform: translate3d(0, 0, 0) scale(1); }
  50% { transform: translate3d(-7vw, 6vh, 0) scale(1.1); }
  100% { transform: translate3d(-3vw, -6vh, 0) scale(0.95); }
}

@keyframes floatOrb3 {
  0% { transform: translate3d(0, 0, 0) scale(1); }
  50% { transform: translate3d(5vw, -6vh, 0) scale(1.06); }
  100% { transform: translate3d(-6vw, -2vh, 0) scale(0.94); }
}

@media (prefers-reduced-motion: reduce) {
  .ambient-orb {
    animation: none !important;
  }
}

.app-shell {
  position: relative;
  z-index: 1;
  min-height: 100vh;
}

a {
  color: #a5b4fc;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

/* Custom sleek scrollbars */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.25);
  border-radius: 999px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(148, 163, 184, 0.42);
}

/* Header / Navbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px clamp(14px, 3vw, 28px);
  background: rgba(7, 11, 20, 0.88);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.12rem;
  letter-spacing: -0.02em;
  color: var(--text);
  text-decoration: none;
}

.brand:hover {
  text-decoration: none;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #10b981 100%);
  display: grid;
  place-items: center;
  font-weight: 800;
  color: #fff;
  font-size: 0.98rem;
  box-shadow: 0 6px 18px rgba(99, 102, 241, 0.4);
}

/* Buttons & Inputs */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 17px;
  min-height: 39px;
  border-radius: 11px;
  border: 1px solid rgba(148, 163, 184, 0.24);
  background: linear-gradient(180deg, rgba(42, 54, 79, 0.92) 0%, rgba(22, 31, 49, 0.96) 100%);
  color: #f8fafc;
  font-weight: 600;
  font-size: 0.89rem;
  letter-spacing: -0.01em;
  cursor: pointer;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.14),
    inset 0 -1px 0 rgba(2, 6, 23, 0.35),
    0 3px 10px rgba(2, 6, 23, 0.36);
  transition: transform 0.14s cubic-bezier(0.22, 1, 0.36, 1), background 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
  white-space: nowrap;
}

.btn:hover:not(:disabled) {
  background: linear-gradient(180deg, rgba(56, 71, 102, 0.96) 0%, rgba(30, 41, 64, 0.98) 100%);
  border-color: rgba(165, 180, 252, 0.45);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.22),
    0 6px 18px rgba(2, 6, 23, 0.45);
  transform: translateY(-1px);
}

.btn:active:not(:disabled) {
  transform: translateY(1px) scale(0.98);
  box-shadow:
    inset 0 2px 4px rgba(2, 6, 23, 0.45),
    0 1px 3px rgba(2, 6, 23, 0.3);
}

.btn:disabled {
  opacity: 0.48;
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(180deg, #7477ff 0%, #4f46e5 100%);
  border-color: rgba(165, 180, 252, 0.6);
  color: #fff;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.32),
    inset 0 -1px 0 rgba(30, 27, 75, 0.45),
    0 6px 20px -2px rgba(99, 102, 241, 0.48);
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(180deg, #8184ff 0%, #5b52f0 100%);
  border-color: rgba(199, 210, 254, 0.8);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.4),
    0 10px 26px -2px rgba(99, 102, 241, 0.62);
}

.btn-danger {
  background: linear-gradient(180deg, rgba(239, 68, 68, 0.3) 0%, rgba(153, 27, 27, 0.38) 100%);
  border-color: rgba(248, 113, 113, 0.48);
  color: #fecaca;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.16),
    0 4px 14px rgba(127, 29, 29, 0.28);
}

.btn-danger:hover:not(:disabled) {
  background: linear-gradient(180deg, rgba(239, 68, 68, 0.44) 0%, rgba(185, 28, 28, 0.5) 100%);
  border-color: rgba(252, 165, 165, 0.72);
  color: #fff;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.22),
    0 6px 20px rgba(239, 68, 68, 0.35);
}

.btn-success {
  background: linear-gradient(180deg, rgba(16, 185, 129, 0.28) 0%, rgba(6, 95, 70, 0.38) 100%);
  border-color: rgba(52, 211, 153, 0.48);
  color: #a7f3d0;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.16),
    0 4px 14px rgba(6, 95, 70, 0.28);
}

.btn-sm {
  padding: 6px 12px;
  min-height: 32px;
  font-size: 0.81rem;
  border-radius: 9px;
}

.input,
.select,
.textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 13px;
  font-size: 0.94rem;
  outline: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.input:focus,
.select:focus,
.textarea:focus {
  border-color: var(--accent);
  background: rgba(9, 14, 27, 0.96);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.field label {
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--text-muted);
}

.hint {
  font-size: 0.81rem;
  color: var(--text-muted);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--accent-soft);
  color: #c7d2fe;
  border: 1px solid rgba(99, 102, 241, 0.3);
}

.badge-success {
  background: var(--success-soft);
  color: #6ee7b7;
  border-color: rgba(16, 185, 129, 0.35);
}

.badge-warning {
  background: var(--warning-soft);
  color: #fcd34d;
  border-color: rgba(245, 158, 11, 0.35);
}

.badge-danger {
  background: var(--danger-soft);
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.35);
}

/* Landing & Join Layouts */
.container {
  max-width: 1160px;
  margin: 0 auto;
  padding: clamp(18px, 3vw, 36px) clamp(14px, 3vw, 24px) 72px;
}

.hero {
  text-align: center;
  max-width: 760px;
  margin: 14px auto 34px;
}

.hero-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(99, 102, 241, 0.14);
  border: 1px solid rgba(129, 140, 248, 0.32);
  color: #c7d2fe;
  font-size: 0.82rem;
  font-weight: 600;
  margin-bottom: 16px;
}

.hero h1 {
  font-size: clamp(2rem, 4.6vw, 3.35rem);
  line-height: 1.1;
  letter-spacing: -0.035em;
  margin: 0 0 14px;
  background: linear-gradient(135deg, #ffffff 10%, #c7d2fe 55%, #6ee7b7 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero p {
  color: var(--text-muted);
  font-size: clamp(0.98rem, 1.5vw, 1.12rem);
  margin: 0;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr));
  gap: 24px;
}

/* Landing Create / Join Switcher */
.auth-switcher-wrap {
  max-width: 580px;
  margin: 0 auto;
}

.auth-mode-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 5px;
  background: rgba(9, 14, 27, 0.88);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  margin-bottom: 16px;
}

.auth-mode-btn {
  padding: 11px 16px;
  border-radius: 10px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.94rem;
  cursor: pointer;
  transition: background 0.16s ease, color 0.16s ease, box-shadow 0.16s ease;
}

.auth-mode-btn:hover:not(.active) {
  color: var(--text);
  background: rgba(148, 163, 184, 0.08);
}

.auth-mode-btn.active {
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  color: #fff;
  box-shadow: 0 6px 18px rgba(99, 102, 241, 0.36);
}

/* Opening Splash Animation */
.splash-overlay {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: radial-gradient(circle at 50% 40%, rgba(99, 102, 241, 0.24), #060913 70%);
  transition: opacity 0.45s ease, transform 0.45s ease;
  cursor: pointer;
}

.splash-overlay.done {
  opacity: 0;
  transform: scale(1.03);
  pointer-events: none;
}

.splash-mark {
  width: 72px;
  height: 72px;
  border-radius: 20px;
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #10b981 100%);
  display: grid;
  place-items: center;
  font-size: 2.1rem;
  font-weight: 800;
  color: #fff;
  box-shadow: 0 18px 46px rgba(99, 102, 241, 0.5);
  animation: splashLogoIn 0.55s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.splash-title {
  font-size: clamp(2rem, 5vw, 2.8rem);
  font-weight: 800;
  letter-spacing: -0.04em;
  background: linear-gradient(135deg, #ffffff 10%, #c7d2fe 55%, #6ee7b7 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: splashTextUp 0.6s 0.12s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.splash-credit {
  font-size: 0.92rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #94a3b8;
  animation: splashTextUp 0.6s 0.28s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes splashLogoIn {
  from { opacity: 0; transform: scale(0.72) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes splashTextUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  .splash-mark, .splash-title, .splash-credit {
    animation: none !important;
  }
}

.card {
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid var(--border);
  box-shadow: var(--shadow), inset 0 1px 0 var(--border-highlight);
  border-radius: var(--radius);
  padding: clamp(18px, 2.5vw, 26px);
  transition: border-color 0.16s ease;
}

.card:hover {
  border-color: rgba(148, 163, 184, 0.26);
}

.card h2 {
  margin: 0 0 6px;
  font-size: 1.3rem;
  letter-spacing: -0.02em;
}

.card-subtitle {
  margin: 0 0 18px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.feature-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 230px), 1fr));
  gap: 16px;
  margin-top: 32px;
}

.feature-item {
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid var(--border);
  box-shadow: inset 0 1px 0 var(--border-highlight);
  border-radius: var(--radius);
  padding: 18px;
  transition: transform 0.16s ease, border-color 0.16s ease;
}

.feature-item:hover {
  transform: translateY(-2px);
  border-color: rgba(99, 102, 241, 0.35);
}

.feature-item h3 {
  margin: 0 0 6px;
  font-size: 1rem;
}

.feature-item p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.86rem;
}

/* Workspace Shell */
.ws-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.ws-tabs {
  display: inline-flex;
  background: rgba(9, 14, 27, 0.78);
  padding: 4px;
  border-radius: 12px;
  border: 1px solid var(--border);
  gap: 4px;
}

.ws-tab {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 7px 15px;
  border-radius: 9px;
  font-weight: 600;
  font-size: 0.86rem;
  cursor: pointer;
  transition: background 0.16s ease, color 0.16s ease, box-shadow 0.16s ease;
}

.ws-tab:hover:not(.active) {
  color: var(--text);
  background: rgba(148, 163, 184, 0.08);
}

.ws-tab.active {
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  color: #fff;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.38);
}

.ws-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.presence-pills {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.presence-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(30, 41, 59, 0.65);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.78rem;
}

.dot-online {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 8px var(--success);
}

.ws-main {
  max-width: 1440px;
  margin: 0 auto;
  padding: clamp(12px, 2vw, 22px) clamp(12px, 2.5vw, 24px) 42px;
}

.module-panel {
  display: none;
  animation: fadePanel 0.2s ease;
}

.module-panel.active {
  display: block;
}

@keyframes fadePanel {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Module A: Text Collaboration */
.editor-shell {
  display: grid;
  grid-template-columns: 250px 1fr;
  gap: 16px;
  min-height: calc(100vh - 140px);
}

.editor-sidebar {
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid var(--border);
  box-shadow: var(--shadow), inset 0 1px 0 var(--border-highlight);
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.doc-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
  max-height: 360px;
}

.doc-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.doc-item:hover {
  background: rgba(148, 163, 184, 0.08);
}

.doc-item.active {
  background: var(--accent-soft);
  border-color: rgba(99, 102, 241, 0.45);
}

.editor-main {
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid var(--border);
  box-shadow: var(--shadow), inset 0 1px 0 var(--border-highlight);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.editor-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: rgba(9, 14, 27, 0.58);
  flex-wrap: wrap;
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.editor-body {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr;
  min-height: 460px;
}

.editor-body.split {
  grid-template-columns: 1fr 1fr;
}

.editor-textarea {
  width: 100%;
  height: 100%;
  min-height: 460px;
  padding: 18px;
  background: var(--bg-input);
  border: none;
  outline: none;
  resize: vertical;
  font-family: var(--font-mono);
  font-size: 0.94rem;
  line-height: 1.65;
}

.markdown-preview {
  padding: 18px 22px;
  background: var(--bg-elev);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  max-height: 680px;
}

.markdown-preview h1,
.markdown-preview h2,
.markdown-preview h3 {
  margin-top: 0.8em;
  margin-bottom: 0.4em;
}

.markdown-preview pre {
  background: #060913;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  overflow-x: auto;
}

.markdown-preview code {
  font-family: var(--font-mono);
  background: rgba(148, 163, 184, 0.14);
  padding: 2px 5px;
  border-radius: 4px;
}

.markdown-preview blockquote {
  margin: 10px 0;
  padding: 6px 14px;
  border-left: 3px solid var(--accent);
  color: var(--text-muted);
}

.editor-statusbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 14px;
  border-top: 1px solid var(--border);
  font-size: 0.82rem;
  color: var(--text-muted);
  flex-wrap: wrap;
}

/* Module B: Audio & Video Rooms */
.room-shell {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 16px;
}

.room-stage {
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid var(--border);
  box-shadow: var(--shadow), inset 0 1px 0 var(--border-highlight);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.room-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
  gap: 16px;
  padding: 6px;
  min-height: 360px;
  align-items: stretch;
}

.video-tile {
  position: relative;
  --speak-level: 0;
  background: radial-gradient(circle at center, #121a30, #070b15);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  overflow: hidden;
  width: 100%;
  aspect-ratio: 16 / 9;
  min-height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  transition: box-shadow 0.08s ease-out, border-color 0.14s ease, transform 0.12s ease-out;
}

.video-tile::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 3px;
  background: conic-gradient(
    from 0deg,
    #ff2a85,
    #8b5cf6,
    #3b82f6,
    #00f5d4,
    #22c55e,
    #f59e0b,
    #ff2a85
  );
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: 0;
  pointer-events: none;
  z-index: 4;
  transition: opacity 0.12s ease;
}

.video-tile.speaking {
  border-color: rgba(255, 255, 255, 0.22);
  box-shadow:
    0 0 calc(10px + var(--speak-level, 0.35) * 26px) rgba(255, 42, 133, calc(0.28 + var(--speak-level, 0.35) * 0.45)),
    0 0 calc(18px + var(--speak-level, 0.35) * 38px) rgba(0, 245, 212, calc(0.24 + var(--speak-level, 0.35) * 0.48)),
    0 0 calc(28px + var(--speak-level, 0.35) * 46px) rgba(99, 102, 241, calc(0.2 + var(--speak-level, 0.35) * 0.4));
}

.video-tile.speaking::before {
  opacity: calc(0.5 + var(--speak-level, 0.35) * 0.5);
  animation: ksVoiceRgbFlow 1.8s linear infinite;
}

.video-tile.speaking .video-avatar {
  transform: scale(calc(1 + var(--speak-level, 0.2) * 0.12));
  box-shadow:
    0 0 calc(14px + var(--speak-level, 0.35) * 24px) rgba(0, 245, 212, 0.65),
    0 8px 24px rgba(99, 102, 241, 0.55);
}

@keyframes ksVoiceRgbFlow {
  0% { filter: hue-rotate(0deg) saturate(1.25); }
  100% { filter: hue-rotate(360deg) saturate(1.25); }
}

.video-tile video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  z-index: 1;
  background: #070b15;
  transition: opacity 0.2s ease;
}

.video-tile video.screen-share {
  object-fit: contain;
  background: #040711;
}

.video-tile video.video-off {
  opacity: 0;
  pointer-events: none;
}

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

.rooms-pill-list {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.room-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.7);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.room-pill.active {
  background: var(--accent-soft);
  border-color: rgba(129, 140, 248, 0.7);
  color: #e0e7ff;
}

.video-avatar {
  position: relative;
  z-index: 2;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #10b981);
  display: grid;
  place-items: center;
  font-size: 1.5rem;
  font-weight: 700;
  box-shadow: 0 8px 24px rgba(99, 102, 241, 0.4);
  transition: transform 0.1s ease-out, box-shadow 0.12s ease;
}

.video-label {
  position: absolute;
  left: 10px;
  bottom: 10px;
  z-index: 3;
  background: rgba(7, 11, 20, 0.82);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(148, 163, 184, 0.22);
  padding: 5px 11px;
  border-radius: 8px;
  font-size: 0.8rem;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.room-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 10px 14px;
  margin-top: 4px;
  border-radius: 16px;
  background: rgba(9, 14, 27, 0.78);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(148, 163, 184, 0.2);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 12px 30px rgba(2, 6, 23, 0.5);
  flex-wrap: wrap;
}

.room-sidebar {
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid var(--border);
  box-shadow: var(--shadow), inset 0 1px 0 var(--border-highlight);
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.participant-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 11px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.86rem;
}

/* Module C: File Storage */
.files-shell {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.quota-bar-wrap {
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid var(--border);
  box-shadow: var(--shadow), inset 0 1px 0 var(--border-highlight);
  border-radius: var(--radius);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.progress-track {
  flex: 1;
  min-width: 180px;
  height: 10px;
  background: var(--bg-input);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--success));
  width: 0%;
  transition: width 0.25s ease;
}

.dropzone {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 28px 20px;
  text-align: center;
  background: rgba(15, 22, 38, 0.85);
  transition: border-color 0.15s ease, background 0.15s ease;
  cursor: pointer;
}

.dropzone:hover,
.dropzone.dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
  transform: translateY(-1px);
}

.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 0.92rem;
}

.files-table-wrap {
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid var(--border);
  box-shadow: var(--shadow), inset 0 1px 0 var(--border-highlight);
  border-radius: var(--radius);
  overflow-x: auto;
}

.files-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.files-table th,
.files-table td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.files-table th {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.files-table tr:hover td {
  background: rgba(148, 163, 184, 0.06);
}

/* Modals & Toasts */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(2, 6, 23, 0.8);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-backdrop.open {
  display: flex;
  animation: fadePanel 0.16s ease;
}

.modal {
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  overflow-y: auto;
  background: rgba(15, 23, 42, 0.98);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow), inset 0 1px 0 var(--border-highlight);
  border-radius: var(--radius);
  padding: 22px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.modal-header h3 {
  margin: 0;
}

.qr-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 16px;
  background: #fff;
  color: #0f172a;
  border-radius: var(--radius);
  margin: 12px auto;
  width: fit-content;
}

.qr-box img {
  width: min(210px, 60vw);
  height: auto;
  display: block;
}

.toast-container {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: min(360px, calc(100vw - 32px));
}

.toast {
  background: rgba(15, 23, 42, 0.92);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-strong);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 12px 15px;
  box-shadow: var(--shadow);
  font-size: 0.88rem;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.toast-out {
  opacity: 0;
  transform: translateY(6px);
}

.toast.success {
  border-left-color: var(--success);
}

.toast.error {
  border-left-color: var(--danger);
}

.hidden {
  display: none !important;
}

/* Module E: Key Chat (WhatsApp-style messaging with multiple sections) */
.chat-layout {
  display: grid;
  grid-template-columns: 235px 1fr;
  gap: 16px;
  height: calc(100vh - 140px);
  min-height: 480px;
}

.chat-sidebar {
  background: rgba(15, 23, 42, 0.92);
  border: 1px solid var(--border);
  box-shadow: var(--shadow), inset 0 1px 0 var(--border-highlight);
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: hidden;
}

.chat-shell {
  width: 100%;
  height: 100%;
  min-height: 460px;
  background: rgba(15, 23, 42, 0.92);
  border: 1px solid var(--border);
  box-shadow: var(--shadow), inset 0 1px 0 var(--border-highlight);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

@media (max-width: 900px) {
  .chat-layout {
    grid-template-columns: 1fr;
    height: auto;
  }
  .chat-sidebar {
    max-height: 160px;
  }
  .chat-sidebar .doc-list {
    flex-direction: row;
    overflow-x: auto;
    overflow-y: hidden;
  }
  .chat-sidebar .doc-item {
    width: auto;
    white-space: nowrap;
  }
  .chat-shell {
    height: calc(100vh - 280px);
    min-height: 380px;
  }
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 18px;
  border-bottom: 1px solid var(--border);
  background: rgba(9, 14, 27, 0.78);
}

.chat-messages {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: radial-gradient(circle at 20% 20%, rgba(99, 102, 241, 0.06), transparent 55%),
    rgba(7, 11, 20, 0.45);
}

.chat-row {
  display: flex;
  flex-direction: column;
  max-width: min(76%, 540px);
}

.chat-row.outgoing {
  align-self: flex-end;
  align-items: flex-end;
}

.chat-row.incoming {
  align-self: flex-start;
  align-items: flex-start;
}

.chat-bubble {
  padding: 10px 13px;
  border-radius: 14px;
  background: rgba(30, 41, 59, 0.92);
  border: 1px solid var(--border);
  box-shadow: 0 4px 14px rgba(2, 6, 23, 0.25);
  word-break: break-word;
}

.chat-row.outgoing .chat-bubble {
  background: linear-gradient(135deg, rgba(79, 70, 229, 0.92), rgba(67, 56, 202, 0.92));
  border-color: rgba(129, 140, 248, 0.45);
  border-bottom-right-radius: 4px;
}

.chat-row.incoming .chat-bubble {
  border-bottom-left-radius: 4px;
}

.chat-sender {
  font-size: 0.76rem;
  font-weight: 700;
  color: #6ee7b7;
  margin-bottom: 3px;
}

.chat-quote {
  border-left: 3px solid #a5b4fc;
  background: rgba(7, 11, 20, 0.45);
  padding: 5px 9px;
  border-radius: 6px;
  margin-bottom: 6px;
  font-size: 0.8rem;
}

.chat-text {
  white-space: pre-wrap;
  font-size: 0.94rem;
  line-height: 1.45;
}

.chat-voice {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 220px;
}

.chat-voice audio {
  width: 100%;
  height: 36px;
}

.chat-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 5px;
  font-size: 0.72rem;
  color: rgba(226, 232, 240, 0.72);
}

.chat-action-btn {
  background: transparent;
  border: none;
  color: rgba(226, 232, 240, 0.75);
  font-size: 0.72rem;
  cursor: pointer;
  padding: 0 3px;
}

.chat-action-btn:hover {
  color: #fff;
  text-decoration: underline;
}

.chat-reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 6px;
}

.chat-reaction-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.76rem;
  line-height: 1.3;
  background: rgba(15, 23, 42, 0.72);
  border: 1px solid rgba(148, 163, 184, 0.25);
  color: #e2e8f0;
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.15s ease, background 0.15s ease;
}

.chat-reaction-pill:hover {
  transform: scale(1.06);
  border-color: rgba(129, 140, 248, 0.55);
}

.chat-reaction-pill.reacted {
  background: rgba(99, 102, 241, 0.34);
  border-color: #818cf8;
  color: #ffffff;
  font-weight: 600;
}

.chat-react-picker {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.94);
  border: 1px solid rgba(129, 140, 248, 0.45);
  box-shadow: 0 6px 18px rgba(2, 6, 23, 0.45);
}

.chat-react-option {
  background: transparent;
  border: none;
  font-size: 1.05rem;
  line-height: 1;
  padding: 3px 4px;
  border-radius: 6px;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.12s ease;
}

.chat-react-option:hover {
  transform: scale(1.22);
  background: rgba(99, 102, 241, 0.25);
}

.chat-reply-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 14px;
  background: rgba(30, 41, 59, 0.92);
  border-top: 1px solid var(--border);
  border-left: 4px solid var(--accent);
}

.chat-recording-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  background: rgba(127, 29, 29, 0.35);
  border-top: 1px solid rgba(239, 68, 68, 0.35);
  flex-wrap: wrap;
}

.rec-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ef4444;
  animation: pulseRec 1s ease-in-out infinite;
}

@keyframes pulseRec {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.82); }
}

.chat-composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  background: rgba(9, 14, 27, 0.86);
}

.chat-input {
  resize: none;
  min-height: 40px;
  max-height: 110px;
  line-height: 1.4;
}

.chat-activity-bar {
  padding: 7px 14px;
  font-size: 0.82rem;
  font-weight: 700;
  color: #6ee7b7;
  background: rgba(16, 185, 129, 0.14);
  border-top: 1px solid rgba(16, 185, 129, 0.35);
  display: flex;
  align-items: center;
  gap: 8px;
}

.chat-activity-bar.is-recording {
  color: #fca5a5;
  background: rgba(239, 68, 68, 0.16);
  border-top-color: rgba(239, 68, 68, 0.4);
}

/* Video Room: Hand Raise, Emoji Reactions & In-Call Chat */
.room-stage-wrap {
  position: relative;
}

.room-reactions-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 20;
}

.floating-reaction {
  position: absolute;
  bottom: 18px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(11, 15, 25, 0.85);
  border: 1px solid rgba(165, 180, 252, 0.4);
  font-size: 1.15rem;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.45);
  animation: floatReaction 2.3s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.floating-reaction-name {
  font-size: 0.74rem;
  font-weight: 600;
  color: #e2e8f0;
}

@keyframes floatReaction {
  0% { opacity: 0; transform: translateY(12px) scale(0.7); }
  15% { opacity: 1; transform: translateY(-10px) scale(1.08); }
  80% { opacity: 1; transform: translateY(-150px) scale(1); }
  100% { opacity: 0; transform: translateY(-210px) scale(0.92); }
}

.hand-raised-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 4;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(245, 158, 11, 0.92);
  color: #090d16;
  font-size: 0.76rem;
  font-weight: 800;
  box-shadow: 0 6px 16px rgba(245, 158, 11, 0.4);
}

.btn-hand-active {
  background: linear-gradient(180deg, rgba(245, 158, 11, 0.38) 0%, rgba(180, 83, 9, 0.42) 100%);
  border-color: rgba(251, 191, 36, 0.8);
  color: #fef08a;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.22),
    0 4px 16px rgba(245, 158, 11, 0.32);
}

.room-emoji-bar {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(148, 163, 184, 0.22);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.emoji-btn {
  min-height: 32px;
  padding: 4px 8px;
  font-size: 1.05rem;
  border-radius: 8px;
  background: transparent;
  border-color: transparent;
  box-shadow: none;
}

.emoji-btn:hover:not(:disabled) {
  background: rgba(99, 102, 241, 0.24);
  border-color: rgba(129, 140, 248, 0.4);
  transform: translateY(-1px) scale(1.14);
  box-shadow: none;
}

.room-chat-box {
  margin-top: auto;
  border-top: 1px solid var(--border);
  padding-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.room-chat-feed {
  max-height: 220px;
  min-height: 110px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px;
  border-radius: 10px;
  background: rgba(9, 14, 27, 0.72);
  border: 1px solid var(--border);
  font-size: 0.82rem;
}

.room-chat-item {
  line-height: 1.35;
  word-break: break-word;
}

.room-chat-item strong {
  color: #a5b4fc;
}

/* Mobile Bottom Nav for Workspaces */
.mobile-nav {
  display: none;
}

@media (max-width: 960px) {
  .editor-shell,
  .room-shell,
  .editor-body.split {
    grid-template-columns: 1fr;
  }

  .markdown-preview {
    border-left: none;
    border-top: 1px solid var(--border);
  }
}

@media (max-width: 720px) {
  .topbar {
    padding: 10px 14px;
  }

  .topbar .ws-tabs[aria-label="Workspace Modules"] {
    display: none;
  }

  .ws-main {
    padding-bottom: 84px;
  }

  .mobile-nav {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: max(10px, env(safe-area-inset-bottom));
    z-index: 50;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 5px;
    padding: 6px;
    background: rgba(11, 17, 32, 0.94);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--border-strong);
    border-radius: 16px;
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.55);
  }

  .chat-shell {
    height: calc(100vh - 180px);
  }

  .chat-row {
    max-width: 88%;
  }

  .mobile-nav .ws-tab {
    padding: 10px 8px;
    font-size: 0.82rem;
    text-align: center;
  }

  .toast-container {
    bottom: 78px;
  }

  .editor-textarea {
    min-height: 320px;
  }

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

  .room-controls {
    padding: 8px 10px;
    gap: 6px;
  }

  .room-controls .btn {
    padding: 8px 11px;
    font-size: 0.8rem;
  }

  .files-table th,
  .files-table td {
    padding: 9px 10px;
    font-size: 0.82rem;
  }

  .modal {
    padding: 16px;
    max-height: 88vh;
  }
}
