/* Browser Bridge visitor app. Tokens: assets/theme.css (supplied design pack). */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font: 15px/1.45 var(--bb-font-body); color: var(--bb-ink); background: var(--bb-cream); }
h1, h2 { font-family: var(--bb-font-heading); margin: 0; letter-spacing: -0.01em; }
p { margin: 0; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: #5d4f73; }
.small { font-size: 13px; }
.row { display: flex; align-items: center; gap: 8px; }
.row.end { justify-content: flex-end; }
.stack { display: grid; gap: 10px; }
.grow { flex: 1; }
.icon { display: inline-flex; width: 20px; height: 20px; flex: none; }
.icon svg { width: 100%; height: 100%; }
:where(button, a, input, select, textarea, [tabindex]):focus-visible { outline: 3px solid var(--bb-purple-deep); outline-offset: 3px; }

.btn {
  appearance: none; border: 0; cursor: pointer; min-height: 44px; padding: 10px 18px; border-radius: 14px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: 700 15px/1.1 var(--bb-font-heading); background: var(--bb-lilac); color: var(--bb-ink);
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.invite { background: var(--bb-yellow); color: var(--bb-purple-deep); font-size: 17px; min-height: 52px; box-shadow: 0 3px 0 #e2b800; }
.btn.stop { background: var(--bb-coral); color: #fff; }

/* ---------------------------------------------------------------- join --- */
.screen.center {
  min-height: 100%; display: grid; place-items: center; padding: 24px 16px;
  background:
    radial-gradient(circle at 8% 90%, #FFE98A 0 120px, transparent 121px),
    radial-gradient(circle at 96% 6%, #DCCBF4 0 140px, transparent 141px),
    var(--bb-cream);
}
.join-card {
  width: min(460px, 100%); background: #fff; border-radius: 28px; padding: 28px 24px;
  box-shadow: var(--bb-shadow); border: 3px solid #fff; display: grid; gap: 14px; text-align: center; justify-items: center;
}
.join-card .illus { width: 200px; height: auto; margin-top: -8px; }
.join-card h1 { font-size: 32px; line-height: 1.05; font-weight: 900; color: var(--bb-purple-deep); }
.hl { background: var(--bb-yellow); padding: 0 8px; border-radius: 10px; }
.join-card form { width: 100%; text-align: left; }
.field { font-weight: 700; font-size: 14px; }
input[type=text] {
  font: 16px var(--bb-font-body); color: var(--bb-ink); min-height: 48px; padding: 8px 14px;
  border-radius: 14px; border: 2px solid #d9cbee; background: #fff; width: 100%;
}
.error { color: #8d2b24; background: #F9DEDB; border-radius: 12px; padding: 10px 12px; width: 100%; }

/* ----------------------------------------------------------- workspace --- */
.work { height: 100%; display: grid; grid-template-columns: 260px 1fr; }
.work.collapsed { grid-template-columns: 72px 1fr; }
.sidebar {
  background: var(--bb-purple-deep); color: #fff; padding: 16px 12px; display: flex; flex-direction: column; gap: 14px;
  border-radius: 0 28px 28px 0; min-height: 0; overflow: hidden;
}
.brand { display: flex; align-items: center; gap: 10px; font: 900 19px/1.05 var(--bb-font-heading); }
.brand img { width: 42px; height: 42px; flex: none; }
.brand .side-btn { margin-left: auto; }
.work.collapsed .brand span, .work.collapsed .side-body { display: none; }
.work.collapsed .brand { flex-direction: column; }
.work.collapsed #collapseBtn .icon { transform: scaleX(-1); }
.side-body { display: flex; flex-direction: column; gap: 10px; flex: 1; min-height: 0; }
.side-head { display: flex; align-items: center; justify-content: space-between; }
.side-head h2 { font-size: 16px; color: #F3ECFC; }
.side-btn {
  appearance: none; border: 0; cursor: pointer; width: 40px; height: 40px; border-radius: 12px;
  display: grid; place-items: center; background: rgba(255,255,255,.14); color: #fff;
}
.side-btn:hover { background: rgba(255,255,255,.24); }
.tab-list { overflow: auto; display: grid; gap: 6px; align-content: start; min-height: 0; padding: 2px; }
.win-label { font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: #DCCBF4; margin: 6px 4px 0; }
.tab-item { display: flex; align-items: center; gap: 4px; border-radius: 14px; background: rgba(255,255,255,.10); }
.tab-item.current { background: #fff; color: var(--bb-ink); }
.tab-item .sel {
  appearance: none; border: 0; background: transparent; color: inherit; cursor: pointer; text-align: left;
  flex: 1; min-width: 0; min-height: 48px; padding: 6px 4px 6px 10px; display: flex; align-items: center; gap: 8px; border-radius: 14px;
}
.tab-item .sel .t { min-width: 0; }
.tab-item .sel b { display: block; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tab-item .sel small { display: block; font-size: 12px; opacity: .8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tab-item .fav {
  width: 28px; height: 28px; border-radius: 9px; flex: none; display: grid; place-items: center;
  background: var(--bb-lilac); color: var(--bb-purple-deep); font-weight: 900; font-size: 13px;
}
.tab-item .live-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--bb-yellow); flex: none; box-shadow: 0 0 0 2px var(--bb-purple-deep); }
.tab-item .x {
  appearance: none; border: 0; background: transparent; color: inherit; cursor: pointer; width: 36px; height: 36px; border-radius: 10px;
  display: grid; place-items: center; opacity: .8; flex: none; margin-right: 4px;
}
.tab-item .x:hover { background: rgba(0,0,0,.08); opacity: 1; }
.tab-item .x .icon { width: 16px; height: 16px; }
.link-btn { appearance: none; border: 0; background: none; color: #F3ECFC; text-decoration: underline; cursor: pointer; font: inherit; font-size: 13px; text-align: left; padding: 6px 4px; min-height: 36px; }
.conn-card { border: 2px solid rgba(255,255,255,.28); border-radius: 16px; padding: 10px 12px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: #c9c0d6; display: inline-block; flex: none; }
.dot.ok { background: #4cd18d; }
.dot.warn { background: var(--bb-yellow); }
.dot.bad { background: #ff8a80; }
.btn.leave { background: transparent; border: 2px solid #ff9d94; color: #ffd9d4; }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; padding: 10px 14px 8px; gap: 8px; }
.topbar { display: grid; gap: 6px; }
.status-row { display: flex; align-items: center; gap: 12px; min-height: 32px; }
.pill { display: inline-flex; align-items: center; gap: 8px; font: 800 17px var(--bb-font-heading); color: var(--bb-purple-deep); }
.pill.ok .dot { background: var(--bb-green); }
.pill.warn .dot { background: #d9a600; }
.pill.view .dot { background: var(--bb-purple); }
.toolbar { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.tool {
  appearance: none; border: 0; cursor: pointer; min-width: 40px; height: 40px; padding: 0 8px; border-radius: 12px;
  display: inline-grid; place-items: center; background: #fff; color: var(--bb-purple-deep); font: 800 14px var(--bb-font-heading);
  box-shadow: 0 1px 0 #e7dcf5;
}
.tool:disabled { opacity: .45; cursor: not-allowed; }
.urlbar {
  flex: 1; min-width: 200px; display: flex; align-items: center; gap: 6px; background: #fff; border-radius: 14px;
  padding: 0 4px 0 12px; height: 44px; border: 2px solid #e7dcf5; color: var(--bb-purple);
}
.urlbar:focus-within { border-color: var(--bb-purple-deep); }
.urlbar input { border: 0; outline: none; flex: 1; min-width: 0; font: 15px var(--bb-font-body); color: var(--bb-ink); background: transparent; min-height: 40px; padding: 0; }
.urlbar .go { box-shadow: none; background: var(--bb-lilac); }
.zoom { display: inline-flex; gap: 2px; }
.quality {
  display: inline-flex; align-items: center; gap: 6px; background: var(--bb-lilac); color: var(--bb-purple-deep);
  border-radius: 12px; padding: 0 6px 0 10px; height: 40px; border: 2px solid #DCCBF4;
}
.quality select { border: 0; background: transparent; font: 700 14px var(--bb-font-heading); color: var(--bb-purple-deep); min-height: 36px; }
.diag { background: #fff; border-radius: 16px; padding: 10px 14px; box-shadow: var(--bb-shadow); }
.diag dl { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px 14px; margin: 0; }
.diag dt { font-size: 11px; font-weight: 800; text-transform: uppercase; color: #5d4f73; }
.diag dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; }

/* The live website: no decoration over it, no scaling that breaks coordinates. */
.viewport {
  position: relative; flex: 1; min-height: 0; background: #1f1730; border-radius: 18px; overflow: hidden;
  outline: none; box-shadow: inset 0 0 0 2px #e7dcf5;
}
.viewport.kbd-on { box-shadow: inset 0 0 0 3px var(--bb-yellow); }
.viewport video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #1f1730; cursor: default; }
.viewport.control video { cursor: crosshair; }
.kbd-sink { position: absolute; left: 0; top: 0; width: 1px; height: 1px; opacity: 0; border: 0; padding: 0; resize: none; pointer-events: none; }
.overlay {
  position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 24px;
  background: var(--bb-cream); color: var(--bb-purple-deep);
}
.overlay b { font: 900 22px var(--bb-font-heading); }
.overlay p { margin-top: 6px; color: #5d4f73; }

.strip {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 13px;
  background: #fff; border-radius: 14px; padding: 8px 14px; box-shadow: 0 1px 0 #e7dcf5;
}
.strip .sep { width: 1px; height: 16px; background: #e0d5ef; }
.dot.live { background: #c9c0d6; }
.dot.live.on { background: var(--bb-green); }

/* Dropdown relayed from the host page (native <select> lists are not in the stream). */
.select-pop {
  position: absolute; z-index: 3; min-width: 180px; max-height: 50%; overflow: auto;
  background: #fff; border-radius: 12px; box-shadow: 0 12px 32px rgba(46,33,64,.35); border: 2px solid var(--bb-purple-deep); padding: 4px;
}
.select-pop button {
  display: block; width: 100%; text-align: left; border: 0; background: transparent; font: 15px var(--bb-font-body);
  color: var(--bb-ink); padding: 8px 10px; border-radius: 8px; min-height: 36px; cursor: pointer;
}
.select-pop button:hover, .select-pop button:focus-visible { background: var(--bb-lilac); }
.select-pop button[aria-selected=true] { font-weight: 800; background: #FFF6CC; }
.select-pop button:disabled { color: #9a90a8; cursor: not-allowed; }
.select-pop .grp { font-size: 12px; font-weight: 800; color: #5d4f73; padding: 6px 10px 2px; }
.picker-pop { padding: 10px; display: grid; gap: 8px; }
.picker-pop input { font: 16px var(--bb-font-body); min-height: 40px; border: 2px solid #d9cbee; border-radius: 10px; padding: 4px 8px; }
.picker-pop input[type=color] { width: 100%; height: 44px; padding: 2px; }
.btn.mini { min-height: 36px; padding: 6px 12px; font-size: 14px; }
.dlg-text { white-space: pre-wrap; max-height: 40vh; overflow: auto; }
#soundBtn { font-size: 18px; }

dialog { border: 0; border-radius: 24px; padding: 20px; width: min(440px, 92vw); box-shadow: var(--bb-shadow); }
dialog::backdrop { background: rgba(46,33,64,.45); }
dialog h2 { color: var(--bb-purple-deep); }
.choice { display: flex; gap: 10px; align-items: center; min-height: 40px; }
.choice input { width: 20px; height: 20px; accent-color: var(--bb-purple-deep); }

/* Phones: view-first layout; control requires a desktop browser. */
@media (max-width: 760px) {
  .work, .work.collapsed { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .sidebar { border-radius: 0 0 22px 22px; padding: 12px; gap: 8px; }
  .side-body { gap: 6px; }
  .tab-list { min-height: 52px; max-height: 26vh; }
  .conn-card { display: none; } /* status is shown in the pill above the viewport */
  .btn.leave { min-height: 40px; }
  .work.collapsed .side-body { display: none; }
  .work.collapsed .brand { flex-direction: row; }
  .work.collapsed .brand span { display: block; }
  .zoom, #diagBtn { display: none; }
  .main { padding: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Single-window (native host) mode: one clean live view, no tab-model chrome. */
.work.window-mode { grid-template-columns: 1fr; }
.work.window-mode .sidebar { display: none; }
.work.window-mode #backBtn,
.work.window-mode #fwdBtn,
.work.window-mode #reloadBtn,
.work.window-mode #urlForm,
.work.window-mode .zoom { display: none; }
