:root {
                --bg: #151a1c;
                --bg-soft: #1c2326;
                --surface: #20282c;
                --surface-2: #262f33;
                --surface-3: #111618;
                --border: rgba(255, 255, 255, 0.08);
                --border-strong: rgba(255, 255, 255, 0.14);
                --text: #f3f7f6;
                --muted: #9da8aa;
                --success: #6fe483;
                --danger: #ff7c93;
                --pending: #ffd45e;
                --accent: #41d65e;
                --accent-strong: #2fbb4b;
                --shadow: 0 28px 60px rgba(0, 0, 0, 0.35);
                --radius-xl: 32px;
                --radius-lg: 24px;
                --radius-md: 18px;
                --radius-sm: 14px;
                --font: "Segoe UI", Roboto, Arial, Helvetica, sans-serif;
                /* --appstream-scale: 0.62; */
                --appstream-scale: 1.350;
                --appstream-viewport-height: 575.6px;
                --appstream-content-height: 963px;
            }

            :root[data-theme="light"] {
                --bg: #edf2f6;
                --bg-soft: #f5f8fb;
                --surface: #ffffff;
                --surface-2: #f7fafc;
                --surface-3: #ffffff;
                --border: rgba(9, 30, 66, 0.14);
                --border-strong: rgba(9, 30, 66, 0.24);
                --text: #0f172a;
                --muted: #475569;
                --success: #6fe483;
                --danger: #ff7c93;
                --pending: #ffd45e;
                --accent: #41d65e;
                --accent-strong: #2fbb4b;
                --shadow: 0 18px 40px rgba(15, 23, 42, 0.14);
            }

            * { box-sizing: border-box; }

            html, body { height: 100%; }

            body {
                margin: 0;
                font-family: var(--font);
                color: var(--text);
                background:
                    linear-gradient(180deg, var(--bg-soft) 0%, var(--bg) 100%);
                transition: background 180ms ease, color 180ms ease;
            }

            a {
                color: inherit;
            }

            body.device-focus-mode {
                overflow: hidden;
            }

            iframe {
                width: 100%;
                height: 100%;
            }

            #appstream-container iframe {
                position: absolute;
                top: 50%;
                left: 50%;
                display: block;
                width: calc(100% / var(--appstream-scale)) !important;
                height: var(--appstream-content-height) !important;
                min-height: var(--appstream-content-height) !important;
                border: 0;
                background: transparent;
                transform: translate(-50%, -50%) scale(var(--appstream-scale));
                transform-origin: center center;
            }

            .page {
                min-height: 100vh;
                display: flex;
                flex-direction: column;
                /* padding: 28px; */
            }

            .shell {
                flex: 1;
                min-height: calc(100vh - 56px);
                max-width: 1240px;
                margin: 0 auto;
                padding: 28px;
                border-radius: 28px;
                /* background: var(--surface); */
                /* border: 1px solid var(--border); */
                /* box-shadow: var(--shadow); */
            }

            .topbar {
                display: flex;
                align-items: center;
                justify-content: space-between;
                gap: 20px;
                margin-bottom: 20px;
                flex-wrap: wrap;
            }

            .brand-wrap {
                display: flex;
                align-items: center;
                gap: 14px;
            }

            .brand-mark {
                width: 52px;
                height: 52px;
                border-radius: 18px;
                background: linear-gradient(180deg, #53ea75 0%, #32c751 100%);
                box-shadow: 0 16px 30px rgba(65, 214, 94, 0.35);
            }

            .brand-eyebrow {
                margin: 0 0 4px;
                font-size: 12px;
                letter-spacing: 0.18em;
                text-transform: uppercase;
                color: #7ef493;
            }

            .brand-title {
                margin: 0;
                font-size: 22px;
                font-weight: 700;
                letter-spacing: 0.01em;
            }

            .brand-subtitle {
                margin: 4px 0 0;
                font-size: 13px;
                color: var(--muted);
            }

            .status-pill {
                display: inline-flex;
                align-items: center;
                justify-content: center;
                gap: 8px;
                min-width: 126px;
                padding: 11px 16px;
                border-radius: 999px;
                border: 1px solid var(--border-strong);
                background: rgba(255, 255, 255, 0.04);
                color: var(--text);
                font-size: 13px;
                font-weight: 600;
            }

            .toolbar-right {
                display: flex;
                align-items: center;
                gap: 12px;
                flex-wrap: wrap;
            }

            .theme-tabs {
                display: inline-flex;
                align-items: center;
                gap: 6px;
                padding: 6px;
                border-radius: 999px;
                border: 1px solid var(--border);
                background: var(--surface-2);
            }

            .theme-tab {
                border: 0;
                border-radius: 999px;
                padding: 7px 14px;
                font-size: 12px;
                font-weight: 700;
                cursor: pointer;
                color: var(--muted);
                background: transparent;
            }

            .theme-tab.is-active {
                background: var(--accent);
                color: #08220f;
            }

            .theme-switch-wrap {
                display: inline-flex;
                align-items: center;
                gap: 8px;
                font-size: 12px;
                color: var(--muted);
            }

            .theme-switch {
                position: relative;
                width: 46px;
                height: 26px;
                border-radius: 999px;
                border: 1px solid var(--border);
                background: var(--surface-2);
                appearance: none;
                cursor: pointer;
                transition: background 120ms ease;
            }

            .theme-switch::after {
                content: "";
                position: absolute;
                top: 2px;
                left: 2px;
                width: 20px;
                height: 20px;
                border-radius: 999px;
                background: var(--text);
                transition: transform 120ms ease;
            }

            .theme-switch:checked {
                background: var(--accent);
            }

            .theme-switch:checked::after {
                transform: translateX(20px);
                background: #0b1d10;
            }

            .controls-bar {
                display: grid;
                grid-template-columns: repeat(4, minmax(0, 1fr));
                gap: 10px;
                margin-bottom: 20px;
            }

            .status-pill--idle {
                color: #cfd7d7;
            }

            .status-pill--pending {
                color: #201a00;
                background: var(--pending);
                border-color: transparent;
            }

            .status-pill--success {
                color: #06210c;
                background: var(--success);
                border-color: transparent;
            }

            .status-pill--danger {
                color: #290813;
                background: var(--danger);
                border-color: transparent;
            }

            .layout {
                display: grid;
                grid-template-columns: 1fr;
                gap: 28px;
                align-items: stretch;
            }

            .panel {
                /* border-radius: var(--radius-lg); */
                /* border: 1px solid var(--border); */
                /* background: var(--surface); */
                overflow: hidden;
            }

            .panel-body {
                padding: 28px;
            }

            .hero-copy {
                padding-bottom: 22px;
                border-bottom: 1px solid var(--border);
            }

            .hero-title {
                margin: 0;
                font-size: 40px;
                line-height: 1.08;
                letter-spacing: -0.03em;
            }

            .hero-text {
                margin: 14px 0 0;
                color: var(--muted);
                font-size: 15px;
                line-height: 1.7;
            }

            .meta-grid {
                display: grid;
                grid-template-columns: repeat(2, minmax(0, 1fr));
                gap: 14px;
                margin: 24px 0;
            }

            .meta-card {
                padding: 16px;
                border-radius: var(--radius-md);
                background: rgba(255, 255, 255, 0.03);
                border: 1px solid var(--border);
            }

            .meta-label {
                display: block;
                font-size: 11px;
                letter-spacing: 0.12em;
                text-transform: uppercase;
                color: var(--muted);
                margin-bottom: 8px;
            }

            .meta-value {
                font-size: 16px;
                font-weight: 700;
            }

            .controls-card {
                padding: 20px;
                border-radius: 26px;
                background: var(--surface-3);
                border: 1px solid var(--border);
            }

            .section-title {
                margin: 0 0 8px;
                font-size: 18px;
                font-weight: 700;
            }

            .section-text {
                margin: 0;
                font-size: 14px;
                line-height: 1.6;
                color: var(--muted);
            }

            .stack {
                display: grid;
                gap: 12px;
                margin-top: 20px;
            }

            .action-grid {
                display: grid;
                gap: 12px;
                grid-template-columns: repeat(2, minmax(0, 1fr));
            }

            .btn {
                appearance: none;
                width: 100%;
                border: 0;
                border-radius: 18px;
                padding: 15px 18px;
                font-size: 14px;
                font-weight: 700;
                cursor: pointer;
                transition: transform 120ms ease, filter 120ms ease, opacity 120ms ease;
            }

            .btn:hover { filter: brightness(1.04); }
            .btn:active { transform: translateY(1px); }
            .btn:disabled { opacity: 0.6; cursor: wait; }

            .btn-primary {
                color: #08220f;
                background: linear-gradient(180deg, var(--accent) 0%, var(--accent-strong) 100%);
                box-shadow: 0 18px 26px rgba(65, 214, 94, 0.22);
            }

            .btn-secondary {
                color: var(--text);
                background: var(--surface-2);
                border: 1px solid var(--border);
            }

            .btn-danger {
                color: #fff2f5;
                background: #7a1f32;
                border: 1px solid #b94563;
            }

            .stream-panel {
                display: flex;
                flex-direction: column;
                min-height: 740px;
                /* background: var(--surface-2); */
            }

            .stream-head {
                display: grid;
                gap: 18px;
                /* padding: 26px 28px 0; */
                padding: 0px;
            }

            .stream-head-copy {
                display: grid;
                gap: 0;
                text-align: center;
            }

            .stream-head-actions {
                width: min(100%, 430px);
                margin: 0 auto;
                display: flex;
                align-items: center;
                justify-content: space-between;
                gap: 16px;
            }

            .stream-title {
                margin: 0;
                font-size: 32px;
                font-weight: 700;
            }

            .stream-text {
                margin: 6px 0 0;
                color: var(--muted);
                font-size: 14px;
            }

            .focus-toggle {
                position: relative;
                width: 44px;
                height: 44px;
                min-width: 44px;
                padding: 0;
                border-radius: 12px;
                display: inline-flex;
                align-items: center;
                justify-content: center;
                color: var(--text);
                font-size: 0;
            }

            .focus-toggle::before,
            .focus-toggle::after {
                content: "";
                position: absolute;
                width: 10px;
                height: 10px;
                border-top: 2px solid currentColor;
                border-right: 2px solid currentColor;
                transition: transform 120ms ease;
            }

            .focus-toggle[aria-pressed="false"]::before {
                transform: translate(5px, -5px);
            }

            .focus-toggle[aria-pressed="false"]::after {
                transform: translate(-5px, 5px) rotate(180deg);
            }

            .focus-toggle[aria-pressed="true"]::before {
                transform: translate(1px, -1px) rotate(180deg);
            }

            .focus-toggle[aria-pressed="true"]::after {
                transform: translate(-1px, 1px);
            }

            .device-badge {
                padding: 10px 14px;
                border-radius: 999px;
                border: 1px solid var(--border);
                background: rgba(255, 255, 255, 0.04);
                color: var(--muted);
                font-size: 12px;
                white-space: nowrap;
            }

            .stream-body {
                flex: 1;
                display: grid;
                place-items: center;
                /* padding: 24px 28px 28px; */
                padding: 12px;
            }

            .device-shell {
                position: relative;
                width: min(100%, 430px);
                min-height: calc(var(--appstream-viewport-height) + 36px);
                padding: 45px;
                /* border-radius: 40px; */
                border-radius: 10px;
                background: linear-gradient(180deg, #2c3438 0%, #1a2022 100%);
                border: 1px solid rgba(255, 255, 255, 0.08);
                box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 28px 50px rgba(0, 0, 0, 0.36);
                transition: transform 180ms ease;
            }

            :root[data-theme="light"] .device-shell {
                background: linear-gradient(180deg, #dae2e8 0%, #cbd6dd 100%);
                border-color: rgba(15, 23, 42, 0.2);
                box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8), 0 22px 40px rgba(15, 23, 42, 0.2);
            }

            .device-shell::before {
                content: "";
                position: absolute;
                top: 12px;
                left: 50%;
                transform: translateX(-50%);
                width: 120px;
                height: 10px;
                border-radius: 999px;
                background: rgba(0, 0, 0, 0.5);
            }

            .screen {
                position: relative;
                height: 100%;
                min-height: var(--appstream-viewport-height);
                /* border-radius: 28px; */
                border-radius: 8px;
                overflow: hidden;
                background: #0c1011;
                border: 1px solid rgba(255, 255, 255, 0.05);
            }

            .start-overlay {
                position: absolute;
                inset: 0;
                z-index: 3;
            }

            #appstream-url-form.is-hidden {
                visibility: collapse;
                display: none;
            }

            #in-stream-functions {
                visibility: hidden;
                display: none;
            }

            #in-stream-functions.is-active {
                visibility: visible;
                display: grid;
            }

            .start-overlay-inner {
                height: 100%;
                display: grid;
                place-items: center;
            }

            .start-button {
                min-width: 25vh;
                width: 25vh;
            }

            .reset-button {
                  min-width: 25vh;
                width: 25vh;
            }

            :root[data-theme="light"] .screen {
                border-color: rgba(15, 23, 42, 0.1);
            }

            #appstream-container {
                position: relative;
                visibility: hidden;
                width: 100% !important;
                height: var(--appstream-viewport-height) !important;
                min-width: 100% !important;
                min-height: var(--appstream-viewport-height) !important;
                margin: 0 auto;
                background: #0c1011;
                overflow: hidden;
            }

            #appstream-container.is-visible {
                visibility: visible;
            }

            .kbd-capture {
                position: absolute;
                width: 1px;
                height: 1px;
                padding: 0;
                margin: -1px;
                overflow: hidden;
                clip: rect(0, 0, 0, 0);
                white-space: nowrap;
                border: 0;
            }

            .footer {
                width: 100%;
                margin-top: 18px;
                padding: 22px 28px 28px;
                border-top: 1px solid var(--border);
                background: var(--surface);
                color: var(--muted);
                font-size: 12px;
            }

            .footer-shell {
                max-width: 1240px;
                margin: 0 auto;
                display: flex;
                align-items: center;
                justify-content: space-between;
                gap: 18px;
                flex-wrap: wrap;
            }

            .footer-copy {
                margin: 0;
                font-size: 13px;
            }

            .footer-links {
                display: flex;
                align-items: center;
                gap: 18px;
                flex-wrap: wrap;
            }

            .footer-link {
                color: var(--muted);
                text-decoration: none;
                font-weight: 600;
                transition: color 120ms ease;
            }

            .footer-link:hover {
                color: var(--text);
            }

            .footer-actions {
                display: flex;
                align-items: center;
                justify-content: center;
                gap: 12px;
            }

            .footer-info-button {
                width: auto;
                min-width: 150px;
            }

            .footer-reset-button {
                position: relative;
                width: 44px;
                height: 44px;
                min-width: 44px;
                padding: 0;
                border-radius: 12px;
                display: inline-flex;
                align-items: center;
                justify-content: center;
                font-size: 0;
            }

            .footer-reset-button::before {
                content: "";
                position: absolute;
                width: 14px;
                height: 14px;
                border: 2px solid currentColor;
                border-bottom-color: transparent;
                border-radius: 50%;
            }

            .footer-reset-button::after {
                content: "";
                position: absolute;
                width: 0;
                height: 0;
                border-left: 4px solid transparent;
                border-right: 4px solid transparent;
                border-top: 5px solid currentColor;
                transform: translate(5px, 6px);
            }

            .footer-details {
                max-width: 1240px;
                margin: 12px auto 0;
                padding: 0 28px;
                color: var(--muted);
                font-size: 13px;
                line-height: 1.6;
            }

            .footer-details[hidden] {
                display: none;
            }

            .device-focus-mode .stream-head {
                position: fixed;
                top: 20px;
                right: 20px;
                z-index: 30;
                margin: 0;
                display: block;
            }

            .device-focus-mode .stream-head-copy {
                display: none;
            }

            .device-focus-mode .stream-head-actions {
                width: auto;
                margin: 0;
            }

            .device-focus-mode .theme-tabs {
                display: none;
            }

            .device-focus-mode .stream-panel {
                min-height: 100vh;
            }

            .device-focus-mode .footer,
            .device-focus-mode .footer-details {
                display: none;
            }

            .device-focus-mode .stream-body {
                position: fixed;
                inset: 0;
                z-index: 20;
                padding: 32px;
                background: linear-gradient(180deg, var(--bg-soft) 0%, var(--bg) 100%);
            }

            .device-focus-mode .device-shell {
                width: 430px;
                max-width: none;
                transform: scale(1);
                transform-origin: center center;
            }

            .device-focus-mode.device-focus-scale-75 .device-shell { transform: scale(0.75); }
            .device-focus-mode.device-focus-scale-90 .device-shell { transform: scale(0.9); }
            .device-focus-mode.device-focus-scale-110 .device-shell { transform: scale(1.1); }
            .device-focus-mode.device-focus-scale-130 .device-shell { transform: scale(1.3); }
            .device-focus-mode.device-focus-scale-150 .device-shell { transform: scale(1.5); }
            .device-focus-mode.device-focus-scale-185 .device-shell { transform: scale(1.85); }

            @media (max-width: 980px) {
                .shell {
                    min-height: auto;
                    padding: 20px;
                    border-radius: 28px;
                }

                .topbar,
                .stream-head {
                    flex-direction: column;
                    align-items: flex-start;
                }

                .stream-head-actions {
                    width: 100%;
                }

                .focus-toggle {
                    min-width: 0;
                }

                .controls-bar {
                    grid-template-columns: repeat(2, minmax(0, 1fr));
                }

                .layout {
                    grid-template-columns: 1fr;
                }

                .hero-title {
                    font-size: 32px;
                }

                .meta-grid,
                .action-grid {
                    grid-template-columns: 1fr;
                }

                .stream-panel {
                    min-height: auto;
                }

                .footer {
                    padding: 20px 16px 24px;
                }

                .footer-shell {
                    flex-direction: column;
                    align-items: stretch;
                    text-align: center;
                }

                .footer-links,
                .footer-actions {
                    justify-content: center;
                    flex-wrap: wrap;
                }

                .footer-details {
                    padding: 0 16px;
                    text-align: center;
                }

                .device-shell {
                    width: min(100%, 420px);
                    min-height: calc(var(--appstream-viewport-height) + 36px);
                }

                .screen,
                #appstream-container {
                    min-height: var(--appstream-viewport-height) !important;
                    height: var(--appstream-viewport-height) !important;
                }

                .device-focus-mode .stream-head {
                    top: 16px;
                    right: 16px;
                    left: 16px;
                    align-items: flex-end;
                }

                .device-focus-mode .stream-body {
                    padding: 20px;
                }
            }