/* ===== Skip Link (a11y, WCAG 2.4.1) ===== */
.skip-link {
    position: absolute;
    top: -100px;
    left: 8px;
    z-index: 1000;
    padding: 8px 16px;
    background: #000;
    color: #fff;
    text-decoration: none;
    border-radius: 4px;
    font-weight: 600;
}
.skip-link:focus {
    top: 8px;
    outline: 2px solid #fff;
    outline-offset: 2px;
}

/* ===== Reset & Base ===== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* HTML spec: [hidden] musi zawsze ukrywać. Bronimy się przed regresją gdy
   selektor np. .template-form deklaruje display: grid bez :not([hidden]). */
[hidden] {
    display: none !important;
}

/* WCAG 2.4.7 (AA): visible focus indicator for keyboard users */

:root {
    --bg: #f0f2f5;
    --surface: #ffffff;
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-light: #eef2ff;
    --text: #1e293b;
    --text-secondary: #52606d;
    --text-muted: #5f6f82;
    --border: #e2e8f0;
    --text-primary: var(--text);
    --border-focus: #4f46e5;
    --radius: 16px;
    --radius-sm: 10px;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
    --shadow-lg: 0 10px 25px -5px rgba(0,0,0,0.1), 0 8px 10px -6px rgba(0,0,0,0.05);
    --transition: 0.2s ease;
}

[data-theme="dark"] {
    --bg: #0f172a;
    --surface: #1e293b;
    --primary: #818cf8;
    --primary-hover: #6366f1;
    --primary-light: rgba(99, 102, 241, 0.15);
    --text: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #a0aec0;
    --border: #334155;
    --border-focus: #818cf8;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
    --shadow: 0 4px 6px -1px rgba(0,0,0,0.4), 0 2px 4px -2px rgba(0,0,0,0.3);
    --shadow-lg: 0 10px 25px -5px rgba(0,0,0,0.5), 0 8px 10px -6px rgba(0,0,0,0.4);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #f0f2f5 0%, #e0e7ff 50%, #fce7f3 100%);
    background-attachment: fixed;
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    position: relative;
    overflow-x: hidden;
}

/* Animated mesh pattern */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image:
        radial-gradient(circle at 20% 50%, rgba(79, 70, 229, 0.06) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(124, 58, 237, 0.05) 0%, transparent 40%),
        radial-gradient(circle at 50% 80%, rgba(236, 72, 153, 0.04) 0%, transparent 40%);
    background-size: 100% 100%;
    animation: meshShift 20s ease-in-out infinite;
    pointer-events: none;
    z-index: -1;
}

@keyframes meshShift {
    0%, 100% { opacity: 0.8; }
    50% { opacity: 1; }
}

/* ===== App Layout ===== */
.app {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
}

/* ===== Header ===== */
header {
    text-align: center;
    padding: 48px 0 32px;
    position: relative;
}

@media (max-width: 600px) {
    #main-content {
        display: flex;
        flex-direction: column;
    }

    #main-content > :not(.generator-panel):not(.popular-section) {
        order: 3;
    }

    header,
    .animated-header {
        padding-top: 76px;
    }
}

.animated-header {
    animation: slideDown 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-30px); }
    to { opacity: 1; transform: translateY(0); }
}

.subtitle {
    color: var(--text-secondary);
    font-size: 16px;
    font-weight: 400;
}

/* ===== Generator Panel ===== */

/* Glass-morphism cards */

.preview {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-radius: var(--radius);
    padding: 22px;
    box-shadow: 0 8px 32px rgba(79, 70, 229, 0.08),
                inset 0 1px 0 rgba(255, 255, 255, 0.6);
    border: 1px solid rgba(79, 70, 229, 0.12);
    display: flex;
    flex-direction: column;
    animation: slideInRight 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) 0.3s both;
}

@keyframes slideInRight {
    from { opacity: 0; transform: translateX(30px); }
    to { opacity: 1; transform: translateX(0); }
}

/* ===== Control Groups ===== */

/* ===== Inputs ===== */
select,
input[type="text"] {
    width: 100%;
    min-width: 0;
    padding: 8px 12px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 13px;
    color: var(--text);
    background: rgba(255, 255, 255, 0.8);
    transition: all var(--transition);
    outline: none;
    appearance: none;
    box-sizing: border-box;
}

select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%234f46e5' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 30px;
    cursor: pointer;
}

select:hover {
    border-color: rgba(79, 70, 229, 0.5);
    background-color: rgba(255, 255, 255, 0.95);
}

select:focus,
input[type="text"]:focus {
    border-color: transparent;
    background: rgba(255, 255, 255, 0.95);
    box-shadow:
        0 0 0 3px rgba(79, 70, 229, 0.1),
        inset 0 0 0 1.5px rgba(79, 70, 229, 0.25),
        0 4px 16px rgba(79, 70, 229, 0.15);
    transform: translateY(-1px);
}

input[type="text"]::placeholder {
    color: var(--text-muted);
}

/* ===== Range Sliders ===== */

/* ===== Color Inputs ===== */

input[type="color"] {
    width: 34px;
    height: 30px;
    border: 2px solid rgba(79, 70, 229, 0.15);
    border-radius: var(--radius-sm);
    cursor: pointer;
    padding: 2px;
    background: transparent;
    transition: all var(--transition);
}

input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 2px;
}

input[type="color"]::-webkit-color-swatch {
    border: none;
    border-radius: 6px;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.15);
}

input[type="color"]:hover {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.12);
    transform: scale(1.05);
}

/* ===== Toggle Switch ===== */
.toggle {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 26px;
    cursor: pointer;
}

.toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

/* ===== Button Group (text align) ===== */

/* ===== Generate Button ===== */

/* ===== Preview Section ===== */
.preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}

.preview-header h2 {
    font-size: 18px;
    font-weight: 600;
}

.preview-actions {
    display: flex;
    flex-wrap: nowrap;
    gap: 8px;
}

/* Preview canvas with animated gradient border */
.preview-canvas {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 220px;
    background: linear-gradient(135deg, rgba(255,255,255,0.5) 0%, rgba(79,70,229,0.03) 100%);
    border-radius: var(--radius-sm);
    padding: 18px;
    position: relative;
    overflow: hidden;
}

.preview-canvas::before {
    content: '';
    position: absolute;
    inset: -2px;
    border-radius: var(--radius-sm);
    padding: 2px;
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 50%, #ec4899 100%);
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    opacity: 0.3;
    animation: borderGlow 3s ease-in-out infinite;
    pointer-events: none;
}

.preview-canvas::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle 400px at center, rgba(79,70,229,0.06), transparent);
    pointer-events: none;
    animation: glowPulse 4s ease-in-out infinite;
}

@keyframes borderGlow {
    0%, 100% { opacity: 0.15; }
    50% { opacity: 0.5; }
}

@keyframes glowPulse {
    0%, 100% { opacity: 0; }
    50% { opacity: 1; }
}

.preview-hint {
    color: var(--text-muted);
    font-size: 14px;
    text-align: center;
    position: relative;
    z-index: 2;
}

/* ===== Error Message ===== */
.error-message {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
    padding: 12px 16px;
    background: linear-gradient(135deg, #fef2f2, #ffe4e6);
    border: 1px solid #fecaca;
    border-left: 3px solid #ef4444;
    border-radius: var(--radius-sm);
    color: #dc2626;
    font-size: 13px;
    font-weight: 500;
    animation: slideInError 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes slideInError {
    from { opacity: 0; transform: translateX(-16px); }
    to { opacity: 1; transform: translateX(0); }
}

/* ===== Rotation Styles ===== */

/* ===== Dark Accent Section ===== */

/* ===== Info Section ===== */

/* ===== Footer ===== */
footer {
    text-align: center;
    padding: 32px 0;
    border-top: 1px solid rgba(79, 70, 229, 0.1);
    color: var(--text-muted);
    font-size: 13px;
}

/* ===== Toast Notification ===== */

/* ===== Responsive ===== */

@media (max-width: 600px) {
    header {
        padding: 32px 0 24px;
    }

    .preview-actions {
        flex-wrap: wrap;
    }

    .preview-actions .btn-action {
        flex: 1 1 auto;
        justify-content: center;
    }

    .preview-header {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* ===== Print Button Accent ===== */

/* ===== Modal ===== */

/* Print Sections */

/* Printer Tabs */

/* Label Templates */

/* Custom Size */

/* Label Content Fields */

/* Print Preview */

/* Single label preview */

/* Cut lines */

/* A4 grid preview (for print output) */

/* A4 two-section preview layout */

/* Schematic A4 sheet */

/* Cut lines on schematic grid */

/* Scissors icon on grid */

/* ===== Print-only styles ===== */
@media print {
    /* Hide everything except the print output; display:none keeps reflowed content
       out of pagination (visibility:hidden left empty pages behind). */
    body > *:not(#print-output) {
        display: none !important;
    }

    html, body {
        background: #fff !important;
        background-image: none !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    html::before, body::before, html::after, body::after {
        display: none !important;
        background: none !important;
    }

    /* Only print colors where they matter â€” barcode labels. */

    @page {
        margin: 0;
        marks: none;
    }
}

/* ===== Modal Responsive ===== */

/* ===== Dark Mode Overrides ===== */
[data-theme="dark"] body,
[data-theme="dark"] {
    background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 50%, #1e1b4b 100%);
}

[data-theme="dark"] body::before {
    background-image:
        radial-gradient(circle at 20% 50%, rgba(129, 140, 248, 0.08) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(124, 58, 237, 0.06) 0%, transparent 40%),
        radial-gradient(circle at 50% 80%, rgba(236, 72, 153, 0.05) 0%, transparent 40%);
}


[data-theme="dark"] .preview {
    background: rgba(30, 41, 59, 0.8);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3),
                inset 0 1px 0 rgba(255, 255, 255, 0.05);
    border-color: rgba(51, 65, 85, 0.6);
}

[data-theme="dark"] select,
[data-theme="dark"] input[type="text"],
[data-theme="dark"] input[type="number"] {
    background-color: rgba(15, 23, 42, 0.6);
    border-color: var(--border);
    color: var(--text);
}

[data-theme="dark"] select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%23a78bfa' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
}

/* Native option list must stay readable in dark mode (Chrome/Edge on Windows) */

[data-theme="dark"] select:hover {
    background-color: rgba(30, 41, 59, 0.8);
    border-color: rgba(167, 139, 250, 0.5);
}

[data-theme="dark"] select:focus,
[data-theme="dark"] input[type="text"]:focus,
[data-theme="dark"] input[type="number"]:focus {
    outline: 3px solid var(--border-focus);
    outline-offset: 2px;
    border-color: transparent;
    background: rgba(15, 23, 42, 0.85);
    box-shadow:
        0 0 0 3px rgba(129, 140, 248, 0.25),
        inset 0 0 0 1.5px rgba(167, 139, 250, 0.4);
}

[data-theme="dark"] .preview-canvas {
    background: rgba(15, 23, 42, 0.5);
}

[data-theme="dark"] footer {
    color: var(--text-muted);
}

/* ===== Theme Toggle ===== */
.theme-toggle {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 42px;
    height: 42px;
    border: 1.5px solid var(--border);
    border-radius: 50%;
    background: var(--surface);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    color: var(--text-secondary);
    box-shadow: var(--shadow-sm);
    z-index: 10;
}

.theme-toggle:hover {
    border-color: var(--primary);
    color: var(--primary);
    transform: rotate(20deg);
    box-shadow: var(--shadow);
}

.theme-toggle .icon-sun,
.theme-toggle .icon-moon {
    width: 20px;
    height: 20px;
    transition: all 0.3s ease;
}

.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }

[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

/* ===== Language Switcher ===== */
.lang-switch {
    position: absolute;
    top: 20px;
    left: 20px;
    z-index: 10;
}

.lang-current {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
}

.lang-current:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.lang-dropdown {
    display: none;
    flex-direction: column;
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    min-width: 170px;
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: 10px;
    box-shadow: var(--shadow-lg);
    padding: 6px;
    z-index: 100;
}

.lang-dropdown.open {
    display: flex;
}

.lang-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 6px;
    transition: all var(--transition);
}

.lang-option:hover {
    background: var(--primary-light);
    color: var(--primary);
}

.lang-option.active {
    background: var(--primary);
    color: white;
    font-weight: 600;
}

/* ===== Ad Slots ===== */
/* Sloty nie rezerwują miejsca — AdSense odkrywa pozycję po markup,
   a kontener rośnie dopiero gdy ins ma data-ad-status="filled".
   Unfilled = całkowity collapse (patrz reguły poniżej). */
.ad-slot {
    width: 100%;
    max-width: 1200px;
    margin: 16px auto;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Collapse unfilled AdSense slots — bez pustych miejsc na stronie */
.ad-slot:has(> ins.adsbygoogle[data-ad-status="unfilled"]):not(:has(> ins.adsbygoogle[data-ad-status="filled"])),
.ad-sidebar:has(> ins.adsbygoogle[data-ad-status="unfilled"]):not(:has(> ins.adsbygoogle[data-ad-status="filled"])),
.ad-sticky-bottom:has(> ins.adsbygoogle[data-ad-status="unfilled"]):not(:has(> ins.adsbygoogle[data-ad-status="filled"])) {
    display: none !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* Sticky bottom mobile ad (anchor) — only on small screens */
.ad-sticky-bottom {
    display: none;
}

@media (max-width: 900px) {
    .ad-sticky-bottom.is-ready {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 9990;
        min-height: 60px;
        background: var(--surface);
        border-top: 1px solid var(--border);
        box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.08);
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 6px 36px 6px 8px;
    }
    .ad-sticky-bottom.is-hidden { display: none; }
    .ad-sticky-bottom ins.adsbygoogle {
        display: block;
        width: 100%;
        max-width: 320px;
        min-height: 50px;
    }
    .ad-sticky-bottom__close {
        position: absolute;
        top: 4px;
        right: 6px;
        width: 28px;
        height: 28px;
        border: 0;
        background: transparent;
        color: var(--text-muted);
        font-size: 20px;
        line-height: 1;
        cursor: pointer;
        border-radius: 6px;
    }
    .ad-sticky-bottom__close:hover,
    .ad-sticky-bottom__close:focus-visible {
        background: var(--border);
        color: var(--text);
    }
    .ad-sticky-bottom__close:focus-visible {
        outline: 2px solid var(--border-focus);
        outline-offset: 2px;
    }
    /* Push content above sticky ad on mobile */
    body.has-sticky-ad main { padding-bottom: 80px; }
}

/* ===== Footer Links ===== */
.footer-links {
    margin-top: 8px;
    font-size: 13px;
}

.footer-links a {
    color: var(--text-muted);
    text-decoration: none;
    transition: color var(--transition);
}

.footer-links a:hover {
    color: var(--primary);
    text-decoration: underline;
}

.cookie-settings-link {
    padding: 0;
    border: 0;
    background: none;
    color: var(--text-muted);
    font: inherit;
    cursor: pointer;
}

.cookie-settings-link:hover,
.cookie-settings-link:focus-visible {
    color: var(--primary);
    text-decoration: underline;
}

.cookie-settings-link:focus-visible {
    outline: 2px solid var(--border-focus);
    outline-offset: 3px;
    border-radius: 4px;
}

/* ===== Cookie Consent Banner ===== */
#cookie-banner {
    position: fixed;
    bottom: max(12px, env(safe-area-inset-bottom));
    left: 16px;
    right: 16px;
    z-index: 9999;
    width: min(760px, calc(100% - 32px));
    max-height: calc(100dvh - 24px);
    margin: 0 auto;
    overflow-y: auto;
    background: var(--surface);
    border-top: 1.5px solid var(--border);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 12px 34px rgba(15, 23, 42, 0.18);
    padding: 16px;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from { transform: translateY(100%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.cookie-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.cookie-text {
    margin: 0;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-secondary);
    flex: 1;
    min-width: 200px;
}

.cookie-buttons {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.cookie-btn {
    min-height: 42px;
    padding: 9px 18px;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.cookie-accept {
    background: var(--primary);
    color: white;
}

.cookie-accept:hover {
    background: var(--primary-hover);
}

[data-theme="dark"] .cookie-accept {
    background: #4f46e5;
}

[data-theme="dark"] .cookie-accept:hover {
    background: #4338ca;
}

.cookie-reject {
    background: var(--surface);
    color: var(--text-primary);
    border: 1.5px solid var(--border);
}

.cookie-reject:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.cookie-btn:focus-visible {
    outline: 3px solid var(--border-focus);
    outline-offset: 2px;
}

@media (max-width: 560px) {
    body.has-cookie-banner {
        padding-bottom: calc(176px + env(safe-area-inset-bottom));
    }

    #cookie-banner {
        left: 10px;
        right: 10px;
        bottom: max(10px, env(safe-area-inset-bottom));
        width: calc(100% - 20px);
        padding: 14px;
    }

    .cookie-inner {
        align-items: stretch;
        gap: 12px;
    }

    .cookie-text,
    .cookie-buttons {
        width: 100%;
    }

    .cookie-buttons {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }

    .cookie-btn {
        width: 100%;
        padding-inline: 10px;
    }
}

/* ===== DECODER PAGE â€” Premium Redesign ===== */
.decoder-main [hidden],
.decoder-main img[hidden],
.spinner[hidden],
.preview-img[hidden],
.result-box[hidden],
.error-box[hidden] { display: none !important; }

.decoder-main {
    max-width: 860px;
    margin: 0 auto;
    padding: 8px 20px 80px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px 18px;
    align-items: stretch;
}
.decoder-main > .decoder-intro { grid-column: 1 / -1; grid-row: 1; }
.decoder-main > .camera-row    { grid-column: 1 / -1; grid-row: 2; }
.decoder-main > .drop-area     { grid-column: 1 / -1; grid-row: 3; }
.decoder-main > .decoder-features { grid-column: 1 / -1; grid-row: 4; }
.decoder-main > #spinner,
.decoder-main > .preview-container,
.decoder-main > #error-box,
.decoder-main > #result-box { grid-column: 1 / -1; }
@media (max-width: 720px) {
    .decoder-main { grid-template-columns: 1fr; }
}

.decoder-intro {
    text-align: center;
    max-width: 640px;
    margin: 0 auto 28px;
    color: var(--text-secondary, #64748b);
    font-size: 16px;
    line-height: 1.65;
    animation: fadeSlideUp 0.7s ease both;
    animation-delay: 0.1s;
}

/* Segmented tab navigation (Generator / Decoder) */
.decoder-nav {
    display: flex;
    width: fit-content;
    margin: -8px auto 20px;
    padding: 5px;
    background: rgba(255, 255, 255, 0.55);
    backdrop-filter: blur(12px) saturate(160%);
    -webkit-backdrop-filter: blur(12px) saturate(160%);
    border: 1px solid rgba(79, 70, 229, 0.12);
    border-radius: 999px;
    gap: 2px;
    box-shadow: 0 2px 12px rgba(79, 70, 229, 0.08);
    animation: fadeSlideUp 0.6s ease both;
}
[data-theme="dark"] .decoder-nav {
    background: rgba(30, 41, 59, 0.6);
    border-color: rgba(129, 140, 248, 0.18);
}

.decoder-nav a {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary, #64748b);
    text-decoration: none;
    padding: 9px 22px;
    border-radius: 999px;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    letter-spacing: 0.01em;
}

.decoder-nav a:hover {
    color: var(--primary, #4f46e5);
    background: rgba(79, 70, 229, 0.06);
}

.decoder-nav a.active {
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    color: #fff;
    box-shadow: 0 4px 14px rgba(79, 70, 229, 0.35);
}

/* Drop area â€” glass-morphic card with animated gradient border */
.drop-area {
    display: block;
    position: relative;
    border-radius: 20px;
    padding: 56px 28px;
    text-align: center;
    cursor: pointer;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s ease;
    background: rgba(255, 255, 255, 0.5);
    backdrop-filter: blur(16px) saturate(160%);
    -webkit-backdrop-filter: blur(16px) saturate(160%);
    overflow: hidden;
    animation: fadeSlideUp 0.8s ease both;
    animation-delay: 0.2s;
    box-shadow: 0 4px 24px rgba(79, 70, 229, 0.06), inset 0 0 0 1.5px rgba(79, 70, 229, 0.18);
}
[data-theme="dark"] .drop-area {
    background: rgba(30, 41, 59, 0.55);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.2), inset 0 0 0 1.5px rgba(129, 140, 248, 0.22);
}

/* Dashed outline drawn via SVG-like background for smooth corners */
.drop-area::before {
    content: '';
    position: absolute;
    inset: 8px;
    border-radius: 14px;
    border: 2px dashed rgba(79, 70, 229, 0.32);
    pointer-events: none;
    transition: border-color 0.3s ease, transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}
[data-theme="dark"] .drop-area::before {
    border-color: rgba(129, 140, 248, 0.4);
}

/* Soft moving glow behind drop area */
.drop-area::after {
    content: '';
    position: absolute;
    inset: -50%;
    background: radial-gradient(circle at 30% 30%, rgba(79, 70, 229, 0.25), transparent 50%),
                radial-gradient(circle at 70% 70%, rgba(124, 58, 237, 0.22), transparent 50%);
    opacity: 0;
    transition: opacity 0.4s ease;
    pointer-events: none;
    animation: meshRotate 18s linear infinite;
}

.drop-area:hover,
.drop-area:focus-visible,
.drop-area.drag-over {
    transform: translateY(-3px) scale(1.005);
    box-shadow: 0 12px 40px rgba(79, 70, 229, 0.22), inset 0 0 0 1.5px rgba(79, 70, 229, 0.38);
    outline: none;
}
.drop-area:hover::before,
.drop-area.drag-over::before {
    border-color: rgba(79, 70, 229, 0.7);
    transform: scale(0.99);
}
.drop-area:hover::after,
.drop-area.drag-over::after {
    opacity: 1;
}
.drop-area.drag-over {
    transform: translateY(-5px) scale(1.012);
}

@keyframes meshRotate {
    to { transform: rotate(360deg); }
}

.drop-area > * {
    position: relative;
    z-index: 1;
}

/* SVG icon â€” pulsing camera/scanner */
.drop-area-icon {
    width: 72px;
    height: 72px;
    margin: 0 auto 18px;
    display: grid;
    place-items: center;
    border-radius: 20px;
    background: linear-gradient(135deg, rgba(79, 70, 229, 0.12), rgba(124, 58, 237, 0.1));
    color: #4f46e5;
    box-shadow: 0 6px 20px rgba(79, 70, 229, 0.18);
    transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
    animation: iconFloat 3.6s ease-in-out infinite;
}
[data-theme="dark"] .drop-area-icon {
    color: #a5b4fc;
    background: linear-gradient(135deg, rgba(129, 140, 248, 0.18), rgba(167, 139, 250, 0.14));
}
.drop-area-icon svg {
    width: 38px;
    height: 38px;
}
.drop-area:hover .drop-area-icon,
.drop-area.drag-over .drop-area-icon {
    transform: scale(1.12) rotate(-4deg);
}

@keyframes iconFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}

.drop-area-text {
    font-size: 17px;
    color: var(--text-primary, #0f172a);
    margin-bottom: 6px;
    font-weight: 600;
    letter-spacing: -0.01em;
}
[data-theme="dark"] .drop-area-text { color: #f1f5f9; }

.drop-area-hint {
    font-size: 13px;
    color: var(--text-secondary, #64748b);
    letter-spacing: 0.02em;
}
[data-theme="dark"] .drop-area-hint { color: #94a3b8; }

.decoder-hidden-input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

/* Feature strip â€” trust signals */
.decoder-features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin: 22px 0 0;
    animation: fadeSlideUp 0.8s ease both;
    animation-delay: 0.35s;
}

.decoder-feature {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.45);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(79, 70, 229, 0.1);
    font-size: 13.5px;
    font-weight: 500;
    color: var(--text-primary, #0f172a);
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}
[data-theme="dark"] .decoder-feature {
    background: rgba(30, 41, 59, 0.5);
    border-color: rgba(129, 140, 248, 0.14);
    color: #e2e8f0;
}
.decoder-feature:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(79, 70, 229, 0.14);
}
.decoder-feature svg {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    color: #4f46e5;
}
[data-theme="dark"] .decoder-feature svg { color: #a5b4fc; }

/* Preview â€” with scan-line sweep overlay while decoding */
.preview-container {
    margin-top: 28px;
    text-align: center;
    position: relative;
}

.preview-img {
    max-width: 100%;
    max-height: 360px;
    border-radius: 16px;
    box-shadow: 0 12px 36px rgba(15, 23, 42, 0.12);
    margin: 0 auto;
    display: block;
    animation: previewIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}
[data-theme="dark"] .preview-img {
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.4);
}

@keyframes previewIn {
    from { opacity: 0; transform: scale(0.94); }
    to   { opacity: 1; transform: scale(1); }
}

.preview-container.scanning::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 0;
    transform: translateX(-50%);
    width: min(100%, 360px);
    height: 3px;
    background: linear-gradient(90deg, transparent, #4f46e5 30%, #a855f7 70%, transparent);
    box-shadow: 0 0 20px rgba(79, 70, 229, 0.6);
    border-radius: 2px;
    animation: scanSweep 1.4s cubic-bezier(0.65, 0, 0.35, 1) infinite;
    pointer-events: none;
}

@keyframes scanSweep {
    0%   { top: 6%;  opacity: 0; }
    15%  { opacity: 1; }
    85%  { opacity: 1; }
    100% { top: 94%; opacity: 0; }
}

/* Spinner */
.spinner {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 28px;
    margin-top: 20px;
    font-size: 15px;
    font-weight: 500;
    color: var(--text-secondary, #64748b);
    animation: fadeSlideUp 0.3s ease both;
}

.spinner::before {
    content: '';
    width: 22px;
    height: 22px;
    border: 2.5px solid rgba(79, 70, 229, 0.18);
    border-top-color: #4f46e5;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    margin-right: 12px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Result card â€” celebratory gradient panel */
.result-box {
    margin-top: 28px;
    padding: 28px 28px 24px;
    background: linear-gradient(135deg, rgba(79, 70, 229, 0.09), rgba(124, 58, 237, 0.08) 50%, rgba(236, 72, 153, 0.06));
    border: 1px solid rgba(79, 70, 229, 0.22);
    border-radius: 20px;
    box-shadow: 0 8px 32px rgba(79, 70, 229, 0.12);
    animation: resultPop 0.55s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
    overflow: hidden;
}
[data-theme="dark"] .result-box {
    background: linear-gradient(135deg, rgba(129, 140, 248, 0.12), rgba(167, 139, 250, 0.1) 50%, rgba(244, 114, 182, 0.08));
    border-color: rgba(129, 140, 248, 0.28);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.result-box::before {
    content: 'âś“';
    position: absolute;
    top: 18px;
    right: 22px;
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    color: #fff;
    font-size: 17px;
    font-weight: 700;
    box-shadow: 0 4px 14px rgba(79, 70, 229, 0.35);
    animation: checkPop 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) 0.15s both;
}

@keyframes resultPop {
    from { opacity: 0; transform: translateY(14px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes checkPop {
    from { opacity: 0; transform: scale(0); }
    to   { opacity: 1; transform: scale(1); }
}

.result-row {
    display: flex;
    gap: 14px;
    margin-bottom: 14px;
    align-items: baseline;
    padding-right: 44px;
}
.result-row:last-of-type { margin-bottom: 0; }

.result-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-secondary, #64748b);
    min-width: 72px;
    padding-top: 2px;
}

.result-value {
    flex: 1;
    font-family: 'SF Mono', 'JetBrains Mono', Consolas, monospace;
    font-size: 17px;
    font-weight: 600;
    color: var(--text-primary, #0f172a);
    word-break: break-all;
    user-select: all;
    line-height: 1.45;
}
[data-theme="dark"] .result-value { color: #f1f5f9; }
[data-theme="dark"] .result-label { color: #94a3b8; }

/* Format as inline pill */
#result-type {
    display: inline-block;
    padding: 4px 12px;
    background: rgba(79, 70, 229, 0.12);
    color: #4f46e5;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.02em;
}
[data-theme="dark"] #result-type {
    background: rgba(129, 140, 248, 0.2);
    color: #a5b4fc;
}

.result-actions {
    margin-top: 20px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.decoder-btn {
    padding: 11px 22px;
    border-radius: 12px;
    border: none;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.2s ease, background 0.2s ease;
    font-family: inherit;
    letter-spacing: 0.01em;
    display: inline-flex;
    align-items: center;
    gap: 7px;
}

.decoder-btn:active { transform: translateY(1px) scale(0.98); }

.decoder-btn-primary {
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    color: #fff;
    box-shadow: 0 4px 14px rgba(79, 70, 229, 0.3);
}

.decoder-btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(79, 70, 229, 0.45);
}

.decoder-btn-primary.copied {
    background: linear-gradient(135deg, #10b981, #059669);
    box-shadow: 0 4px 14px rgba(16, 185, 129, 0.4);
}

.decoder-btn-ghost {
    background: rgba(255, 255, 255, 0.6);
    color: var(--text-primary, #0f172a);
    border: 1px solid rgba(79, 70, 229, 0.18);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}
[data-theme="dark"] .decoder-btn-ghost {
    background: rgba(30, 41, 59, 0.6);
    border-color: rgba(129, 140, 248, 0.22);
    color: var(--text-primary, #f1f5f9);
}
.decoder-btn-ghost:hover {
    border-color: #4f46e5;
    color: #4f46e5;
    transform: translateY(-1px);
}
[data-theme="dark"] .decoder-btn-ghost:hover { color: #a5b4fc; border-color: #a5b4fc; }

/* Error box */
.error-box {
    margin-top: 20px;
    padding: 16px 20px;
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.12), rgba(220, 38, 38, 0.09));
    border: 1px solid rgba(185, 28, 28, 0.45);
    border-radius: 14px;
    color: #7f1d1d;
    font-size: 14.5px;
    line-height: 1.55;
    font-weight: 600;
    animation: errorShake 0.45s ease;
}
[data-theme="dark"] .error-box {
    color: #fca5a5;
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.14), rgba(220, 38, 38, 0.1));
}

/* Decoder footer */
.decoder-footer {
    text-align: center;
    padding: 24px 20px;
    font-size: 13px;
    color: var(--text-secondary, #64748b);
}
.decoder-footer a {
    color: #4f46e5;
    text-decoration: none;
    font-weight: 500;
}
.decoder-footer a:hover { text-decoration: underline; }
[data-theme="dark"] .decoder-footer { color: #94a3b8; }
[data-theme="dark"] .decoder-footer a { color: #a5b4fc; }

/* Search and help content follows the scanner, keeping the tool first. */
.decoder-guide {
    width: min(100% - 40px, 1040px);
    margin: 8px auto 32px;
    padding: 44px 0 12px;
    border-top: 1px solid rgba(100, 116, 139, 0.22);
    color: var(--text-primary, #0f172a);
}

.decoder-batch-option {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin: 14px 0 0;
    padding: 14px 16px;
    border: 1px solid rgba(100, 116, 139, 0.22);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.58);
    color: var(--text-primary, #0f172a);
}
.decoder-batch-option input {
    width: 20px;
    height: 20px;
    flex: 0 0 20px;
    margin: 2px 0 0;
    accent-color: #4f46e5;
}
.decoder-batch-option label {
    display: block;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.4;
    cursor: pointer;
}
.decoder-batch-option p {
    margin: 3px 0 0;
    color: var(--text-secondary, #64748b);
    font-size: 13px;
    line-height: 1.45;
}
[data-theme="dark"] .decoder-batch-option {
    background: rgba(30, 41, 59, 0.55);
    border-color: rgba(148, 163, 184, 0.25);
}
.decoder-guide__kicker { margin: 0 0 8px; color: #4f46e5; font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; }
.decoder-guide h2 { margin: 0; font-size: 30px; line-height: 1.2; letter-spacing: 0; }
.decoder-guide__lead { max-width: 760px; margin: 14px 0 32px; color: var(--text-secondary, #64748b); font-size: 17px; line-height: 1.7; }
.decoder-guide__columns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 48px; padding: 32px 0; border-top: 1px solid rgba(100, 116, 139, 0.16); }
.decoder-guide__columns--secondary { padding-bottom: 16px; }
.decoder-guide h3 { margin: 0 0 14px; font-size: 19px; line-height: 1.35; letter-spacing: 0; }
.decoder-guide p,
.decoder-guide li,
.decoder-format-list dd { color: var(--text-secondary, #64748b); font-size: 15px; line-height: 1.7; }
.decoder-guide ol,
.decoder-guide ul { margin: 0; padding-left: 22px; }
.decoder-guide li + li { margin-top: 9px; }
.decoder-format-list { margin: 18px 0 0; }
.decoder-format-list > div { margin-top: 12px; }
.decoder-format-list dt { font-size: 14px; font-weight: 700; }
.decoder-format-list dd { margin: 2px 0 0; }
.decoder-related { display: flex; flex-wrap: wrap; gap: 8px 18px; }
.decoder-related a { color: #4338ca; font-size: 14px; font-weight: 650; text-underline-offset: 3px; }
[data-theme="dark"] .decoder-guide { border-color: rgba(148, 163, 184, 0.22); color: #f1f5f9; }
[data-theme="dark"] .decoder-guide__kicker,
[data-theme="dark"] .decoder-related a { color: #a5b4fc; }

.decoder-faq {
    width: min(100% - 40px, 1040px);
    margin: 0 auto 36px;
    color: var(--text-primary, #0f172a);
}
.decoder-faq h2 {
    margin: 0 0 18px;
    font-size: 25px;
    line-height: 1.25;
    letter-spacing: 0;
}
.decoder-faq details {
    border-top: 1px solid rgba(100, 116, 139, 0.2);
    padding: 16px 0;
}
.decoder-faq details:last-child {
    border-bottom: 1px solid rgba(100, 116, 139, 0.2);
}
.decoder-faq summary {
    cursor: pointer;
    font-weight: 700;
    line-height: 1.45;
}
.decoder-faq p {
    max-width: 820px;
    margin: 10px 0 0;
    color: var(--text-secondary, #64748b);
    font-size: 15px;
    line-height: 1.7;
}
[data-theme="dark"] .decoder-faq {
    color: #f1f5f9;
}
[data-theme="dark"] .decoder-faq details {
    border-color: rgba(148, 163, 184, 0.22);
}

@media (max-width: 720px) {
    .decoder-guide { width: min(100% - 32px, 1040px); padding-top: 32px; }
    .decoder-guide h2 { font-size: 25px; }
    .decoder-guide__lead { font-size: 16px; margin-bottom: 24px; }
    .decoder-guide__columns { grid-template-columns: 1fr; gap: 28px; padding: 26px 0; }
    .decoder-faq { width: min(100% - 32px, 1040px); }
}

/* Camera scan â€” equal-weight CTA sitting next to drop-area */
.camera-row {
    display: flex;
    animation: fadeSlideUp 0.8s ease both;
    animation-delay: 0.25s;
    margin: 0;
}
.camera-btn {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    width: 100%;
    min-height: 100%;
    padding: 56px 28px;
    border-radius: 20px;
    border: none;
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 60%, #9333ea 100%);
    color: #fff;
    font-size: 17px;
    font-weight: 700;
    letter-spacing: 0.01em;
    cursor: pointer;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(79, 70, 229, 0.3), inset 0 1px 0 rgba(255,255,255,0.18);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s ease;
}
.camera-btn::before {
    content: '';
    position: absolute;
    inset: -50%;
    background: radial-gradient(circle at 30% 30%, rgba(255,255,255,0.25), transparent 50%),
                radial-gradient(circle at 70% 70%, rgba(255,255,255,0.18), transparent 50%);
    opacity: 0;
    transition: opacity 0.4s ease;
    pointer-events: none;
    animation: meshRotate 18s linear infinite;
}
.camera-btn > * { position: relative; z-index: 1; }
.camera-btn:hover {
    transform: translateY(-3px) scale(1.005);
    box-shadow: 0 18px 44px rgba(79, 70, 229, 0.42), inset 0 1px 0 rgba(255,255,255,0.22);
}
.camera-btn:hover::before { opacity: 1; }
.camera-btn:focus-visible {
    outline: 3px solid rgba(255,255,255,0.75);
    outline-offset: -6px;
}
.camera-btn:active { transform: translateY(-1px) scale(1); }
.camera-btn svg {
    width: 44px;
    height: 44px;
    padding: 14px;
    border-radius: 20px;
    background: rgba(255,255,255,0.18);
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.25);
    animation: iconFloat 3.6s ease-in-out infinite;
}
.camera-btn span { font-size: 17px; font-weight: 700; }
[data-theme="dark"] .camera-btn {
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255,255,255,0.12);
}

/* Camera modal â€” full-screen overlay with video preview */
.camera-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, 0.78);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    padding: 20px;
    animation: fadeIn 0.2s ease;
}
.camera-modal[hidden] { display: none !important; }
.camera-modal-inner {
    position: relative;
    width: 100%;
    max-width: 640px;
    background: #0f172a;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: fadeSlideUp 0.3s ease both;
    display: grid;
    grid-template-areas:
        "header"
        "stage"
        "side"
        "hint";
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(240px, 1fr) auto auto;
    max-height: calc(100vh - 40px);
}
@media (min-width: 860px) {
    .camera-modal-inner {
        max-width: 960px;
        grid-template-areas:
            "header header"
            "side   stage"
            "hint   hint";
        grid-template-columns: 300px 1fr;
    }
}
.camera-header {
    grid-area: header;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    background: rgba(15, 23, 42, 0.85);
    border-bottom: 1px solid rgba(148, 163, 184, 0.12);
    min-height: 52px;
}
.camera-header-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1 1 auto;
    min-width: 0;
    flex-wrap: wrap;
}
.camera-stage {
    grid-area: stage;
    position: relative;
    background: #000;
    overflow: hidden;
    min-height: 240px;
}
.camera-side {
    grid-area: side;
    background: rgba(15, 23, 42, 0.88);
    border-top: 1px solid rgba(148, 163, 184, 0.12);
    overflow: hidden;
    display: flex;
    min-height: 120px;
    max-height: 35vh;
}
.camera-side[hidden] { display: none !important; }
@media (min-width: 860px) {
    .camera-side {
        max-height: none;
        min-height: 0;
        border-top: none;
        border-right: 1px solid rgba(148, 163, 184, 0.12);
    }
}
.camera-video {
    display: block;
    width: 100%;
    height: 100%;
    aspect-ratio: 4 / 3;
    background: #000;
    object-fit: cover;
}
@media (min-width: 860px) {
    .camera-video { aspect-ratio: auto; }
}
.camera-frame {
    position: absolute;
    inset: 12% 8%;
    border: 2px solid rgba(255, 255, 255, 0.85);
    border-radius: 14px;
    box-shadow: 0 0 0 9999px rgba(15, 23, 42, 0.35);
    pointer-events: none;
}
.camera-frame::before {
    content: '';
    position: absolute;
    left: 10%;
    right: 10%;
    top: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, #4f46e5 30%, #a855f7 70%, transparent);
    box-shadow: 0 0 14px rgba(79, 70, 229, 0.8);
    transform: translate3d(0, 0, 0);
    will-change: transform, opacity;
    animation: cameraScan 2.4s linear infinite alternate;
}
@keyframes cameraScan {
    0%   { transform: translate3d(0, 0, 0); opacity: 0.35; }
    50%  { opacity: 1; }
    100% { transform: translate3d(0, var(--scan-travel, 180px), 0); opacity: 0.35; }
}
.camera-hint {
    grid-area: hint;
    padding: 12px 16px;
    text-align: center;
    color: #e2e8f0;
    font-size: 14px;
    background: rgba(0, 0, 0, 0.4);
}
.camera-close {
    flex: 0 0 auto;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: rgba(15, 23, 42, 0.7);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, transform 0.2s ease;
}
.camera-close:hover {
    background: rgba(239, 68, 68, 0.85);
    transform: scale(1.05);
}
.camera-close:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}
.camera-close svg { width: 22px; height: 22px; }

/* Scan mode toggle (Single / Multi) */
.scan-mode-toggle {
    display: inline-flex;
    gap: 4px;
    padding: 4px;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}
.scan-mode-btn {
    appearance: none;
    border: none;
    background: transparent;
    color: rgba(226, 232, 240, 0.85);
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.02em;
    padding: 7px 18px;
    border-radius: 999px;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
}
.scan-mode-btn:hover { color: #fff; }
.scan-mode-btn.is-active {
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    color: #fff;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.4);
}
.scan-mode-btn:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

/* Scan counter badge (multi mode) */
.scan-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px 6px 10px;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.7);
    color: #e2e8f0;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}
.scan-badge[hidden] { display: none !important; }
.scan-badge-count {
    min-width: 24px;
    padding: 2px 8px;
    border-radius: 999px;
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    color: #fff;
    font-size: 13px;
    text-align: center;
}

/* Scan list panel (multi mode) */
.scan-list-panel {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    width: 100%;
    background: transparent;
    color: #e2e8f0;
    overflow: hidden;
}
.scan-list {
    list-style: none;
    margin: 0;
    padding: 8px;
    overflow-y: auto;
    flex: 1 1 auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(148, 163, 184, 0.5) transparent;
}
.scan-list::-webkit-scrollbar { width: 6px; }
.scan-list::-webkit-scrollbar-thumb { background: rgba(148, 163, 184, 0.5); border-radius: 3px; }
.scan-list-item {
    display: grid;
    grid-template-columns: auto auto 1fr auto;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 10px;
    font-size: 13px;
    animation: fadeSlideUp 0.25s ease both;
}
.scan-list-item + .scan-list-item { margin-top: 4px; }
.scan-list-item:hover { background: rgba(255, 255, 255, 0.05); }

/* Quantity controls (â’ [n] +) */
.scan-list-qty {
    display: inline-flex;
    align-items: center;
    gap: 0;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(148, 163, 184, 0.25);
    overflow: hidden;
}
.scan-list-qty-btn {
    appearance: none;
    border: none;
    background: transparent;
    color: inherit;
    width: 28px;
    height: 28px;
    font-size: 16px;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    transition: background 0.15s ease;
}
.scan-list-qty-btn:hover { background: rgba(255, 255, 255, 0.12); }
.scan-list-qty-btn:focus-visible {
    outline: 2px solid #a5b4fc;
    outline-offset: -2px;
}
.scan-list-qty-input {
    width: 44px;
    height: 28px;
    border: none;
    background: transparent;
    color: inherit;
    font: inherit;
    font-weight: 700;
    text-align: center;
    padding: 0;
    -moz-appearance: textfield;
}
.scan-list-qty-input::-webkit-outer-spin-button,
.scan-list-qty-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.scan-list-qty-input:focus-visible {
    outline: 2px solid #a5b4fc;
    outline-offset: -1px;
    background: rgba(255, 255, 255, 0.08);
}
.scan-list-remove {
    appearance: none;
    border: none;
    background: transparent;
    color: rgba(248, 113, 113, 0.85);
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}
.scan-list-remove:hover {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}
.scan-list-remove:focus-visible {
    outline: 2px solid #ef4444;
    outline-offset: 2px;
}
.scan-list-count {
    min-width: 36px;
    padding: 3px 8px;
    border-radius: 999px;
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    text-align: center;
}
.scan-list-format {
    padding: 2px 8px;
    border-radius: 6px;
    background: rgba(129, 140, 248, 0.18);
    color: #c7d2fe;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
}
.scan-list-value {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 13px;
    color: #f1f5f9;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.scan-list-empty {
    padding: 28px 16px;
    text-align: center;
    font-size: 13px;
    color: rgba(226, 232, 240, 0.6);
}
.scan-list-actions {
    display: flex;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid rgba(148, 163, 184, 0.15);
    background: rgba(15, 23, 42, 0.6);
}
.scan-list-btn {
    flex: 1 1 0;
    appearance: none;
    border: 1px solid rgba(148, 163, 184, 0.3);
    background: rgba(255, 255, 255, 0.05);
    color: #e2e8f0;
    font-size: 13px;
    font-weight: 600;
    padding: 9px 14px;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease;
}
.scan-list-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(148, 163, 184, 0.5);
}
.scan-list-btn:focus-visible {
    outline: 2px solid #a5b4fc;
    outline-offset: 2px;
}
.scan-list-copy {
    background: linear-gradient(135deg, rgba(79, 70, 229, 0.9), rgba(124, 58, 237, 0.9));
    border-color: transparent;
    color: #fff;
}
.scan-list-copy:hover {
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
}

/* Multi-scan results rendered in the main result box after closing camera */
.result-multi-row {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px 0;
    border-bottom: 1px solid rgba(148, 163, 184, 0.15);
}
.result-multi-row:last-child { border-bottom: none; }
.result-multi-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}
.result-multi-qty {
    background: rgba(79, 70, 229, 0.10);
    border-color: rgba(79, 70, 229, 0.35);
    align-self: flex-start;
}
[data-theme="dark"] .result-multi-qty {
    background: rgba(129, 140, 248, 0.12);
}
.result-multi-format {
    padding: 2px 8px;
    border-radius: 6px;
    background: rgba(79, 70, 229, 0.12);
    color: #4f46e5;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
}
[data-theme="dark"] .result-multi-format {
    background: rgba(129, 140, 248, 0.18);
    color: #c7d2fe;
}
.scan-list-qr {
    background: #fff;
    border-radius: 4px;
    padding: 2px;
    box-sizing: content-box;
}
.result-multi-value {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 15px;
    line-height: 1.4;
    word-break: break-word;
    overflow-wrap: anywhere;
    user-select: all;
}

/* Hide decorative scan frame when list panel takes over the bottom half */
.camera-modal-inner:has(.scan-list-panel:not([hidden])) .camera-hint { display: none; }

@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes errorShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-6px); }
    75% { transform: translateX(6px); }
}

@keyframes fadeSlideUp {
    from { opacity: 0; transform: translateY(18px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .drop-area, .drop-area-icon, .result-box, .result-box::before,
    .preview-img, .decoder-intro, .decoder-features, .decoder-nav,
    .spinner, .error-box, .preview-container.scanning::after {
        animation: none !important;
        transition: none !important;
    }
}

@media (max-width: 640px) {
    .drop-area { padding: 40px 20px; }
    .drop-area-icon { width: 60px; height: 60px; }
    .drop-area-icon svg { width: 30px; height: 30px; }
    .result-box { padding: 22px 20px; }
    .result-row { padding-right: 40px; }
    .result-value { font-size: 15px; }
}

@media (max-width: 560px) {
    .drop-area { padding: 36px 16px; }
    .drop-area-icon { font-size: 40px; }
    .decoder-nav {
        display: flex;
        width: calc(100% - 24px);
        justify-content: center;
        margin-left: auto;
        margin-right: auto;
        left: auto;
        transform: none;
    }
    .decoder-nav a { padding: 9px 16px; flex: 1; text-align: center; }
    .decoder-features { grid-template-columns: 1fr; }
    .decoder-footer { padding: 20px 16px; font-size: 12.5px; }
    .result-row { flex-direction: column; gap: 4px; }
    .result-label { min-width: 0; }
}

/* ===== FAQ + HowTo sections (SEO) ===== */
/* ===== Flag emoji polyfill images ===== */
.flag-img {
    display: inline-block;
    vertical-align: -2px;
    width: 20px;
    height: 15px;
    border-radius: 2px;
    margin-right: 6px;
    object-fit: cover;
    box-shadow: 0 0 0 1px rgba(0,0,0,0.06);
}
.lang-option .flag-img { margin-right: 8px; }

/* ===== DECODER: scan list previews, summary dialog, exporters ===== */
.scan-list-preview {
    max-width: 110px;
    height: auto;
    flex-shrink: 0;
    background: #fff;
    border-radius: 4px;
    padding: 2px;
}
.scan-list-2d {
    display: inline-block;
    font-size: 11px;
    padding: 4px 8px;
    border: 1px dashed currentColor;
    border-radius: 4px;
    opacity: 0.75;
    white-space: nowrap;
}
.scan-list-meta {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}
.scan-list-meta .scan-value {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 12px;
    word-break: break-all;
    line-height: 1.3;
}
.scan-list-meta .scan-format {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    opacity: 0.6;
}

/* Toolbar above embedded multi-result */
.result-multi-toolbar {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 8px;
}

/* Toast (lightweight notification) */
.scan-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    padding: 10px 18px;
    background: #1f2937;
    color: #fff;
    border-radius: 999px;
    font-size: 13px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.25);
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: 9999;
    pointer-events: none;
    max-width: 90vw;
    text-align: center;
}
.scan-toast.is-visible { opacity: 1; }

/* Summary dialog */
.scan-summary-dialog {
    border: none;
    border-radius: 16px;
    padding: 0;
    max-width: 760px;
    width: min(92vw, 760px);
    max-height: 90vh;
    background: var(--bg, #fff);
    color: var(--fg, #111);
    box-shadow: 0 20px 60px rgba(0,0,0,0.35);
}
.scan-summary-dialog::backdrop {
    background: rgba(0,0,0,0.55);
    backdrop-filter: blur(2px);
}
.scan-summary-inner {
    display: flex;
    flex-direction: column;
    max-height: 90vh;
}
.scan-summary-header {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 18px 20px 12px;
    border-bottom: 1px solid rgba(148,163,184,0.25);
}
.scan-summary-header > div { flex: 1 1 auto; }
.scan-summary-title {
    margin: 0 0 4px;
    font-size: 18px;
    font-weight: 600;
}
.scan-summary-subtitle {
    margin: 0;
    font-size: 13px;
    opacity: 0.75;
}
.scan-summary-close {
    background: transparent;
    border: 1px solid rgba(148,163,184,0.4);
    border-radius: 8px;
    padding: 6px 12px;
    cursor: pointer;
    color: inherit;
    font-size: 13px;
}
.scan-summary-close:hover { background: rgba(148,163,184,0.15); }
.scan-summary-body {
    overflow-y: auto;
    padding: 12px 20px;
    flex: 1 1 auto;
}
.scan-summary-empty {
    text-align: center;
    padding: 32px 12px;
    opacity: 0.7;
}
.scan-summary-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.scan-summary-row {
    display: grid;
    grid-template-columns: 56px minmax(120px, 200px) 1fr;
    align-items: center;
    gap: 14px;
    padding: 10px 12px;
    border: 1px solid rgba(148,163,184,0.25);
    border-radius: 10px;
    background: rgba(148,163,184,0.06);
}
.scan-summary-count {
    font-size: 16px;
    font-weight: 600;
    text-align: center;
}
.scan-summary-preview {
    background: #fff;
    padding: 4px;
    border-radius: 6px;
    max-width: 100%;
    height: auto;
}
.scan-summary-meta {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}
.scan-summary-format {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    opacity: 0.65;
}
.scan-summary-value {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 13px;
    word-break: break-all;
}
.scan-summary-footer {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 14px 20px;
    border-top: 1px solid rgba(148,163,184,0.25);
}
.scan-summary-footer button {
    flex: 1 1 auto;
    min-width: 110px;
    padding: 10px 14px;
    border-radius: 10px;
    border: 1px solid rgba(148,163,184,0.4);
    background: rgba(148,163,184,0.1);
    color: inherit;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.15s ease;
}
.scan-summary-footer button:hover { background: rgba(148,163,184,0.25); }
.scan-summary-footer button:focus-visible {
    outline: 2px solid #2563eb;
    outline-offset: 2px;
}
@media (max-width: 540px) {
    .scan-summary-row {
        grid-template-columns: 44px 1fr;
    }
    .scan-summary-preview { grid-column: 1 / -1; max-width: 100%; }
}

/* ===== Popular Gallery (6 quick-pick cards above generator) ===== */
/* Per-format left-border accent â€” colour-codes the category at a glance */ /* indigo-600 */ /* indigo→blue 1/5 */ /* indigo→blue 2/5 */ /* indigo→blue 3/5 */ /* indigo→blue 4/5 */ /* indigo→blue 4/5 */ /* cyan-500 */
/* Square frame for QR â€” finder patterns need breathing room */

.search-intent__card {
    display: grid;
    gap: 6px;
    min-width: 0;
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    background: var(--bg);
    text-decoration: none;
}

.search-intent__card:hover {
    border-color: var(--primary);
}

.search-intent__card:focus-visible {
    outline: 3px solid var(--primary);
    outline-offset: 2px;
}

.search-intent__card span {
    color: var(--text-secondary);
    line-height: 1.5;
}

.decoder-btn[hidden] { display: none; }

@media (max-width: 600px) {
    body {
        background: var(--bg);
        background-attachment: scroll;
    }

    body::before {
        display: none;
    }

    .animated-header,
    .preview {
        animation: none !important;
    }

    
    .preview {
        -webkit-backdrop-filter: none;
        backdrop-filter: none;
        background: var(--surface);
    }

    /* Match the collapsed advanced-settings layout before its static bootstrap
       reaches the end of the document, preventing a large first-paint shift. */

}

/* Wrapper lets a "learn more" guide link sit under each quick-pick card */
.popular-card__more {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 5px 8px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
    color: var(--primary);
    text-decoration: none;
    border-radius: 6px;
    transition: background var(--transition), color var(--transition);
}
.popular-card__more::after {
    content: "\2192";
    transition: transform var(--transition);
}
.popular-card__more:hover {
    background: var(--primary-light);
    text-decoration: underline;
}
.popular-card__more:hover::after {
    transform: translateX(2px);
}
.popular-card__more:focus-visible {
    outline: 3px solid var(--border-focus);
    outline-offset: 2px;
}

/* ===== QR-specific options ===== */

/* QR preview container â€” fluid square that fills the preview panel */


/* ===== AUTH: tabs + checkbox row (Phase 1 email+password) ===== */

/* ===== My codes (saved_codes library) â€” Phase 2 ===== */

/* === Phase 3: Label templates === */


/* ===== M2.5 Phase 5: Print Builder ===== */
.preview-area {
    margin-top: 16px;
    padding: 12px;
    background: var(--surface-alt, #f9fafb);
    border: 1px solid var(--border, #e5e7eb);
    border-radius: 8px;
}
.preview-area iframe {
    width: 100%;
    height: 400px;
    border: 1px solid var(--border, #d1d5db);
    background: #fff;
    border-radius: 4px;
}

/* ===== Auth UX (M3.1) â€” header CTA + konto card ===== */

/* Header CTA cluster (injected by auth-ui.js) */

/* ===== konto.html â€” auth card ===== */

/* ===== Account Dashboard (Phase 3) ===== */

/* ===== Password show/hide toggle ===== */

/* =========================================================================
   Primary navigation (account area) â€” modern pill nav with auth-gating
   ========================================================================= */

/* Auth-gating: hide account-only links when not signed in */

/* Mobile: horizontal scroll with snap, hide scrollbar */


/* ===== QR options additions (Phase 6) ===== */

/* ===== Phase B: Color-mode segmented toggle ===== */

/* ===== Phase C: kompaktowy panel ustawień, większy preview ===== */
@media (min-width: 901px) {
    .preview-canvas {
        min-height: 240px;
        max-height: 520px;
    }
}

/* ===== Top bar (lang switch + theme toggle + auth controls) ===== */


.topbar__right {
    display: flex;
    align-items: center;
    gap: 10px;
}

@media (max-width: 600px) {
    .animated-header {
        animation: none;
    }

    header,
    .animated-header {
        padding-top: 16px;
    }
    .animated-header:has(> .lang-switch) {
        padding-top: 72px;
    }
    .topbar__right {
        flex-wrap: wrap;
        justify-content: flex-end;
    }
}

/* ===== Account dropdown menu (logged-in state) ===== */

/* ===== Layout with side ad rails =====
   Content stays at 1200px (centered) on all viewports.
   Ad sidebars float as fixed off-canvas rails on very wide screens
   so they NEVER compete with the main column for width. */
.layout-with-sidebars {
    display: block;
    align-items: start;
}

.ad-sidebar {
    display: none;
}

@media (min-width: 1600px) {
    .ad-sidebar {
        display: block;
        position: fixed;
        top: 120px;
        width: 180px;
        max-height: calc(100vh - 160px);
        overflow: hidden;
        background: transparent;
        border-radius: 12px;
        z-index: 1;
    }
    .ad-sidebar--left {
        left: max(16px, calc((100vw - 1200px) / 2 - 200px));
    }
    .ad-sidebar--right {
        right: max(16px, calc((100vw - 1200px) / 2 - 200px));
    }
}

@media (min-width: 1800px) {
    .ad-sidebar {
        width: 200px;
    }
    .ad-sidebar--left {
        left: max(24px, calc((100vw - 1200px) / 2 - 224px));
    }
    .ad-sidebar--right {
        right: max(24px, calc((100vw - 1200px) / 2 - 224px));
    }
}
/* Bulk barcode workspace */.task-cta{display:inline-flex;margin:16px 0 48px;text-decoration:none}

/* Keep high contrast authoritative over page-specific styles declared above. */

/* Consistent form controls and touch targets on utility pages. */

.cookie-settings-link,
.decoder-faq summary {
    display: flex;
    align-items: center;
    min-height: 44px;
}

.cookie-settings-link {
    display: inline-flex;
    align-items: center;
    padding: 8px 4px;
}

@media (pointer: coarse), (max-width: 700px) {
    #lang-toggle {
        min-height: 44px;
    }
}
