:root {
            --primary-color: #007aff;
            --app-bg: #f0f2f5;
            --card-bg: #ffffff;
            --text-main: #1c1c1e;
            --text-sub: #8e8e93;
            --border-color: #e5e5ea;
            --success-color: #34c759;
            --radius-lg: 20px;
            --radius-md: 12px;
            --safe-area-bottom: env(safe-area-inset-bottom);
            --container-padding: 20px;
        }

        * {
            box-sizing: border-box;
            -webkit-tap-highlight-color: transparent;
        }

        html,
        body {
            margin: 0;
            padding: 0;
            min-height: 100%;
            font-family: -apple-system, BlinkMacSystemFont, sans-serif;
            background-color: var(--app-bg);
            color: var(--text-main);
        }

        body {
            padding: 20px 0 calc(20px + var(--safe-area-bottom)) 0;
        }

        .container {
            width: 100%;
            background: var(--card-bg);
            padding: 0;
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
        }

        .content-wrapper {
            padding: 0 var(--container-padding) var(--container-padding) var(--container-padding);
        }

        .header-wrapper {
            padding: var(--container-padding) var(--container-padding) 0 var(--container-padding);
        }

        h1 {
            text-align: center;
            font-weight: 700;
            margin: 10px 0 20px 0;
            font-size: 1.5rem;
        }

        .tabs {
            display: flex;
            background: var(--app-bg);
            padding: 4px;
            border-radius: var(--radius-md);
            margin-bottom: 25px;
        }

        .tab {
            flex: 1;
            padding: 12px;
            text-align: center;
            cursor: pointer;
            font-weight: 600;
            color: var(--text-sub);
            border-radius: 10px;
            transition: all 0.3s ease;
            font-size: 1rem;
        }

        .tab.active {
            background: var(--card-bg);
            color: var(--primary-color);
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
        }

        .panel {
            display: none;
        }

        .panel.active {
            display: block;
            animation: fadeIn 0.2s ease;
        }

        @keyframes fadeIn {
            from {
                opacity: 0;
                transform: translateY(5px);
            }

            to {
                opacity: 1;
                transform: translateY(0);
            }
        }

        .control-group {
            margin-bottom: 20px;
        }

        textarea,
        input,
        select {
            width: 100%;
            padding: 14px;
            border: 1px solid var(--border-color);
            border-radius: var(--radius-md);
            background: var(--app-bg);
            font-size: 16px;
            appearance: none;
            transition: border 0.2s;
        }

        select {
            background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 4 5'%3E%3Cpath fill='%23999' d='M2 0L0 2h4zm0 5L0 3h4z'/%3E%3C/svg%3E");
            background-repeat: no-repeat;
            background-position: right .8em center;
            background-size: .65em;
            padding-right: 2.5em;
        }

        textarea:focus,
        input:focus,
        select:focus {
            outline: none;
            border-color: var(--primary-color);
            background: #fff;
        }

        textarea {
            height: 120px;
            resize: vertical;
        }

        button {
            width: 100%;
            padding: 16px;
            background-color: var(--primary-color);
            color: white;
            border: none;
            border-radius: var(--radius-md);
            font-size: 16px;
            font-weight: 600;
            cursor: pointer;
            transition: opacity 0.2s;
        }

        button:active {
            opacity: 0.8;
        }

        button.secondary {
            background-color: var(--app-bg);
            color: var(--text-main);
        }

        button.small-btn {
            padding: 8px 15px;
            font-size: 14px;
            width: auto;
        }

        /* --- Sender: QR Display Area --- */
        #qr-container {
            text-align: center;
            margin: 30px auto;
            width: 100%;
            display: flex;
            justify-content: center;
            align-items: center;
            background: transparent;
            padding: 0;
        }

        #qr-container img {
            max-width: 100%;
            width: 100%;
            height: auto;
            aspect-ratio: 1 / 1;
            object-fit: contain;
            display: block;
            border-radius: 0;
            box-shadow: none;
        }

        #qr-placeholder {
            width: 100%;
            max-width: 320px;
            aspect-ratio: 1/1;
        }

        /* --- Receiver: Camera Preview (Interactive) --- */
        #video-preview-container {
            position: relative;
            background: #000;
            aspect-ratio: 4/3;
            margin-bottom: 20px;
            overflow: hidden;
            width: 100%;
            border-radius: var(--radius-md);
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
            cursor: pointer;
        }

        #video-preview {
            width: 100%;
            height: 100%;
            object-fit: cover;
        }

        .camera-overlay {
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            color: white;
            font-weight: 600;
            z-index: 2;
            pointer-events: none;
            text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
            font-size: 1.1rem;
        }

        .scan-laser {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 4px;
            background: linear-gradient(to right, transparent, var(--success-color), transparent);
            box-shadow: 0 0 15px var(--success-color), 0 0 5px var(--success-color);
            animation: scanMove 2.5s linear infinite;
            z-index: 5;
            opacity: 0.8;
        }

        @keyframes scanMove {
            0% {
                top: 0%;
                opacity: 0;
            }

            10% {
                opacity: 1;
            }

            90% {
                opacity: 1;
            }

            100% {
                top: 100%;
                opacity: 0;
            }
        }

        .progress-bar {
            height: 10px;
            background: var(--app-bg);
            border-radius: 5px;
            overflow: hidden;
            margin-top: 15px;
        }

        .progress-fill {
            height: 100%;
            background: var(--success-color);
            width: 0%;
            transition: width 0.3s;
        }

        .status-info {
            text-align: center;
            margin-top: 10px;
            font-size: 14px;
            color: var(--text-sub);
            font-weight: 500;
        }

        #output-pre {
            background: var(--app-bg);
            padding: 15px;
            border-radius: var(--radius-md);
            white-space: pre-wrap;
            word-break: break-all;
            max-height: 300px;
            overflow-y: auto;
            font-family: monospace;
            font-size: 14px;
            border: 1px solid var(--border-color);
        }

        .hidden {
            display: none !important;
        }

        .flex-gap {
            display: flex;
            gap: 15px;
        }

        .flex-1 {
            flex: 1;
        }

        .flex-between {
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        details summary {
            padding: 10px 0;
            outline: none;
            font-weight: 600;
            color: var(--text-sub);
        }

        @media (min-width: 769px) {
            body {
                display: flex;
                justify-content: center;
                padding: 40px 20px;
                background-color: #e8ecf0;
            }

            .container {
                max-width: 960px;
                border-radius: var(--radius-lg);
                padding: 10px;
            }

            #video-preview-container {
                aspect-ratio: 16/9;
            }

            .content-wrapper,
            .header-wrapper {
                padding: 20px;
            }
        }