/* Lab Stream viewer: Windows App web client look (dark, neutral, Fluent-like). No gradients, 4 px radii. */
:root {
  color-scheme: dark;
  --bg: #000;
  --surface: #2b2b2b;        /* bar, menus, panels */
  --surface-2: #323232;      /* hover */
  --surface-3: #3a3a3a;      /* pressed / active */
  --card: #202020;           /* screens, dialog */
  --line: rgba(255, 255, 255, .09);
  --line-strong: rgba(255, 255, 255, .16);
  --fg: #fff;
  --fg-2: rgba(255, 255, 255, .79);
  --fg-3: rgba(255, 255, 255, .55);
  --accent: #60cdff;
  --accent-fg: #000;
  --ok: #6ccb5f;
  --warn: #fce100;
  --bad: #ff99a4;
  --danger: #c42b1c;
  --shadow: 0 8px 16px rgba(0, 0, 0, .28), 0 0 2px rgba(0, 0, 0, .24);
  --r: 4px;
  --font: "Segoe UI", "Segoe UI Variable Text", system-ui, -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg); font: 14px/20px var(--font); overflow: hidden; }
[hidden] { display: none !important; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.ic { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.ic.sm { width: 12px; height: 12px; stroke-width: 2; }
.ic.xs { width: 10px; height: 10px; stroke-width: 2.25; }
h1, h2 { margin: 0; font-weight: 600; }
kbd { font: 12px/16px var(--font); color: var(--fg-3); }

/* ----- stage / video ----- */
#stage { position: fixed; inset: 0; display: flex; overflow: hidden; background: #000; }
#video { width: 100%; height: 100%; margin: auto; flex: none; object-fit: contain; background: #000; outline: none;
  touch-action: none; user-select: none; -webkit-user-select: none; }
#stage.actual { overflow: auto; }
#stage.actual #video { width: auto; height: auto; }

/* ----- buttons ----- */
button { font: inherit; color: inherit; }
.btn { min-width: 80px; height: 32px; padding: 0 12px; border-radius: var(--r); border: 1px solid var(--line-strong);
  background: var(--surface-2); color: var(--fg); cursor: pointer; font-size: 14px; }
.btn:hover { background: var(--surface-3); }
.btn:active { color: var(--fg-2); }
.btn.primary { background: var(--accent); color: var(--accent-fg); border-color: transparent; }
.btn.primary:hover { background: #5abce8; }
.btn.danger-solid { background: var(--danger); color: #fff; border-color: transparent; }
.btn.danger-solid:hover { background: #b0261a; }
.btn:focus-visible, .tb:focus-visible, .menu button:focus-visible, #tb-handle:focus-visible, textarea:focus-visible, .switch:focus-visible {
  outline: 2px solid var(--fg); outline-offset: 1px; }

/* ----- toolbar ----- */
#toolbar { position: fixed; top: 0; left: 0; right: 0; height: 0; z-index: 30; display: flex; justify-content: center; pointer-events: none; }
#toolbar > * { pointer-events: auto; }
#tb-handle { position: absolute; top: 0; width: 40px; height: 12px; padding: 0; display: flex; align-items: center; justify-content: center;
  background: var(--surface); color: var(--fg-2); border: 1px solid var(--line-strong); border-top: 0; border-radius: 0 0 var(--r) var(--r);
  box-shadow: 0 2px 4px rgba(0, 0, 0, .3); cursor: pointer; transition: opacity .12s; }
#tb-handle:hover { background: var(--surface-2); color: var(--fg); }
#toolbar.expanded #tb-handle { opacity: 0; pointer-events: none; }

#bar { position: absolute; top: 0; display: flex; align-items: center; gap: 2px; height: 44px; padding: 0 6px 0 10px;
  background: var(--surface); border: 1px solid var(--line-strong); border-top: 0; border-radius: 0 0 var(--r) var(--r);
  box-shadow: var(--shadow); white-space: nowrap; max-width: calc(100vw - 16px); transform: translateY(-100%); visibility: hidden;
  transition: transform .16s cubic-bezier(.1, .9, .2, 1), visibility 0s linear .16s; }
#toolbar.expanded #bar { transform: none; visibility: visible; transition: transform .16s cubic-bezier(.1, .9, .2, 1), visibility 0s; }
.sep { width: 1px; height: 20px; margin: 0 6px; background: var(--line-strong); flex: none; }

.identity { flex: 0 1 auto; display: flex; align-items: center; gap: 8px; padding-right: 2px; min-width: 0; max-width: 320px; }
.id-ic { color: var(--fg-2); }
.id-text { display: flex; flex-direction: column; min-width: 0; }
.id-line { display: flex; align-items: center; gap: 6px; min-width: 0; }
.id-label { font-size: 13px; line-height: 16px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.id-mac { font-size: 11px; line-height: 14px; color: var(--fg-3); overflow: hidden; text-overflow: ellipsis; }
.chip { flex: none; font-size: 11px; line-height: 16px; padding: 0 6px; border-radius: var(--r); border: 1px solid var(--line-strong);
  color: var(--fg-2); background: rgba(255, 255, 255, .06); }
.chip:empty { display: none; }

.status { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--fg-2); padding: 0 2px; }
.status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--warn); flex: none; }
.status[data-state="connected"] .dot { background: var(--ok); }
.status[data-state="disconnected"] .dot { background: var(--bad); }
.status[data-state="connecting"] .dot, .status[data-state="reconnecting"] .dot { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }

.tb { position: relative; width: 32px; height: 32px; padding: 0; display: inline-flex; align-items: center; justify-content: center;
  border: 0; border-radius: var(--r); background: transparent; color: var(--fg); cursor: pointer; flex: none; }
.tb:hover { background: var(--surface-2); }
.tb:active, .tb.active, .tb[aria-pressed="true"] { background: var(--surface-3); }
.tb[aria-disabled="true"] { color: var(--fg-3); opacity: .55; cursor: default; }
.tb[aria-disabled="true"]:hover { background: transparent; }
.tb.danger { color: var(--bad); }
.tb.danger:hover { background: rgba(255, 153, 164, .14); }
.tb.sm { width: 24px; height: 24px; }
.badge-dot { position: absolute; top: 5px; right: 5px; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }

/* Tooltips (CSS only, so they also work on the aria-disabled Upload button). */
[data-tip]::after { content: attr(data-tip); position: absolute; top: calc(100% + 8px); left: 50%; transform: translateX(-50%);
  padding: 5px 8px; border-radius: var(--r); background: var(--card); border: 1px solid var(--line-strong); color: var(--fg);
  font-size: 12px; line-height: 16px; white-space: nowrap; box-shadow: var(--shadow); pointer-events: none;
  opacity: 0; transition: opacity .1s; z-index: 2; }
[data-tip]:hover::after { opacity: 1; transition-delay: .45s; }
[data-tip]:focus-visible::after { opacity: 1; }
[data-tip].active::after { display: none; }

/* ----- popovers: menus and panels ----- */
.popover { position: fixed; top: 50px; left: 0; z-index: 31; background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: var(--r); box-shadow: var(--shadow); animation: pop .12s cubic-bezier(.1, .9, .2, 1); }
@keyframes pop { from { opacity: 0; transform: translateY(-4px); } }
.menu { min-width: 248px; padding: 4px; display: flex; flex-direction: column; }
.menu-title { padding: 6px 10px 4px; font-size: 12px; color: var(--fg-3); }
.menu button { display: flex; align-items: center; gap: 10px; height: 32px; padding: 0 10px 0 8px; border: 0; border-radius: var(--r);
  background: transparent; color: var(--fg); text-align: left; cursor: pointer; font-size: 14px; }
.menu button:hover, .menu button:focus-visible { background: var(--surface-2); }
.menu button:active { background: var(--surface-3); }
.mi-check { width: 12px; display: inline-flex; color: var(--accent); }
.mi-check .ic { visibility: hidden; }
.menu [aria-checked="true"] .mi-check .ic { visibility: visible; }
.mi-label { flex: 1; }
.menu-sep { height: 1px; margin: 4px -4px; background: var(--line); }
.menu-note { padding: 6px 10px 6px 30px; font-size: 12px; line-height: 16px; color: var(--fg-3); white-space: normal; max-width: 280px; }

.panel { width: 340px; padding: 16px; }
.panel h2 { font-size: 14px; line-height: 20px; margin-bottom: 12px; }
.field-label { display: block; font-size: 12px; color: var(--fg-2); margin: 0 0 4px; }
textarea { width: 100%; resize: vertical; min-height: 64px; max-height: 240px; padding: 6px 8px; font: 13px/18px var(--font);
  color: var(--fg); background: rgba(255, 255, 255, .05); border: 1px solid var(--line-strong); border-bottom-color: rgba(255, 255, 255, .5);
  border-radius: var(--r); outline: none; }
textarea:focus { border-bottom: 2px solid var(--accent); padding-bottom: 5px; }
textarea[readonly] { color: var(--fg-2); background: rgba(255, 255, 255, .03); border-bottom-color: var(--line-strong); }
.row { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin: 8px 0 14px; }
.row .hint { margin-right: auto; }
.hint { font-size: 12px; line-height: 16px; color: var(--fg-3); }
.hint.foot { margin: 12px 0 0; }
.divider { height: 1px; background: var(--line); margin: 2px -16px 12px; }
.switch-row { display: flex; align-items: flex-start; gap: 12px; padding: 6px 0; cursor: pointer; }
.switch-text { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.switch-title { font-size: 14px; }
.switch { appearance: none; -webkit-appearance: none; flex: none; width: 40px; height: 20px; margin: 0; border-radius: 10px;
  border: 1px solid var(--fg-2); background: transparent; position: relative; cursor: pointer; transition: background .12s; }
.switch::before { content: ""; position: absolute; top: 3px; left: 3px; width: 12px; height: 12px; border-radius: 50%;
  background: var(--fg-2); transition: transform .12s; }
.switch:checked { background: var(--accent); border-color: var(--accent); }
.switch:checked::before { transform: translateX(20px); background: var(--accent-fg); }

/* ----- clipboard sync, password confirm, toast ----- */
.sync-state { display: flex; align-items: center; gap: 6px; margin: 2px 0 8px; font-size: 12px; color: var(--fg-2); }
.sync-state .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); flex: none; }
.sync-state[data-state="off"] .dot, .sync-state[data-state="offline"] .dot { background: var(--fg-3); }
.sync-state[data-state="blocked"] .dot { background: var(--warn); }
.sync-note { display: flex; align-items: center; gap: 10px; margin: 0 0 10px; padding: 8px 10px; border-radius: var(--r);
  background: rgba(252, 225, 0, .08); border: 1px solid var(--line-strong); font-size: 12px; line-height: 16px; color: var(--fg-2); }
.sync-note span { flex: 1; }
.sync-note .btn { min-width: 0; height: 28px; }
.manual { border-top: 1px solid var(--line); margin: 6px -16px -4px; padding: 8px 16px 0; }
.manual summary { cursor: pointer; font-size: 13px; color: var(--fg-2); padding: 2px 0 8px; }
.manual[open] summary { color: var(--fg); }
.panel.confirm { width: 300px; }
.confirm-text { margin: 0; font-size: 13px; line-height: 18px; color: var(--fg-2); }
.confirm .row { margin: 12px 0 0; }
.menu button[aria-disabled="true"] { color: var(--fg-3); cursor: default; }
.menu button[aria-disabled="true"]:hover { background: transparent; }
#toast { position: fixed; left: 50%; bottom: 40px; transform: translateX(-50%); z-index: 45; padding: 8px 14px; border-radius: var(--r);
  background: var(--card); border: 1px solid var(--line-strong); box-shadow: var(--shadow); font-size: 13px; pointer-events: none; }

/* ----- connection details ----- */
.stats { position: fixed; top: 24px; right: 12px; z-index: 25; width: 300px; padding: 12px 14px; background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: var(--r); box-shadow: var(--shadow); }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin: -2px -4px 8px 0; }
.panel-head h2 { margin: 0; }
#stats-body div { display: flex; justify-content: space-between; gap: 16px; font-size: 12px; line-height: 20px; }
#stats-body div span:first-child { color: var(--fg-3); }
#stats-body div span:last-child { font-variant-numeric: tabular-nums; text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ----- identity badge (always visible) ----- */
#id-badge { position: fixed; right: 8px; bottom: 8px; z-index: 24; display: flex; align-items: center; gap: 6px; max-width: 60vw;
  padding: 2px 8px; border-radius: var(--r); background: rgba(32, 32, 32, .78); border: 1px solid var(--line);
  font-size: 11px; line-height: 18px; color: var(--fg-2); pointer-events: none; white-space: nowrap; }
#id-badge .id-label { font-size: 11px; line-height: 18px; font-weight: 600; color: var(--fg); }
#id-badge .chip { font-size: 10px; line-height: 14px; padding: 0 4px; }
#id-badge .id-mac { font-size: 11px; line-height: 18px; }
#id-badge .id-label:empty, #id-badge .id-mac:empty { display: none; }

/* ----- screens ----- */
#screen { position: fixed; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center; padding: 24px;
  background: rgba(0, 0, 0, .72); }
#screen[data-kind="ended"] { background: #1a1a1a; }
.screen-card { width: 440px; max-width: 100%; padding: 28px 28px 24px; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--r); box-shadow: var(--shadow); text-align: center; }
.screen-card h1 { font-size: 20px; line-height: 28px; font-weight: 600; }
#screen-detail { margin: 8px 0 0; color: var(--fg-2); }
#screen-code { margin: 10px 0 0; font-size: 12px; color: var(--fg-3); }
.screen-card .actions { margin-top: 20px; justify-content: center; }
.actions { display: flex; gap: 8px; }
.spinner { width: 32px; height: 32px; margin: 0 auto 18px; border-radius: 50%; border: 3px solid rgba(255, 255, 255, .12);
  border-top-color: var(--accent); animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ----- dialog ----- */
#dialog-backdrop { position: fixed; inset: 0; z-index: 40; display: flex; align-items: center; justify-content: center; background: rgba(0, 0, 0, .5); }
#dialog { width: 400px; max-width: calc(100% - 32px); background: var(--card); border: 1px solid var(--line-strong); border-radius: var(--r);
  box-shadow: var(--shadow); overflow: hidden; }
#dialog h2 { font-size: 20px; line-height: 28px; padding: 24px 24px 0; }
#dialog p { margin: 8px 0 0; padding: 0 24px 24px; color: var(--fg-2); }
#dialog .actions { padding: 20px 24px; background: var(--surface); border-top: 1px solid var(--line); }
#dialog .actions .btn { flex: 1; }

@media (prefers-reduced-motion: reduce) { #bar, #toolbar.expanded #bar, .popover, .switch, .switch::before, [data-tip]::after { transition: none; animation: none; } }
