:root {
  --bg: #0d1117;
  --panel: #161b22;
  --line: #262d36;
  --text: #e6edf3;
  --muted: #8b949e;
  --accent: #39d98a;
  --danger: #f85149;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

/* display on .btn/.history-panel would otherwise beat the hidden attribute */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

header,
main,
footer {
  max-width: 560px;
  margin: 0 auto;
  padding: 0 16px;
}

header {
  padding-top: 20px;
  padding-bottom: 8px;
}

h1 {
  margin: 0;
  font-size: 20px;
  letter-spacing: -0.01em;
}

.sub {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.viewport {
  position: relative;
  margin-top: 14px;
  aspect-ratio: 3 / 4;
  background: #000;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
}

#video,
#overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

#video {
  object-fit: cover;
}

.guide {
  position: absolute;
  inset: 12%;
  pointer-events: none;
}

.guide span {
  position: absolute;
  width: 26px;
  height: 26px;
  border: 2px solid rgba(230, 237, 243, 0.45);
}

.guide span:nth-child(1) {
  top: 0;
  left: 0;
  border-right: 0;
  border-bottom: 0;
  border-top-left-radius: 8px;
}
.guide span:nth-child(2) {
  top: 0;
  right: 0;
  border-left: 0;
  border-bottom: 0;
  border-top-right-radius: 8px;
}
.guide span:nth-child(3) {
  bottom: 0;
  left: 0;
  border-right: 0;
  border-top: 0;
  border-bottom-left-radius: 8px;
}
.guide span:nth-child(4) {
  bottom: 0;
  right: 0;
  border-left: 0;
  border-top: 0;
  border-bottom-right-radius: 8px;
}

body.scanning .guide span {
  border-color: rgba(57, 217, 138, 0.7);
}

.status {
  margin: 12px 0;
  min-height: 22px;
  color: var(--muted);
  font-size: 14px;
}

.status.ok {
  color: var(--accent);
}

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

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  border-radius: 10px;
  padding: 11px 16px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}

.btn:active {
  transform: translateY(1px);
}

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #06281a;
  font-weight: 650;
}

.btn.ghost {
  background: transparent;
}

.btn.small {
  padding: 6px 10px;
  font-size: 13px;
}

.btn[aria-pressed="true"] {
  border-color: var(--accent);
  color: var(--accent);
}

.results {
  margin-top: 16px;
  display: grid;
  gap: 10px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
}

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.tag {
  font-weight: 650;
  font-size: 13px;
  color: var(--accent);
}

.meta {
  font-size: 12px;
  color: var(--muted);
}

.payload {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  word-break: break-all;
  background: #0b0f14;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  max-height: 160px;
  overflow: auto;
}

.actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.history-panel {
  margin-top: 22px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.history-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.history-head h2 {
  font-size: 14px;
  margin: 0;
  color: var(--muted);
  font-weight: 600;
}

.history {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.history li {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
}

.history-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  word-break: break-all;
}

.history time {
  display: block;
  margin-top: 4px;
  font-size: 11px;
  color: var(--muted);
}

footer {
  margin: 26px auto;
  color: var(--muted);
  font-size: 12px;
}

footer a {
  color: var(--muted);
}
