:root {
  --bg: #f2f2f7;
  --card: #ffffff;
  --text: #111114;
  --muted: #6e6e76;
  --line: rgba(60, 60, 67, 0.14);
  --accent: #5b4cf0;
  --accent-soft: rgba(91, 76, 240, 0.12);
  --on: #22a447;
  --off: #a1a1aa;
  --warn-bg: #fff4dd;
  --warn-text: #7a4b00;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.05), 0 6px 24px rgba(0, 0, 0, 0.06);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --card: #1c1c1e;
    --text: #f5f5f7;
    --muted: #98989f;
    --line: rgba(84, 84, 88, 0.5);
    --accent: #8b7fff;
    --accent-soft: rgba(139, 127, 255, 0.16);
    --on: #32d74b;
    --off: #636366;
    --warn-bg: #3a2c0c;
    --warn-text: #ffd48a;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; border: 0; background: none; padding: 0; cursor: pointer; }
[hidden] { display: none !important; }

.app {
  max-width: 640px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 20px) 16px calc(env(safe-area-inset-bottom) + 140px);
}

/* Header */
.eyebrow { font-size: 13px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
.title-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 2px; }
h1 { font-size: 30px; line-height: 1.15; margin: 0; letter-spacing: -0.02em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.status .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--off); }
.status.online .dot { background: var(--on); box-shadow: 0 0 0 4px color-mix(in srgb, var(--on) 20%, transparent); }
.status.online { color: var(--text); }
.subline { margin: 6px 0 0; color: var(--muted); font-size: 15px; }

/* Notices */
.notice { margin-top: 16px; padding: 12px 14px; border-radius: 14px; background: var(--warn-bg); color: var(--warn-text); font-size: 15px; }

/* Primary action */
.primary {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; margin-top: 18px; padding: 15px 18px; border-radius: 14px;
  background: var(--accent); color: #fff; font-weight: 600; font-size: 17px;
}
.primary:active { transform: scale(0.99); opacity: 0.9; }
.primary[disabled] { opacity: 0.5; }
.all-good { margin-top: 18px; padding: 14px; border-radius: 14px; background: var(--card); color: var(--muted); text-align: center; font-size: 15px; box-shadow: var(--shadow); }

/* Session list */
.list { margin: 0; padding: 0; list-style: none; background: var(--card); border-radius: 14px; overflow: hidden; box-shadow: var(--shadow); }
.row { display: flex; align-items: center; gap: 12px; padding: 12px 12px 12px 16px; min-height: 64px; }
.row + .row { border-top: 0.5px solid var(--line); }
.row .dot { flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--off); }
.row.on .dot { background: var(--on); }
.row.waking .dot { background: none; border: 2px solid var(--accent); border-top-color: transparent; width: 14px; height: 14px; margin: -2px; animation: spin 0.8s linear infinite; }
.row .body { flex: 1; min-width: 0; }
.row .name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .meta { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .pin { color: var(--muted); font-size: 12px; margin-left: 4px; }
.pill { flex: none; padding: 6px 12px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: 14px; font-weight: 600; }
.pill[disabled] { opacity: 0.45; }
.empty { padding: 28px 16px; text-align: center; color: var(--muted); font-size: 15px; }
.hint { margin: 10px 4px 0; color: var(--muted); font-size: 13px; }

.list-head { display: flex; align-items: baseline; justify-content: space-between; margin: 24px 4px 8px; }
.list-head h2 { margin: 0; font-size: 13px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
.list-head h2 span { margin-left: 6px; font-weight: 500; letter-spacing: 0; text-transform: none; }
.text-button { color: var(--accent); font-size: 17px; }
.text-button.bold { font-weight: 600; }
.intro { margin-top: 18px; padding: 18px 16px; }
.intro strong { font-size: 18px; }
.intro p { margin: 6px 0 0; color: var(--muted); font-size: 15px; }

/* Choosing sessions */
.picker-bar { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between;
  margin: calc(-1 * env(safe-area-inset-top) - 20px) -16px 0; padding: calc(env(safe-area-inset-top) + 12px) 16px 12px;
  background: color-mix(in srgb, var(--bg) 88%, transparent); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px); }
.picker-bar strong { font-size: 17px; }
.picker-bar + .subline { margin: 4px 4px 14px; }
.row.pick { width: 100%; text-align: left; }
.list li + li .row.pick { border-top: 0.5px solid var(--line); }
.row.pick .name, .row.pick .meta { display: block; }
.row.pick[disabled] { opacity: 0.4; }
.check { flex: none; width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--off); display: grid; place-items: center; color: #fff; font-size: 14px; font-weight: 700; }
.row.pick[aria-pressed="true"] .check { background: var(--accent); border-color: var(--accent); }

/* Settings cards */
.section { margin-top: 26px; }
.section h2 { margin: 0 0 8px 4px; font-size: 13px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
.card { background: var(--card); border-radius: 14px; box-shadow: var(--shadow); overflow: hidden; }
.setting { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; }
.setting + .setting { border-top: 0.5px solid var(--line); }
.setting small { display: block; color: var(--muted); font-size: 13px; }
.link-danger { color: #e5484d; font-weight: 500; }
.switch { position: relative; flex: none; width: 51px; height: 31px; border-radius: 999px; background: color-mix(in srgb, var(--off) 45%, transparent); transition: background 0.2s; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2); transition: transform 0.2s; }
.switch[aria-checked="true"] { background: var(--on); }
.switch[aria-checked="true"]::after { transform: translateX(20px); }

/* Welcome (no computer linked yet) */
.welcome { text-align: center; padding-top: 8vh; }
.welcome img { width: 96px; height: 96px; border-radius: 22px; box-shadow: var(--shadow); }
.welcome h1 { white-space: normal; margin-top: 18px; }
.welcome p { color: var(--muted); max-width: 440px; margin: 12px auto 0; }
.steps { text-align: left; max-width: 440px; margin: 28px auto 0; padding: 0; list-style: none; counter-reset: step; }
.steps li { position: relative; padding: 12px 0 12px 44px; counter-increment: step; }
.steps li::before { content: counter(step); position: absolute; left: 0; top: 10px; width: 30px; height: 30px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-weight: 700; display: grid; place-items: center; }

.foot { margin-top: 30px; text-align: center; color: var(--muted); font-size: 12px; }
.foot a { color: inherit; }

/* Add to Home Screen */
.install { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; padding: 0 12px calc(env(safe-area-inset-bottom) + 6px); pointer-events: none; }
.install-card {
  pointer-events: auto; display: flex; align-items: center; gap: 12px; max-width: 520px; margin: 0 auto;
  padding: 12px 14px; border-radius: 18px; background: color-mix(in srgb, var(--card) 92%, transparent);
  -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.18); border: 0.5px solid var(--line);
}
.install-icon { width: 44px; height: 44px; border-radius: 10px; flex: none; }
.install-text { flex: 1; min-width: 0; font-size: 14px; line-height: 1.35; }
.install-text strong { display: block; font-size: 15px; }
.install-text span { color: var(--muted); }
.install-text b { color: var(--text); font-weight: 600; }
.install-arrow { display: block; width: 30px; height: 40px; margin: 4px 0 0; color: var(--accent); animation: bounce 1.1s ease-in-out infinite; filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.2)); }
.install[data-arrow="bottom-right"] .install-arrow { margin-left: auto; margin-right: 14px; }
.install[data-arrow="bottom-center"] .install-arrow { margin-left: auto; margin-right: auto; }
/* Safari 26+: the ☰ page menu sits about a quarter of the way across the bottom bar. */
.install[data-arrow="bottom-left"] .install-arrow { margin-left: calc(26vw - 27px); }
body.has-install-bottom .app { padding-bottom: calc(env(safe-area-inset-bottom) + 230px); }
.install[data-arrow="top-right"] { top: 0; bottom: auto; padding: calc(env(safe-area-inset-top) + 2px) 12px 0; display: flex; flex-direction: column-reverse; }
.install[data-arrow="top-right"] .install-arrow { transform: rotate(180deg); margin-left: auto; margin-right: 22px; margin-bottom: 4px; animation-name: bounce-up; }
.install[data-arrow="none"] .install-arrow { display: none; }
body.has-install-top .app { padding-top: calc(env(safe-area-inset-top) + 150px); }

@keyframes bounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(9px); } }
@keyframes bounce-up { 0%, 100% { transform: rotate(180deg) translateY(0); } 50% { transform: rotate(180deg) translateY(9px); } }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .install-arrow { animation: none; } }

/* Toast */
.toast {
  position: fixed; left: 50%; top: calc(env(safe-area-inset-top) + 12px); transform: translateX(-50%); z-index: 20;
  max-width: min(92vw, 520px); padding: 12px 16px; border-radius: 14px; background: rgba(28, 28, 30, 0.94); color: #fff;
  font-size: 15px; box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
}
.notice-button { display: block; margin-top: 10px; padding: 8px 14px; border-radius: 999px; background: var(--warn-text); color: var(--warn-bg); font-size: 14px; font-weight: 600; }

/* Computers (shown when more than one is linked) */
.chips { display: flex; gap: 8px; overflow-x: auto; margin: 0 -16px 14px; padding: 2px 16px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; display: inline-flex; align-items: center; gap: 7px; padding: 7px 13px; border-radius: 999px; background: var(--card); box-shadow: var(--shadow); font-size: 14px; font-weight: 600; white-space: nowrap; }
.chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--off); }
.chip .dot.online { background: var(--on); }
.chip[aria-pressed="true"] { background: var(--accent); color: #fff; }
.chip[aria-pressed="true"] .dot { box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.6); }
.chip-count { min-width: 20px; padding: 1px 6px; border-radius: 999px; background: #ff3b30; color: #fff; font-size: 12px; text-align: center; }
.chip.add { padding: 7px 12px; color: var(--accent); font-size: 16px; }

/* Scanning a computer's QR code */
.scanner { position: relative; overflow: hidden; aspect-ratio: 1; border-radius: 18px; background: #000; }
.scanner video { width: 100%; height: 100%; object-fit: cover; }
.scan-frame { position: absolute; inset: 18%; border: 3px solid rgba(255, 255, 255, 0.9); border-radius: 18px; box-shadow: 0 0 0 999px rgba(0, 0, 0, 0.35); }
.welcome .primary { max-width: 440px; margin: 24px auto 0; }
