:root {
  color-scheme: light;
  --ink: #171714;
  --muted: #666156;
  --paper: #f4f0e8;
  --panel: #fffaf0;
  --line: #d6cdbc;
  --green: #005f4b;
  --green-2: #0f876c;
  --red: #cc3f2e;
  --blue: #2457a6;
  --shadow: 0 24px 70px rgba(42, 34, 20, 0.16);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background:
    linear-gradient(135deg, rgba(0, 95, 75, 0.08), transparent 34%),
    radial-gradient(circle at 88% 12%, rgba(204, 63, 46, 0.13), transparent 28%),
    var(--paper);
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  font-family: Avenir Next, Avenir, Optima, Segoe UI, sans-serif;
}

.trigger-body {
  display: grid;
  place-items: center;
  padding: 24px;
}

.display-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 18px;
  background: #141915;
}

button,
a,
label {
  font: inherit;
}

.shell {
  width: min(1120px, calc(100% - 32px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 32px 0;
  display: grid;
  grid-template-columns: 0.95fr 1.05fr;
  gap: 18px;
  align-content: center;
}

.trigger-shell {
  width: min(560px, 100%);
}

.display-shell {
  width: min(760px, 100%);
}

.trigger-panel {
  border: 1px solid var(--line);
  background: rgba(255, 250, 240, 0.92);
  box-shadow: var(--shadow);
  padding: clamp(28px, 8vw, 54px);
  display: grid;
  gap: 22px;
}

.display-panel {
  min-height: calc(100vh - 36px);
  border: 1px solid rgba(255, 250, 240, 0.32);
  background: #fffaf0;
  padding: clamp(18px, 5vw, 42px);
  display: grid;
  justify-items: center;
  align-content: center;
  gap: clamp(18px, 4vw, 32px);
  text-align: center;
}

.trigger-panel h1 {
  max-width: none;
  font-size: clamp(3.2rem, 18vw, 6.4rem);
}

.display-panel h1 {
  max-width: none;
  font-size: clamp(2.7rem, 12vw, 6rem);
}

#displayQr {
  width: min(78vw, 620px);
  height: auto;
  border: 10px solid #fffaf0;
  box-shadow: 0 0 0 1px var(--ink), 0 26px 70px rgba(0, 0, 0, 0.22);
  image-rendering: pixelated;
}

.intro,
.scanner,
.manual,
.result {
  border: 1px solid var(--line);
  background: rgba(255, 250, 240, 0.86);
  box-shadow: var(--shadow);
}

.intro {
  min-height: 520px;
  padding: clamp(28px, 5vw, 56px);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.scanner,
.result {
  padding: 18px;
}

.scanner {
  display: grid;
  gap: 14px;
}

.manual,
.result {
  grid-column: 2;
  display: grid;
  gap: 14px;
}

.manual {
  padding: 18px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--green);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  font-family: Georgia, Charter, serif;
  font-weight: 700;
  letter-spacing: 0;
}

h1 {
  max-width: 8ch;
  font-size: clamp(3.5rem, 8vw, 7.7rem);
  line-height: 0.88;
}

h2 {
  font-size: clamp(1.6rem, 3vw, 2.35rem);
  line-height: 1;
}

.subcopy {
  max-width: 36rem;
  margin: 28px 0 0;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.55;
}

.subcopy code {
  color: var(--green);
  font-size: 0.94em;
}

.mark {
  width: 132px;
  aspect-ratio: 1;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--ink);
  background: var(--panel);
}

.mark span {
  background: var(--ink);
}

.mark span:nth-child(2),
.mark span:nth-child(5),
.mark span:nth-child(8),
.mark span:nth-child(10),
.mark span:nth-child(13) {
  background: var(--red);
}

.mark span:nth-child(4),
.mark span:nth-child(11) {
  opacity: 0;
}

.scan-stage {
  position: relative;
  min-height: 340px;
  overflow: hidden;
  border: 1px solid var(--ink);
  background: #141915;
}

#camera,
#canvas {
  width: 100%;
  height: 100%;
  min-height: 340px;
  object-fit: cover;
  display: block;
}

.placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 32px;
  color: #f8f2e6;
  background:
    linear-gradient(rgba(248, 242, 230, 0.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(248, 242, 230, 0.07) 1px, transparent 1px),
    #141915;
  background-size: 28px 28px;
}

.placeholder.hidden {
  display: none;
}

.placeholder p {
  position: absolute;
  bottom: 26px;
  margin: 0;
  color: rgba(248, 242, 230, 0.72);
}

.scan-frame {
  width: min(260px, 74%);
  aspect-ratio: 1;
  border: 3px solid #f8f2e6;
  box-shadow: 0 0 0 999px rgba(0, 0, 0, 0.22);
}

.controls,
.result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

button,
.file-button,
.open-link {
  min-height: 46px;
  border: 1px solid var(--ink);
  border-radius: 0;
  padding: 0 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  text-decoration: none;
  transition:
    transform 140ms ease,
    box-shadow 140ms ease,
    background 140ms ease;
}

button:hover,
.file-button:hover,
.open-link:hover {
  transform: translateY(-1px);
}

.primary,
.open-link {
  background: var(--green);
  color: #fffaf0;
  box-shadow: 5px 5px 0 var(--ink);
}

.secondary,
.file-button {
  background: #fffaf0;
  color: var(--ink);
}

.compact {
  min-width: 104px;
}

button:disabled,
.disabled {
  pointer-events: none;
  cursor: not-allowed;
  opacity: 0.48;
  box-shadow: none;
}

#fileInput {
  width: 1px;
  height: 1px;
  opacity: 0;
  position: absolute;
}

.status {
  min-height: 46px;
  padding: 12px 14px;
  border: 1px dashed var(--line);
  color: var(--muted);
  background: rgba(255, 255, 255, 0.34);
}

.status.ok {
  color: var(--green);
  border-color: rgba(0, 95, 75, 0.38);
}

.status.warn {
  color: var(--red);
  border-color: rgba(204, 63, 46, 0.38);
}

pre {
  min-height: 110px;
  max-height: 220px;
  margin: 0;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  padding: 16px;
  border: 1px solid var(--line);
  background: #f8f4eb;
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.92rem;
  line-height: 1.45;
}

.qr-output {
  display: inline-grid;
  justify-items: start;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  background: #fffaf0;
}

.qr-output[hidden] {
  display: none;
}

.qr-output canvas {
  width: min(220px, 100%);
  height: auto;
  border: 1px solid var(--ink);
  image-rendering: pixelated;
}

.note {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

textarea {
  width: 100%;
  min-height: 112px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 0;
  padding: 14px;
  background: #f8f4eb;
  color: var(--ink);
  font: 0.92rem/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  outline: none;
}

textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(0, 95, 75, 0.14);
}

@media (max-width: 820px) {
  .shell {
    grid-template-columns: 1fr;
    align-content: start;
  }

  .intro {
    min-height: auto;
    gap: 44px;
  }

  .manual,
  .result {
    grid-column: auto;
  }

  .scan-stage,
  #camera,
  #canvas {
    min-height: 300px;
  }
}
