:root {
  color-scheme: dark light;
  --bg: #0e0f11;
  --surface: #17181b;
  --surface-2: #202125;
  --surface-3: #2a2b30;
  --text: #ececee;
  --muted: #9b9ca3;
  --faint: #6c6d74;
  --accent: #8fb0f5;
  --accent-text: #0e1320;
  --online: #5cc794;
  --danger: #f08c84;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 8px 24px rgba(0, 0, 0, 0.25);
  --radius: 14px;
  --font: "Geist", "Instrument Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f5f5f3;
    --surface: #ffffff;
    --surface-2: #efefed;
    --surface-3: #e5e5e2;
    --text: #1a1b1e;
    --muted: #64666d;
    --faint: #8f9197;
    --accent: #3a5fc0;
    --accent-text: #ffffff;
    --online: #23935d;
    --danger: #b9473e;
    --shadow: 0 1px 2px rgba(20, 20, 30, 0.06), 0 8px 24px rgba(20, 20, 30, 0.06);
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  min-height: 100dvh;
}
a { color: inherit; }
button, .button {
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  border: 0;
  border-radius: 10px;
  padding: 9px 14px;
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  white-space: nowrap;
  transition: background 120ms ease, opacity 120ms ease;
}
button:hover, .button:hover { background: var(--surface-3); }
button:disabled { opacity: 0.55; cursor: default; }
button:focus-visible, .button:focus-visible, input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.primary { background: var(--accent); color: var(--accent-text); }
.primary:hover { background: var(--accent); opacity: 0.9; }
.quiet { background: transparent; color: var(--muted); padding: 9px 10px; }
.quiet:hover { background: var(--surface-2); color: var(--text); }
.danger { color: var(--danger); }
.wide { width: 100%; }
.muted { color: var(--muted); }
.hidden { display: none !important; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  max-width: 880px;
  margin: 0 auto;
}
.wordmark { font-weight: 600; letter-spacing: -0.01em; font-size: 16px; text-decoration: none; }
.who { display: flex; align-items: center; gap: 6px; min-width: 0; }
.who .email { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

main { max-width: 880px; margin: 0 auto; padding: 8px 16px 48px; }
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin: 16px 0 18px; flex-wrap: wrap; }
h1 { font-size: 24px; line-height: 1.25; letter-spacing: -0.015em; font-weight: 600; margin: 0; }
h2 { font-size: 18px; font-weight: 600; margin: 0 0 6px; letter-spacing: -0.01em; }
p { margin: 0; }

.list { display: grid; gap: 10px; }
.machine {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px 16px;
}
.machine .info { min-width: 0; }
.machine .name { font-weight: 600; display: flex; align-items: center; gap: 10px; min-width: 0; }
.machine .name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.machine .meta { color: var(--muted); font-size: 13px; margin-top: 2px; padding-left: 18px; }
.machine .actions { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.machine .confirm, .machine .edit { grid-column: 1 / -1; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.machine .confirm { justify-content: flex-end; }
.machine .confirm p { flex: 1 1 100%; color: var(--muted); font-size: 14px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); flex: none; }
.dot.on { background: var(--online); box-shadow: 0 0 0 4px color-mix(in srgb, var(--online) 18%, transparent); }

input[type="text"] {
  font: inherit;
  color: var(--text);
  background: var(--surface-2);
  border: 0;
  border-radius: 10px;
  padding: 9px 12px;
  min-height: 38px;
  flex: 1 1 200px;
  min-width: 0;
}

.empty {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 20px;
  text-align: center;
  color: var(--muted);
}
.empty p + p { margin-top: 4px; }

.center { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.card {
  background: var(--surface);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 28px 24px;
  width: 100%;
  max-width: 380px;
}
.card .wordmark { display: block; margin-bottom: 22px; color: var(--muted); }
.card h1 { margin-bottom: 8px; }
.card p { color: var(--muted); margin-bottom: 22px; }
.card .actions { display: grid; gap: 8px; }

dialog {
  border: 0;
  padding: 0;
  background: var(--surface);
  color: var(--text);
  border-radius: 18px;
  box-shadow: var(--shadow);
  width: min(440px, calc(100vw - 32px));
}
dialog::backdrop { background: rgba(0, 0, 0, 0.45); }
.dialog-body { padding: 22px 20px 18px; }
.steps { margin: 14px 0 16px; padding-left: 20px; color: var(--muted); }
.steps li + li { margin-top: 4px; }
.code-row { display: flex; gap: 8px; align-items: stretch; }
.code {
  flex: 1;
  min-width: 0;
  font-family: var(--mono);
  font-size: 20px;
  letter-spacing: 0.06em;
  background: var(--surface-2);
  border-radius: 10px;
  padding: 10px 12px;
  text-align: center;
  user-select: all;
  overflow-wrap: anywhere;
}
.status { margin-top: 12px; font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 8px; min-height: 20px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.notice { margin-top: 14px; font-size: 14px; color: var(--muted); }

@media (max-width: 520px) {
  .machine { grid-template-columns: 1fr; }
  .machine .actions { justify-content: flex-start; margin-left: 8px; }
  .who .email { display: none; }
  h1 { font-size: 21px; }
  .code { font-size: 17px; letter-spacing: 0.03em; }
}
