
/* ==========================================================================
   SCAN VIEW
   ========================================================================== */
.scan-stage {
  position: relative; overflow: hidden;
  aspect-ratio: 4 / 3; max-height: 56dvh;
  border: 1px solid var(--line2); border-radius: var(--radius);
  background: var(--viewport-bg); margin-bottom: 14px;
  display: flex; align-items: center; justify-content: center;
}
.scan-stage video {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.scan-stage .scan-idle {
  text-align: center; padding: 24px; color: var(--viewport-ink); max-width: 38ch;
}
.scan-stage .scan-idle svg { width: 36px; height: 36px; margin-bottom: 10px; color: var(--viewport-dim); }
.scan-stage .scan-idle p { font-size: 13.5px; margin: 0 0 14px; line-height: 1.5; }

/* Reticle overlay */
.reticle { position: absolute; inset: 0; pointer-events: none; }
.reticle .box {
  position: absolute; inset: 50% auto auto 50%; translate: -50% -50%;
  width: min(62%, 240px); aspect-ratio: 1;
  border-radius: 16px; box-shadow: 0 0 0 100vmax var(--viewport-veil);
}
.reticle .box i {
  position: absolute; width: 26px; height: 26px;
  border: 3px solid var(--brand); border-radius: 4px;
}
.reticle .box i:nth-child(1) { top: -1px; left: -1px; border-right: 0; border-bottom: 0; border-top-left-radius: 14px; }
.reticle .box i:nth-child(2) { top: -1px; right: -1px; border-left: 0; border-bottom: 0; border-top-right-radius: 14px; }
.reticle .box i:nth-child(3) { bottom: -1px; left: -1px; border-right: 0; border-top: 0; border-bottom-left-radius: 14px; }
.reticle .box i:nth-child(4) { bottom: -1px; right: -1px; border-left: 0; border-top: 0; border-bottom-right-radius: 14px; }

.scan-note {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 11px 13px; border-radius: var(--radius-sm);
  background: var(--caution-soft); border: 1px solid color-mix(in srgb, var(--caution) 32%, var(--line));
  font-size: 13px; color: var(--ink2); margin-bottom: 14px;
}
.scan-note svg { width: 17px; height: 17px; color: var(--caution); flex: none; margin-top: 1px; }
.scan-note code {
  font-family: var(--font-mono); font-size: 12px;
  background: color-mix(in srgb, var(--caution) 14%, transparent);
  padding: 1px 5px; border-radius: var(--radius-xs);
}

.divider {
  display: flex; align-items: center; gap: 12px;
  margin: 18px 0 14px; color: var(--muted);
  font-size: 11.5px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase;
}
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--line); }

.manual-card {
  padding: 15px; border: 1px solid var(--line);
  border-radius: var(--radius); background: var(--panel);
}
.manual-card h3 { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.manual-card > p { margin: 0 0 13px; font-size: 13px; color: var(--muted); }
.manual-row { display: flex; gap: 9px; }
.manual-row .input { flex: 1; min-width: 0; }

/* ==========================================================================
   HISTORY VIEW
   ========================================================================== */
.hist { display: flex; flex-direction: column; gap: 2px; }
.hist-day {
  position: sticky; top: 0; z-index: 5;
  padding: 12px 2px 7px; margin-top: 8px;
  background: linear-gradient(var(--bg) 72%, transparent);
  font-size: 11.5px; font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--muted);
}
@media (min-width: 700px) { .hist-day { top: -1px; } }

.hevent {
  position: relative; display: grid;
  grid-template-columns: auto 1fr; gap: 0 13px;
  padding: 0 0 4px 0;
}
.hevent .rail { display: flex; flex-direction: column; align-items: center; width: 26px; }
.hevent .knob {
  width: 26px; height: 26px; border-radius: 50%; flex: none;
  display: grid; place-items: center; margin-top: 9px;
  background: var(--s-wash, var(--panel2)); color: var(--s, var(--muted));
  border: 1px solid color-mix(in srgb, var(--s, var(--muted)) 32%, transparent);
}
.hevent .knob svg { width: 13px; height: 13px; }
.hevent .line { flex: 1; width: 2px; background: var(--line); margin: 4px 0 0; border-radius: 2px; }
.hevent:last-child .line { display: none; }
.hevent .hbody { padding: 9px 0 12px; min-width: 0; }
.hevent .hl1 { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.hevent .haction { font-weight: 600; font-size: 14px; }
.hevent .htool {
  font-family: var(--font-heading); font-weight: 600; font-size: 14px;
}
.hevent .hid { font-family: var(--font-mono); font-size: 11.5px; color: var(--muted); }
.hevent .hl2 {
  margin-top: 3px; font-size: 13px; color: var(--ink2);
  display: flex; gap: 4px 12px; flex-wrap: wrap;
}
.hevent .hl2 .lbl { color: var(--muted); }
.hevent .hl2 b { font-weight: 600; color: var(--ink); }
.hevent .htime {
  font-family: var(--font-mono); font-size: 11.5px; color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.hevent .hnote {
  margin-top: 5px; font-size: 13px; color: var(--ink2);
  padding-left: 9px; border-left: 2px solid var(--line2);
}
.hevent .gone {
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--lost); background: var(--lost-soft); padding: 1px 6px; border-radius: 99px;
}

/* ==========================================================================
   QR
   ========================================================================== */
.qr-card {
  display: grid; place-items: center; gap: 12px;
  padding: 18px; border-radius: var(--radius);
  background: var(--paper); border: 1px solid var(--line2);
}
.qr-card .qr-box { display: grid; place-items: center; }
.qr-card .qr-box img, .qr-card .qr-box canvas { display: block; }
.qr-card .qr-id {
  font-family: var(--font-mono); font-weight: 700; font-size: 17px;
  letter-spacing: 0.1em; color: var(--paper-ink);
}
.qr-card .qr-name {
  font-family: var(--font-heading); font-weight: 600; font-size: 15px;
  color: var(--paper-ink); text-align: center; overflow-wrap: anywhere;
}
.qr-card .qr-cat { font-size: 12px; color: var(--paper-muted); }

/* ==========================================================================
   PRINT
   ========================================================================== */
#print-area { display: none; }

@media print {
  @page { margin: 12mm; }

  /* Hide the app chrome; show only the generated print area. */
  .app, .toasts, .modal-backdrop { display: none !important; }
  #print-area { display: block !important; }

  html, body {
    background: var(--paper) !important; color: var(--paper-ink) !important;
    font-size: 11pt;
  }

  .p-head {
    display: flex; align-items: flex-end; justify-content: space-between;
    gap: 16px; padding-bottom: 8px; margin-bottom: 14px;
    border-bottom: 2px solid var(--paper-ink);
  }
  .p-head .p-title { font-family: 'Space Grotesk', sans-serif; font-weight: 700; font-size: 17pt; }
  .p-head .p-sub { font-size: 9pt; color: var(--paper-ink2); }

  .p-grid {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 6mm;
  }
  .p-cell {
    break-inside: avoid; page-break-inside: avoid;
    display: flex; flex-direction: column; align-items: center; gap: 3mm;
    padding: 4mm 3mm; border: 1px solid var(--paper-line); border-radius: 3mm;
    text-align: center;
  }
  .p-cell img, .p-cell canvas { display: block; }
  .p-cell .p-id {
    font-family: 'JetBrains Mono', monospace; font-weight: 700;
    font-size: 12pt; letter-spacing: 0.1em;
  }
  .p-cell .p-name {
    font-family: 'Space Grotesk', sans-serif; font-weight: 600;
    font-size: 10pt; line-height: 1.25; overflow-wrap: anywhere;
  }
  .p-cell .p-cat { font-size: 8pt; color: var(--paper-muted); }
  .p-cell .p-sn { font-size: 8pt; font-family: var(--font-mono, monospace); }

  /* Single-code sheet: one big centred card */
  .p-grid.single { grid-template-columns: 1fr; max-width: 92mm; margin: 12mm auto 0; }
  .p-grid.single .p-cell { padding: 8mm 6mm; gap: 5mm; }
  .p-grid.single .p-id { font-size: 18pt; }
  .p-grid.single .p-name { font-size: 14pt; }

  .p-foot {
    margin-top: 10mm; padding-top: 4mm; border-top: 1px solid var(--paper-line);
    font-size: 8pt; color: var(--paper-muted); display: flex; justify-content: space-between;
  }
}
