:root {
  --bench: #e4e8e4;
  --panel: #f4f6f3;
  --ink: #142320;
  --muted: #56655f;
  --line: #c9d1cc;
  --cobalt: #2c4bdb;
  --cobalt-ink: #1f37a8;
  --signal: #1f9d63;
  --danger: #b8382c;
  --body: #1b1e20;

  --font: 'Schibsted Grotesk', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --step--1: 0.8125rem;
  --step-0: 0.9375rem;
  --step-1: 1.125rem;
  --step-3: 2rem;

  --bezel: 10px;
  --screen-w: 280px;
  --screen-h: 600px;
  color-scheme: light;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
}

body {
  font-family: var(--font);
  font-size: var(--step-0);
  line-height: 1.5;
  color: var(--ink);
  background: var(--bench);
  -webkit-font-smoothing: antialiased;
}

button,
select,
input {
  font: inherit;
  color: inherit;
}

a {
  color: var(--cobalt-ink);
  text-underline-offset: 0.18em;
}

code {
  font-size: 0.92em;
  padding: 0.05em 0.3em;
  border-radius: 4px;
  background: #e2e7e3;
}

:focus-visible {
  outline: 2px solid var(--cobalt);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

/* Layout */

.app {
  display: grid;
  grid-template-columns: minmax(300px, 380px) 1fr;
  height: 100%;
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  padding: 1.75rem 1.75rem 1.25rem;
  overflow-y: auto;
  background: var(--panel);
  border-right: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.brand-mark {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: var(--ink);
  stroke-width: 2.4;
  stroke-linecap: round;
}

.brand-name {
  font-weight: 800;
  font-size: var(--step-1);
  letter-spacing: -0.01em;
}

h1 {
  margin: 0;
  font-size: var(--step-3);
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.025em;
  text-wrap: balance;
}

.lede {
  margin: 0.75rem 0 0;
  color: var(--muted);
  max-width: 34em;
}

.steps {
  margin: 1.25rem 0 0;
  padding: 0;
  list-style: none;
  counter-reset: step;
  display: grid;
  gap: 0.75rem;
}

.steps li {
  counter-increment: step;
  display: grid;
  grid-template-columns: 1.75rem 1fr;
  color: var(--muted);
}

.steps li::before {
  content: counter(step);
  grid-row: span 2;
  width: 1.375rem;
  height: 1.375rem;
  border-radius: 50%;
  border: 1.5px solid var(--ink);
  color: var(--ink);
  font-size: var(--step--1);
  font-weight: 600;
  display: grid;
  place-items: center;
  margin-top: 0.1rem;
}

.steps strong {
  color: var(--ink);
  font-weight: 600;
}

.session-label {
  margin: 0;
  color: var(--muted);
}

.device-name {
  margin-top: 0.15rem;
  word-break: break-word;
}

.device-meta {
  margin: 0.4rem 0 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.device-meta::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--signal);
}

.hint {
  margin: 1rem 0 0;
  color: var(--muted);
}

.unsupported {
  padding: 0.875rem 1rem;
  border-left: 3px solid var(--danger);
  background: #f6e7e4;
  color: #5a1d17;
}

.unsupported strong {
  display: block;
}

/* Buttons */

.actions {
  display: grid;
  gap: 0.75rem;
}

.primary,
.secondary {
  appearance: none;
  border: 0;
  cursor: pointer;
  font-weight: 600;
  font-size: var(--step-1);
  padding: 0.8rem 1.1rem;
  border-radius: 999px;
  transition: background-color 120ms ease, transform 120ms ease;
}

.primary {
  background: var(--cobalt);
  color: #fff;
}

.primary:hover {
  background: var(--cobalt-ink);
}

.primary:active,
.secondary:active {
  transform: translateY(1px);
}

.primary:disabled {
  background: #8d9ad6;
  cursor: progress;
}

.secondary {
  background: transparent;
  color: var(--ink);
  box-shadow: inset 0 0 0 1.5px var(--ink);
}

.secondary:hover {
  background: #e6ebe7;
}

.known p {
  margin: 0 0 0.35rem;
  color: var(--muted);
  font-size: var(--step--1);
}

.known ul {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.25rem;
}

.known button {
  appearance: none;
  width: 100%;
  text-align: left;
  border: 0;
  background: none;
  padding: 0.45rem 0;
  cursor: pointer;
  color: var(--cobalt-ink);
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 0.18em;
}

/* Disclosure panels */

details {
  border-top: 1px solid var(--line);
  padding-top: 0.9rem;
}

summary {
  cursor: pointer;
  font-weight: 600;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

summary::-webkit-details-marker {
  display: none;
}

summary::after {
  content: '';
  width: 7px;
  height: 7px;
  border-right: 1.75px solid currentColor;
  border-bottom: 1.75px solid currentColor;
  transform: rotate(45deg) translateY(-2px);
  transition: transform 150ms ease;
}

details[open] > summary::after {
  transform: rotate(225deg) translateY(-1px);
}

.settings-body {
  display: grid;
  gap: 0.85rem;
  padding-top: 0.9rem;
}

.field {
  display: grid;
  gap: 0.3rem;
}

.field span {
  font-size: var(--step--1);
  color: var(--muted);
}

select {
  appearance: none;
  width: 100%;
  padding: 0.55rem 2rem 0.55rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23142320' stroke-width='1.5'/%3E%3C/svg%3E")
    no-repeat right 0.75rem center / 10px;
}

.check {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 0.6rem;
  align-items: start;
  cursor: pointer;
}

.check input {
  margin: 0.25rem 0 0;
  width: 1rem;
  height: 1rem;
  accent-color: var(--cobalt);
}

.check small {
  grid-column: 2;
  color: var(--muted);
  font-size: var(--step--1);
}

.note {
  margin: 0;
  font-size: var(--step--1);
  color: var(--muted);
}

.help ul {
  margin: 0.75rem 0 0;
  padding-left: 1.1rem;
  display: grid;
  gap: 0.5rem;
  color: var(--muted);
}

.log ol {
  margin: 0.75rem 0 0;
  padding: 0.75rem;
  list-style: none;
  max-height: 14rem;
  overflow: auto;
  background: #e9ede9;
  border-radius: 8px;
  font-size: var(--step--1);
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

.log li + li {
  margin-top: 0.2rem;
}

.log li.error {
  color: var(--danger);
}

.credits {
  margin-top: auto;
  padding-top: 0.5rem;
  font-size: var(--step--1);
  color: var(--muted);
}

/* Stage, phone and cable */

.stage {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  padding: 2rem 2rem 0;
  overflow: hidden;
  min-height: 0;
}

.rig {
  display: flex;
  flex-direction: column;
  align-items: center;
  align-self: stretch;
  justify-content: center;
  min-width: 0;
}

.phone {
  flex: none;
  padding: var(--bezel);
  border-radius: calc(var(--bezel) * 3.2);
  background: var(--body);
  box-shadow:
    inset 0 0 0 1.5px #3a4044,
    0 1px 0 #fff8,
    0 24px 48px -28px #14232088;
}

.screen {
  position: relative;
  width: var(--screen-w);
  height: var(--screen-h);
  border-radius: calc(var(--bezel) * 2.2);
  overflow: hidden;
  background: #000;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: pointer;
  outline: none;
}

body:not([data-state='connected']) canvas {
  visibility: hidden;
}

.screen:has(canvas:focus-visible) {
  box-shadow: 0 0 0 2px var(--cobalt);
}

.screen-message,
.drop-hint {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  text-align: center;
  color: #b9c4bf;
  pointer-events: none;
}

.screen-message p,
.drop-hint p {
  margin: 0;
  max-width: 14em;
  font-weight: 500;
  text-wrap: balance;
}

body[data-state='connected'] .screen-message {
  display: none;
}

.drop-hint {
  display: none;
  background: #2c4bdbcc;
  color: #fff;
}

.screen.dropping .drop-hint {
  display: grid;
}

.cable {
  flex: none;
  width: 80px;
  height: clamp(56px, 13vh, 118px);
  margin-top: -1px;
  overflow: visible;
}

.boot {
  fill: #2a2f33;
}

.boot-ridges {
  fill: none;
  stroke: #3f464b;
  stroke-width: 1.2;
}

.mold-edge {
  fill: none;
  stroke: #ffffff14;
}

.wire-base,
.wire-pulse {
  fill: none;
  stroke-width: 8.5;
  stroke-linecap: round;
}

.wire-base {
  stroke: #30363a;
}

.wire-pulse {
  stroke: #8fa4ff;
  stroke-width: 3;
  stroke-dasharray: 24 4000;
  stroke-dashoffset: 24;
  opacity: 0;
}

body[data-state='connecting'] .wire-pulse {
  opacity: 1;
  animation: pulse 1.2s linear infinite;
}

body[data-state='connected'] .wire-pulse {
  opacity: 0.9;
  stroke-dasharray: none;
  stroke-width: 1.6;
  stroke: #6f86f0;
}

@keyframes pulse {
  from {
    stroke-dashoffset: 24;
  }
  to {
    stroke-dashoffset: -320;
  }
}

/* The cable leaves the phone where its USB port is: below in portrait, beside it in landscape. */
.rig[data-port='right'] {
  flex-direction: row;
}

.rig[data-port='left'] {
  flex-direction: row-reverse;
}

.rig[data-port='right'] .cable,
.rig[data-port='left'] .cable {
  width: clamp(56px, 13vh, 118px);
  height: 80px;
  margin: 0 0 0 -1px;
}

.rig[data-port='left'] .cable {
  margin: 0 -1px 0 0;
}

/* Keep the toolbar out of the cable's way. */
.stage:has(.rig[data-port='right']) .toolbar {
  order: -1;
}

/* Toolbar */

.toolbar {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  align-self: center;
  transition: opacity 200ms ease;
}

.stage:not(:fullscreen):has(.rig[data-port='bottom']) .toolbar {
  margin-bottom: clamp(56px, 13vh, 118px);
}

body:not([data-state='connected']) .toolbar {
  opacity: 0.35;
  pointer-events: none;
}

.group {
  display: flex;
  flex-direction: column;
  padding: 0.25rem;
  border-radius: 14px;
  background: var(--panel);
  box-shadow: inset 0 0 0 1px var(--line);
}

.toolbar button {
  appearance: none;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 10px;
  background: none;
  display: grid;
  place-items: center;
  cursor: pointer;
  color: var(--ink);
}

.toolbar button:hover {
  background: #e2e8e4;
}

.toolbar button[aria-pressed='true'] {
  background: var(--ink);
  color: var(--panel);
}

.toolbar svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Fullscreen */

.stage:fullscreen {
  background: #000;
  padding: 0;
  gap: 1rem;
}

.stage:fullscreen .phone {
  padding: 0;
  background: none;
  box-shadow: none;
}

.stage:fullscreen .screen {
  border-radius: 0;
}

.stage:fullscreen .cable {
  display: none;
}

.stage:fullscreen .toolbar {
  margin: 0 1rem 0 0;
}

.stage:fullscreen .group {
  background: #1b1e20;
  box-shadow: none;
}

.stage:fullscreen .toolbar button {
  color: #dfe6e2;
}

.stage:fullscreen .toolbar button:hover {
  background: #2c3134;
}

/* Toasts */

.toasts {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  display: grid;
  gap: 0.5rem;
  z-index: 10;
  max-width: min(26rem, calc(100vw - 2.5rem));
}

.toast {
  padding: 0.75rem 1rem;
  border-radius: 10px;
  background: var(--ink);
  color: #eef2ef;
  box-shadow: 0 12px 30px -16px #14232099;
  white-space: pre-wrap;
}

.toast.error {
  background: var(--danger);
  color: #fff;
}

/* Small screens: stack the panel under the phone */

@media (max-width: 820px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto;
    height: auto;
  }

  .stage {
    order: -1;
    height: 78vh;
    padding: 1rem 0.75rem 0;
    gap: 0.75rem;
  }

  .panel {
    border-right: 0;
    border-top: 1px solid var(--line);
    padding: 1.5rem 1.25rem;
  }

  .toolbar {
    gap: 0.4rem;
  }

  .toolbar button {
    width: 36px;
    height: 36px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }

  body[data-state='connecting'] .wire-pulse {
    opacity: 0;
  }
}
