/* QR Beam */

*, *::before, *::after { box-sizing: border-box; }

:root {
  --bg: #0b0c0f;
  --bg-2: #14161b;
  --line: #23262e;
  --ink: #f2f3f5;
  --ink-2: #9aa0ac;
  --ink-3: #5f6672;
  --send: #ffc247;
  --recv: #56b8ff;
  --bad: #ff6b6b;
  --r: 16px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, monospace;
}

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

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  overscroll-behavior: none;
}

button { font: inherit; color: inherit; }

/* ───────────────────────────────────────────── Views */

.view {
  position: fixed;
  inset: 0;
  display: none;
  flex-direction: column;
}
.view.is-active { display: flex; }

.pane {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.pane--beam, .pane--scan { overflow: hidden; }

.stack {
  width: min(560px, 100%);
  margin: 0 auto;
  padding: 22px 20px calc(40px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ───────────────────────────────────────────── Start */

.home {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 44px;
  padding: 32px 20px calc(32px + env(safe-area-inset-bottom));
  background:
    radial-gradient(120% 80% at 50% -10%, #1b1e27 0%, transparent 60%),
    radial-gradient(80% 50% at 50% 110%, #15181f 0%, transparent 60%);
}

.home__head { text-align: center; }

.mark {
  width: 54px; height: 54px;
  margin: 0 auto 20px;
  display: grid;
  grid-template: repeat(2, 1fr) / repeat(2, 1fr);
  gap: 6px;
}
.mark span {
  border-radius: 4px;
  background: var(--send);
  animation: blink 1.8s steps(1, end) infinite;
}
.mark span:nth-child(2) { animation-delay: .45s; background: var(--recv); }
.mark span:nth-child(3) { animation-delay: 1.35s; background: var(--recv); }
.mark span:nth-child(4) { animation-delay: .9s; }
@keyframes blink { 0%, 49% { opacity: 1; } 50%, 100% { opacity: .18; } }
@media (prefers-reduced-motion: reduce) { .mark span { animation: none; opacity: .85; } }

h1 {
  margin: 0 0 12px;
  font-size: clamp(2.1rem, 8vw, 2.9rem);
  letter-spacing: -0.035em;
  font-weight: 600;
}

.lede {
  margin: 0;
  color: var(--ink-2);
  line-height: 1.6;
  font-size: 1.02rem;
}

.choices {
  width: min(480px, 100%);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.choice {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  padding: 18px 18px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--bg-2);
  text-align: left;
  cursor: pointer;
  transition: border-color .18s, transform .18s, background .18s;
}
.choice:hover { transform: translateY(-2px); background: #191c23; }
.choice--send:hover { border-color: color-mix(in srgb, var(--send) 55%, var(--line)); }
.choice--recv:hover { border-color: color-mix(in srgb, var(--recv) 55%, var(--line)); }
.choice:active { transform: translateY(0); }

.choice__icon {
  flex: 0 0 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: #0f1116;
}
.choice__icon svg { width: 24px; height: 24px; }
.choice--send .choice__icon { color: var(--send); }
.choice--recv .choice__icon { color: var(--recv); }

.choice__text { display: flex; flex-direction: column; gap: 3px; }
.choice__text strong { font-size: 1.06rem; font-weight: 600; }
.choice__text em { font-style: normal; font-size: .87rem; color: var(--ink-3); }

.home__foot {
  text-align: center;
  color: var(--ink-3);
  font-size: .82rem;
  margin: 0;
}
.home__foot a { color: var(--ink-2); text-underline-offset: 3px; }

/* ───────────────────────────────────────────── Leiste */

.bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: max(12px, env(safe-area-inset-top)) 14px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  z-index: 3;
}
.bar h2 { margin: 0; font-size: 1rem; font-weight: 600; letter-spacing: -0.01em; }
.bar__back {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: transparent;
  cursor: pointer;
}
.bar__back svg { width: 18px; height: 18px; }
.bar__back:hover { background: var(--bg-2); }
.bar__tag {
  margin-left: auto;
  font-family: var(--mono);
  font-size: .74rem;
  color: var(--ink-3);
}

/* ───────────────────────────────────────────── Formular */

.field { display: flex; flex-direction: column; gap: 9px; }
.field__label { font-size: .82rem; color: var(--ink-2); font-weight: 500; }

textarea {
  width: 100%;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg-2);
  color: var(--ink);
  font: inherit;
  font-size: .95rem;
  line-height: 1.55;
  resize: vertical;
}
textarea:focus { outline: none; border-color: var(--send); }

.or {
  display: flex; align-items: center; gap: 12px;
  color: var(--ink-3); font-size: .78rem;
}
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.drop {
  display: flex; align-items: center; gap: 8px;
  padding: 15px 16px;
  border: 1px dashed var(--line);
  border-radius: 12px;
  color: var(--ink-2);
  transition: border-color .16s, color .16s, background .16s;
}
.drop:hover, .drop.is-over { border-color: var(--send); color: var(--ink); background: #16181e; }
.drop.has-file { border-style: solid; border-color: color-mix(in srgb, var(--send) 45%, var(--line)); color: var(--ink); }

.drop__pick {
  flex: 1;
  min-width: 0;
  display: flex; align-items: center; gap: 12px;
  font-size: .9rem;
  cursor: pointer;
}
.drop__pick svg { width: 20px; height: 20px; flex: none; }
.drop__pick span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.drop__clear {
  flex: none;
  width: 30px; height: 30px;
  display: grid; place-items: center;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-3);
  cursor: pointer;
}
.drop__clear svg { width: 16px; height: 16px; }
.drop__clear:hover { background: rgba(255, 255, 255, .08); color: var(--bad); }

.segs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.segs button {
  padding: 10px 4px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg-2);
  font-size: .82rem;
  cursor: pointer;
  transition: .15s;
}
.segs button:hover { background: #1a1d24; }
.segs button[aria-checked="true"] {
  background: color-mix(in srgb, var(--send) 16%, var(--bg-2));
  border-color: var(--send);
  color: var(--send);
}

.hint { margin: 0; font-size: .8rem; color: var(--ink-3); line-height: 1.5; }

.estimate {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}
.estimate > div {
  background: var(--bg-2);
  padding: 13px 10px;
  text-align: center;
  display: flex; flex-direction: column; gap: 3px;
}
.estimate strong { font-family: var(--mono); font-size: 1.02rem; font-weight: 600; }
.estimate span { font-size: .71rem; color: var(--ink-3); }

.warn {
  margin: 0;
  padding: 11px 13px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--bad) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--bad) 30%, transparent);
  color: #ffb3b3;
  font-size: .84rem;
  line-height: 1.5;
}

.primary {
  padding: 15px 20px;
  border: none;
  border-radius: 12px;
  background: var(--send);
  color: #14100a;
  font-size: .98rem;
  font-weight: 600;
  cursor: pointer;
  transition: filter .16s, opacity .16s;
}
.primary--recv { background: var(--recv); color: #04121e; }
.primary:hover:not(:disabled) { filter: brightness(1.08); }
.primary:disabled { opacity: .35; cursor: not-allowed; }

.ghost {
  padding: 15px 20px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: transparent;
  font-size: .92rem;
  cursor: pointer;
}
.ghost:hover { background: var(--bg-2); }

.row { display: flex; gap: 10px; }
.row > * { flex: 1; }

/* ───────────────────────────────────────────── Blinkender Code */

.beam {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
}

.beam__card {
  background: #fff;
  padding: 12px;
  border-radius: 10px;
  line-height: 0;
  box-shadow: 0 0 90px rgba(255, 194, 71, .1);
}
/* Maße setzt app.js, damit Bitmap- und Gerätepixel exakt aufeinanderfallen. */
#qr {
  display: block;
  width: min(88vw, 56vh);
  height: min(88vw, 56vh);
  image-rendering: pixelated; /* keine Interpolation — jedes Modul bleibt hart */
}

.beam__meta {
  width: min(460px, 100%);
  display: flex;
  flex-direction: column;
  gap: 14px;
  text-align: center;
}

.beam__stats {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px 18px;
  font-size: .78rem;
  color: var(--ink-3);
}
.beam__stats b { font-family: var(--mono); color: var(--ink); font-weight: 600; }

.beam__tip { margin: 0; font-size: .82rem; color: var(--ink-2); line-height: 1.55; }

.beam__ctrl { display: flex; align-items: center; gap: 12px; }
.beam__ctrl .ghost { padding: 11px 18px; flex: none; }

.slider {
  flex: 1;
  display: flex; align-items: center; gap: 9px;
  font-size: .68rem; color: var(--ink-3);
  white-space: nowrap;
}
.slider input {
  flex: 1; min-width: 0;
  accent-color: var(--send);
}

/* ───────────────────────────────────────────── Scannen */

.scan { position: relative; height: 100%; background: #000; }

#cam {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}

.scan__frame {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: min(72vw, 56vh);
  height: min(72vw, 56vh);
  pointer-events: none;
}
.scan__frame i {
  position: absolute;
  width: 30px; height: 30px;
  border: 2.5px solid var(--recv);
  opacity: .9;
}
.scan__frame i:nth-child(1) { top: 0; left: 0; border-right: 0; border-bottom: 0; border-radius: 8px 0 0 0; }
.scan__frame i:nth-child(2) { top: 0; right: 0; border-left: 0; border-bottom: 0; border-radius: 0 8px 0 0; }
.scan__frame i:nth-child(3) { bottom: 0; left: 0; border-right: 0; border-top: 0; border-radius: 0 0 0 8px; }
.scan__frame i:nth-child(4) { bottom: 0; right: 0; border-left: 0; border-top: 0; border-radius: 0 0 8px 0; }

.scan__hud {
  position: absolute;
  left: 0; right: 0;
  bottom: calc(20px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 0 20px;
  text-align: center;
}

.ring { position: relative; width: 108px; height: 108px; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 7; stroke-linecap: round; }
.ring__bg { stroke: rgba(255, 255, 255, .16); }
.ring__fg {
  stroke: var(--recv);
  stroke-dasharray: 326.7;
  stroke-dashoffset: 326.7;
  transition: stroke-dashoffset .25s ease-out;
}
.ring.is-done .ring__fg { stroke: #4ade80; }
.ring__label {
  position: absolute; inset: 0;
  display: flex; align-items: baseline; justify-content: center; gap: 1px;
  font-family: var(--mono);
}
.ring__label b { font-size: 1.7rem; font-weight: 600; }
.ring__label span { font-size: .8rem; color: var(--ink-2); }

.scan__status {
  margin: 0;
  font-size: .94rem;
  font-weight: 500;
  text-shadow: 0 1px 12px rgba(0, 0, 0, .9);
}
.scan__sub {
  margin: 0;
  font-family: var(--mono);
  font-size: .74rem;
  color: var(--ink-2);
  text-shadow: 0 1px 12px rgba(0, 0, 0, .9);
}

/* ───────────────────────────────────────────── Ergebnis */

.done { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px; padding-top: 14px; }
.done__check {
  width: 58px; height: 58px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: color-mix(in srgb, #4ade80 18%, transparent);
  color: #4ade80;
}
.done__check svg { width: 28px; height: 28px; }
.done h3 { margin: 4px 0 0; font-size: 1.2rem; font-weight: 600; word-break: break-all; }

.result-text {
  margin: 0;
  padding: 14px;
  max-height: 42vh;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg-2);
  font-family: var(--mono);
  font-size: .84rem;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

@media (min-width: 720px) {
  .beam { flex-direction: row; gap: 40px; }
  .beam__meta { text-align: left; }
  .beam__stats { justify-content: flex-start; }
}
