/* ───────────────────────── Design tokens ───────────────────────── */
:root {
  color-scheme: dark;
  --bg: #07080c;
  --bg-stage: #040508;
  --panel: hsl(228 22% 9% / 0.72);
  --panel-solid: hsl(228 20% 11%);
  --border: hsl(0 0% 100% / 0.08);
  --border-strong: hsl(0 0% 100% / 0.14);
  --text: hsl(225 25% 94%);
  --muted: hsl(226 12% 62%);
  --faint: hsl(226 10% 42%);
  --violet: hsl(248 100% 72%);
  --teal: hsl(172 70% 50%);
  --accent: linear-gradient(135deg, var(--violet), var(--teal));
  --ok: hsl(152 66% 55%);
  --warn: hsl(38 100% 64%);
  --danger: hsl(352 100% 68%);
  --radius-lg: 22px;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow-lg: 0 30px 80px -20px hsl(240 60% 2% / 0.8), 0 0 0 1px var(--border);
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", monospace;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.glass {
  background: var(--panel);
  backdrop-filter: blur(22px) saturate(160%);
  -webkit-backdrop-filter: blur(22px) saturate(160%);
  border: 1px solid var(--border);
}

/* ───────────────────────── Aurora background ───────────────────────── */
.aurora { position: fixed; inset: 0; overflow: hidden; pointer-events: none; z-index: 0; }
.aurora span {
  position: absolute;
  width: 60vmax; height: 60vmax;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.38;
  animation: drift 26s var(--ease-out) infinite alternate;
}
.aurora span:nth-child(1) { background: hsl(250 90% 55%); top: -20vmax; left: -15vmax; }
.aurora span:nth-child(2) { background: hsl(175 80% 38%); bottom: -25vmax; right: -15vmax; animation-delay: -8s; }
.aurora span:nth-child(3) { background: hsl(300 70% 40%); top: 30%; left: 45%; width: 35vmax; height: 35vmax; opacity: 0.18; animation-delay: -14s; }
@keyframes drift {
  0%   { transform: translate(0, 0) scale(1); }
  100% { transform: translate(6vmax, 4vmax) scale(1.15); }
}
body.in-session .aurora { opacity: 0; transition: opacity 0.6s; }

/* ───────────────────────── Login ───────────────────────── */
.login {
  position: relative; z-index: 1;
  min-height: 100%;
  display: grid; place-items: center;
  padding: 24px;
}
.login-card {
  width: min(400px, 100%);
  padding: 40px 36px 28px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  text-align: center;
  animation: rise 0.7s var(--ease-out) both;
}
@keyframes rise { from { opacity: 0; transform: translateY(18px) scale(0.98); } }

.brand-mark {
  display: block;
  width: 72px; height: 72px; margin: 0 auto 20px;
  border-radius: 20px;
  box-shadow: 0 12px 40px -8px hsl(248 100% 65% / 0.6);
  animation: glow 4s ease-in-out infinite;
}
@keyframes glow {
  50% { box-shadow: 0 12px 50px -4px hsl(172 70% 50% / 0.55); }
}
.login h1 { margin: 0; font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }
.subtitle { margin: 6px 0 28px; color: var(--muted); }

#login-form { text-align: left; display: grid; gap: 14px; }
.field-label { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.input-wrap { position: relative; display: flex; align-items: center; margin-top: -6px; }
.input-icon { position: absolute; left: 14px; width: 18px; height: 18px; color: var(--faint); pointer-events: none; transition: color 0.2s; }
.input-wrap input {
  width: 100%;
  height: 48px;
  padding: 0 46px 0 44px;
  font: 500 15px var(--font);
  color: var(--text);
  background: hsl(228 25% 5% / 0.6);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}
.input-wrap input::placeholder { color: var(--faint); }
.input-wrap input:focus { border-color: hsl(248 100% 72% / 0.7); box-shadow: 0 0 0 4px hsl(248 100% 72% / 0.15); background: hsl(228 25% 4% / 0.8); }
.input-wrap:focus-within .input-icon { color: var(--violet); }
.input-action {
  position: absolute; right: 6px;
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border: 0; border-radius: 9px;
  background: transparent; color: var(--faint);
  cursor: pointer; transition: color 0.2s, background 0.2s;
}
.input-action:hover { color: var(--text); background: hsl(0 0% 100% / 0.06); }
.input-action svg { width: 18px; height: 18px; }

.check { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; cursor: pointer; user-select: none; }
.check input { position: absolute; opacity: 0; pointer-events: none; }
.check-box {
  width: 18px; height: 18px; border-radius: 6px;
  border: 1px solid var(--border-strong);
  background: hsl(228 25% 5% / 0.6);
  display: grid; place-items: center;
  transition: background 0.2s, border-color 0.2s;
}
.check-box::after {
  content: ""; width: 9px; height: 5px;
  border-left: 2px solid white; border-bottom: 2px solid white;
  transform: rotate(-45deg) translate(1px, -1px) scale(0);
  transition: transform 0.2s var(--ease-out);
}
.check input:checked + .check-box { background: var(--violet); border-color: transparent; }
.check input:checked + .check-box::after { transform: rotate(-45deg) translate(1px, -1px) scale(1); }
.check input:focus-visible + .check-box { box-shadow: 0 0 0 3px hsl(248 100% 72% / 0.35); }

.btn-primary {
  position: relative;
  height: 50px; margin-top: 6px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: var(--radius);
  background: var(--accent);
  background-size: 160% 160%;
  color: white; font-weight: 600; font-size: 15px;
  cursor: pointer;
  overflow: hidden;
  box-shadow: 0 10px 30px -10px hsl(248 100% 65% / 0.8), inset 0 1px 0 hsl(0 0% 100% / 0.25);
  transition: transform 0.2s var(--ease-out), box-shadow 0.25s, background-position 0.6s;
}
.btn-primary::before {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(110deg, transparent 30%, hsl(0 0% 100% / 0.28) 50%, transparent 70%);
  transform: translateX(-100%);
  transition: transform 0.8s var(--ease-out);
}
.btn-primary:hover { transform: translateY(-1px); background-position: 100% 100%; box-shadow: 0 16px 36px -10px hsl(172 70% 50% / 0.7), inset 0 1px 0 hsl(0 0% 100% / 0.25); }
.btn-primary:hover::before { transform: translateX(100%); }
.btn-primary:active { transform: translateY(0) scale(0.99); }
.btn-primary:focus-visible { outline: 2px solid white; outline-offset: 3px; }
.btn-arrow { width: 18px; height: 18px; transition: transform 0.25s var(--ease-out); }
.btn-primary:hover .btn-arrow { transform: translateX(3px); }
.btn-spinner {
  display: none; width: 18px; height: 18px;
  border: 2px solid hsl(0 0% 100% / 0.35); border-top-color: white; border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.btn-primary.loading { pointer-events: none; }
.btn-primary.loading .btn-arrow { display: none; }
.btn-primary.loading .btn-spinner { display: block; }
@keyframes spin { to { transform: rotate(360deg); } }

.login-error { min-height: 20px; margin: 0; color: var(--danger); font-size: 13px; text-align: center; }
.login-error:not(:empty) { animation: shake 0.4s; }
@keyframes shake { 25% { transform: translateX(-6px); } 50% { transform: translateX(5px); } 75% { transform: translateX(-3px); } }

.login-foot {
  margin-top: 18px; padding-top: 18px;
  border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center; gap: 8px;
  color: var(--faint); font: 500 12px var(--mono);
}
.pulse-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 0 hsl(152 66% 55% / 0.6); animation: pulse 2s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 8px hsl(152 66% 55% / 0); } 100% { box-shadow: 0 0 0 0 hsl(152 66% 55% / 0); } }

/* ───────────────────────── Session ───────────────────────── */
.session { position: fixed; inset: 0; z-index: 1; display: flex; flex-direction: column; background: var(--bg-stage); }

.toolbar {
  position: relative; z-index: 10;
  align-self: center;
  margin: 10px 12px 0;
  height: 48px;
  padding: 0 6px 0 14px;
  display: flex; align-items: center; gap: 10px;
  border-radius: 16px;
  box-shadow: 0 14px 40px -12px hsl(240 60% 2% / 0.9);
  max-width: calc(100% - 24px);
  transition: transform 0.35s var(--ease-out), opacity 0.35s;
  animation: drop 0.5s var(--ease-out) both;
}
@keyframes drop { from { opacity: 0; transform: translateY(-14px); } }
.tb-sep { width: 1px; height: 22px; background: var(--border-strong); flex: none; }

.tb-host { display: flex; align-items: center; gap: 9px; min-width: 0; }
.host-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 160px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); flex: none; transition: background 0.3s, box-shadow 0.3s; }
.status-dot.good { background: var(--ok); box-shadow: 0 0 10px hsl(152 66% 55% / 0.8); }
.status-dot.fair { background: var(--warn); box-shadow: 0 0 10px hsl(38 100% 64% / 0.7); }
.status-dot.poor { background: var(--danger); box-shadow: 0 0 10px hsl(352 100% 68% / 0.7); }

/* Display switcher */
.segmented {
  position: relative;
  display: flex; gap: 2px; padding: 3px;
  border-radius: 12px;
  background: hsl(228 25% 4% / 0.6);
  border: 1px solid var(--border);
}
.seg-btn {
  position: relative;
  height: 32px; padding: 0 12px 0 8px;
  display: flex; align-items: center; gap: 8px;
  border: 0; border-radius: 9px;
  background: transparent; color: var(--muted);
  cursor: pointer; white-space: nowrap;
  transition: color 0.2s, background 0.25s;
}
.seg-btn:hover { color: var(--text); background: hsl(0 0% 100% / 0.05); }
.seg-btn[aria-pressed="true"] {
  color: white;
  background: linear-gradient(135deg, hsl(248 100% 72% / 0.32), hsl(172 70% 50% / 0.22));
  box-shadow: inset 0 0 0 1px hsl(248 100% 80% / 0.35), 0 4px 14px -4px hsl(248 100% 65% / 0.5);
}
.seg-btn:focus-visible { outline: 2px solid var(--violet); outline-offset: 1px; }
.seg-num {
  width: 20px; height: 20px; border-radius: 6px;
  display: grid; place-items: center;
  font: 600 11px var(--mono);
  background: hsl(0 0% 100% / 0.08);
}
.seg-btn[aria-pressed="true"] .seg-num { background: var(--accent); color: white; }
.seg-name { font-weight: 500; max-width: 140px; overflow: hidden; text-overflow: ellipsis; }
.seg-res { font: 500 11px var(--mono); color: var(--faint); }
.seg-btn[aria-pressed="true"] .seg-res { color: hsl(0 0% 100% / 0.6); }

.tb-stats { display: flex; gap: 14px; color: var(--faint); font-size: 12px; white-space: nowrap; }
.tb-stats b { font: 500 12px var(--mono); color: var(--text); display: inline-block; min-width: 2ch; text-align: right; }
.tb-stats i { font-style: normal; }

.tb-actions { display: flex; align-items: center; gap: 2px; }
.icon-btn {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border: 0; border-radius: 10px;
  background: transparent; color: var(--muted);
  cursor: pointer;
  transition: color 0.2s, background 0.2s, transform 0.15s;
}
.icon-btn svg { width: 19px; height: 19px; }
.icon-btn:hover { color: var(--text); background: hsl(0 0% 100% / 0.07); }
.icon-btn:active { transform: scale(0.92); }
.icon-btn:focus-visible { outline: 2px solid var(--violet); outline-offset: -2px; }
.icon-btn.danger:hover { color: var(--danger); background: hsl(352 100% 68% / 0.12); }
.icon-btn[aria-expanded="true"] { color: white; background: hsl(248 100% 72% / 0.2); }
#fullscreen-btn .ico-exit { display: none; }
.is-fullscreen #fullscreen-btn .ico-exit { display: block; }
.is-fullscreen #fullscreen-btn .ico-enter { display: none; }

.kbd-indicator {
  width: 32px; height: 32px; display: grid; place-items: center;
  color: var(--faint); border-radius: 9px;
  transition: color 0.25s, background 0.25s;
}
.kbd-indicator svg { width: 19px; height: 19px; }
.kbd-indicator.active { color: var(--teal); background: hsl(172 70% 50% / 0.12); }

/* Immersive (auto-hide) toolbar */
.toolbar-hotzone { display: none; }
.session.immersive .toolbar { position: absolute; top: 0; left: 50%; translate: -50% 0; }
.session.immersive .toolbar-hotzone { display: block; position: absolute; top: 0; left: 0; right: 0; height: 6px; z-index: 9; }
.session.immersive.toolbar-hidden .toolbar { transform: translateY(calc(-100% - 16px)); opacity: 0; pointer-events: none; }

/* Stage */
.stage {
  position: relative;
  flex: 1;
  min-height: 0;
  display: grid; place-items: center;
  padding: 12px;
  outline: none;
  background:
    radial-gradient(ellipse at 50% 0%, hsl(248 50% 20% / 0.25), transparent 60%),
    var(--bg-stage);
}
.session.immersive .stage { padding: 0; }
/* The canvas fills the stage; the Mac's screen is letterboxed and zoomed inside it (screen.js). */
#screen { display: block; width: 100%; height: 100%; cursor: default; }

.stage-overlay {
  position: absolute; inset: 0;
  display: grid; place-content: center; justify-items: center; gap: 18px;
  color: var(--muted);
  background: hsl(230 30% 3% / 0.55);
  backdrop-filter: blur(6px);
  transition: opacity 0.3s;
}
.stage-overlay.hide { opacity: 0; pointer-events: none; }
.stage-overlay p { margin: 0; font-weight: 500; }
.loader { display: flex; gap: 8px; }
.loader span { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); animation: bounce 1.1s var(--ease-out) infinite; }
.loader span:nth-child(2) { animation-delay: 0.15s; }
.loader span:nth-child(3) { animation-delay: 0.3s; }
@keyframes bounce { 0%, 100% { transform: translateY(0); opacity: 0.4; } 40% { transform: translateY(-10px); opacity: 1; } }

/* ───────────────────────── Menus (popovers) ───────────────────────── */
.menu {
  position: fixed; inset: auto; margin: 0;
  width: 300px; padding: 14px;
  border-radius: 16px;
  color: var(--text);
  box-shadow: var(--shadow-lg);
  background: hsl(228 22% 9% / 0.88);
  opacity: 0; transform: translateY(-6px) scale(0.98);
  transition: opacity 0.2s, transform 0.25s var(--ease-out), overlay 0.25s allow-discrete, display 0.25s allow-discrete;
}
.menu:popover-open { opacity: 1; transform: none; }
@starting-style { .menu:popover-open { opacity: 0; transform: translateY(-6px) scale(0.98); } }
.stream-info { margin: 10px 4px 0; font: 500 11px var(--mono); color: var(--faint); }
.stream-info:empty { display: none; }
.menu-title { margin: 2px 4px 10px; font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--faint); }
.menu-note { margin: 10px 4px 2px; font-size: 12px; color: var(--faint); line-height: 1.45; }
.menu-divider { height: 1px; background: var(--border); margin: 12px 0; }

.shortcut-list { display: grid; gap: 2px; }
.shortcut {
  display: flex; align-items: center; justify-content: space-between;
  height: 38px; padding: 0 10px;
  border: 0; border-radius: 10px;
  background: transparent; cursor: pointer; text-align: left;
  transition: background 0.15s;
}
.shortcut:hover, .shortcut:focus-visible { background: hsl(0 0% 100% / 0.07); outline: none; }
.shortcut kbd {
  font: 500 12px var(--mono); color: var(--muted);
  padding: 3px 7px; border-radius: 6px;
  background: hsl(0 0% 100% / 0.06); border: 1px solid var(--border);
}

.quality-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.quality-grid button {
  display: grid; gap: 3px; text-align: left;
  padding: 10px 12px;
  border: 1px solid var(--border); border-radius: 12px;
  background: hsl(228 25% 4% / 0.5);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}
.quality-grid button:hover { border-color: var(--border-strong); }
.quality-grid button span { font: 11.5px/1.35 var(--font); color: var(--faint); }
.quality-grid button[aria-checked="true"] {
  border-color: hsl(248 100% 72% / 0.6);
  background: linear-gradient(135deg, hsl(248 100% 72% / 0.18), hsl(172 70% 50% / 0.1));
}
.quality-grid button:focus-visible { outline: 2px solid var(--violet); outline-offset: 1px; }

.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 4px; cursor: pointer; }
.toggle-row span { display: grid; gap: 2px; }
.toggle-row small { color: var(--faint); font-size: 12px; }
.switch {
  appearance: none; flex: none;
  width: 38px; height: 22px; margin: 0;
  border-radius: 999px;
  background: hsl(0 0% 100% / 0.12);
  position: relative; cursor: pointer;
  transition: background 0.25s;
}
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 16px; height: 16px; border-radius: 50%;
  background: white; box-shadow: 0 2px 6px hsl(0 0% 0% / 0.4);
  transition: translate 0.25s var(--ease-out);
}
.switch:checked { background: var(--violet); }
.switch:checked::after { translate: 16px 0; }
.switch:focus-visible { outline: 2px solid var(--violet); outline-offset: 2px; }

/* ───────────────────────── Toasts ───────────────────────── */
.toasts { position: fixed; bottom: 20px; left: 50%; translate: -50% 0; z-index: 100; display: grid; gap: 8px; justify-items: center; pointer-events: none; }
.toast {
  padding: 10px 16px; border-radius: 12px;
  background: hsl(228 22% 11% / 0.92); backdrop-filter: blur(16px);
  border: 1px solid var(--border-strong);
  box-shadow: 0 14px 40px -12px black;
  font-weight: 500; font-size: 13px;
  animation: toast-in 0.35s var(--ease-out) both;
}
.toast.error { border-color: hsl(352 100% 68% / 0.45); color: hsl(352 100% 85%); }
.toast.out { animation: toast-out 0.3s forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px) scale(0.96); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(6px); } }

/* ───────────────────────── Touch ───────────────────────── */
/* No double-tap-to-zoom anywhere, so taps on buttons register immediately (no ~300 ms wait). */
html { touch-action: manipulation; }
/* The page handles every touch itself: no browser scrolling, zooming, text selection or callouts. */
.stage, #screen { touch-action: none; -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
.stage { overflow: hidden; }
.touch-only { display: none; }
.has-touch .touch-only:not([hidden]) { display: grid; }
/* On touch devices the keyboard button replaces the "keys go to the Mac" indicator. */
.has-touch .kbd-indicator { display: none; }
.icon-btn.on { color: white; background: hsl(172 70% 50% / 0.22); }

/* Off-screen text box that brings up the phone/tablet keyboard. 16px avoids iOS auto-zoom. */
.soft-kbd {
  position: fixed; left: 0; bottom: 0; width: 1px; height: 1px;
  opacity: 0; border: 0; padding: 0; resize: none; font-size: 16px;
  caret-color: transparent; color: transparent; background: transparent;
}

/* Special keys shown above the on-screen keyboard. */
.key-bar {
  position: fixed; left: 50%; translate: -50% 0; bottom: 8px; z-index: 30;
  display: flex; gap: 4px; padding: 5px;
  border-radius: 14px;
  max-width: calc(100vw - 16px); overflow-x: auto;
  box-shadow: 0 10px 30px -8px hsl(240 60% 2% / 0.9);
}
.key-bar[hidden] { display: none; }
.key-bar button {
  min-width: 40px; height: 38px; padding: 0 10px;
  border: 0; border-radius: 9px;
  background: hsl(0 0% 100% / 0.08); color: var(--text);
  font: 500 15px var(--font);
  flex: none;
}
.key-bar button:active { background: hsl(0 0% 100% / 0.18); }
.key-bar button[aria-pressed="true"] { background: var(--accent); color: white; }
.key-bar .done { color: var(--teal); font-weight: 600; }

/* ───────────────────────── Help & tour ───────────────────────── */
.demo-link {
  display: block; margin: 16px auto 0; padding: 10px 14px;
  border: 1px dashed hsl(172 70% 50% / 0.5); border-radius: 12px;
  background: hsl(172 70% 50% / 0.06); color: var(--muted);
  font: 14px var(--font); cursor: pointer;
}
.demo-link b { color: var(--teal); }
.demo-link:hover { background: hsl(172 70% 50% / 0.12); }
.session.demo .stage::after {
  content: "DEMO · practice here, nothing controls a real Mac";
  position: absolute; left: 50%; bottom: 14px; translate: -50% 0;
  padding: 6px 12px; border-radius: 999px;
  background: hsl(38 100% 64% / 0.92); color: #1a1205;
  font: 600 12px var(--font); letter-spacing: 0.02em; pointer-events: none; white-space: nowrap;
}
.login-help { margin-top: 18px; font-size: 13px; color: var(--muted); }
.login-help summary { cursor: pointer; color: var(--faint); list-style: none; text-align: center; }
.login-help summary::-webkit-details-marker { display: none; }
.login-help summary::after { content: " ›"; }
.login-help[open] summary { margin-bottom: 8px; }
.login-help ul { margin: 0; padding-left: 18px; display: grid; gap: 6px; line-height: 1.45; }
.login-help code { font: 12px var(--mono); color: var(--text); }
.login-help a, .help-dialog a { color: var(--teal); }

.btn-ghost {
  height: 38px; padding: 0 14px;
  display: inline-flex; align-items: center;
  border: 1px solid var(--border-strong); border-radius: 10px;
  background: transparent; color: var(--text); text-decoration: none;
  font: 500 14px var(--font); cursor: pointer;
}
.btn-ghost:hover { background: hsl(0 0% 100% / 0.06); }
.help-dialog a.btn-ghost { color: var(--text); }

.help-dialog {
  width: min(680px, calc(100vw - 24px)); max-height: min(86vh, 900px);
  padding: 0; border: 0; border-radius: 20px;
  color: var(--text); background: var(--panel-solid);
  box-shadow: var(--shadow-lg);
  display: none; flex-direction: column;
}
.help-dialog[open] { display: flex; }
.help-dialog::backdrop { background: hsl(230 30% 3% / 0.6); backdrop-filter: blur(4px); }
.help-head { display: flex; align-items: center; gap: 12px; padding: 16px 16px 12px 20px; border-bottom: 1px solid var(--border); }
.help-head img { border-radius: 10px; }
.help-head div { flex: 1; }
.help-head h2 { margin: 0; font-size: 18px; }
.help-head p { margin: 2px 0 0; font-size: 13px; color: var(--muted); }
.help-body { padding: 4px 20px 16px; overflow-y: auto; }
.help-body h3 { margin: 18px 0 10px; font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--faint); }
.help-body details { border-top: 1px solid var(--border); padding: 10px 0; }
.help-body summary { cursor: pointer; font-weight: 500; }
.help-body details p { margin: 8px 0 2px; color: var(--muted); line-height: 1.5; }
.help-note { color: var(--muted); font-size: 14px; line-height: 1.5; }
.help-list { margin: 0; display: grid; grid-template-columns: max-content 1fr; gap: 8px 16px; font-size: 14px; }
.help-list dt { font-weight: 600; }
.help-list dd { margin: 0; color: var(--muted); }
.legend { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; font-size: 14px; }
.legend li { display: flex; gap: 12px; align-items: center; color: var(--muted); }
.legend b { color: var(--text); margin-right: 4px; }
.legend-icon { flex: none; width: 34px; height: 34px; display: grid; place-items: center; border-radius: 9px; background: hsl(0 0% 100% / 0.07); color: var(--text); }
.legend-icon svg { width: 18px; height: 18px; }
.legend-num { width: 20px; height: 20px; border-radius: 6px; display: grid; place-items: center; font: 600 11px var(--mono); background: var(--accent); color: white; }
.help-foot { display: flex; gap: 10px; justify-content: flex-end; padding: 12px 20px 16px; border-top: 1px solid var(--border); }

/* Tour: a spotlight (a hole in a dark overlay) plus a card that explains it. */
.tour { position: fixed; inset: 0; z-index: 50; }
.tour[hidden] { display: none; }
.tour-spot {
  position: fixed; border-radius: 14px;
  box-shadow: 0 0 0 200vmax hsl(230 30% 3% / 0.72), 0 0 0 2px var(--teal), 0 0 30px 4px hsl(172 70% 50% / 0.5);
  transition: all 0.35s var(--ease-out);
  pointer-events: none;
}
.tour-spot.full { inset: 0; width: 0; height: 0; left: 50%; top: 50%; box-shadow: 0 0 0 200vmax hsl(230 30% 3% / 0.72); }
.tour-card {
  position: fixed; width: 360px; max-width: calc(100vw - 24px);
  padding: 20px; border-radius: 18px;
  box-shadow: var(--shadow-lg);
  transition: left 0.35s var(--ease-out), top 0.35s var(--ease-out);
  animation: drop 0.4s var(--ease-out) both;
}
.tour-card.center { left: 50% !important; top: 50% !important; translate: -50% -50%; }
.tour-card.wide { width: min(640px, calc(100vw - 24px)); }
.tour-card h2 { margin: 0 0 6px; font-size: 19px; }
.tour-card p { margin: 0; color: var(--muted); line-height: 1.5; }
.tour-art { margin: -4px 0 14px; display: grid; place-items: center; }
.tour-art[hidden] { display: none; }
.tour-nav { margin-top: 18px; display: flex; align-items: center; gap: 8px; }
.tour-skip, .tour-back { border: 0; background: transparent; color: var(--muted); font: 500 14px var(--font); cursor: pointer; padding: 8px; }
.tour-back[hidden] { display: none; }
.tour-dots { flex: 1; display: flex; gap: 5px; justify-content: center; }
.tour-dots span { width: 6px; height: 6px; border-radius: 50%; background: hsl(0 0% 100% / 0.2); }
.tour-dots span.on { background: var(--teal); width: 16px; border-radius: 3px; }
.tour-next { height: 40px; margin: 0; padding: 0 18px; width: auto; font-size: 15px; }

/* Illustrations */
.connect-art { width: 240px; height: 110px; }
.connect-art .dev, .connect-art .mac { fill: hsl(0 0% 100% / 0.06); stroke: var(--text); stroke-width: 2.5; }
.connect-art .dev-base { fill: var(--text); }
.connect-art .mac-stand { fill: none; stroke: var(--text); stroke-width: 2.5; stroke-linecap: round; }
.connect-art .mac { stroke: var(--teal); }
.connect-art .wave { fill: none; stroke: var(--teal); stroke-width: 3; stroke-linecap: round; opacity: 0.2; animation: wave 1.8s infinite; }
.connect-art .w2 { animation-delay: 0.3s; } .connect-art .w3 { animation-delay: 0.6s; }
.connect-art .dot { fill: var(--violet); }
@keyframes wave { 0%, 100% { opacity: 0.15; } 40% { opacity: 1; } }
.mouse-art { display: flex; gap: 12px; align-items: center; color: var(--muted); padding: 10px 0; }
.mouse-art kbd { font: 600 15px var(--mono); padding: 10px 16px; border-radius: 10px; background: hsl(0 0% 100% / 0.08); color: var(--text); box-shadow: inset 0 -2px 0 hsl(0 0% 100% / 0.12); }

.gesture-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 12px; width: 100%; }
.gesture-grid figure { margin: 0; text-align: center; }
.gesture-grid figcaption { display: grid; gap: 1px; margin-top: 4px; font-size: 13px; }
.gesture-grid figcaption span { color: var(--muted); font-size: 12px; }
.gesture { width: 100%; max-width: 150px; height: auto; }
.gesture .scr { fill: hsl(228 30% 16%); stroke: hsl(0 0% 100% / 0.14); }
.gesture .fp { fill: hsl(0 0% 100% / 0.85); stroke: var(--violet); stroke-width: 2; opacity: 0; }
.gesture .ring { fill: none; stroke: var(--teal); stroke-width: 2; opacity: 0; }
.gesture .win { fill: var(--violet); opacity: 0.8; }
.gesture .cursor { fill: white; stroke: black; stroke-width: 0.8; }
.gesture .lines path, .gesture .zoomed path { stroke: hsl(0 0% 100% / 0.35); stroke-width: 3; stroke-linecap: round; }
.gesture .zoomed rect { fill: hsl(248 100% 72% / 0.5); }
.gesture .ctxmenu rect { fill: hsl(228 20% 92%); }
.gesture .ctxmenu path { stroke: hsl(228 20% 60%); stroke-width: 2; }
.gesture .ctxmenu { opacity: 0; }

/* Each animation loops over 2.4 s. Fingertips are positioned with transforms. */
.g-tap .fp, .g-tap .ring { transform: translate(60px, 45px); animation: g-tap 2.4s infinite; }
.g-tap .ring { animation-name: g-ring; }
@keyframes g-tap { 0%, 15% { opacity: 0; } 25%, 45% { opacity: 1; } 55%, 100% { opacity: 0; } }
@keyframes g-ring { 0%, 28% { opacity: 0; r: 7; } 35% { opacity: 1; } 60%, 100% { opacity: 0; r: 22; } }
.g-double .fp, .g-double .ring { transform: translate(60px, 45px); }
.g-double .fp { animation: g-double 2.4s infinite; }
.g-double .ring { animation: g-double-ring 2.4s infinite; }
@keyframes g-double { 0%, 12% { opacity: 0; } 18%, 26% { opacity: 1; } 30% { opacity: 0.2; } 34%, 42% { opacity: 1; } 50%, 100% { opacity: 0; } }
@keyframes g-double-ring { 0%, 18% { opacity: 0; r: 7; } 24% { opacity: 1; } 34% { opacity: 0; r: 18; } 36% { opacity: 1; r: 7; } 55%, 100% { opacity: 0; r: 24; } }
.g-longpress .fp, .g-longpress .ring { transform: translate(52px, 40px); }
.g-longpress .fp { animation: g-long 2.4s infinite; }
.g-longpress .ring { animation: g-long-ring 2.4s infinite; }
.g-longpress .ctxmenu { animation: g-menu 2.4s infinite; }
@keyframes g-long { 0%, 8% { opacity: 0; } 14%, 60% { opacity: 1; } 68%, 100% { opacity: 0; } }
@keyframes g-long-ring { 0%, 14% { opacity: 0; r: 7; } 20% { opacity: 1; r: 8; } 50% { opacity: 1; r: 15; } 58%, 100% { opacity: 0; r: 15; } }
@keyframes g-menu { 0%, 50% { opacity: 0; } 56%, 88% { opacity: 1; } 96%, 100% { opacity: 0; } }
.g-drag .fp { animation: g-drag 2.4s infinite; }
.g-drag .win { animation: g-drag-win 2.4s infinite; }
@keyframes g-drag { 0% { opacity: 0; transform: translate(39px, 38px); } 8% { opacity: 1; transform: translate(39px, 38px) scale(1.25); } 30% { transform: translate(39px, 38px) scale(1); } 70% { opacity: 1; transform: translate(83px, 58px); } 80%, 100% { opacity: 0; transform: translate(83px, 58px); } }
@keyframes g-drag-win { 0%, 30% { transform: none; } 70%, 85% { transform: translate(44px, 20px); } 100% { transform: none; } }
.g-move .fp { animation: g-move 2.4s infinite; }
.g-move .cursor { animation: g-move-cur 2.4s infinite; }
@keyframes g-move { 0% { opacity: 0; transform: translate(30px, 60px); } 10% { opacity: 1; } 70% { opacity: 1; transform: translate(90px, 30px); } 80%, 100% { opacity: 0; transform: translate(90px, 30px); } }
@keyframes g-move-cur { 0%, 5% { transform: translate(34px, 40px); } 70%, 100% { transform: translate(94px, 10px); } }
.g-scroll .fp.a { animation: g-scroll-a 2.4s infinite; }
.g-scroll .fp.b { animation: g-scroll-b 2.4s infinite; }
.g-scroll .lines { animation: g-lines 2.4s infinite; }
@keyframes g-scroll-a { 0% { opacity: 0; transform: translate(48px, 68px); } 10% { opacity: 1; } 70% { opacity: 1; transform: translate(48px, 26px); } 80%, 100% { opacity: 0; transform: translate(48px, 26px); } }
@keyframes g-scroll-b { 0% { opacity: 0; transform: translate(72px, 68px); } 10% { opacity: 1; } 70% { opacity: 1; transform: translate(72px, 26px); } 80%, 100% { opacity: 0; transform: translate(72px, 26px); } }
@keyframes g-lines { 0%, 10% { transform: none; } 70%, 100% { transform: translateY(-42px); } }
.g-pinch .fp.a { animation: g-pinch-a 2.4s infinite; }
.g-pinch .fp.b { animation: g-pinch-b 2.4s infinite; }
.g-pinch .zoomed { transform-origin: 60px 45px; animation: g-zoom 2.4s infinite; }
@keyframes g-pinch-a { 0% { opacity: 0; transform: translate(52px, 50px); } 10% { opacity: 1; } 70% { opacity: 1; transform: translate(26px, 70px); } 80%, 100% { opacity: 0; transform: translate(26px, 70px); } }
@keyframes g-pinch-b { 0% { opacity: 0; transform: translate(68px, 40px); } 10% { opacity: 1; } 70% { opacity: 1; transform: translate(94px, 20px); } 80%, 100% { opacity: 0; transform: translate(94px, 20px); } }
@keyframes g-zoom { 0%, 10% { transform: scale(1); } 70%, 90% { transform: scale(2.2); } 100% { transform: scale(1); } }
.g-twotap .fp.a, .g-twotap .r2a { transform: translate(48px, 45px); }
.g-twotap .fp.b, .g-twotap .r2b { transform: translate(72px, 45px); }
.g-twotap .fp { animation: g-tap 2.4s infinite; }
.g-twotap .ring { animation: g-ring 2.4s infinite; }

@media (max-width: 640px) {
  .help-list { grid-template-columns: 1fr; gap: 2px; }
  .help-list dd { margin-bottom: 8px; }
  .tour-card { padding: 16px; }
}

/* ───────────────────────── Responsive ───────────────────────── */
@media (max-width: 900px) {
  .tb-stats { display: none; }
  .tb-stats + .tb-sep { display: none; }
  .seg-res { display: none; }
}
@media (max-width: 640px) {
  .seg-name, .host-name { display: none; }
  .toolbar { gap: 6px; padding-left: 10px; margin-top: max(6px, env(safe-area-inset-top)); }
  .tb-sep { display: none; }
  .kbd-indicator { display: none; }
  .stage { padding: 6px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
.session.demo .tb-stats, .session.demo .tb-stats + .tb-sep { visibility: hidden; }
.icon-btn[hidden] { display: none; }
