:root {
  color-scheme: dark;
  --bg: #0e1013;
  --surface: #171a1f;
  --surface-2: #1f232a;
  --line: #2b3038;
  --text: #e8eaed;
  --muted: #9aa2ad;
  --accent: #4f9cf9;
  --accent-ink: #06121f;
  --ok: #4cc38a;
  --warn: #e5a74b;
  --danger: #ef6a6a;
  --radius: 10px;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

/* Author display rules would otherwise defeat the attribute. */
[hidden] { display: none !important; }

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

body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, sans-serif;
}

h1, h2, h3, p { margin: 0; }

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

button {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
}
button:hover { border-color: #414854; }
button:disabled { opacity: .5; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
button.danger { color: var(--danger); }

input, select {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  min-width: 0;
}
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }

.muted { color: var(--muted); }
.mono { font-family: var(--mono); }

/* Landing */
.center {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px 16px;
}
.join { width: min(420px, 100%); display: grid; gap: 16px; text-align: center; }
.join h1 { font-size: 26px; }
.join form { display: grid; gap: 12px; }
.join input {
  font-family: var(--mono);
  font-size: 28px;
  letter-spacing: .14em;
  text-align: center;
  text-transform: uppercase;
  padding: 14px 8px;
}
.join button { padding: 13px; font-size: 16px; }

.join a { color: var(--accent); }

/* Download */
.download { width: min(640px, 100%); display: grid; gap: 20px; }
.download h1 { font-size: 26px; }
.download .card a.button {
  display: block;
  text-align: center;
  text-decoration: none;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
  border-radius: 8px;
  padding: 12px;
}
.download .card.other a.button { background: var(--surface-2); color: var(--text); border: 1px solid var(--line); }
.download code { font-family: var(--mono); font-size: 13px; overflow-wrap: anywhere; }
.download ul { margin: 0; padding-left: 18px; color: var(--muted); }
.download .links a { color: var(--accent); }

/* Viewer */
body.viewer { background: #000; overflow: hidden; }
#screen {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}
body.viewer.idle, body.viewer.idle #screen { cursor: none; }
#status {
  position: fixed;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 8px;
  padding: 16px;
  text-align: center;
  pointer-events: none;
}
#status h1 { font-size: 22px; font-weight: 600; }
#status .code { font-family: var(--mono); color: var(--muted); letter-spacing: .1em; }
#hint {
  position: fixed;
  left: 50%;
  bottom: 28px;
  translate: -50% 0;
  max-width: calc(100vw - 32px);
  background: rgb(23 26 31 / .92);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 9px 18px;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: opacity .3s;
  pointer-events: none;
}
#hint.gone { opacity: 0; }
#hud {
  position: fixed;
  top: 12px;
  left: 12px;
  max-width: calc(100vw - 24px);
  background: rgb(0 0 0 / .78);
  border-radius: 8px;
  padding: 10px 12px;
  font: 12px/1.6 var(--mono);
  white-space: pre;
  overflow: hidden;
  pointer-events: none;
}

/* Panel */
.page { width: min(1040px, 100%); margin: 0 auto; padding: 24px 16px 48px; display: grid; gap: 24px; }
.page > header { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.page > header h1 { font-size: 22px; }
.starters { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  display: grid;
  gap: 12px;
  align-content: start;
  min-width: 0;
}
.card h2 { font-size: 16px; }
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 10px; }
.fields input, .fields select { width: 100%; }
.monitor-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}
.monitor-row:first-of-type { border-top: 0; padding-top: 0; }
.monitor-row > div { min-width: 0; }
.notice { background: var(--surface-2); border-radius: 8px; padding: 10px 12px; font-size: 14px; color: var(--muted); }
.notice.error { color: var(--danger); }

.share { grid-template-columns: minmax(0, 1fr) auto; gap: 16px; }
.share .body { display: grid; gap: 10px; min-width: 0; }
.share .title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.share .big-code { font-family: var(--mono); font-size: 26px; letter-spacing: .1em; }
.share .qr { width: 136px; height: 136px; background: #fff; border-radius: 8px; display: block; }
.badge { font-size: 12px; padding: 1px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.link-row { display: flex; gap: 8px; align-items: center; min-width: 0; }
.link-row a { color: var(--accent); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 1; }
.link-row button { padding: 3px 10px; font-size: 13px; flex: none; }
.stats { display: flex; flex-wrap: wrap; gap: 4px 18px; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.stats b { color: var(--text); font-weight: 600; }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.actions select { padding: 6px 8px; font-size: 14px; }
.viewer-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 14px; border-top: 1px solid var(--line); padding-top: 8px; }
.viewer-row button { padding: 2px 10px; font-size: 13px; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--warn); margin-right: 6px; }
.dot.on { background: var(--ok); }

@media (max-width: 560px) {
  .share { grid-template-columns: minmax(0, 1fr); }
  .share .qr { display: none; }
}
