@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@600;700&family=Inter:wght@400;500;600;700&display=swap');

:root {
	--wine: #7b1e3a;
	--wine-dark: #4a0f22;
	--wine-deep: #22060f;
	--gold: #d8b448;
	--cream: #f7efe3;
	--ok: #15a34a;
	--warn: #e08a00;
	--bad: #d42a3c;
	--muted: #c9a7b2;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
	font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
	color: var(--cream);
	background: radial-gradient(120% 80% at 50% 0%, #5c1530 0%, var(--wine-dark) 35%, var(--wine-deep) 100%) fixed;
	-webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; cursor: pointer; }

.app { max-width: 560px; margin: 0 auto; min-height: 100%; padding: calc(env(safe-area-inset-top) + 12px) 16px calc(env(safe-area-inset-bottom) + 24px); }

/* Hlavička */
.top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.brand { display: flex; gap: 10px; align-items: center; }
.brand-name { font-family: 'Playfair Display', Georgia, serif; font-size: 1.25rem; font-weight: 700; line-height: 1.1; }
.brand-sub { font-size: .75rem; color: var(--muted); letter-spacing: .08em; text-transform: uppercase; }
.counter { background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.12); padding: 6px 12px; border-radius: 99px; font-weight: 600; font-variant-numeric: tabular-nums; }
.counter i { color: var(--gold); }

/* Kamera */
.viewport { position: relative; aspect-ratio: 1 / 1; width: 100%; border-radius: 22px; overflow: hidden; background: #12030a; box-shadow: 0 20px 50px rgba(0,0,0,.45), inset 0 0 0 1px rgba(255,255,255,.08); }
#reader { position: absolute; inset: 0; }
#reader video { width: 100% !important; height: 100% !important; object-fit: cover; display: block; }
#reader canvas, #reader img, #qr-shaded-region { display: none !important; }

.frame { position: absolute; inset: 16%; pointer-events: none; opacity: 0; transition: opacity .3s; }
.scanning .frame { opacity: 1; }
.frame span { position: absolute; width: 34px; height: 34px; border: 4px solid var(--gold); }
.frame span:nth-child(1) { top: 0; left: 0; border-right: 0; border-bottom: 0; border-top-left-radius: 14px; }
.frame span:nth-child(2) { top: 0; right: 0; border-left: 0; border-bottom: 0; border-top-right-radius: 14px; }
.frame span:nth-child(3) { bottom: 0; left: 0; border-right: 0; border-top: 0; border-bottom-left-radius: 14px; }
.frame span:nth-child(4) { bottom: 0; right: 0; border-left: 0; border-top: 0; border-bottom-right-radius: 14px; }
.laser { position: absolute; left: 6%; right: 6%; height: 2px; background: linear-gradient(90deg, transparent, var(--gold), transparent); box-shadow: 0 0 12px var(--gold); animation: laser 2.2s ease-in-out infinite; }
@keyframes laser { 0%, 100% { top: 8%; } 50% { top: 92%; } }

.start { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 24px; text-align: center;
	background: radial-gradient(circle at 50% 40%, rgba(123,30,58,.55), rgba(18,3,10,.95)); }
.scanning .start { display: none; }
.btn-start { display: flex; flex-direction: column; align-items: center; gap: 10px; border: 0; padding: 26px 34px; border-radius: 22px; font-weight: 600; font-size: 1.1rem;
	background: linear-gradient(160deg, #a12a50, var(--wine)); box-shadow: 0 10px 30px rgba(0,0,0,.4), inset 0 1px 0 rgba(255,255,255,.2); }
.btn-start i { font-size: 3rem; }
.btn-start:active { transform: scale(.97); }
.hint { margin: 0; color: var(--muted); font-size: .9rem; max-width: 280px; }
.error { margin: 0; color: #ffb3bd; font-size: .9rem; max-width: 320px; }

.status-line { display: flex; align-items: center; gap: 8px; justify-content: center; margin: 12px 0 8px; font-size: .85rem; color: var(--muted); }
.status-line .dot { width: 8px; height: 8px; border-radius: 50%; background: #888; }
.status-line.live .dot { background: var(--ok); box-shadow: 0 0 0 0 rgba(21,163,74,.6); animation: pulse 1.6s infinite; }
.status-line.busy .dot { background: var(--gold); }
.status-line.offline .dot { background: var(--bad); }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(21,163,74,.6); } 70% { box-shadow: 0 0 0 8px rgba(21,163,74,0); } 100% { box-shadow: 0 0 0 0 rgba(21,163,74,0); } }

/* Nástroje */
.tools { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 12px; }
.tool { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px 4px; border-radius: 14px; border: 1px solid rgba(255,255,255,.1); background: rgba(255,255,255,.06); font-size: .75rem; }
.tool i { font-size: 1.3rem; }
.tool:disabled { opacity: .35; cursor: default; }
.tool.on { background: rgba(216,180,72,.18); border-color: rgba(216,180,72,.5); color: #ffe7a3; }

.manual[hidden] { display: none; }
.manual { display: flex; gap: 8px; margin-bottom: 14px; }
.manual input { flex: 1; min-width: 0; padding: 14px; border-radius: 14px; border: 1px solid rgba(255,255,255,.18); background: rgba(0,0,0,.25); color: #fff; font: 600 1rem ui-monospace, Menlo, Consolas, monospace; text-transform: uppercase; }
.manual input:focus { outline: 2px solid var(--gold); }
.manual button { border: 0; border-radius: 14px; padding: 0 16px; background: var(--gold); color: #2a0a14; font-weight: 700; white-space: nowrap; }

/* História */
.history h2 { font-size: .75rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); font-weight: 600; margin: 8px 0; }
.history ul { list-style: none; margin: 0; padding: 0; }
.history li { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: rgba(255,255,255,.05); border-radius: 12px; margin-bottom: 6px; font-size: .9rem; }
.history li.empty { color: var(--muted); justify-content: center; }
.history .h-icon { font-size: 1.2rem; }
.history .h-main { flex: 1; min-width: 0; }
.history .h-code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .8rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history .h-time { font-size: .75rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.history .ok .h-icon { color: #4ade80; }
.history .used .h-icon { color: #fbbf24; }
.history .invalid .h-icon, .history .not_found .h-icon, .history .error .h-icon { color: #f87171; }

/* Výsledok */
.result { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; padding: 24px; animation: fadein .15s ease-out; }
.result[hidden] { display: none; }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
.result.ok { background: radial-gradient(circle, #1fbf5b, #0b6b2f); }
.result.used { background: radial-gradient(circle, #f2a516, #a35b00); }
.result.invalid, .result.not_found, .result.error { background: radial-gradient(circle, #e8475a, #8f1222); }
.result-card { text-align: center; color: #fff; max-width: 440px; width: 100%; animation: pop .25s cubic-bezier(.2, 1.4, .4, 1); }
@keyframes pop { from { transform: scale(.85); } to { transform: scale(1); } }
.result-icon i { font-size: 7rem; line-height: 1; filter: drop-shadow(0 6px 16px rgba(0,0,0,.25)); }
.result-title { font-family: 'Playfair Display', Georgia, serif; font-size: 2.4rem; font-weight: 700; margin: 10px 0 6px; line-height: 1.1; }
.result-cat { display: inline-block; font-size: 1.4rem; font-weight: 700; padding: 6px 22px; border-radius: 99px; background: rgba(255,255,255,.95); color: #222; margin: 6px 0; letter-spacing: .04em; }
.result-cat:empty { display: none; }
.result-code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 1.05rem; opacity: .9; margin-top: 8px; word-break: break-all; }
.result-detail { font-size: 1.05rem; margin-top: 8px; opacity: .95; }
.result-detail:empty { display: none; }
.result-tap { margin-top: 26px; font-size: .8rem; opacity: .75; text-transform: uppercase; letter-spacing: .1em; }
.result-timer { height: 4px; background: rgba(255,255,255,.25); border-radius: 4px; margin: 10px auto 0; max-width: 200px; overflow: hidden; }
.result-timer span { display: block; height: 100%; background: #fff; width: 100%; }
.result-timer span.run { animation: timer linear forwards; }
@keyframes timer { from { width: 100%; } to { width: 0; } }

@media (min-width: 700px) {
	.app { padding-top: 32px; }
}
