/* =========================================================
   QrPDF — style.css
   Stitch visual design, styled against the DOM that the
   working JS (js/*.js) actually creates and touches.
   ========================================================= */

/* ---------- tokens ---------- */
:root {
  --bg: #07090e;
  --bg-surface: #0e121b;
  --bg-surface-elevated: #161c2b;
  --bg-inset: rgba(0, 0, 0, 0.35);
  --bg-glass: rgba(18, 24, 38, 0.75);
  --border: rgba(255, 255, 255, 0.08);
  --accent: #00f2aa;
  --accent-glow: rgba(0, 242, 170, 0.35);
  --accent-dark: #008f64;
  --accent-secondary: #3b82f6;
  --accent-secondary-glow: rgba(59, 130, 246, 0.35);
  --on-accent: #050b14;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --danger: #f43f5e;
  --warning: #f59e0b;
  --info: #60a5fa;
  --lock: #4ade80;
  --font-display: 'Chakra Petch', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, Menlo, Consolas, monospace;
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;

  /* aliases — app.js writes these names inside innerHTML strings */
  --ink-soft: var(--text-muted);
  --amber: var(--warning);
  --ok: var(--accent);
  --err: var(--danger);
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f3f5f9;
    --bg-surface: #ffffff;
    --bg-surface-elevated: #f8fafc;
    --bg-inset: rgba(15, 23, 42, 0.05);
    --bg-glass: rgba(255, 255, 255, 0.85);
    --border: rgba(0, 0, 0, 0.09);
    --accent: #00a877;
    --accent-glow: rgba(0, 168, 119, 0.25);
    --accent-dark: #006b4b;
    --accent-secondary: #2563eb;
    --accent-secondary-glow: rgba(37, 99, 235, 0.2);
    --on-accent: #ffffff;
    --text: #0f172a;
    --text-muted: #475569;
    --text-dim: #94a3b8;
    --danger: #e11d48;
    --warning: #b45309;
    --info: #2563eb;
    --lock: #16a34a;
  }
}

/* ---------- base ---------- */
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

body {
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  background-image:
    radial-gradient(circle at 50% 0%, var(--accent-glow) 0%, transparent 60%),
    radial-gradient(circle at 100% 100%, var(--accent-secondary-glow) 0%, transparent 50%),
    linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
  background-size: 100% 100%, 100% 100%, 32px 32px, 32px 32px;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.03;
  z-index: 999;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.hidden { display: none !important; }

/* ---------- icons (inline SVG sprite, no CDN) ---------- */
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.ic {
  width: 1em; height: 1em; flex: none;
  fill: none; stroke: currentColor; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
}
.ic-16 { width: 16px; height: 16px; }
.ic-18 { width: 18px; height: 18px; }
.ic-20 { width: 20px; height: 20px; }
.ic-24 { width: 24px; height: 24px; }

/* ---------- shell ---------- */
.app-shell {
  width: 100%;
  max-width: 820px;
  padding: 1.5rem 1rem 4rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  z-index: 10;
  flex: 1;
}

/* ---------- header ---------- */
.brand-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 0.75rem 1.25rem;
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
}

.brand-title { display: flex; align-items: center; gap: 0.75rem; }

.brand-glyph {
  width: 42px; height: 42px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-secondary) 100%);
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  color: var(--on-accent);
  font-size: 24px;
  box-shadow: 0 0 20px var(--accent-glow);
  position: relative;
}
.brand-glyph::after {
  content: '';
  position: absolute; inset: -2px;
  border-radius: 14px;
  border: 1px solid var(--accent);
  opacity: 0.5;
  animation: pulse-ring 3s infinite;
}
@keyframes pulse-ring {
  0%   { transform: scale(1);    opacity: 0.6; }
  50%  { transform: scale(1.15); opacity: 0; }
  100% { transform: scale(1);    opacity: 0; }
}

.brand-text h1 {
  font-family: var(--font-display);
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.brand-text h1 .highlight { color: var(--accent); text-shadow: 0 0 12px var(--accent-glow); }

.brand-tag {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  display: flex; align-items: center; gap: 0.35rem;
  margin-top: 2px;
}
.status-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
  animation: blink 2s infinite ease-in-out;
}
@keyframes blink {
  0%, 100% { opacity: 1;   transform: scale(1); }
  50%      { opacity: 0.4; transform: scale(0.85); }
}

.meta-badges { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.badge-secure {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  padding: 0.3rem 0.65rem;
  background: rgba(0, 242, 170, 0.08);
  border: 1px solid rgba(0, 242, 170, 0.25);
  border-radius: 999px;
  color: var(--accent);
  display: flex; align-items: center; gap: 0.35rem;
}
.build-tag { font-family: var(--font-mono); font-size: 0.65rem; color: var(--text-dim); }

/* ---------- tabs ---------- */
.tab-nav {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 0.35rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.25rem;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3);
}
.tab {
  color: var(--text-muted);
  padding: 0.85rem 1rem;
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center; gap: 0.6rem;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  user-select: none;
}
.tab:hover { color: var(--text); }
.tab.active {
  color: var(--on-accent);
  background: linear-gradient(135deg, var(--accent) 0%, #00d294 100%);
  box-shadow: 0 4px 18px var(--accent-glow);
}

/* ---------- panels ---------- */
.panel-container { width: 100%; }
.panel { display: none; flex-direction: column; gap: 1.5rem; }
.panel.active { display: flex; animation: panelIn 0.35s cubic-bezier(0.16, 1, 0.3, 1) both; }
@keyframes panelIn {
  from { opacity: 0; transform: translateY(8px) scale(0.99); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.stack { display: flex; flex-direction: column; gap: 1.5rem; }

/* ---------- cards ---------- */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.2);
  position: relative;
  overflow: hidden;
}
.card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.15), transparent);
}

.section-title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  display: flex; align-items: center; justify-content: space-between; gap: 0.5rem;
  margin-bottom: 0.4rem;
}
.step-pill {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 500;
  padding: 0.2rem 0.5rem;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--accent);
  white-space: nowrap;
}
.sub { color: var(--text-muted); font-size: 0.85rem; margin-bottom: 1rem; max-width: 70ch; }

/* ---------- dropzone + file list ---------- */
.dropzone {
  position: relative;
  border: 2px dashed rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-md);
  padding: 2rem 1.5rem;
  text-align: center;
  background: rgba(255, 255, 255, 0.015);
  transition: all 0.25s ease;
  display: flex; flex-direction: column; align-items: center; gap: 0.6rem;
}
@media (prefers-color-scheme: light) { .dropzone { border-color: rgba(0, 0, 0, 0.18); } }
.dropzone:hover, .dropzone.dragover {
  border-color: var(--accent);
  background: rgba(0, 242, 170, 0.04);
  box-shadow: 0 0 20px rgba(0, 242, 170, 0.1);
}
.dropzone input[type="file"] {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  opacity: 0; cursor: pointer; z-index: 5;
}
.dropzone-icon-ring {
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  color: var(--accent);
  font-size: 26px;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.dropzone:hover .dropzone-icon-ring { transform: scale(1.1) translateY(-2px); box-shadow: 0 0 16px var(--accent-glow); }
.dropzone-text { font-size: 0.95rem; font-weight: 600; }
.dropzone-hint { font-size: 0.75rem; font-family: var(--font-mono); color: var(--text-muted); }

/* rows are created by encode.js: .filerow > .nm + .sz + button */
.filelist {
  margin-top: 1rem;
  display: flex; flex-direction: column; gap: 0.5rem;
  max-height: 240px; overflow-y: auto;
}
.filerow {
  display: flex; align-items: center; gap: 0.65rem;
  padding: 0.6rem 0.85rem;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
}
.filerow .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.filerow .sz { font-family: var(--font-mono); font-size: 0.7rem; color: var(--text-dim); white-space: nowrap; }
.filerow button {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-dim);
  padding: 0.3rem 0.6rem;
  border-radius: 6px;
  border: 1px solid transparent;
  transition: all 0.2s;
}
.filerow button:hover { color: var(--danger); background: rgba(244, 63, 94, 0.1); border-color: rgba(244, 63, 94, 0.25); }
.filelist .empty {
  padding: 0.85rem;
  text-align: center;
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
}

/* ---------- settings ---------- */
.controls-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 1rem;
  margin-top: 0.75rem;
}
.input-field { display: flex; flex-direction: column; gap: 0.4rem; }
.field-label {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

input[type="number"], #playGoInput, select {
  width: 100%;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  padding: 0.65rem 0.85rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
input[type="number"]:focus, #playGoInput:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 10px rgba(0, 242, 170, 0.25); }
input[type="range"] { accent-color: var(--accent); cursor: pointer; }

.checkbox-field {
  display: flex; align-items: center; gap: 0.5rem;
  font-size: 0.8rem; color: var(--text-muted); cursor: pointer;
}
.checkbox-field input[type="checkbox"] { accent-color: var(--accent); width: 16px; height: 16px; cursor: pointer; }

/* estimate: the JS writes plain HTML (<b>, <br>, <span>) into this box */
#estimate {
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1rem;
  margin-top: 1.25rem;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  line-height: 1.7;
  color: var(--text-muted);
  overflow-x: auto;
}
#estimate b { color: var(--accent); font-weight: 700; }

/* ---------- buttons ---------- */
.btn-row { display: flex; gap: 0.75rem; flex-wrap: wrap; align-items: center; }
.card > .btn-row { margin-top: 1.25rem; }

.btn-primary {
  flex: 1;
  min-width: 200px;
  background: linear-gradient(135deg, var(--accent) 0%, #00ba83 100%);
  color: var(--on-accent);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: 0.03em;
  border-radius: var(--radius-md);
  padding: 0.95rem 1.5rem;
  display: flex; align-items: center; justify-content: center; gap: 0.5rem;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 4px 18px var(--accent-glow);
}
.btn-primary:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 8px 25px var(--accent-glow); filter: brightness(1.05); }
.btn-primary:active:not(:disabled) { transform: translateY(0); }
.btn-primary:disabled { opacity: 0.45; cursor: not-allowed; box-shadow: none; filter: grayscale(0.5); }

.btn-secondary {
  background: var(--bg-surface-elevated);
  color: var(--text);
  font-weight: 600;
  font-size: 0.88rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.8rem 1.2rem;
  display: flex; align-items: center; justify-content: center; gap: 0.4rem;
  transition: all 0.2s;
}
.btn-secondary:hover:not(:disabled) { background: rgba(127, 140, 160, 0.16); border-color: rgba(127, 140, 160, 0.4); }
.btn-secondary:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-ghost {
  color: var(--text-dim);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  padding: 0.8rem 1rem;
  font-size: 0.85rem;
  display: flex; align-items: center; gap: 0.4rem;
  transition: all 0.2s;
}
.btn-ghost:hover { color: var(--danger); background: rgba(244, 63, 94, 0.08); border-color: rgba(244, 63, 94, 0.2); }

.btn-sm { padding: 0.45rem 0.9rem; font-size: 0.8rem; min-width: 0; flex: none; }
.btn-primary.btn-sm { font-size: 0.85rem; }
.btn-xs { padding: 0.4rem 0.75rem; font-size: 0.75rem; border-radius: var(--radius-sm); }

/* ---------- status banners (JS injects <div class="status kind">) ---------- */
.status {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  line-height: 1.55;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  border-left-width: 3px;
  background: var(--bg-surface-elevated);
  color: var(--text-muted);
  word-break: break-word;
}
.status.info { color: var(--info);    border-color: rgba(59, 130, 246, 0.3); border-left-color: var(--accent-secondary); background: rgba(59, 130, 246, 0.06); }
.status.ok   { color: var(--accent);  border-color: rgba(0, 242, 170, 0.3);  border-left-color: var(--accent);           background: rgba(0, 242, 170, 0.06); }
.status.warn { color: var(--warning); border-color: rgba(245, 158, 11, 0.3); border-left-color: var(--warning);          background: rgba(245, 158, 11, 0.07); }
.status.err  { color: var(--danger);  border-color: rgba(244, 63, 94, 0.3);  border-left-color: var(--danger);           background: rgba(244, 63, 94, 0.07); }
#genStatus .status, #scanStatus .status { margin-top: 1rem; }

/* ---------- result / QR grid ---------- */
#resultCard { border-color: rgba(0, 242, 170, 0.3); box-shadow: 0 0 30px rgba(0, 242, 170, 0.1); }
#resultSub { font-family: var(--font-mono); font-size: 0.75rem; color: var(--text-muted); margin-bottom: 1rem; max-width: none; }
#resultCard .btn-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 0.6rem; }
#resultCard .btn-row .btn-primary { min-width: 0; padding: 0.8rem 1rem; font-size: 0.95rem; background: linear-gradient(135deg, var(--accent) 0%, var(--accent-secondary) 100%); }

#qrGrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0.85rem;
  margin-top: 1.25rem;
  max-height: 520px;
  overflow-y: auto;
  padding: 0.6rem;
  background: var(--bg-inset);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}
/* cells are created by encode.js: .qr-cell > (.ph | qr holder) + .idx */
.qr-cell {
  background: #fff;
  padding: 0.5rem;
  border-radius: var(--radius-sm);
  text-align: center;
  min-height: 180px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s;
}
.qr-cell:hover { transform: translateY(-3px); box-shadow: 0 8px 20px rgba(0, 242, 170, 0.3); }
.qr-cell canvas, .qr-cell img { max-width: 100%; height: auto; }
.qr-cell .idx {
  font-family: var(--font-mono); font-size: 0.65rem; font-weight: 700;
  color: #0f172a; background: #e2e8f0;
  padding: 0.15rem 0.4rem; border-radius: 4px; margin-top: 0.4rem;
}
.qr-cell .ph { color: #cbd5e1; font-family: var(--font-mono); font-size: 0.75rem; padding-top: 70px; }

/* =========================================
   FULLSCREEN PLAYER
   (scoped dark palette so it looks the same in light mode)
   ========================================= */
#playOverlay {
  --bg-surface: #0e121b;
  --bg-surface-elevated: #161c2b;
  --border: rgba(255, 255, 255, 0.1);
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --accent: #00f2aa;
  --accent-glow: rgba(0, 242, 170, 0.35);
  --on-accent: #050b14;

  position: fixed; inset: 0;
  background: #04070d;
  z-index: 9999;
  display: flex; flex-direction: column; align-items: center; justify-content: space-between;
  gap: 0.75rem;
  padding: 1rem;
  opacity: 0; visibility: hidden; pointer-events: none;
  transition: opacity 0.25s ease, visibility 0.25s;
  color: var(--text);
}
#playOverlay.active { opacity: 1; visibility: visible; pointer-events: auto; }

/* top bar: [frame counter] [go-to box] [close] / hint row underneath */
.player-top-bar { width: 100%; max-width: 640px; display: grid; grid-template-columns: 1fr auto auto; align-items: center; column-gap: 0.75rem; row-gap: 0.4rem; }
#playSub { grid-column: 1 / -1; }
#playInfo { font-family: var(--font-mono); font-size: 1.2rem; font-weight: 700; color: var(--accent); letter-spacing: 0.04em; }
#playSub { font-family: var(--font-mono); font-size: 0.72rem; color: var(--text-muted); }
/* go-to-frame box (jump to a code the scanner reports as missing) */
.play-go { display: flex; align-items: center; gap: 0.4rem; }
#playGoInput {
  width: 92px; padding: 0.5rem 0.6rem; font-size: 0.85rem; text-align: center;
  -moz-appearance: textfield; appearance: textfield;
}
#playGoInput::-webkit-outer-spin-button, #playGoInput::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
#playGoInput.invalid { border-color: var(--danger); box-shadow: 0 0 10px rgba(244, 63, 94, 0.35); }
.player-go-btn {
  height: 36px; padding: 0 0.9rem; border-radius: var(--radius-sm);
  background: var(--bg-surface-elevated); border: 1px solid var(--accent); color: var(--accent);
  font-family: var(--font-mono); font-size: 0.8rem; font-weight: 700;
  transition: all 0.2s;
}
.player-go-btn:hover { background: var(--accent); color: var(--on-accent); }

#playClose {
  flex: none;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border);
  width: 44px; height: 44px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  transition: all 0.2s;
}
#playClose:hover { background: var(--danger); color: #fff; transform: scale(1.05); }

/* QR stage — white box with generous quiet zone. Sizing follows the
   original working player: big, square, pixelated. */
#playStage {
  --stage: max(160px, min(92vw, calc(100vh - 290px), 640px));
  width: var(--stage);
  height: var(--stage);
  background: #fff;
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 60px var(--accent-glow), 0 0 100px rgba(0, 0, 0, 0.8);
  flex: none;
}
#playStage > div { width: 100%; height: 100%; }
#playStage canvas, #playStage img {
  width: 100%; height: 100%;
  image-rendering: pixelated;
  shape-rendering: crispEdges;
}

.player-controls {
  width: 100%; max-width: 500px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 0.85rem 1.1rem;
  display: flex; flex-direction: column; gap: 0.75rem;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
}
.player-btn-group { display: flex; align-items: center; justify-content: center; gap: 1rem; }
.player-icon-btn {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border);
  width: 46px; height: 46px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  transition: all 0.2s;
}
.player-icon-btn:hover { background: rgba(255, 255, 255, 0.1); color: var(--accent); }
/* text button: app.js rewrites its label ("⏸ Pause" / "▶ Resume") */
.player-pill {
  min-width: 120px; height: 46px; padding: 0 1.4rem;
  background: var(--accent); color: var(--on-accent);
  border-radius: 999px;
  font-family: var(--font-display); font-weight: 700; font-size: 0.95rem;
  box-shadow: 0 0 20px var(--accent-glow);
  transition: transform 0.2s;
}
.player-pill:hover { transform: scale(1.05); }

.speed-select-wrap {
  display: flex; align-items: center; justify-content: center; gap: 0.5rem; flex-wrap: wrap;
  font-family: var(--font-mono); font-size: 0.72rem; color: var(--text-muted);
}
#playSpeed { width: auto; min-width: 190px; padding: 0.45rem 0.6rem; font-size: 0.78rem; }
#playCustom { width: 90px; padding: 0.45rem 0.5rem; font-size: 0.78rem; }

@media (orientation: landscape) and (max-height: 520px) {
  #playOverlay { flex-direction: row; flex-wrap: wrap; justify-content: center; align-content: center; }
  .player-top-bar { order: 1; max-width: none; }
  #playStage { --stage: max(140px, min(100vh - 150px, 60vw)); order: 2; }
  .player-controls { order: 3; max-width: 320px; }
  #playSub { display: none; }
}

/* =========================================
   DECODE PANEL
   ========================================= */
/* #diagBar: JS overwrites its class to "status <kind>" and its text */
#diagBar {
  cursor: pointer;
  user-select: none;
  display: flex; align-items: center; gap: 0.6rem;
  border-left-width: 1px;
}
#diagBar::before {
  content: '';
  width: 7px; height: 7px; border-radius: 50%; flex: none;
  background: currentColor;
  box-shadow: 0 0 8px currentColor;
}
#diagBar:hover { filter: brightness(1.15); }

#logPanel { margin-top: 0.5rem; }
#logBox {
  display: block;
  background: #020408;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  margin-top: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  line-height: 1.5;
  color: #38bdf8;
  height: 180px;
  overflow-y: auto;
  white-space: pre-wrap;
}
#logPanel .btn-row { margin-top: 0.75rem; gap: 0.5rem; }
#copyLogMsg { font-family: var(--font-mono); font-size: 0.7rem; }

.decode-note { margin-bottom: 0.75rem; }

/* camera viewport — the <video> stays a normal in-flow block
   (width:100%, height:auto) so the wrapper takes its height from it.
   Do NOT add object-fit / min-height / max-height here: the green
   lock outline in app.js maps corners assuming an uncropped video. */
.viewport {
  position: relative;
  width: 100%;
  max-width: 520px;
  margin: 1rem auto 0;
  background: #030509;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.8), 0 8px 32px rgba(0, 0, 0, 0.3);
}
.viewport video { display: block; width: 100%; height: auto; max-width: 100%; background: #030509; }
.viewport #overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; z-index: 4; }

/* idle placeholder: static block (JS toggles display none/block) */
.viewport .vp-idle {
  position: static;
  display: block;
  padding: 2.5rem 1.5rem 3rem;
  text-align: center;
  color: var(--text-muted);
  background: radial-gradient(circle at 50% 50%, rgba(14, 21, 33, 0.95), #060910);
}
.vp-idle .ic {
  display: block; margin: 0 auto 0.75rem;
  width: 44px; height: 44px;
  color: var(--accent); opacity: 0.85;
  filter: drop-shadow(0 0 12px var(--accent-glow));
}
.vp-idle .vp-idle-title { font-family: var(--font-display); font-weight: 700; font-size: 1.1rem; color: #e2e8f0; }
.vp-idle p { font-family: var(--font-mono); font-size: 0.78rem; max-width: 280px; margin: 0.4rem auto 1rem; line-height: 1.45; color: #94a3b8; }
.vp-idle .btn-primary { display: inline-flex; min-width: 0; flex: none; padding: 0.6rem 1.25rem; font-size: 0.9rem; }

/* corner brackets — turn green when app.js adds .locked */
.viewport .brackets { position: absolute; top: 10%; left: 10%; right: 10%; bottom: 10%; pointer-events: none; z-index: 4; }
.viewport .brackets i { position: absolute; width: 26px; height: 26px; border: 3px solid var(--accent); opacity: 0.85; transition: border-color 0.15s; }
.viewport .brackets i:nth-child(1) { top: 0;    left: 0;  border-right: none; border-bottom: none; }
.viewport .brackets i:nth-child(2) { top: 0;    right: 0; border-left: none;  border-bottom: none; }
.viewport .brackets i:nth-child(3) { bottom: 0; left: 0;  border-right: none; border-top: none; }
.viewport .brackets i:nth-child(4) { bottom: 0; right: 0; border-left: none;  border-top: none; }
.viewport.locked .brackets i { border-color: var(--lock); opacity: 1; }

/* laser sweep — only while the camera is live (.scanning set by ui-extras.js) */
.scan-laser {
  position: absolute; left: 0; right: 0; top: 15%; height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  box-shadow: 0 0 15px var(--accent);
  z-index: 4; opacity: 0; pointer-events: none;
  transition: opacity 0.3s;
}
.viewport.scanning .scan-laser { opacity: 0.9; animation: laserSweep 2s ease-in-out infinite alternate; }
@keyframes laserSweep { 0% { top: 15%; } 100% { top: 85%; } }

/* HUD — app.js rewrites its textContent every frame */
.viewport .vp-hud {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 5;
  padding: 0.45rem 0.85rem;
  background: linear-gradient(180deg, transparent 0%, rgba(3, 7, 14, 0.9) 100%);
  border-top: 1px solid rgba(0, 242, 170, 0.15);
  font-family: var(--font-mono); font-size: 0.68rem;
  letter-spacing: 0.06em; text-transform: uppercase;
  color: #00f2aa;
  min-height: 1.9rem;
}
.viewport.locked .vp-hud { color: var(--lock); }

.vp-tools { align-items: center; gap: 0.75rem; max-width: 520px; margin: 0.75rem auto 0; flex-wrap: wrap; }
#zoomWrap {
  flex: 1; min-width: 160px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.4rem 0.75rem;
  font-family: var(--font-mono); font-size: 0.72rem; color: var(--text-muted);
}
#zoomWrap .zoom-inner { display: flex; align-items: center; gap: 0.5rem; }
#zoomRange { flex: 1; min-width: 60px; }

.import-row { max-width: 520px; margin: 0.75rem auto 0; display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.file-input-compact { position: relative; display: inline-flex; }
.file-input-compact input[type="file"] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.import-hint { font-family: var(--font-mono); font-size: 0.7rem; color: var(--text-dim); }

/* capture progress — elements are shown/hidden by app.js */
.capture-hint { font-family: var(--font-mono); font-size: 0.72rem; color: var(--text-muted); margin-bottom: 0.25rem; }
#progressBar {
  height: 8px; margin-top: 0.75rem;
  background: rgba(127, 140, 160, 0.2);
  border-radius: 999px; overflow: hidden;
  border: 1px solid var(--border);
}
#progressFill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--accent-secondary), var(--accent));
  border-radius: 999px;
  transition: width 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 0 12px var(--accent-glow);
}
#progressLabel { font-family: var(--font-mono); font-size: 0.8rem; font-weight: 600; color: var(--text); margin-top: 0.6rem; }

/* chunk tiles are created by app.js: .chunk-dot (+ .got when captured) */
.chunk-grid {
  display: flex; flex-wrap: wrap; gap: 4px;
  margin-top: 0.85rem; padding: 0.75rem;
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  max-height: 200px; overflow-y: auto;
}
.chunk-grid:empty { display: none; }
.chunk-dot {
  width: 22px; height: 22px; border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono); font-size: 8.5px;
  background: rgba(127, 140, 160, 0.14);
  color: var(--text-dim);
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.chunk-dot.got {
  background: var(--accent); color: var(--on-accent);
  box-shadow: 0 0 8px var(--accent-glow);
  animation: chunkPop 0.25s ease-out;
}
@keyframes chunkPop {
  0%   { transform: scale(0.6); filter: brightness(2); }
  70%  { transform: scale(1.2); }
  100% { transform: scale(1); }
}

/* rebuilt files: JS injects <a class="download-link"> into #downloadArea */
#downloadArea { display: flex; flex-direction: column; gap: 0.6rem; margin-top: 0.85rem; }
#downloadArea:empty { display: none; }
a.download-link {
  display: flex; align-items: center; justify-content: center;
  padding: 0.85rem 1.25rem;
  background: linear-gradient(135deg, rgba(0, 242, 170, 0.16) 0%, rgba(59, 130, 246, 0.1) 100%);
  border: 1px solid var(--accent);
  border-radius: var(--radius-md);
  color: var(--accent);
  text-decoration: none;
  font-family: var(--font-display); font-weight: 700; font-size: 0.95rem;
  word-break: break-all;
  transition: all 0.2s;
}
a.download-link:hover { background: var(--accent); color: var(--on-accent); box-shadow: 0 4px 18px var(--accent-glow); }

#resetRow { justify-content: flex-end; margin-top: 1rem; }

/* ---------- footer ---------- */
.app-footer {
  margin-top: auto;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-dim);
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

/* ---------- scrollbars ---------- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: rgba(0, 0, 0, 0.2); }
::-webkit-scrollbar-thumb { background: rgba(127, 140, 160, 0.35); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* ---------- mobile ---------- */
@media (max-width: 640px) {
  .app-shell { padding: 0.75rem 0.5rem 3rem; }
  .card { padding: 1rem; }
  .controls-grid { grid-template-columns: 1fr; }
  .tab { font-size: 0.85rem; padding: 0.75rem 0.4rem; gap: 0.4rem; }
  .tab span { white-space: nowrap; }
  .btn-primary { min-width: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- print (Print / Save as PDF of the QR sheet) ---------- */
@media print {
  .brand-header, .tab-nav, .sub, #genForm, .app-footer, .no-print, .filelist, .sprite, #resultCard .btn-row, #resultCard .section-title { display: none !important; }
  body { background: #fff !important; }
  body::before { display: none; }
  .app-shell { max-width: none; padding: 0; }
  .card { border: none; box-shadow: none; background: #fff; padding: 0; }
  #qrGrid { grid-template-columns: repeat(2, 1fr); gap: 24px; max-height: none; overflow: visible; background: #fff; border: none; }
  .qr-cell { break-inside: avoid; border: none; box-shadow: none; }
}
