/* Elrendezés: egyetlen műszerszerű oszlop; küldés közben a QR-kód tölti ki a képernyőt. */
:root {
  --bg: #e9eef0;
  --surface: #f7f9fa;
  --ink: #13222b;
  --muted: #566771;
  --line: #c6d1d6;
  --accent: #0b6e69;
  --accent-ink: #ffffff;
  --signal: #d9480f;
  --cell-empty: #d4dde1;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, "SF Mono", monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1a20; --surface: #17252c; --ink: #e6eef1; --muted: #93a6af; --line: #2c3f48;
    --accent: #3cc2b8; --accent-ink: #06211f; --signal: #ff8a50; --cell-empty: #24353d;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1a20; --surface: #17252c; --ink: #e6eef1; --muted: #93a6af; --line: #2c3f48;
  --accent: #3cc2b8; --accent-ink: #06211f; --signal: #ff8a50; --cell-empty: #24353d;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 var(--sans);
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: env(safe-area-inset-top, 0px) env(safe-area-inset-bottom, 0px);
}
[hidden] { display: none !important; }

.top, main { max-width: 640px; margin-inline: auto; }
.top {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 12px; padding-block: 16px;
}
.brand {
  display: inline-flex; align-items: center; gap: 8px;
  color: inherit; text-decoration: none;
  font: 600 18px/1 var(--mono); letter-spacing: -0.02em;
}
.brand svg { width: 22px; height: 22px; color: var(--accent); }
.modes { display: flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.modes a { padding: 7px 16px; color: var(--muted); text-decoration: none; font-weight: 600; font-size: 15px; }
.modes a[aria-current="page"] { background: var(--ink); color: var(--bg); }
main { padding-bottom: 32px; }

.offline { margin: 0 0 12px; color: var(--muted); font-size: 14px; }
.offline[data-kind="ready"] { color: var(--accent); }
.offline[data-kind="error"] { color: var(--signal); font-weight: 600; }
body.sending .offline { display: none; }

.stack { display: flex; flex-direction: column; gap: 16px; }
.stack.tight { gap: 8px; }

.drop {
  display: flex; flex-direction: column; gap: 4px; align-items: flex-start;
  padding: 32px 20px; cursor: pointer; background: var(--surface);
  border: 2px dashed var(--line); border-radius: 8px; overflow-wrap: anywhere;
}
.drop:hover, .drop.over, .drop:focus-within { border-color: var(--accent); }
.drop input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.drop strong { font-size: 20px; }
.drop span { color: var(--muted); }

.settings { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field label { font-weight: 600; font-size: 14px; }
.field output { font-family: var(--mono); }
select, input[type="range"], input[type="text"] { width: 100%; accent-color: var(--accent); }
select, input[type="text"] {
  padding: 9px; font: inherit; color: inherit; background: var(--surface);
  border: 1px solid var(--line); border-radius: 6px;
}

.facts {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 0;
  padding-block: 10px; border-block: 1px solid var(--line);
}
.facts dt { color: var(--muted); font-size: 13px; }
.facts dd { margin: 0; font: 600 15px/1.4 var(--mono); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }

button, .button {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 11px 20px; font: 600 16px/1.2 var(--sans); cursor: pointer; text-decoration: none;
  color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 8px;
}
.primary { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); }
button:disabled { opacity: 0.45; cursor: not-allowed; }
:focus-visible { outline: 3px solid var(--signal); outline-offset: 2px; }

.notice { margin: 0; color: var(--signal); font-weight: 600; }

.pair { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; padding-top: 16px; border-top: 1px solid var(--line); }
.pair canvas { background: #fff; border-radius: 4px; width: 132px; height: 132px; }
.pair > div { flex: 1 1 200px; min-width: 0; }
.pair h2 { margin: 0; font-size: 16px; }
.pair p { margin: 2px 0 6px; color: var(--muted); font-size: 14px; }
.pair code { font: 14px var(--mono); overflow-wrap: anywhere; }

/* Küldés: a QR-kód a teljes kijelzőt kapja, mindig fehér alapon. */
body.sending { background: #fff; color: #13222b; }
body.sending .top { display: none; }
body.sending main { max-width: none; padding: 0; }
.live {
  position: fixed; inset: 0; display: flex; flex-direction: column; background: #fff;
  padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px);
}
.qr-frame { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; }
#qr { display: block; image-rendering: pixelated; }
.live-bar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px;
  padding: 4px max(16px, env(safe-area-inset-left, 0px));
}
.live-bar { position: relative; }
#pack-bar { position: absolute; inset: 0 0 auto; width: 100%; height: 5px; accent-color: #0b6e69; }
#pack-text { font-weight: 600; }
.live.waiting { justify-content: center; }
.live.waiting .qr-frame { display: none; }
.live.waiting .live-bar { padding-block: 16px; max-width: 480px; width: 100%; margin-inline: auto; }
.live.waiting #pack-bar { position: static; height: 16px; flex: 1 0 100%; }
.live-bar p { margin: 0; font: 14px/1.4 var(--mono); font-variant-numeric: tabular-nums; flex: 1 1 220px; }
.live-bar button { color: #13222b; background: #fff; border-color: #9fb0b8; padding: 4px 12px; font-size: 14px; }

.viewfinder {
  --ratio: 0.5625;
  position: relative; aspect-ratio: var(--ratio); margin-inline: auto;
  width: min(100%, calc(62dvh * var(--ratio)));
  overflow: hidden; border-radius: 8px; background: #000;
  display: flex; align-items: center; justify-content: center;
}
.viewfinder video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.reticle { position: absolute; inset: 2%; border: 2px solid #fff8; border-radius: 4px; pointer-events: none; }
.reticle.locked { border-color: #3cc2b8; }
.viewfinder button { position: relative; }
.status { margin: 0; font-weight: 600; }
.camera-note { margin: -12px 0 0; color: var(--muted); font-size: 13px; }
.camera-note span { font-family: var(--mono); }
.missing { margin: 0; font: 14px/1.4 var(--mono); overflow-wrap: anywhere; }

.progress-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.progress-head strong { min-width: 0; overflow-wrap: anywhere; }
.progress-head span { font: 600 18px var(--mono); font-variant-numeric: tabular-nums; }
#block-map { display: block; width: 100%; height: 64px; border-radius: 4px; }

.result { padding: 20px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; overflow-wrap: anywhere; }
.result h2 { margin: 0 0 4px; font-size: 20px; }
.result p { margin: 0; color: var(--muted); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }

.settings.color-mode .qr-option { display: none; }

.watch { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; }
.watch p { margin: 0; flex: 1 1 240px; min-width: 0; color: var(--muted); overflow-wrap: anywhere; }

.incoming {
  position: fixed; inset: auto 0 0; z-index: 30;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px;
  padding-block: 12px calc(12px + env(safe-area-inset-bottom, 0px));
  padding-inline: max(16px, env(safe-area-inset-left, 0px)) max(16px, env(safe-area-inset-right, 0px));
  color: var(--ink); background: var(--surface); border-top: 2px solid var(--accent);
}
.incoming > div:first-child { display: flex; flex-direction: column; min-width: 0; flex: 1 1 240px; }
.incoming span { color: var(--muted); font: 14px var(--mono); overflow-wrap: anywhere; }

@media (prefers-reduced-motion: no-preference) {
  .reticle { transition: border-color 0.15s; }
}
