:root { --bg:#0e0f12; --panel:#17191e; --line:#2a2d35; --text:#e9eaee; --muted:#9aa0ab; --accent:#2d8cff; --danger:#ff5c5c; }
* { box-sizing: border-box; }
html, body { margin:0; height:100%; background:var(--bg); color:var(--text); font:14px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; }
.wrap { display:flex; flex-direction:column; height:100%; }
header { display:flex; align-items:center; gap:8px; padding:10px 12px; border-bottom:1px solid var(--line); }
header h1 { font-size:15px; margin:0; font-weight:600; }
header .status { margin-left:auto; color:var(--muted); font-size:12px; }
main { flex:1; min-height:0; display:flex; flex-direction:column; gap:10px; padding:12px; overflow:auto; }
.card { background:var(--panel); border:1px solid var(--line); border-radius:10px; padding:12px; display:flex; flex-direction:column; gap:8px; }
.card h2 { font-size:13px; margin:0; color:var(--muted); text-transform:uppercase; letter-spacing:.04em; }
.row { display:flex; gap:8px; flex-wrap:wrap; align-items:center; }
button, select, input { font:inherit; color:var(--text); background:#22252c; border:1px solid var(--line); border-radius:7px; padding:7px 10px; }
button { cursor:pointer; }
button:hover { border-color:#3b404b; }
button.primary { background:var(--accent); border-color:var(--accent); color:#fff; font-weight:600; }
button.danger { background:transparent; border-color:var(--danger); color:var(--danger); }
button.on { background:#3b2a12; border-color:#ffb02e; color:#ffb02e; }
input[readonly] { width:100%; font-family:ui-monospace, Menlo, monospace; font-size:12px; }
.muted { color:var(--muted); font-size:12px; }
.hidden { display:none !important; }
.err { color:var(--danger); }
pre.kv { margin:0; white-space:pre-wrap; font:12px ui-monospace, Menlo, monospace; color:#cfd3da; }

/* Stage */
.stage { display:flex; flex-direction:column; flex:1; min-height:240px; background:#000; border-radius:10px; overflow:hidden; border:1px solid var(--line); }
.stage:fullscreen { border-radius:0; }
.stage-media { position:relative; flex:1; min-height:0; }
.stage-media video { position:absolute; inset:0; width:100%; height:100%; object-fit:contain; background:#000; }
.stage-media canvas { position:absolute; inset:0; width:100%; height:100%; }
.stage-media canvas.ink { pointer-events:none; cursor:crosshair; touch-action:none; z-index:2; }
.stage-media canvas.wm { pointer-events:none; z-index:1; }
.stage-media .waiting { position:absolute; inset:0; display:grid; place-items:center; color:var(--muted); }
.stage-media .stats { position:absolute; top:8px; left:8px; z-index:3; background:rgba(0,0,0,.65); padding:6px 8px; border-radius:6px; font:11px ui-monospace, Menlo, monospace; }
.stage-bar { display:flex; gap:6px; padding:6px; background:var(--panel); border-top:1px solid var(--line); flex-wrap:wrap; }
.stage-bar button, .stage-bar select { padding:5px 8px; font-size:12px; }
.stage-bar [data-act=full] { margin-left:auto; }

/* Presenter capture page */
.present-page main { max-width:880px; width:100%; margin:0 auto; }
.pv-start { display:flex; flex:1; min-height:260px; }
.pv-target { flex:1; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:8px; text-align:center; cursor:pointer; border:2px dashed var(--line); border-radius:14px; background:var(--panel); padding:32px 16px; transition:border-color .15s, background .15s; }
.pv-target:hover, .pv-target:focus-visible { border-color:var(--accent); background:#1a1e26; outline:none; }
.pv-target h2 { margin:0; font-size:22px; font-weight:600; }
.pv-icon { font-size:44px; line-height:1; color:var(--accent); }
body[data-view=start], body[data-view=loading] { cursor:pointer; }
body[data-view=start] [data-nocapture], body[data-view=loading] [data-nocapture] { cursor:auto; }
.pv-livehead { display:flex; align-items:center; gap:10px; min-width:0; }
.pv-badge { font-weight:700; font-size:12px; letter-spacing:.04em; text-transform:uppercase; padding:3px 8px; border-radius:999px; background:#22252c; color:var(--muted); white-space:nowrap; }
.pv-badge.live { background:rgba(255,59,48,.15); color:#ff3b30; }
.pv-badge.paused { background:#3b2a12; color:#ffb02e; }
.pv-source { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; color:var(--text); }
.pv-metrics { display:flex; gap:18px; flex-wrap:wrap; }
.pv-metrics > div { display:flex; flex-direction:column; }
.pv-metrics b { font:600 18px ui-monospace, Menlo, monospace; }
.pv-paused { display:flex; flex-direction:column; align-items:flex-start; gap:8px; padding:12px; border:1px solid #ffb02e; border-radius:10px; background:#24190b; }
.pv-paused p { margin:0; }
button.pv-big { font-size:17px; padding:12px 22px; }
.pv-keys kbd { font:11px ui-monospace, Menlo, monospace; border:1px solid var(--line); border-bottom-width:2px; border-radius:4px; padding:0 4px; background:#22252c; color:var(--text); }
.pv-msg .card { text-align:center; padding:28px 16px; }
.pv-msg h2 { font-size:18px; margin:0; color:var(--text); text-transform:none; letter-spacing:0; }
.pv-stage { flex:0 0 auto; height:clamp(200px, 38vh, 420px); min-height:200px; }

/* ---- panel: presenter status card / one-click start ---- */
button.big { font-size: 1.05rem; padding: .7rem 1.2rem; }
.pill { font-size: .8rem; padding: .15rem .5rem; border-radius: 999px; background: rgba(76, 217, 100, .15); color: #4cd964; }
@keyframes zp-pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(52, 195, 255, .6); } 50% { box-shadow: 0 0 0 6px rgba(52, 195, 255, 0); } }
button.pulse { animation: zp-pulse 1.4s ease-in-out infinite; border-color: #34c3ff; }
#liveTitle { margin-bottom: .2rem; }
details summary { cursor: pointer; margin: .6rem 0 .3rem; }
#liveTitle { text-transform: none; color: inherit; font-size: 15px; letter-spacing: 0; }

/* ---- Watching: video fills the panel, chrome floats on top and fades when idle ---- */
body.watching header, body.watching #watchInfo, body.watching #takeOverInline { display: none; }
body.watching main { padding: 0; gap: 0; overflow: hidden; }
body.watching .stage { position: fixed; inset: 0; min-height: 0; border: 0; border-radius: 0; z-index: 10; }
.stage { position: relative; }
.stage-title {
  position: absolute; top: 0; left: 0; right: 0; z-index: 5; padding: 8px 12px 18px;
  font-size: 12px; color: #fff; text-shadow: 0 1px 2px #000;
  background: linear-gradient(rgba(0,0,0,.55), transparent); pointer-events: none;
  opacity: 0; transition: opacity .25s;
}
body.watching .stage-bar {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 5; border: 0; flex-wrap: nowrap;
  padding: 18px 8px 8px; background: linear-gradient(transparent, rgba(0,0,0,.6));
  opacity: 0; transition: opacity .25s;
}
body.watching .stage-bar button, body.watching .stage-bar select {
  background: rgba(20,20,24,.75); border-color: rgba(255,255,255,.15); min-width: 30px;
}
.stage.show-ui .stage-bar, .stage.show-ui .stage-title, .stage-bar:focus-within { opacity: 1; }
body.watching .stage:not(.show-ui) { cursor: none; }
body.watching .stage-media .stats { top: 34px; }
.stage-bar [data-act=mute].on { color: #ff6b6b; }

/* ---- presenter controls ---- */
.viewer-list { list-style: none; margin: 6px 0; padding: 0; max-height: 220px; overflow: auto; }
.viewer-list li { display: flex; align-items: center; gap: 8px; padding: 4px 0; border-bottom: 1px solid var(--line); }
.viewer-list .who { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewer-list .via { font-size: 11px; }
button.small { padding: 2px 8px; font-size: 11px; }
#e2eePill { align-self: flex-start; }

/* ---- big "Tap for sound" target (autoplay blocked), always visible, works without a mouse ---- */
.stage-media .tap-audio {
  position: absolute; left: 50%; bottom: 18%; transform: translateX(-50%); z-index: 6;
  font-size: 18px; padding: 14px 26px; border-radius: 999px;
  background: rgba(20, 20, 24, .85); border: 1px solid rgba(255, 255, 255, .3); color: #fff;
}
/* ---- Zoom Rooms: nobody moves a mouse over the room display, so keep the controls visible ---- */
body.room .stage-bar, body.room .stage-title { opacity: 1 !important; }
body.room .stage:not(.show-ui) { cursor: auto; }
body.room .stage-bar button, body.room .stage-bar select { min-height: 40px; min-width: 44px; font-size: 15px; }

/* ---- presenter preview thumbnail ---- */
.pv-wrap { height: 160px; border-radius: 8px; overflow: hidden; background: #000; }
.pv-wrap .stage { min-height: 0; height: 100%; border: 0; border-radius: 0; }
.pv-wrap .stage-bar, .pv-wrap .tap-audio { display: none !important; }

/* ---- Calm full-bleed layout: centered empty state, no header ---- */
html, body { background: #0e0f11; }
main { padding: 16px; }
.empty {
  flex: 1; min-height: 70vh; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; gap: 6px; padding: 24px 16px;
}
.empty-icon { width: 64px; height: 64px; color: #8a8f98; margin-bottom: 14px; }
.empty h2 { font-size: 20px; font-weight: 500; margin: 0; color: #e8e9eb; text-transform: none; letter-spacing: 0; }
.empty > p { margin: 4px 0 0; max-width: 34ch; color: #8a8f98; font-size: 14px; }
.empty-actions { margin-top: 22px; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.empty-actions .opts { display: flex; flex-direction: column; gap: 6px; text-align: left; max-width: 320px; }
button.link { background: none; border: 0; color: #8a8f98; font-size: 12px; text-decoration: underline; cursor: pointer; padding: 2px; }
#presenterCard { max-width: 560px; width: 100%; margin: 0 auto; }
.corner-status { position: fixed; left: 10px; bottom: 6px; font-size: 11px; color: #5d626b; pointer-events: none; z-index: 20; }
body.watching .corner-status { display: none; }

/* ---- Capture page: desktop helper hand-off ---- */
.pv-start { flex-direction: column; gap: 10px; }
.pv-helper-opt { display: flex; flex-direction: column; gap: 6px; padding: 2px 4px; }
.pv-helper-opt p { margin: 0; max-width: 70ch; }
.pv-dl { font-size: 12px; color: var(--muted); }
.pv-dl:hover { color: var(--text); }
.pv-center { justify-content: center; }
.pv-helper-big {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; text-align: center;
  min-height: 220px; border: 2px solid var(--accent); border-radius: 14px; background: #141a24; padding: 32px 16px; cursor: pointer;
}
.pv-helper-big:hover, .pv-helper-big:focus-visible { background: #18202d; outline: none; }
.pv-helper-title { font-size: 22px; font-weight: 600; color: var(--text); }
/* Helper preferred: the browser card becomes the smaller, secondary option and only it opens the picker */
body[data-prefer=helper][data-view=start], body[data-prefer=helper][data-view=loading] { cursor: auto; }
body[data-prefer=helper] .pv-target { flex: 0 0 auto; padding: 14px 16px; gap: 2px; border-width: 1px; }
body[data-prefer=helper] .pv-target .pv-icon { display: none; }
body[data-prefer=helper] .pv-target h2 { font-size: 15px; }
#viewHandoff p { margin: 6px 0; }
#viewHandoff .row { margin-top: 10px; }

/* ---- Panel: "Control from Zoom" (full-panel stream + input capture) ---- */
body.controlling main { padding: 0; overflow: hidden; }
body.controlling .corner-status { display: none; }
body.controlling #pvWrap {
  position: fixed; inset: 0; z-index: 30; height: auto; border-radius: 0; background: #000;
  display: flex; flex-direction: column;
}
body.controlling #pvWrap #pvStage { flex: 1; min-height: 0; height: auto; }
.ctl-bar {
  flex: 0 0 auto; display: flex; align-items: center; gap: 8px; min-height: 30px; padding: 3px 8px 3px 10px;
  font-size: 12px; color: #e8e9eb; background: rgba(20, 21, 25, .96); border-bottom: 1px solid var(--line); white-space: nowrap;
}
.ctl-dot { color: #ff3b30; font-size: 10px; }
.ctl-label { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.ctl-hint { color: var(--muted); }
.ctl-state { margin-left: auto; color: var(--muted); overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.ctl-state.on { color: #4cd964; }
.ctl-state.off { color: #ffb02e; }
.ctl-bar button.small { padding: 2px 10px; }
.ctl-capture { position: absolute; inset: 0; z-index: 4; background: transparent; cursor: default; touch-action: none; user-select: none; -webkit-user-select: none; outline: none; }
.ctl-sink { position: absolute; left: 0; top: 0; width: 1px; height: 1px; opacity: 0; border: 0; padding: 0; resize: none; pointer-events: none; }
.ctl-note {
  position: absolute; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 31; max-width: min(92%, 520px);
  padding: 10px 14px; border-radius: 10px; font-size: 13px; text-align: center; color: #e8e9eb;
  background: rgba(20, 20, 24, .88); border: 1px solid rgba(255, 176, 46, .5); pointer-events: none;
}
body:not(.controlling) .ctl-note { display: none; }

/* Spotlight (Zoom Layers API immersive mode): the app instance drawn on Zoom's main meeting canvas shows only the
   stream (or a quiet waiting state), never controls. The host's toggle floats top-right in the side panel. */
.spotlight-btn { position: fixed; top: 8px; right: 8px; z-index: 60; }
body.layer, body.layer .wrap, body.layer main { background: #000; }
body.layer header, body.layer #startCard, body.layer #presenterCard, body.layer #accessCard, body.layer #helperHint,
body.layer #takeOverInline, body.layer #watchInfo, body.layer .corner-status, body.layer .empty-actions, body.layer details { display: none !important; }
body.layer .empty { color: #bbb; }
body.layer .empty-icon { opacity: .35; }
