:root {
  --mb-navy: #0b1f3a;
  --mb-navy-2: #12294a;
  --mb-blue: #1f6feb;
  --mb-blue-2: #3b8bff;
  --mb-teal: #17c3b2;
  --mb-red: #e5484d;
  --mb-bg: #0a1626;
  --mb-panel: #0f1f36;
  --mb-panel-2: #16294687;
  --mb-border: #22406b;
  --mb-text: #e9f0fb;
  --mb-muted: #9fb2cf;
  --mb-radius: 14px;
  --mb-shadow: 0 10px 40px rgba(0, 0, 0, .35);
  --mb-font: "Segoe UI", "Cairo", system-ui, -apple-system, Tahoma, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--mb-font);
  color: var(--mb-text);
  background:
    radial-gradient(1200px 600px at 80% -10%, #14315a 0%, transparent 60%),
    radial-gradient(900px 500px at -10% 110%, #10283f 0%, transparent 55%),
    var(--mb-bg);
  min-height: 100vh;
}

a { color: var(--mb-blue-2); }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 24px; border-bottom: 1px solid var(--mb-border);
  background: rgba(10, 22, 38, .6); backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand .logo { width: 38px; height: 38px; }
.brand .name { font-weight: 700; font-size: 18px; letter-spacing: .3px; }
.brand .name small { display: block; font-weight: 500; font-size: 11px; color: var(--mb-muted); letter-spacing: 2px; text-transform: uppercase; }
.topbar .right { display: flex; align-items: center; gap: 10px; }

.lang-toggle {
  background: transparent; border: 1px solid var(--mb-border); color: var(--mb-text);
  padding: 7px 12px; border-radius: 10px; cursor: pointer; font-family: inherit; font-size: 13px;
}
.lang-toggle:hover { border-color: var(--mb-blue); }

.wrap { max-width: 1100px; margin: 0 auto; padding: 32px 20px 60px; }

.hero { text-align: center; padding: 30px 0 10px; }
.hero h1 { font-size: 32px; margin: 0 0 12px; line-height: 1.3;
  background: linear-gradient(90deg, var(--mb-text) 30%, var(--mb-blue-2));
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.hero p { color: var(--mb-muted); max-width: 580px; margin: 0 auto; line-height: 1.8; font-size: 15px; }
.feat-chips { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 20px; }
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--mb-text);
  background: var(--mb-panel-2); border: 1px solid var(--mb-border); padding: 7px 14px; border-radius: 999px; }

.how { margin-top: 40px; text-align: center; }
.how h2 { font-size: 20px; margin: 0 0 22px; }
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
@media (max-width: 720px) { .steps { grid-template-columns: 1fr; } }
.step { background: var(--mb-panel-2); border: 1px solid var(--mb-border); border-radius: var(--mb-radius);
  padding: 22px 18px; position: relative; }
.step .num { width: 34px; height: 34px; border-radius: 50%; margin: 0 auto 12px;
  display: grid; place-items: center; font-weight: 800; color: #fff;
  background: linear-gradient(180deg, var(--mb-blue-2), var(--mb-blue)); }
.step .st { font-weight: 700; margin-bottom: 6px; }
.step .sd { font-size: 13px; color: var(--mb-muted); line-height: 1.6; }

.cards { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 34px; }
@media (max-width: 720px) { .cards { grid-template-columns: 1fr; } }

.card {
  background: linear-gradient(180deg, var(--mb-panel) 0%, #0c1b30 100%);
  border: 1px solid var(--mb-border); border-radius: var(--mb-radius);
  padding: 26px; box-shadow: var(--mb-shadow);
}
.card h2 { margin: 0 0 6px; font-size: 20px; }
.card .sub { color: var(--mb-muted); font-size: 14px; margin-bottom: 20px; line-height: 1.6; }
.card .icon {
  width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center;
  margin-bottom: 14px; background: rgba(31, 111, 235, .14); color: var(--mb-blue-2);
}
.card.join .icon { background: rgba(23, 195, 178, .14); color: var(--mb-teal); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  width: 100%; padding: 13px 18px; border-radius: 11px; border: none;
  font-family: inherit; font-size: 15px; font-weight: 600; cursor: pointer;
  transition: transform .05s ease, filter .15s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: linear-gradient(180deg, var(--mb-blue-2), var(--mb-blue)); color: #fff; }
.btn-primary:hover { filter: brightness(1.07); }
.btn-teal { background: linear-gradient(180deg, #1fd6c3, var(--mb-teal)); color: #05231f; }
.btn-teal:hover { filter: brightness(1.05); }
.btn-ghost { background: transparent; border: 1px solid var(--mb-border); color: var(--mb-text); }
.btn-ghost:hover { border-color: var(--mb-blue); }
.btn-danger { background: linear-gradient(180deg, #f06a6e, var(--mb-red)); color: #fff; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--mb-muted); margin-bottom: 7px; }
.input {
  width: 100%; padding: 12px 14px; border-radius: 11px; font-family: inherit; font-size: 15px;
  background: #0a182b; border: 1px solid var(--mb-border); color: var(--mb-text); outline: none;
}
.input:focus { border-color: var(--mb-blue); }
.input.code { letter-spacing: 6px; text-align: center; font-size: 22px; font-weight: 700; }

.note {
  margin-top: 26px; font-size: 13px; color: var(--mb-muted); text-align: center; line-height: 1.7;
  border-top: 1px dashed var(--mb-border); padding-top: 18px;
}
.badge {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--mb-teal);
  background: rgba(23, 195, 178, .1); border: 1px solid rgba(23,195,178,.3);
  padding: 4px 10px; border-radius: 999px;
}

/* ---------- session page ---------- */
.session { display: grid; grid-template-columns: 1fr 320px; gap: 16px; padding: 16px; height: calc(100vh - 71px); }
@media (max-width: 900px) { .session { grid-template-columns: 1fr; height: auto; } }

.stage {
  position: relative; background: #05101f; border: 1px solid var(--mb-border);
  border-radius: var(--mb-radius); overflow: hidden; display: grid; place-items: center; min-height: 320px;
}
.stage video { width: 100%; height: 100%; object-fit: contain; background: #05101f; display: none; }
.stage.has-video video { display: block; }
.stage.has-video .placeholder { display: none; } /* don't overlap the live video */
/* host's small self-preview of what they're sharing */
#selfView { position: absolute; bottom: 14px; inset-inline-end: 14px; width: 220px; max-width: 34%;
  border: 2px solid var(--mb-teal); border-radius: 10px; background: #05101f; z-index: 6;
  box-shadow: 0 6px 20px rgba(0,0,0,.4); object-fit: contain; }
#selfView[hidden] { display: none; }
.stage.has-video #selfView { bottom: 70px; } /* clear the controls when both show */
.selfLabel { position: absolute; bottom: 14px; inset-inline-end: 14px; z-index: 7;
  transform: translateY(-228px); background: rgba(23,195,178,.9); color: #05231f;
  font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 6px; pointer-events: none; }
.selfLabel[hidden] { display: none; }
.diag { position: absolute; top: 8px; inset-inline-start: 8px; z-index: 5;
  background: rgba(0,0,0,.6); color: #7CFC98; font: 12px/1.5 monospace;
  padding: 6px 10px; border-radius: 8px; direction: ltr; pointer-events: none; }
.diag.warn { color: #ffb35a; }
.diag.bad { color: #ff6b6b; }
.stage.controlling { outline: 3px solid var(--mb-teal); outline-offset: -3px; cursor: crosshair; }
.stage.controlling video { cursor: none; }
.stage .placeholder { text-align: center; color: var(--mb-muted); padding: 30px; }
.stage .placeholder .big { font-size: 46px; margin-bottom: 10px; }

.controls {
  position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 10px; background: rgba(8, 18, 32, .82); border: 1px solid var(--mb-border);
  padding: 9px; border-radius: 14px; backdrop-filter: blur(8px);
}
.ctrl {
  width: 46px; height: 46px; border-radius: 11px; border: 1px solid var(--mb-border);
  background: #10233d; color: var(--mb-text); cursor: pointer; display: grid; place-items: center;
}
.ctrl:hover { border-color: var(--mb-blue); }
.ctrl.active { background: var(--mb-blue); border-color: var(--mb-blue); color: #fff; }
.ctrl.danger { background: var(--mb-red); border-color: var(--mb-red); color: #fff; }

.side { display: flex; flex-direction: column; gap: 14px; min-height: 0; }
.panel {
  background: var(--mb-panel); border: 1px solid var(--mb-border); border-radius: var(--mb-radius); padding: 16px;
}
.panel h3 { margin: 0 0 12px; font-size: 15px; }
.status-row { display: flex; align-items: center; gap: 9px; font-size: 14px; margin-bottom: 8px; color: var(--mb-muted); }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--mb-muted); }
.dot.on { background: var(--mb-teal); box-shadow: 0 0 0 3px rgba(23,195,178,.18); }
.dot.off { background: var(--mb-red); }

.code-pill {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: #0a182b; border: 1px solid var(--mb-border); border-radius: 11px; padding: 10px 14px; margin-bottom: 10px;
}
.code-pill .val { font-size: 22px; font-weight: 800; letter-spacing: 4px; }
.copy-btn { background: transparent; border: 1px solid var(--mb-border); color: var(--mb-text); border-radius: 8px; padding: 6px 10px; cursor: pointer; font-size: 12px; }
.copy-btn:hover { border-color: var(--mb-blue); }

.chat { flex: 1; display: flex; flex-direction: column; min-height: 200px; }
.chat .msgs { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding-right: 4px; }
.msg { max-width: 85%; padding: 8px 12px; border-radius: 12px; font-size: 14px; line-height: 1.5; word-break: break-word; }
.msg.me { align-self: flex-start; background: var(--mb-blue); color: #fff; }
.msg.them { align-self: flex-end; background: #14294a; }
.msg .who { display: block; font-size: 11px; opacity: .7; margin-bottom: 2px; }
.msg.sys { align-self: center; background: transparent; color: var(--mb-muted); font-size: 12px; }
.chat form { display: flex; gap: 8px; margin-top: 10px; align-items: center; }
.chat input.input { flex: 1; }
.attach-btn { flex: none; width: 40px; height: 42px; border-radius: 10px; cursor: pointer;
  background: #0a182b; border: 1px solid var(--mb-border); color: var(--mb-text);
  display: grid; place-items: center; }
.attach-btn:hover { border-color: var(--mb-blue); color: var(--mb-blue-2); }

/* file / image messages */
.msg .file { display: flex; align-items: center; gap: 9px; text-decoration: none; color: inherit; }
.msg .file .fi { width: 30px; height: 30px; flex: none; border-radius: 7px; display: grid; place-items: center;
  background: rgba(255,255,255,.15); }
.msg .file .meta { display: flex; flex-direction: column; min-width: 0; }
.msg .file .fn { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 150px; }
.msg .file .fs { font-size: 11px; opacity: .75; }
.msg img.thumb { max-width: 200px; max-height: 200px; border-radius: 10px; display: block; cursor: pointer; }
.msg .dl { font-size: 11px; opacity: .8; text-decoration: underline; }

/* fullscreen: let the stage fill the screen and the video cover it */
.stage:fullscreen { border-radius: 0; }
.stage:fullscreen video { width: 100%; height: 100%; }
#selfView { }

.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: #12294a; border: 1px solid var(--mb-border); color: var(--mb-text);
  padding: 12px 18px; border-radius: 12px; box-shadow: var(--mb-shadow); font-size: 14px;
  opacity: 0; pointer-events: none; transition: opacity .2s ease; z-index: 50; max-width: 90vw;
}
.toast.show { opacity: 1; }

.consent-backdrop {
  position: fixed; inset: 0; background: rgba(3, 9, 18, .7); backdrop-filter: blur(4px);
  display: none; place-items: center; z-index: 100; padding: 20px;
}
.consent-backdrop.show { display: grid; }
.consent {
  background: var(--mb-panel); border: 1px solid var(--mb-border); border-radius: var(--mb-radius);
  max-width: 440px; padding: 26px; box-shadow: var(--mb-shadow);
}
.consent h3 { margin: 0 0 10px; }
.consent p { color: var(--mb-muted); line-height: 1.7; font-size: 14px; }
.consent .row { display: flex; gap: 10px; margin-top: 20px; }

[hidden] { display: none !important; }
