:root {
  --bg: #0e0f11;
  --panel: #17191c;
  --line: #2a2d32;
  --text: #e8e6e1;
  --muted: #9a9890;
  --accent: #f2b233;
  --ok: #57c27a;
  --bad: #e5604d;
  color-scheme: dark;
}

* { box-sizing: border-box; }

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

main {
  max-width: 44rem;
  margin: 0 auto;
  padding: 1.5rem 1rem 3rem;
}

h1 {
  font-size: 2.4rem;
  letter-spacing: 0.02em;
  margin: 0.5rem 0 0.25rem;
}

h1 a { color: inherit; text-decoration: none; }

.lede { color: var(--muted); margin: 0 0 1.5rem; }

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

.choices {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  gap: 1rem;
  margin: 1.5rem 0;
}

.choice {
  display: block;
  padding: 1.5rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  color: var(--text);
  text-decoration: none;
}

.choice strong { display: block; font-size: 1.6rem; color: var(--accent); }
.choice span { color: var(--muted); }
.choice:hover, .choice:focus-visible { border-color: var(--accent); }

button, .button {
  font: inherit;
  font-weight: 600;
  padding: 0.7rem 1.3rem;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #1a1306;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}

button.secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
}

button:disabled { opacity: 0.45; cursor: default; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1rem 1.2rem;
  margin: 1rem 0;
}

.drop {
  display: block;
  border: 2px dashed var(--line);
  border-radius: 12px;
  padding: 2rem 1rem;
  text-align: center;
  color: var(--muted);
  cursor: pointer;
}

.drop.over { border-color: var(--accent); color: var(--text); }
.drop input { display: none; }

.row { display: flex; flex-wrap: wrap; gap: 0.75rem 1.5rem; align-items: center; }

label.field { display: flex; flex-direction: column; gap: 0.2rem; color: var(--muted); font-size: 0.9rem; }

select {
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.35rem 0.5rem;
}

.stats {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.9rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.stats b { color: var(--text); font-weight: 600; }

.figures {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr));
  gap: 0.6rem 1rem;
  margin: 0.75rem 0;
}

.figures dt { color: var(--muted); font-size: 0.8rem; }

.figures dd {
  margin: 0;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-variant-numeric: tabular-nums;
}

.note { color: var(--muted); font-size: 0.8rem; }

.message { color: var(--bad); min-height: 1.5em; }

progress {
  width: 100%;
  height: 0.8rem;
  accent-color: var(--accent);
}

.hidden { display: none !important; }

footer {
  margin-top: 2.5rem;
  color: var(--muted);
  font-size: 0.85rem;
}

/* Send: the code fills the screen on white. */
#stage {
  position: fixed;
  inset: 0;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

#stage canvas { image-rendering: pixelated; }

#stage .bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 1rem;
  background: rgba(14, 15, 17, 0.85);
  color: var(--text);
}

/* Receive: the camera view with an overlay of codes found. */
.viewer {
  position: relative;
  width: 100%;
  border-radius: 12px;
  overflow: hidden;
  background: #000;
  aspect-ratio: 16 / 9;
}

.viewer video, .viewer canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

#blocks {
  width: 100%;
  image-rendering: pixelated;
  border-radius: 6px;
  background: #000;
}

.legend { display: flex; gap: 1rem; font-size: 0.85rem; color: var(--muted); }
.legend .received { background: var(--ok); }
.legend .recovered { background: var(--accent); }
.legend .missing { background: var(--line); }
.legend i { display: inline-block; width: 0.8em; height: 0.8em; border-radius: 2px; margin-right: 0.3em; vertical-align: -0.05em; }
