:root {
  --bg: #0b1220; --panel: #121a2b; --panel-2: #1a2337; --text: #e8edf7; --muted: #8b96ad; --line: #24304a;
  --accent: #2563eb; --accent-2: #1d4ed8; --ok: #22c55e; --warn: #f59e0b; --err: #ef4444; --wa: #25d366;
  --radius: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Heebo", "Noto Sans Arabic", Arial, sans-serif; background: var(--bg); color: var(--text); display: flex; flex-direction: column; min-height: 100%; line-height: 1.45; }
a { color: #93b4ff; }
.hidden { display: none !important; }
:focus-visible { outline: 3px solid #93b4ff; outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* header */
header { display: flex; align-items: center; gap: 10px; padding: 12px 18px; }
header .brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; }
header .brand svg { width: 30px; height: 30px; }
header .brand b { font-weight: 700; letter-spacing: .2px; }
header .brand small { color: var(--muted); }
header .spacer { flex: 1; }
header select { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; font: inherit; font-size: 14px; }

main { flex: 1; display: flex; flex-direction: column; padding: 0 16px 24px; max-width: 1180px; width: 100%; margin: 0 auto; }

/* buttons */
button { font: inherit; border: 0; border-radius: var(--radius); padding: 13px 20px; cursor: pointer; background: var(--accent); color: #fff; font-size: 16px; font-weight: 600; transition: background .15s, transform .05s; min-height: 44px; }
button:hover { background: var(--accent-2); }
button:active { transform: translateY(1px); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.big { padding: 18px 34px; font-size: 20px; }
button.ghost { background: var(--panel-2); }
button.ghost:hover { background: #24304d; }
button.ghost.on { background: var(--accent); }
button.stop, button.danger { background: var(--err); }
button.wa { background: var(--wa); color: #06301a; }
button.wa:hover { background: #1fb457; }
button.sm { padding: 7px 12px; font-size: 13px; border-radius: 9px; min-height: 36px; }
button.icon { padding: 8px 10px; }

/* landing */
.hero { text-align: center; margin: 5vh auto 0; max-width: 620px; }
.hero h1 { font-size: clamp(28px, 5vw, 44px); margin: 0 0 10px; line-height: 1.15; text-wrap: balance; }
.hero p.sub { color: var(--muted); font-size: 18px; margin: 0 0 24px; }
.hero ol { text-align: start; color: var(--muted); margin: 28px auto 0; padding-inline-start: 22px; max-width: 460px; line-height: 1.8; }
.hero .trust { color: var(--muted); font-size: 14px; margin-top: 18px; }
.demo { margin: 22px auto 0; max-width: 560px; }
.demo svg { width: 100%; height: auto; display: block; }
details.adv { margin: 18px auto 0; max-width: 420px; text-align: start; background: var(--panel); border-radius: var(--radius); padding: 10px 14px; }
details.adv summary { cursor: pointer; color: var(--muted); font-size: 14px; }
details.adv label { display: block; margin-top: 10px; font-size: 14px; }
details.adv input { width: 100%; margin-top: 6px; padding: 10px; font: inherit; font-size: 18px; letter-spacing: 4px; text-align: center; border-radius: 8px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); direction: ltr; }
details.adv .help { color: var(--muted); font-size: 12.5px; margin-top: 6px; }
footer.links { text-align: center; color: var(--muted); font-size: 14px; padding: 18px; display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; }
footer.links .ver { flex-basis: 100%; font-size: 12px; opacity: .55; text-decoration: none; letter-spacing: .3px; }
footer.links .ver:hover { opacity: .85; }

/* room */
.bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 10px 0; }
.bar .status { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 15px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--warn); flex: none; }
.dot.ok { background: var(--ok); } .dot.err { background: var(--err); }
.spacer { flex: 1; }
.linkbox { display: flex; align-items: center; gap: 8px; background: var(--panel); border-radius: 10px; padding: 6px 10px; direction: ltr; font-family: ui-monospace, Menlo, monospace; font-size: 14px; }

.layout { display: grid; grid-template-columns: 1fr; gap: 12px; flex: 1; }
.layout.side-open { grid-template-columns: 1fr 300px; }
@media (max-width: 800px) { .layout.side-open { grid-template-columns: 1fr; } }

.stage { position: relative; flex: 1; min-height: 52vh; background: #000; border-radius: 16px; overflow: hidden; display: grid; place-items: center; }
.stage video.remote { width: 100%; height: 100%; object-fit: contain; background: #000; display: block; }
.stage .empty { color: var(--muted); text-align: center; padding: 24px; }
.stage .empty h2 { font-weight: 500; margin: 0 0 6px; }
.pip { position: absolute; bottom: 12px; inset-inline-start: 12px; width: 22%; max-width: 260px; border-radius: 10px; overflow: hidden; border: 2px solid #ffffff44; background: #000; }
.pip video { width: 100%; display: block; }
.pip .tag { position: absolute; top: 4px; inset-inline-end: 6px; font-size: 11px; background: #0009; padding: 2px 6px; border-radius: 6px; }
/* self-view: while I'm sharing and the other side is only watching, show my own
   screen full-size in the stage (behind the overlay) so I can see their pointer/drawing */
.stage.selfview .empty { display: none; }
.stage.selfview .pip { position: absolute; inset: 0; width: 100%; max-width: none; border: 0; border-radius: 0; z-index: 0; display: grid; place-items: center; }
.stage.selfview .pip video { width: 100%; height: 100%; object-fit: contain; }
.stage.selfview .pip .tag { top: 8px; inset-inline-end: 10px; }
.stage.selfview canvas.draw { z-index: 2; }
.stage.selfview .overlay { z-index: 3; }
/* full-monitor share mirrors this tab into itself; dim the video so the tunnel fades to black while the pointer/draw stay bright */
.stage.selfview.mirror-dim .pip video { opacity: .4; }
.stage.selfview.mirror-dim .pip .tag { opacity: .9; z-index: 4; }
/* size the stage to the shared surface's aspect ratio (set inline as aspect-ratio) so black bars nearly vanish; capped so a tall share still fits */
.stage.fitted { flex: none; min-height: 0; width: 100%; height: auto; max-height: 72vh; margin-inline: auto; }
/* unread chat badge */
.chatwrap { position: relative; display: inline-flex; }
.cbadge { position: absolute; top: -7px; inset-inline-end: -7px; min-width: 18px; height: 18px; padding: 0 5px; box-sizing: border-box; border-radius: 9px; background: var(--err); color: #fff; font: 700 11px/1 system-ui, sans-serif; font-style: normal; display: grid; place-items: center; pointer-events: none; box-shadow: 0 0 0 2px var(--bg); }
.overlay { position: absolute; inset: 0; pointer-events: none; }
canvas.draw { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.stage.mode-draw canvas.draw, .stage.mode-pointer canvas.draw { pointer-events: auto; cursor: crosshair; }
.pointer { position: absolute; width: 36px; height: 36px; border-radius: 50%; border: 3px solid var(--warn); box-shadow: 0 0 0 6px #f59e0b44; transform: translate(-50%, -50%); pointer-events: none; opacity: 0; transition: opacity .2s, left .05s linear, top .05s linear; }
.pointer.show { opacity: 1; }
.pointer.pulse { animation: pulse 1s ease-out; }
@keyframes pulse { from { box-shadow: 0 0 0 0 #f59e0b88; } to { box-shadow: 0 0 0 18px #f59e0b00; } }
.frozen { position: absolute; inset: 0; display: grid; place-items: center; background: #0008; color: #fff; font-size: 20px; font-weight: 600; backdrop-filter: blur(2px); }
.stage-note { position: absolute; top: 12px; inset-inline: 12px; background: #1c2740ee; border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; font-size: 14px; }
.fs-btn { position: absolute; top: 10px; inset-inline-end: 10px; }

.controls { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; padding-top: 12px; align-items: center; }
.controls .group { display: flex; gap: 6px; background: var(--panel); padding: 4px; border-radius: 12px; }
.hint { color: var(--muted); text-align: center; font-size: 13.5px; margin-top: 8px; }

/* side panel */
.side { display: flex; flex-direction: column; gap: 12px; }
.card { background: var(--panel); border-radius: var(--radius); padding: 12px 14px; }
.card h3 { margin: 0 0 8px; font-size: 14px; color: var(--muted); font-weight: 600; }
.who { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: 14px; }
.who li { display: flex; gap: 8px; align-items: center; }
.who .dot { width: 8px; height: 8px; }
.who small { color: var(--muted); }
.chat { display: flex; flex-direction: column; min-height: 200px; max-height: 40vh; }
.chat .msgs { flex: 1; overflow-y: auto; display: grid; gap: 6px; align-content: start; font-size: 14px; }
.chat .m { background: var(--panel-2); border-radius: 10px; padding: 6px 10px; max-width: 90%; word-break: break-word; }
.chat .m.me { background: var(--accent); align-self: end; justify-self: end; }
.chat .m.sys { background: none; color: var(--muted); font-size: 12.5px; justify-self: center; }
.chat form { display: flex; gap: 6px; margin-top: 8px; }
.chat input { flex: 1; padding: 9px 10px; border-radius: 9px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); font: inherit; min-width: 0; }
.file-row { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.file-row progress { flex: 1; height: 8px; }

/* banners & modals */
.banner { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; background: #3a2a10; border: 1px solid var(--warn); color: #ffd58a; border-radius: 10px; padding: 8px 12px; font-size: 14px; }
.modal { position: fixed; inset: 0; background: #000a; display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal .box { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 22px; max-width: 460px; width: 100%; box-shadow: 0 20px 60px #000a; }
.modal h2 { margin: 0 0 8px; font-size: 20px; }
.modal p { color: var(--muted); margin: 0 0 16px; font-size: 15px; }
.modal .row { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.modal input.pin { width: 100%; font-size: 26px; letter-spacing: 8px; text-align: center; padding: 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); direction: ltr; margin-bottom: 12px; }
.modal img.qr, .modal .qr svg { width: 240px; height: 240px; background: #fff; border-radius: 10px; display: block; margin: 0 auto 8px; }
.modal .illus { margin: 0 auto 14px; max-width: 320px; }
.modal .illus svg { width: 100%; height: auto; display: block; }

/* simple (parent) mode */
.simple { position: fixed; inset: 0; background: var(--bg); z-index: 40; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 24px; gap: 20px; }
.simple h1 { font-size: clamp(24px, 5vw, 36px); margin: 0; max-width: 20ch; text-wrap: balance; }
.simple button.huge { font-size: clamp(22px, 5vw, 32px); padding: 26px 44px; border-radius: 20px; min-width: min(90vw, 420px); }
.simple .status { color: var(--muted); font-size: 18px; }
.simple .status.ok { color: var(--ok); }
.simple a { color: var(--muted); font-size: 14px; }
.simple video { width: min(90vw, 560px); border-radius: 12px; background: #000; }
.simple .knock { background: var(--panel); border-radius: 14px; padding: 14px 18px; }

.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: #1c2740; padding: 10px 16px; border-radius: 10px; font-size: 15px; box-shadow: 0 8px 30px #0008; opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 60; max-width: 90vw; }
.toast.show { opacity: 1; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

@media (max-width: 640px) {
  .pip { width: 32%; }
  .bar { padding: 8px 0; }
  .linkbox { font-size: 12.5px; }
  button.big { width: 100%; }
  .stage { min-height: 45vh; }
}
@media (orientation: portrait) and (max-width: 640px) { .rotate-hint { display: block; } }
.rotate-hint { display: none; }

/* ===== onboarding overlay (first visit) ===== */
.help-btn{background:var(--panel);color:var(--muted);border:1px solid var(--line);border-radius:50%;width:34px;height:34px;min-height:0;padding:0;font-size:17px;font-weight:700;cursor:pointer;display:grid;place-items:center}
.help-btn:hover{background:var(--panel-2);color:var(--text)}
.ob{position:fixed;inset:0;z-index:100;background:radial-gradient(1200px 600px at 50% -10%, #16233f 0%, transparent 60%), var(--bg);
  display:flex;align-items:center;justify-content:center;padding:calc(env(safe-area-inset-top,0px) + 16px) 16px calc(env(safe-area-inset-bottom,0px) + 16px)}
.ob-card{width:100%;max-width:440px;height:100%;max-height:680px;display:flex;flex-direction:column}
.ob-top{display:flex;align-items:center;justify-content:space-between;padding:6px 4px 4px;flex:none}
.ob-skip{background:none;border:0;color:var(--muted);font:inherit;font-size:15px;cursor:pointer;padding:8px;min-height:0}
.ob-dots{display:flex;gap:6px}
.ob-dots i{width:7px;height:7px;border-radius:99px;background:#2b3550;transition:all .25s}
.ob-dots i.on{background:var(--accent);width:22px}
.ob-slides{flex:1;position:relative;min-height:0}
.ob-slide{position:absolute;inset:0;display:grid;align-content:safe center;justify-items:center;overflow-y:auto;overscroll-behavior:contain;
  opacity:0;transform:translateX(24px);pointer-events:none;transition:opacity .3s,transform .3s}
.ob-slide.on{opacity:1;transform:none;pointer-events:auto}
.ob-slide.past{transform:translateX(-24px)}
.ob-inner{width:100%;padding:8px 20px 12px;display:flex;flex-direction:column;align-items:center;text-align:center}
.ob-art{width:170px;height:150px;margin-bottom:4px;flex:none}
.ob-slide h2{font-size:24px;margin:6px 0 10px;font-weight:800;line-height:1.2;text-wrap:balance}
.ob-slide>.ob-inner>p{color:var(--muted);font-size:15.5px;line-height:1.6;margin:0;max-width:32ch}
.ob-steps{display:flex;flex-direction:column;gap:10px;margin-top:4px;width:100%;max-width:340px;text-align:start}
.ob-step{display:flex;align-items:center;gap:12px;background:var(--panel);border:1px solid var(--line);border-radius:14px;padding:11px 14px}
.ob-step .n{width:30px;height:30px;border-radius:50%;background:var(--accent);color:#fff;display:grid;place-items:center;font-weight:700;flex:none;font-size:15px}
.ob-step.wa .n{background:var(--wa);color:#06301a}
.ob-step .t{font-size:15px}.ob-step .t b{font-weight:700}.ob-step .t small{display:block;color:var(--muted);font-size:13px;margin-top:1px;font-weight:400}
.ob-note{color:var(--muted);font-size:14px;margin-top:12px;max-width:32ch}
.ob-priv{display:flex;flex-direction:column;gap:11px;margin-top:6px;width:100%;max-width:340px;text-align:start}
.ob-priv>div{display:flex;gap:10px;align-items:flex-start;font-size:15px;line-height:1.5}
.ob-priv svg{flex:none;margin-top:3px}
.ob-cta{padding:10px 4px calc(env(safe-area-inset-bottom,0px) + 6px);display:flex;flex-direction:column;gap:6px;flex:none}
.ob-back{background:none;border:0;color:var(--muted);font:inherit;font-size:14px;cursor:pointer;padding:4px;min-height:0}
