/* QR Codes */
.app-qr { background: var(--surface); container-type: inline-size; }
.qr-toolbar { justify-content: center; }
.qr-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }

/* create */
.qr-create { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 380px); }
.qr-left { padding: 18px 20px 24px; display: flex; flex-direction: column; gap: 16px; border-right: 1px solid var(--line); }
.qr-types { display: flex; flex-wrap: wrap; gap: 6px; }
.qr-form { display: flex; flex-wrap: wrap; gap: 12px; }
.qr-field { display: flex; flex-direction: column; gap: 5px; flex: 1 1 100%; min-width: 0; }
.qr-field.half { flex: 1 1 calc(50% - 6px); min-width: 160px; }
.qr-field > span, .qr-lab { font-size: 12px; font-weight: 600; color: var(--text-2); }
.qr-lab b { color: var(--text); font-variant-numeric: tabular-nums; }
.qr-field .input, .qr-field .select { width: 100%; }
.qr-field .textarea { width: 100%; resize: vertical; min-height: 70px; }
.qr-check { display: flex; align-items: center; gap: 10px; font-size: 13px; flex: 1 1 100%; }
.qr-style { border-radius: 14px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); }
.qr-style summary { list-style: none; display: flex; align-items: center; gap: 8px; padding: 11px 14px; font-size: 13px; font-weight: 700; cursor: default; }
.qr-style summary::-webkit-details-marker { display: none; }
.qr-style summary .ic { color: var(--accent); }
.qr-style summary::after { content: ''; margin-left: auto; width: 7px; height: 7px; border-right: 2px solid var(--text-3); border-bottom: 2px solid var(--text-3); transform: rotate(45deg); transition: transform .15s; }
.qr-style[open] summary::after { transform: rotate(-135deg); }
.qr-style-g { display: flex; flex-direction: column; gap: 14px; padding: 2px 14px 14px; }
.qr-colors { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.qr-color { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.qr-color input { width: 34px; height: 34px; padding: 0; border: 0; border-radius: 10px; background: none; overflow: hidden; cursor: pointer; box-shadow: inset 0 0 0 1px var(--line-2); }
.qr-color input::-webkit-color-swatch-wrapper { padding: 3px; }
.qr-color input::-webkit-color-swatch { border: 0; border-radius: 7px; }
.qr-colors .btn { margin-left: auto; }
.qr-ecl { align-self: flex-start; }

.qr-right { padding: 22px; display: flex; flex-direction: column; align-items: center; gap: 12px; background: var(--surface-2); overflow-y: auto; }
.qr-card { width: 100%; max-width: 300px; aspect-ratio: 1; border-radius: 22px; padding: 18px; background: #fff; box-shadow: 0 16px 40px -18px rgba(0, 0, 0, .45), inset 0 0 0 1px rgba(0, 0, 0, .06); display: grid; place-items: center; }
.qr-preview { width: 100%; height: 100%; display: grid; place-items: center; }
.qr-preview svg { width: 100%; height: 100%; display: block; border-radius: 6px; }
.qr-ph { display: flex; flex-direction: column; align-items: center; gap: 10px; color: #9aa3b2; text-align: center; font-size: 13px; padding: 10px; }
.qr-ph.err { color: #c2410c; }
.qr-actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.qr-payload { font-size: 12px; color: var(--text-3); text-align: center; }
.qr-payload b { color: var(--text-2); }
.qr-warn { display: flex; gap: 8px; align-items: flex-start; max-width: 320px; padding: 9px 11px; border-radius: 12px; background: rgba(245, 165, 36, .15); color: var(--text-2); font-size: 12.5px; line-height: 1.4; }
.qr-warn .ic { color: #d48806; margin-top: 1px; }
.qr-warn[hidden] { display: none; }

/* scan */
.qr-scan { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(280px, 1fr); }
.qr-scan-l { display: flex; flex-direction: column; gap: 10px; padding: 16px; min-height: 0; }
.qr-stage { position: relative; flex: 1; min-height: 240px; border-radius: 20px; overflow: hidden; background: #05070d; }
.qr-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.qr-video.mirror { transform: scaleX(-1); }
.qr-frame { position: absolute; left: 50%; top: 50%; width: min(62%, 62vh, 300px); aspect-ratio: 1; transform: translate(-50%, -50%); pointer-events: none; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .32); border-radius: 18px; }
.qr-frame i { position: absolute; width: 34px; height: 34px; border: 4px solid #fff; }
.qr-frame i:nth-child(1) { left: 0; top: 0; border-right: 0; border-bottom: 0; border-top-left-radius: 18px; }
.qr-frame i:nth-child(2) { right: 0; top: 0; border-left: 0; border-bottom: 0; border-top-right-radius: 18px; }
.qr-frame i:nth-child(3) { left: 0; bottom: 0; border-right: 0; border-top: 0; border-bottom-left-radius: 18px; }
.qr-frame i:nth-child(4) { right: 0; bottom: 0; border-left: 0; border-top: 0; border-bottom-right-radius: 18px; }
.qr-frame b { position: absolute; left: 10%; right: 10%; height: 2px; top: 50%; background: linear-gradient(90deg, transparent, #4ade80, transparent); animation: qr-sweep 2.2s ease-in-out infinite; }
@keyframes qr-sweep { 0%, 100% { top: 12%; } 50% { top: 88%; } }
@media (prefers-reduced-motion: reduce) { .qr-frame b { animation: none; } }
.qr-frame.hit i { border-color: #4ade80; }
.qr-frame.hit { animation: qr-hit .5s ease-out; }
@keyframes qr-hit { 30% { transform: translate(-50%, -50%) scale(1.05); } }
.qr-scan-msg { position: absolute; inset: 0; display: none; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 24px; text-align: center; color: #fff; background: rgba(5, 7, 13, .78); }
.qr-scan-msg.show { display: flex; }
.qr-scan-msg p { margin: 0; max-width: 340px; font-size: 14px; line-height: 1.45; color: rgba(255, 255, 255, .85); }
.qr-scan-msg.err span { color: #fca5a5; }
.qr-scan-ctl { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.qr-result-wrap { padding: 16px 16px 16px 0; overflow-y: auto; display: flex; flex-direction: column; }
.qr-result-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; text-align: center; color: var(--text-2); padding: 20px; border-radius: 20px; border: 1px dashed var(--line-2); }
.qr-result-empty h3 { margin: 6px 0 0; font-size: 15px; color: var(--text); }
.qr-result-empty p { margin: 0; font-size: 13px; }
.qr-result-empty > span { color: var(--text-3); }
.qr-result { display: flex; flex-direction: column; gap: 10px; padding: 16px; border-radius: 18px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); animation: qr-in .25s var(--ease); }
@keyframes qr-in { from { opacity: 0; transform: translateY(6px); } }
.qr-res-k { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; color: var(--accent); }
.qr-res-t { font-size: 18px; font-weight: 700; overflow-wrap: anywhere; user-select: text; -webkit-user-select: text; }
.qr-res-f { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0; font-size: 13px; }
.qr-res-f dt { color: var(--text-3); font-weight: 600; }
.qr-res-f dd { margin: 0; overflow-wrap: anywhere; user-select: text; -webkit-user-select: text; }
.qr-res-raw { margin: 0; padding: 10px; border-radius: 10px; background: var(--surface); font: 12.5px/1.45 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; max-height: 220px; overflow: auto; user-select: text; -webkit-user-select: text; }
.qr-res-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.qr-res-note { margin: 0; display: flex; gap: 6px; align-items: center; font-size: 12px; color: #d48806; }

/* history */
.qr-history { flex: 1; padding: 16px 20px 24px; display: flex; flex-direction: column; gap: 10px; }
.qr-hist-h { display: flex; align-items: center; justify-content: space-between; font-size: 13px; }
.qr-hist-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 8px; }
.qr-hist-row { position: relative; display: flex; align-items: center; gap: 12px; padding: 10px 40px 10px 10px; border: 0; border-radius: 14px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); color: var(--text); text-align: left; min-width: 0; transition: background .12s; }
.qr-hist-row:hover { background: var(--tile-hover); }
.qr-hist-thumb { width: 48px; height: 48px; flex: 0 0 auto; border-radius: 9px; background: #fff; padding: 3px; display: grid; place-items: center; }
.qr-hist-thumb svg { width: 100%; height: 100%; }
.qr-hist-txt { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.qr-hist-txt b { font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qr-hist-txt small { display: flex; align-items: center; gap: 4px; font-size: 11.5px; color: var(--text-3); }
.qr-hist-x { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 28px; height: 28px; color: var(--text-3); }

@container (max-width: 720px) {
  .qr-create { grid-template-columns: 1fr; overflow-y: auto; display: flex; flex-direction: column-reverse; justify-content: flex-end; }
  .qr-left { border-right: 0; overflow: visible; padding: 14px; }
  .qr-right { overflow: visible; padding: 16px 14px 6px; background: none; }
  .qr-card { max-width: 220px; padding: 14px; }
  .qr-ph svg { width: 44px; height: 44px; }
  .qr-ph { font-size: 12px; }
  .qr-scan { display: flex; flex-direction: column; overflow-y: auto; }
  .qr-scan-l { padding: 12px; flex: 0 0 auto; }
  .qr-stage { min-height: 300px; flex: 0 0 auto; height: 52vh; }
  .qr-result-wrap { padding: 0 12px 16px; overflow: visible; }
  .qr-result-empty { padding: 18px; }
  .qr-history { padding: 12px; }
  .qr-hist-list { grid-template-columns: 1fr; }
}
