:root {
  color-scheme: dark;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  background: #191d22;
  color: #e8edf2;
  --canvas: #191d22;
  --panel: #22272d;
  --inset: #1d2329;
  --line: #363e47;
  --control: #64707d;
  --dim: #afb9c4;
  --accent: #ac2143;
  --accent-hover: #98203d;
  --accent-text: #f1b2bf;
  --focus: #f3afbf;
  --ok: #95dcb6;
  --amber: #f2cf92;
  --radius: 14px;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

body { margin: 0; min-width: 260px; }
button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .65; }
svg { display: block; flex: none; }

:where(button, input, [tabindex]):focus-visible,
.file-button:focus-within {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}

.shell { margin: 0 auto; max-width: 520px; }
.topbar {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 16px;
  justify-content: space-between;
  min-height: calc(65px + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) max(20px, env(safe-area-inset-right)) 0 max(20px, env(safe-area-inset-left));
}
.brand { display: flex; align-items: center; gap: 11px; white-space: nowrap; font-weight: 750; font-size: 17px; }
.brand svg { color: #f45173; }
.brand strong { color: var(--dim); font-size: 15px; font-weight: 570; }

main {
  padding: 32px max(20px, env(safe-area-inset-right)) max(28px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
}
.section { display: grid; gap: 19px; }
.section-header { display: grid; gap: 6px; }
h1, h2, p { margin: 0; }
h1 { font-size: clamp(29px, 9.4vw, 37px); line-height: 1.13; letter-spacing: -.045em; text-wrap: balance; }
h2 { font-size: 16px; line-height: 1.35; }
p { color: var(--dim); line-height: 1.48; text-wrap: pretty; }
p, input, button { font-size: 16px; }
button svg, .device-icon svg, .scan-frame svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.form-stack, .code-panel { display: grid; gap: 16px; padding: 18px; }
.field { display: grid; gap: 7px; }
label { font-size: 14px; font-weight: 650; }
input:not([type=file]) {
  width: 100%;
  min-width: 0;
  min-height: 48px;
  padding: 9px 12px;
  border: 1px solid var(--control);
  border-radius: 9px;
  background: var(--inset);
  color: inherit;
}
#enroll-code {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 19px;
  letter-spacing: .14em;
  font-variant-numeric: tabular-nums;
}

.button, .text-button {
  align-items: center;
  appearance: none;
  border: 1px solid transparent;
  border-radius: 9px;
  display: inline-flex;
  gap: 8px;
  justify-content: center;
  min-height: 45px;
  padding: 8px 12px;
  text-decoration: none;
}
.button { min-height: 50px; font-weight: 690; }
.primary { background: var(--accent); color: #fff; }
.primary:hover:not(:disabled) { background: var(--accent-hover); }
.secondary { border-color: var(--control); color: inherit; background: transparent; }
.secondary:hover:not(:disabled), .text-button:hover:not(:disabled) { background: #2b3239; }

.text-button { background: transparent; color: var(--accent-text); font-size: 14px; font-weight: 650; }
.back { justify-self: start; margin: -9px 0 -10px -8px; padding-inline: 8px; }
.notice { border: 1px solid #52695f; border-radius: 11px; color: var(--ok); background: #24352f; margin: 0 0 19px; padding: 11px 13px; }
.notice.error { border-color: #806b48; background: #3c3325; color: var(--amber); }
.boot { padding: 28px 0; }

.workers-panel { overflow: hidden; }
.list-header { display: flex; align-items: center; gap: 8px; justify-content: space-between; padding: 4px 9px 4px 15px; }
.list-empty { border-top: 1px solid var(--line); font-size: 14px; padding: 17px 15px 19px; }
.device-list { list-style: none; margin: 0; padding: 0; }
.device-row {
  align-items: center;
  border-top: 1px solid var(--line);
  display: grid;
  gap: 10px;
  grid-template-columns: auto minmax(0, 1fr) minmax(75px, auto);
  padding: 13px 13px 13px 15px;
}
.device-icon { color: #c9d3de; display: grid; place-items: center; background: #2c333b; border-radius: 9px; width: 37px; height: 37px; }
.device-icon.large { width: 47px; height: 47px; }
.device-description, .device-connection { display: grid; gap: 4px; }
.device-description strong, .review-device h2 { overflow-wrap: anywhere; }
.device-description span, .last-seen { color: var(--dim); font-size: 12px; line-height: 1.35; overflow-wrap: anywhere; }
.device-connection { text-align: right; }
.device-status { color: var(--dim); font-size: 13px; white-space: nowrap; }
.device-status::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 100%; background: currentColor; margin-inline-end: 6px; vertical-align: 1px; }
.device-status.online { color: var(--ok); }

.scanner-panel { display: grid; padding: 12px; gap: 10px; }
.scanner {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 10px;
  min-height: 177px;
  aspect-ratio: 15 / 9;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: #16191e;
}
.scanner video { width: 100%; height: 100%; position: absolute; inset: 0; object-fit: cover; }
.scan-frame { width: min(46%, 168px); aspect-ratio: 1; position: relative; display: grid; place-items: center; color: #eaa0b1; }
.scan-frame span { position: absolute; width: 19px; height: 19px; border: 2px solid currentColor; border-radius: 4px; }
.scan-frame span:nth-child(1) { top: 0; left: 0; border-right: 0; border-bottom: 0; border-bottom-left-radius: 0; border-top-right-radius: 0; }
.scan-frame span:nth-child(2) { top: 0; right: 0; border-left: 0; border-bottom: 0; border-top-left-radius: 0; border-bottom-right-radius: 0; }
.scan-frame span:nth-child(3) { bottom: 0; left: 0; border-right: 0; border-top: 0; border-top-left-radius: 0; border-bottom-right-radius: 0; }
.scan-frame span:nth-child(4) { bottom: 0; right: 0; border-left: 0; border-top: 0; border-top-right-radius: 0; border-bottom-left-radius: 0; }
.scan-frame svg { opacity: .75; }
#camera-status { position: absolute; bottom: 6px; padding: 1px 6px; border-radius: 5px; color: #d7dfe8; background: #16191e; font-size: 12px; }
.file-button { position: relative; cursor: pointer; }
.file-button input { position: absolute; width: 1px; height: 1px; overflow: hidden; opacity: 0; }
.file-button.inactive { cursor: wait; opacity: .65; }

.review-panel { padding: 16px; }
.review-device { display: flex; gap: 12px; align-items: center; }
.review-device p { font-size: 13px; }
.review-meta { display: grid; margin: 16px 0 0; }
.review-meta > div { align-items: baseline; display: grid; grid-template-columns: 94px minmax(0, 1fr); gap: 8px; border-top: 1px solid var(--line); padding: 11px 0; }
.review-meta > div:last-child { padding-bottom: 0; }
.review-meta dt { color: var(--dim); font-size: 13px; }
.review-meta dd { margin: 0; overflow-wrap: anywhere; font-size: 13px; }
.device-id { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }

@media (max-width: 340px) {
  main { padding-inline: 14px; }
  .topbar { padding-inline: 14px; }
  .scanner { min-height: 154px; }
  .device-row { gap: 7px; padding-inline: 9px; }
  .last-seen { max-width: 98px; }
}
@media (min-width: 680px) {
  .shell { margin-top: min(7vh, 55px); }
  .topbar { padding-inline: 24px; }
  main { padding: 34px 24px 38px; }
}
