/* EsperantAI — estilos de index.html (la UI principal).
   Extraído de index.html para TASK-105 CSP hardening Fase 1.
   Sin cambios funcionales. */

@font-face {
    font-family: 'Inter';
    src: url('../fonts/Inter-Regular.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Inter';
    src: url('../fonts/Inter-SemiBold.woff2') format('woff2');
    font-weight: 600;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Inter';
    src: url('../fonts/Inter-Bold.woff2') format('woff2');
    font-weight: 700 900;
    font-style: normal;
    font-display: swap;
}

/* ─── TASK-105 fase 2: clases que reemplazan los style="..." inline ─────── */

.profile-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
}

.profile-label {
    margin: 0;
    font-size: 12px;
    color: var(--text-muted);
}

.profile-select {
    padding: 6px 10px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 12px;
    min-width: 120px;
}

.profile-btn {
    padding: 4px 12px;
    font-size: 11px;
}

.profile-btn-danger {
    padding: 4px 12px;
    font-size: 11px;
    color: var(--danger);
}

.panel-mt {
    margin-top: 16px;
}

.muted-small {
    font-size: 12px;
    color: var(--text-muted);
}

.legal-list {
    font-size: 12px;
    line-height: 1.8;
}

.hidden {
    display: none;
}

/* P2-04: Trigger History filtros */
.history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2px;
}
.history-header h2 { margin: 0; }
.history-count {
    display: inline-flex;
    align-items: center;
    padding: 1px 8px;
    border-radius: 20px;
    font-size: 10px;
    font-weight: 700;
    background: rgba(88,166,255,0.12);
    color: var(--brand-1);
    border: 1px solid rgba(88,166,255,0.25);
}
.history-filter-bar {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
    margin: 8px 0;
}
.hf-chip {
    padding: 3px 9px;
    border-radius: 20px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.04em;
    border: 1px solid rgba(139,145,157,0.25);
    background: rgba(255,255,255,0.04);
    color: var(--text-muted);
    cursor: pointer;
    transition: background 0.12s, color 0.12s, border-color 0.12s;
    white-space: nowrap;
}
.hf-chip:hover {
    background: rgba(255,255,255,0.08);
    color: var(--text);
}
.hf-chip--active {
    background: rgba(88,166,255,0.15);
    color: var(--brand-1);
    border-color: rgba(88,166,255,0.40);
}
.history-source {
    font-size: 9px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-left: 4px;
}
.history-area {
    max-height: 300px;
    overflow-y: auto;
    font-family: 'Consolas', monospace;
    font-size: 11px;
}

.history-empty {
    color: var(--text-muted);
}

.row-mt {
    margin-top: 8px;
}

.btn-small {
    font-size: 11px;
}

.slider-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.threshold-slider {
    flex: 1;
    accent-color: var(--brand-1);
}

.threshold-value {
    font-family: Consolas, monospace;
    color: var(--brand-1);
    min-width: 50px;
    text-align: right;
}

.history-empty-note {
    padding: 8px;
    color: var(--text-muted);
}

.history-entry {
    padding: 4px 0;
    border-bottom: 1px solid var(--border);
}

.history-status {
    font-weight: 700;
}

.history-status.ok {
    color: #56d364;
}

.history-status.fail {
    color: #ff7b72;
}

.history-status.pending,
.history-time,
.history-source {
    color: var(--text-muted);
}

.history-trigger {
    color: var(--brand-1);
}

.history-scene {
    color: var(--brand-2);
}

.history-source {
    font-size: 10px;
}

/* ──────────────────────────────────────────────────────────────────────── */

:root {
            --bg: #08090c;
            --panel: #111822;
            --panel-2: #17202b;
            --panel-3: #0d1117;
            --text: #e6edf3;
            /* Z-205 fix 1.4.3: --text-muted aumentado de #8b949e (4.0:1) a #a0adb8 (5.0:1)
               para cumplir WCAG AA mínimo de 4.5:1 sobre --bg #0d1117 */
            --text-muted: #a0adb8;
            /* Z-205 fix 1.4.11: --border aumentado de #30363d (1.9:1) a #444c56 (2.8:1)
               para mejorar contraste de borders de componentes (target AA: 3:1) */
            --border: #344252;
            --border-soft: rgba(111, 132, 158, 0.28);
            --brand-1: #58a6ff;
            --brand-2: #bc8cff;
            --brand-3: #ff7b72;
            --brand-4: #6ee7b7;
            --success: #238636;
            --warning: #d29922;
            --danger: #da3633;
            --brand-gradient: linear-gradient(135deg, #58a6ff 0%, #bc8cff 50%, #ff7b72 100%);
            --surface-gradient: linear-gradient(145deg, rgba(17,24,34,0.94), rgba(13,17,23,0.97));
        }

        /* Z-205 fix 2.4.7: focus visible para teclado / lectores de pantalla.
           Sin esto, la navegación por TAB es invisible en buttons/inputs/links/selects. */
        :focus-visible {
            outline: 2px solid var(--brand-1);
            outline-offset: 2px;
            border-radius: 4px;
        }
        /* Solo remover el outline default cuando NO es focus-visible (mouse click).
           Permite que mouse clicks no muestren outline pero TAB sí. */
        :focus:not(:focus-visible) {
            outline: none;
        }

        /* Z-205 fix 2.4.1: skip link para teclado. Visualmente oculto hasta foco. */
        .skip-link {
            position: absolute;
            top: -100px;
            left: 8px;
            padding: 10px 16px;
            background: var(--brand-1);
            color: var(--bg);
            border-radius: 6px;
            font-weight: 700;
            text-decoration: none;
            z-index: 100000;
            transition: top 0.2s;
        }
        .skip-link:focus,
        .skip-link:focus-visible {
            top: 8px;
            outline: 2px solid var(--brand-2);
            outline-offset: 2px;
        }

        /* Z-205 fix: .brand-name sigue siendo <h1> accesible. */
        h1.brand-name {
            font-size: 1px;
            font-weight: 800;
            margin: 0;
            line-height: 1;
            color: var(--text);
            letter-spacing: 0;
        }

        /* Z-205 fix prefers-reduced-motion: respetar preferencia OS */
        @media (prefers-reduced-motion: reduce) {
            *,
            *::before,
            *::after {
                animation-duration: 0.01ms !important;
                animation-iteration-count: 1 !important;
                transition-duration: 0.01ms !important;
                scroll-behavior: auto !important;
            }
            .skip-link { transition: none; }
        }
        * { box-sizing: border-box; }
        html {
            overflow-x: hidden;
        }
        body {
            background: radial-gradient(circle at 50% 50%, #0d0e11 0%, #08090c 100%);
            color: var(--text);
            font-family: 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            margin: 0;
            padding: 0;
            display: block;
            min-height: 100vh;
            overflow-x: hidden;
        }
        body::before {
            content: '';
            position: fixed;
            inset: 0;
            pointer-events: none;
            background:
                linear-gradient(rgba(162,201,255,0.035) 1px, transparent 1px),
                linear-gradient(90deg, rgba(162,201,255,0.026) 1px, transparent 1px);
            background-size: 64px 64px;
            mask-image: linear-gradient(to bottom, rgba(0,0,0,0.62), transparent 72%);
            z-index: -1;
        }
        html[dir="rtl"] body { direction: rtl; }

        .aurora-bg {
            position: fixed;
            inset: 0;
            z-index: -2;
            pointer-events: none;
            overflow: hidden;
            background: radial-gradient(circle at 50% 50%, #0d0e11 0%, #08090c 100%);
        }
        .aurora-blob {
            position: absolute;
            width: 760px;
            height: 760px;
            border-radius: 50%;
            filter: blur(115px);
            opacity: 0.44;
            mix-blend-mode: screen;
            animation: aurora-drift 38s infinite alternate ease-in-out;
        }
        .aurora-blob-one {
            left: -180px;
            top: -220px;
            background: rgba(88,166,255,0.18);
        }
        .aurora-blob-two {
            right: -220px;
            top: 14vh;
            background: rgba(188,140,255,0.14);
            animation-duration: 44s;
        }
        .aurora-blob-three {
            left: 32vw;
            bottom: -260px;
            background: rgba(255,123,114,0.10);
            animation-duration: 52s;
        }
        @keyframes aurora-drift {
            0% { transform: translate(-7%, -4%) scale(1); }
            45% { transform: translate(8%, 12%) scale(1.08); }
            100% { transform: translate(-2%, 8%) scale(1.18); }
        }

        .app-shell {
            min-height: 100vh;
            display: block;
            position: relative;
            z-index: 1;
        }
        .studio-rail {
            position: fixed;
            top: 0;
            left: 0;
            width: 240px;
            height: 100vh;
            padding: 18px 12px;
            border-right: 1px solid rgba(255,255,255,0.05);
            background:
                radial-gradient(circle at 50% 0%, rgba(88,166,255,0.08), transparent 30%),
                rgba(13,14,17,0.82);
            backdrop-filter: blur(24px);
            box-shadow: 18px 0 60px rgba(0,0,0,0.22);
            z-index: 50;
            overflow-y: auto;
            overscroll-behavior: contain;
        }
        .rail-brand {
            height: 62px;
            display: flex;
            align-items: center;
            padding: 0 12px 12px;
            margin-bottom: 12px;
            border-bottom: 1px solid rgba(255,255,255,0.06);
        }
        .rail-logo {
            width: 150px;
            height: auto;
            display: block;
            border-radius: 0;
            margin: 0;
            filter: drop-shadow(0 0 16px rgba(88,166,255,0.18));
            mix-blend-mode: screen;
        }
        .rail-nav {
            display: grid;
            gap: 8px;
        }
        .rail-link {
            display: flex;
            align-items: center;
            gap: 14px;
            min-height: 48px;
            padding: 12px 14px;
            border-radius: 8px;
            color: var(--text-muted);
            text-decoration: none;
            font-size: 14px;
            font-weight: 500;
            border: 1px solid transparent;
            position: relative;
            transition: background 0.16s ease, color 0.16s ease, border-color 0.16s ease;
        }
        .rail-link::before {
            content: '';
            position: absolute;
            left: 0;
            top: 10px;
            bottom: 10px;
            width: 2px;
            border-radius: 999px;
            background: transparent;
        }
        .rail-icon {
            width: 22px;
            height: 22px;
            display: inline-block;
            flex: 0 0 22px;
            position: relative;
            opacity: 0.9;
        }
        .rail-icon-dashboard {
            background:
                linear-gradient(var(--text-muted), var(--text-muted)) 0 0 / 8px 8px no-repeat,
                linear-gradient(var(--text-muted), var(--text-muted)) 14px 0 / 8px 8px no-repeat,
                linear-gradient(var(--text-muted), var(--text-muted)) 0 14px / 8px 8px no-repeat,
                linear-gradient(var(--text-muted), var(--text-muted)) 14px 14px / 8px 8px no-repeat;
            border-radius: 2px;
        }
        .rail-icon-connection::before,
        .rail-icon-connection::after {
            content: '';
            position: absolute;
            inset: 2px 4px;
            border: 2px solid currentColor;
            border-radius: 999px;
            transform: rotate(35deg);
        }
        .rail-icon-connection::after {
            inset: 8px 4px;
            transform: rotate(35deg);
        }
        .rail-icon-triggers::before {
            content: '';
            position: absolute;
            left: 8px;
            top: 1px;
            width: 6px;
            height: 20px;
            background: currentColor;
            clip-path: polygon(45% 0, 100% 0, 62% 42%, 100% 42%, 32% 100%, 48% 56%, 0 56%);
        }
        .rail-icon-combos {
            border: 2px solid currentColor;
            transform: rotate(45deg) scale(0.78);
        }
        .rail-icon-combos::after {
            content: '';
            position: absolute;
            inset: 4px;
            border: 2px solid currentColor;
        }
        .rail-icon-scenes {
            border: 2px solid currentColor;
            border-radius: 6px;
        }
        .rail-icon-scenes::before,
        .rail-icon-scenes::after {
            content: '';
            position: absolute;
            left: 4px;
            right: 4px;
            height: 2px;
            background: currentColor;
        }
        .rail-icon-scenes::before { top: 6px; }
        .rail-icon-scenes::after { bottom: 6px; }
        .rail-icon-settings {
            border: 2px solid currentColor;
            border-radius: 50%;
        }
        .rail-icon-settings::before,
        .rail-icon-history::before {
            content: '';
            position: absolute;
        }
        .rail-icon-settings::before {
            inset: 6px;
            border: 2px solid currentColor;
            border-radius: 50%;
        }
        .rail-icon-history {
            border: 2px solid currentColor;
            border-radius: 50%;
        }
        .rail-icon-history::before {
            left: 9px;
            top: 4px;
            width: 2px;
            height: 8px;
            background: currentColor;
            box-shadow: 4px 6px 0 currentColor;
        }
        .rail-icon-profile {
            border: 2px solid currentColor;
            border-radius: 50%;
        }
        .rail-icon-profile::before {
            content: '';
            position: absolute;
            left: 4px;
            right: 4px;
            bottom: 2px;
            height: 8px;
            border: 2px solid currentColor;
            border-bottom: 0;
            border-radius: 999px 999px 0 0;
        }
        .rail-link.is-active,
        .rail-link:hover {
            color: var(--text);
            background: linear-gradient(90deg, rgba(88,166,255,0.10) 0%, rgba(255,255,255,0.035) 100%);
            border-color: rgba(255,255,255,0.06);
        }
        .rail-link.is-active::before {
            background: var(--brand-1);
            box-shadow: 0 0 18px rgba(162,201,255,0.55);
        }
        .rail-link.is-active .rail-icon,
        .rail-link:hover .rail-icon {
            color: var(--brand-1);
            opacity: 1;
        }
        .rail-footer {
            position: absolute;
            left: 14px;
            right: 14px;
            bottom: 22px;
            padding: 15px 16px;
            border-radius: 8px;
            background: rgba(17,24,34,0.68);
            border: 1px solid rgba(255,255,255,0.08);
            box-shadow: inset 0 1px 0 rgba(255,255,255,0.05);
        }
        .rail-footer span {
            display: block;
            color: var(--text-muted);
            font-size: 11px;
            font-weight: 800;
            text-transform: uppercase;
        }
        .rail-footer strong {
            display: block;
            margin-top: 4px;
            color: var(--brand-4);
        }
        .studio-main {
            min-width: 0;
            margin-left: 240px;
            padding: 28px 32px 36px;
        }

        /* Header */
        .brand-header {
            width: 100%;
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 12px;
            margin: 0 0 18px;
            padding: 0 0 16px;
            border: 0;
            border-bottom: 1px solid rgba(139,145,157,0.18);
            border-radius: 0;
            background: transparent;
            box-shadow: none;
        }
        .studio-topbar-left {
            display: flex;
            align-items: center;
            min-width: 0;
        }
        .topbar-kicker {
            color: rgba(162,201,255,0.78);
            font-size: 10px;
            font-weight: 900;
            letter-spacing: 0.24em;
            text-transform: uppercase;
        }
        .brand-lockup {
            display: flex;
            align-items: center;
            gap: 18px;
            min-width: 0;
            flex: 1 1 auto;
        }
        .brand-mini-logo {
            width: 88px;
            height: auto;
            display: block;
            mix-blend-mode: screen;
            filter: drop-shadow(0 0 10px rgba(162,201,255,0.20));
        }
        .brand-copy {
            display: grid;
            gap: 4px;
            align-items: start;
            min-width: 0;
            border-left: 0;
            padding-left: 0;
        }
        h1.brand-name {
            font-size: 1px;
            font-weight: 900;
            line-height: 1;
            letter-spacing: 0;
            color: var(--text);
        }
        .brand-claim {
            color: var(--text-muted);
            font-size: 10px;
            font-weight: 900;
            letter-spacing: 0.12em;
            text-transform: uppercase;
        }
        .live-pill {
            display: inline-flex;
            align-items: center;
            gap: 8px;
            min-height: 36px;
            padding: 0 14px;
            border-radius: 999px;
            color: var(--brand-4);
            border: 1px solid rgba(110,231,183,0.24);
            background: rgba(110,231,183,0.08);
            font-size: 11px;
            font-weight: 900;
            text-transform: uppercase;
            letter-spacing: 0.08em;
            white-space: nowrap;
        }
        .live-pill::before {
            content: '';
            width: 7px;
            height: 7px;
            border-radius: 50%;
            background: var(--brand-4);
            box-shadow: 0 0 14px var(--brand-4);
        }
        .session-chip {
            display: inline-flex;
            align-items: center;
            gap: 10px;
            min-height: 42px;
            padding: 0 14px;
            border-radius: 12px;
            background: rgba(17,24,34,0.72);
            border: 1px solid rgba(255,255,255,0.08);
            box-shadow: inset 0 1px 0 rgba(255,255,255,0.05);
        }
        .session-chip span {
            color: var(--text-muted);
            font-size: 9px;
            font-weight: 900;
            letter-spacing: 0.14em;
            text-transform: uppercase;
        }
        .session-chip strong {
            color: var(--text);
            font-family: 'Consolas', 'JetBrains Mono', monospace;
            font-size: 15px;
            letter-spacing: 0.04em;
        }
        .operation-hero {
            width: 100%;
            display: grid;
            grid-template-columns: minmax(0, 1fr) minmax(420px, auto);
            align-items: stretch;
            gap: 24px;
            margin: 8px 0 22px;
        }
        .operation-hero > div {
            border: 0;
            border-radius: 0;
            background:
                linear-gradient(90deg, rgba(17,24,34,0.30), rgba(17,24,34,0.10), transparent);
            padding: 0;
            box-shadow: none;
        }
        .hero-kicker {
            color: var(--brand-1);
            font-size: 11px;
            font-weight: 900;
            letter-spacing: 0.28em;
            text-transform: uppercase;
            margin-bottom: 10px;
        }
        .hero-copy {
            margin: 0;
            background: linear-gradient(135deg, #a2c9ff 0%, #d8baff 48%, #ff7b72 100%);
            -webkit-background-clip: text;
            background-clip: text;
            color: transparent;
            font-size: 78px;
            font-weight: 900;
            line-height: 1;
            max-width: 980px;
            text-transform: uppercase;
            text-shadow: 0 18px 42px rgba(0,0,0,0.42);
        }
        .hero-subcopy {
            margin: 16px 0 0;
            max-width: 720px;
            color: var(--text-muted);
            font-size: 18px;
            line-height: 1.55;
        }
        .hero-stats {
            display: grid;
            grid-template-columns: repeat(3, minmax(0, 1fr));
            gap: 1px;
            align-self: end;
            border: 1px solid rgba(255,255,255,0.08);
            border-radius: 12px;
            overflow: hidden;
            background: rgba(255,255,255,0.06);
            backdrop-filter: blur(16px);
        }
        .hero-stats div {
            min-width: 110px;
            padding: 18px 20px;
            border: 0;
            background: rgba(17,24,34,0.88);
        }
        .hero-stats strong {
            display: block;
            color: var(--text);
            font-size: 20px;
            line-height: 1;
        }
        .hero-stats span {
            display: block;
            margin: 0 0 10px;
            color: var(--text-muted);
            font-size: 10px;
            font-weight: 800;
            text-transform: uppercase;
            letter-spacing: 0.12em;
        }
        /* Visually hidden but accessible to screen readers */
        .visually-hidden {
            position: absolute !important;
            width: 1px; height: 1px;
            padding: 0; margin: -1px;
            overflow: hidden;
            clip: rect(0, 0, 0, 0);
            white-space: nowrap;
            border: 0;
        }
        .brand-subtitle {
            font-size: 13px;
            color: var(--text-muted);
            text-align: left;
            margin: 0;
            max-width: 440px;
        }
        .brand-controls {
            display: flex;
            align-items: center;
            justify-content: flex-end;
            gap: 12px;
            min-width: 220px;
        }

        /* UI-03: botón Pause/Resume Detection */
        .pause-btn {
            display: inline-flex;
            align-items: center;
            gap: 6px;
            padding: 4px 12px;
            font-size: 11px;
            font-weight: 700;
            letter-spacing: 0.06em;
            text-transform: uppercase;
            border-radius: 6px;
            border: 1px solid rgba(139,145,157,0.30);
            background: rgba(255,255,255,0.05);
            color: var(--text-muted);
            cursor: pointer;
            transition: background 0.15s, color 0.15s, border-color 0.15s, box-shadow 0.15s;
            white-space: nowrap;
        }
        .pause-btn:hover {
            background: rgba(255,255,255,0.10);
            color: var(--text);
            border-color: rgba(139,145,157,0.55);
        }
        .pause-btn--active,
        .pause-btn[aria-pressed="true"] {
            background: rgba(220, 53, 69, 0.18);
            border-color: rgba(220, 53, 69, 0.55);
            color: #ff6b7a;
            box-shadow: 0 0 8px rgba(220, 53, 69, 0.25);
        }
        .pause-btn--active:hover,
        .pause-btn[aria-pressed="true"]:hover {
            background: rgba(220, 53, 69, 0.28);
            border-color: rgba(220, 53, 69, 0.80);
        }
        .pause-icon {
            font-size: 13px;
            line-height: 1;
        }

        #dashboard,
        #trigger-section,
        #scene-architecture,
        #platform-events-section,
        #combo-section,
        #core-configuration,
        #combo-trigger-area,
        #advanced-panel,
        #profile-bar {
            scroll-margin-top: 24px;
        }

        .control-strip {
            width: 100%;
            display: flex;
            align-items: stretch;
            justify-content: space-between;
            gap: 18px;
            margin-bottom: 20px;
            padding: 18px 20px;
            border: 1px solid rgba(255,255,255,0.08);
            border-radius: 14px;
            background:
                linear-gradient(145deg, rgba(17,24,34,0.68), rgba(13,17,23,0.76));
            box-shadow: inset 0 1px 0 rgba(255,255,255,0.04);
            backdrop-filter: blur(24px);
        }
        .studio-commandbar {
            align-items: center;
            min-height: 72px;
            margin-bottom: 20px;
            background:
                linear-gradient(90deg, rgba(88,166,255,0.08), transparent 45%),
                rgba(17,24,34,0.66);
        }
        .profile-bar {
            display: grid;
            grid-template-columns: 42px auto minmax(220px, 360px) repeat(3, min-content);
            align-items: center;
            gap: 10px;
            min-width: 0;
            overflow: visible;
            flex: 1 1 auto;
        }
        .profile-orb {
            width: 38px;
            height: 38px;
            border-radius: 12px;
            background:
                radial-gradient(circle at 50% 40%, rgba(162,201,255,0.75), rgba(88,166,255,0.12) 38%, rgba(255,255,255,0.04) 39%),
                rgba(255,255,255,0.04);
            border: 1px solid rgba(162,201,255,0.18);
            box-shadow: 0 0 22px rgba(88,166,255,0.14);
        }
        .profile-label {
            margin: 0;
            color: var(--text-muted);
            font-size: 11px;
            text-transform: uppercase;
            font-weight: 800;
            letter-spacing: 0.12em;
        }
        .profile-select { margin: 0; }
        .profile-btn,
        .profile-btn-danger {
            padding: 9px 13px;
            font-size: 12px;
            white-space: nowrap;
            min-width: auto;
        }

        /* Status bar */
        .status-bar {
            display: flex; gap: 8px;
            flex-wrap: wrap; justify-content: flex-end;
            margin: 0;
            min-width: 0;
            flex: 0 1 620px;
        }
        .badge {
            padding: 8px 12px; border-radius: 999px;
            font-weight: 900; font-size: 11px;
            background: rgba(255,255,255,0.07); color: var(--text);
            display: inline-flex; align-items: center; gap: 6px;
            border: 1px solid rgba(255,255,255,0.08);
            box-shadow: inset 0 1px 0 rgba(255,255,255,0.06);
            white-space: nowrap;
            max-width: 100%;
            letter-spacing: 0;
        }
        .badge.ok {
            background: rgba(110,231,183,0.12);
            color: var(--brand-4);
            border-color: rgba(110,231,183,0.24);
        }
        .badge.warn {
            background: rgba(210,153,34,0.14);
            color: #f0d088;
            border-color: rgba(210,153,34,0.28);
        }
        .badge.streaming-alert {
            background: linear-gradient(135deg, rgba(255, 205, 64, 0.96), rgba(255, 147, 45, 0.88));
            color: #17110a;
            border-color: rgba(255, 220, 111, 0.92);
            box-shadow:
                0 0 0 1px rgba(255, 220, 111, 0.22),
                0 10px 26px rgba(255, 171, 45, 0.18),
                inset 0 1px 0 rgba(255, 255, 255, 0.38);
        }
        .badge.err {
            background: rgba(218,54,51,0.16);
            color: #ffb4ab;
            border-color: rgba(218,54,51,0.30);
        }
        .update-badge {
            background: linear-gradient(135deg, rgba(88,166,255,0.22), rgba(255,126,139,0.18));
            border-color: rgba(162,201,255,0.34);
            color: #f4f8ff;
        }
        .update-badge a {
            color: #9ecbff;
            font-weight: 900;
            text-decoration: none;
        }
        .update-panel {
            display: grid;
            gap: 8px;
            padding: 12px;
            border: 1px solid rgba(162,201,255,0.16);
            border-radius: 10px;
            background: rgba(9,14,22,0.44);
        }
        .update-panel strong {
            color: var(--text);
            font-size: 14px;
        }
        .update-checksum {
            margin: 0;
            color: var(--text-muted);
            font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
            font-size: 11px;
            line-height: 1.45;
            overflow-wrap: anywhere;
        }
        .update-download[hidden] {
            display: none;
        }

        /* Language selector */
        .lang-selector {
            position: static;
            width: min(260px, 26vw);
            background: rgba(7,10,16,0.74); border: 1px solid rgba(139,145,157,0.30);
            border-radius: 8px; padding: 10px 12px;
            color: var(--text); font-size: 13px; cursor: pointer;
        }
        html[dir="rtl"] .brand-copy {
            border-left: 0;
            padding-left: 0;
            border-right: 1px solid rgba(255,255,255,0.10);
            padding-right: 18px;
            text-align: right;
        }

        /* Dashboard layout */
        .dashboard {
            display: grid;
            grid-template-columns: minmax(640px, 1.25fr) minmax(520px, 0.75fr);
            gap: 20px; width: 100%; max-width: none;
            min-width: 0;
            margin-bottom: 24px;
        }
        @media (max-width: 1000px) {
            .dashboard { grid-template-columns: 1fr; }
        }
        .panel {
            position: relative;
            min-width: 0;
            background: rgba(17,24,34,0.65);
            backdrop-filter: blur(24px);
            border: 1px solid rgba(255,255,255,0.08);
            border-radius: 20px;
            padding: 24px;
            box-shadow: 0 4px 24px -1px rgba(0,0,0,0.20), inset 0 1px 0 rgba(255,255,255,0.05);
            overflow: hidden;
            transition: transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1), border-color 0.28s ease, box-shadow 0.28s ease;
        }
        .panel:hover {
            border-color: rgba(88,166,255,0.34);
            box-shadow: 0 8px 32px -4px rgba(88,166,255,0.14), inset 0 1px 0 rgba(255,255,255,0.08);
            transform: translateY(-2px);
        }
        .panel::before {
            content: '';
            position: absolute;
            inset: 0 0 auto;
            height: 1px;
            background: linear-gradient(90deg, transparent, rgba(162,201,255,0.42), rgba(255,123,114,0.24), transparent);
            opacity: 0.9;
        }
        .panel-kicker {
            color: var(--brand-1);
            font-size: 10px;
            font-weight: 900;
            letter-spacing: 0.22em;
            text-transform: uppercase;
            margin-bottom: 9px;
        }
        .panel h2 {
            margin: 0 0 14px 0;
            font-size: 1.25em;
            color: var(--text);
            border-bottom: 1px solid var(--border-soft);
            padding-bottom: 10px;
            letter-spacing: 0;
        }
        .panel h2::first-letter { color: inherit; }
        .panel-automation {
            border-color: rgba(88,166,255,0.34);
            background:
                radial-gradient(circle at 78% 20%, rgba(188,140,255,0.13), transparent 34%),
                radial-gradient(circle at 18% 0%, rgba(88,166,255,0.12), transparent 32%),
                rgba(17,24,34,0.68);
        }
        .panel-automation h2 {
            font-size: 38px;
            line-height: 1;
            text-transform: uppercase;
            letter-spacing: 0;
            border-bottom-color: rgba(88,166,255,0.24);
        }

        /* Video panel */
        .video-panel { text-align: left; }
        .panel-live {
            background:
                radial-gradient(circle at 68% 26%, rgba(255,123,114,0.16), transparent 32%),
                radial-gradient(circle at 20% 20%, rgba(88,166,255,0.16), transparent 35%),
                rgba(17,24,34,0.68);
        }
        @media (min-width: 1001px) {
            .video-panel { position: sticky; top: 20px; align-self: start; }
        }
        .panel-head-row {
            display: flex;
            align-items: start;
            justify-content: space-between;
            gap: 16px;
            margin-bottom: 14px;
        }
        .preview-badges {
            display: flex;
            gap: 8px;
            flex-wrap: wrap;
            justify-content: flex-end;
            align-items: center;
        }
        .detection-engine-toggles {
            display: inline-flex;
            flex-wrap: wrap;
            gap: 6px;
            justify-content: flex-end;
            align-items: center;
            padding: 4px;
            border: 1px solid rgba(88,166,255,0.18);
            border-radius: 999px;
            background: rgba(5,7,11,0.34);
        }
        .detection-engine-toggle {
            border-color: rgba(88,166,255,0.26);
            color: #bcd7ff;
        }
        .detection-engine-toggle input:checked + span {
            color: var(--brand-4);
        }
        .preview-badges > span,
        .hud-toggle {
            min-height: 24px;
            display: inline-flex;
            align-items: center;
            padding: 0 9px;
            border-radius: 999px;
            color: var(--brand-4);
            background: rgba(5,7,11,0.68);
            border: 1px solid rgba(110,231,183,0.20);
            font-size: 10px;
            font-weight: 900;
            text-transform: uppercase;
            letter-spacing: 0.08em;
        }
        .hud-toggle {
            gap: 7px;
            cursor: pointer;
            user-select: none;
        }
        .hud-toggle input {
            width: 12px;
            height: 12px;
            margin: 0;
            accent-color: var(--brand-4);
        }
        .platinum-toggle {
            color: #ffd36e;
            border-color: rgba(255,211,110,0.38);
            background: linear-gradient(135deg, rgba(255,211,110,0.12), rgba(188,140,255,0.14));
        }
        .platinum-toggle input {
            accent-color: #ffd36e;
        }
        .platinum-status {
            min-height: 24px;
            display: inline-flex;
            align-items: center;
            padding: 0 9px;
            border-radius: 999px;
            color: rgba(230,237,243,0.82);
            background: rgba(5,7,11,0.68);
            border: 1px solid rgba(255,255,255,0.10);
            font-size: 10px;
            font-weight: 900;
            text-transform: uppercase;
            letter-spacing: 0.08em;
        }
        .camera-filter-badges {
            display: inline-flex;
            align-items: center;
            gap: 8px;
            flex-wrap: wrap;
            min-height: 0;
            padding: 0;
            border: 0;
            background: transparent;
        }
        .camera-filter-badges[hidden],
        .camera-filter-controls[hidden] {
            display: none !important;
        }
        .camera-filter-controls {
            display: grid;
            grid-template-columns: repeat(5, minmax(120px, 1fr));
            gap: 10px;
            margin: 10px 0 12px;
            padding: 10px;
            border-radius: 12px;
            background: rgba(5,7,11,0.42);
            border: 1px solid rgba(255,211,110,0.18);
        }
        .camera-filter-controls label {
            display: grid;
            gap: 6px;
            color: var(--text-muted);
            font-size: 10px;
            font-weight: 900;
            text-transform: uppercase;
            letter-spacing: 0.08em;
        }
        .camera-filter-controls select,
        .camera-filter-controls input[type="range"] {
            width: 100%;
        }
        @media (max-width: 1180px) {
            .camera-filter-controls {
                grid-template-columns: repeat(2, minmax(160px, 1fr));
            }
        }
        .camera-label {
            display: block;
            color: var(--text-muted);
            font-size: 11px;
            margin-bottom: 8px;
            text-align: left;
        }
        .camera-control-row {
            display: grid;
            grid-template-columns: minmax(0, 1fr) auto;
            gap: 10px;
            align-items: center;
        }
        .camera-start-btn {
            min-height: 38px;
            padding-inline: 18px;
            white-space: nowrap;
        }
        body.camera-live .camera-start-btn {
            display: none;
        }
        #video-container {
            position: relative;
            display: block;
            margin: 12px 0;
            border-radius: 18px;
            overflow: hidden;
            background:
                radial-gradient(circle at 50% 40%, rgba(88,166,255,0.18), transparent 28%),
                linear-gradient(rgba(88,166,255,0.10) 1px, transparent 1px),
                linear-gradient(90deg, rgba(88,166,255,0.08) 1px, transparent 1px),
                linear-gradient(145deg, #05070b, #111822);
            background-size: auto, 34px 34px, 34px 34px, auto;
            width: 100%;
            aspect-ratio: 16 / 9;
            max-width: 100%;
            border: 1px solid rgba(88,166,255,0.58);
            box-shadow:
                0 0 0 1px rgba(88,166,255,0.24),
                0 0 34px rgba(88,166,255,0.22),
                0 20px 54px rgba(0,0,0,0.48);
        }
        .studio-preview-image {
            position: absolute;
            inset: 0;
            width: 100%;
            height: 100%;
            object-fit: cover;
            opacity: 0.82;
            mix-blend-mode: lighten;
            transform: scale(1.01);
        }
        #video-container::before {
            content: '';
            position: absolute;
            inset: 12%;
            border: 1px solid rgba(162,201,255,0.24);
            border-radius: 999px;
            background:
                radial-gradient(circle, rgba(162,201,255,0.16), transparent 42%),
                conic-gradient(from 90deg, transparent 0 18%, rgba(88,166,255,0.30) 18% 19%, transparent 19% 48%, rgba(188,140,255,0.22) 48% 49%, transparent 49%);
            opacity: 0.85;
            filter: blur(0.2px);
        }
        #video-container::after {
            content: attr(data-vision-label);
            position: absolute;
            top: 10px;
            left: 12px;
            color: rgba(230,237,243,0.78);
            font-size: 10px;
            font-weight: 900;
            letter-spacing: 0.12em;
            padding: 4px 7px;
            border-radius: 999px;
            background: rgba(7,10,16,0.62);
            border: 1px solid rgba(255,255,255,0.10);
        }
        #video {
            display: block;
            width: 100%;
            height: 100%;
            object-fit: cover;
            opacity: 0;
            transition: opacity 0.18s ease;
        }
        body.camera-live #video { opacity: 1; }
        body.camera-live .studio-preview-image { opacity: 0; }
        body.camera-live #video-container::before { display: none; }
        #overlay,
        #camera-filter-image-overlay,
        #platinum-visual-overlay {
            position: absolute;
            inset: 0;
            width: 100%;
            height: 100%;
            pointer-events: none;
        }
        #overlay {
            z-index: 1;
            opacity: 0;
            transition: opacity 0.16s ease;
        }
        body.camera-live.platinum-visual-enabled #overlay {
            opacity: 1;
        }
        #camera-filter-image-overlay,
        #platinum-visual-overlay {
            z-index: 2;
            opacity: 0;
            transition: opacity 0.16s ease;
        }
        #platinum-visual-overlay {
            z-index: 3;
            mix-blend-mode: screen;
        }
        body.camera-live.platinum-visual-enabled.platinum-model-active #platinum-visual-overlay {
            mix-blend-mode: normal;
        }
        body.camera-live.platinum-visual-enabled #camera-filter-image-overlay,
        body.camera-live.platinum-visual-enabled #platinum-visual-overlay {
            opacity: 1;
        }
        .current-pose {
            margin: 14px 0; padding: 16px;
            background: rgba(23,32,43,0.55);
            border-radius: 8px;
            font-size: 1.5em; font-weight: 700;
            background: var(--brand-gradient);
            -webkit-background-clip: text; background-clip: text;
            color: transparent;
            min-height: 50px;
            display: flex; align-items: center; justify-content: center;
            flex-direction: column;
            text-align: center;
        }
        .current-pose-sub {
            font-size: 0.5em; color: var(--text-muted);
            font-weight: 400; margin-top: 4px;
            -webkit-text-fill-color: var(--text-muted);
        }

        /* Gesture chip: aparece al disparar un trigger, desaparece después de 1.5s */
        .gesture-chip {
            display: inline-block;
            margin-top: 6px;
            padding: 3px 12px;
            border-radius: 20px;
            font-size: 0.45em; font-weight: 600;
            background: rgba(88,166,255,0.18);
            border: 1px solid rgba(88,166,255,0.5);
            color: #58a6ff;
            -webkit-text-fill-color: #58a6ff;
            letter-spacing: 0.02em;
            opacity: 0;
            transform: translateY(4px) scale(0.95);
            transition: opacity 0.15s ease, transform 0.15s ease;
            pointer-events: none;
            white-space: nowrap;
            max-width: 220px;
            overflow: hidden; text-overflow: ellipsis;
        }
        .gesture-chip.chip-visible {
            opacity: 1;
            transform: translateY(0) scale(1);
        }
        .gesture-chip.chip-success {
            background: rgba(63,185,80,0.18);
            border-color: rgba(63,185,80,0.5);
            color: #3fb950;
            -webkit-text-fill-color: #3fb950;
        }

        /* Glow del contenedor current-pose al disparar */
        @keyframes pose-fired-glow {
            0%   { box-shadow: 0 0 0 0 rgba(88,166,255,0); background: rgba(23,32,43,0.55); }
            25%  { box-shadow: 0 0 18px 4px rgba(88,166,255,0.38); background: rgba(88,166,255,0.08); }
            100% { box-shadow: 0 0 0 0 rgba(88,166,255,0); background: rgba(23,32,43,0.55); }
        }
        #current-pose-wrap.pose-fired {
            animation: pose-fired-glow 0.5s ease-out forwards;
        }

        .metrics-grid {
            display: grid; grid-template-columns: repeat(6, minmax(0, 1fr));
            gap: 6px; margin-top: 10px;
        }
        .metric {
            background: rgba(23,32,43,0.82);
            border: 1px solid rgba(255,255,255,0.04);
            border-radius: 6px;
            padding: 8px 10px;
            font-size: 11px;
            text-align: left;
        }
        .studio-console-grid {
            display: grid;
            grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
            gap: 16px;
            margin-top: 18px;
        }
        .console-card {
            min-width: 0;
            padding: 16px;
            border-radius: 16px;
            background: rgba(13,17,23,0.62);
            border: 1px solid rgba(255,255,255,0.08);
            box-shadow: inset 0 1px 0 rgba(255,255,255,0.04);
        }
        .console-card-head {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 12px;
            margin-bottom: 12px;
            color: var(--text-muted);
            font-size: 10px;
            font-weight: 900;
            text-transform: uppercase;
            letter-spacing: 0.13em;
        }
        .console-card-head strong {
            color: var(--brand-1);
            font-size: 9px;
        }
        .trigger-chip-row {
            display: grid;
            grid-template-columns: 32px minmax(0, 1fr) 28px;
            align-items: center;
            gap: 10px;
            margin-top: 10px;
            padding: 10px;
            border-radius: 12px;
            background: rgba(255,255,255,0.045);
            border: 1px solid rgba(255,255,255,0.06);
        }
        .trigger-chip-row > span {
            width: 32px;
            height: 32px;
            border-radius: 9px;
            background: rgba(88,166,255,0.14);
            border: 1px solid rgba(88,166,255,0.18);
        }
        .trigger-chip-row.active > span {
            background: rgba(110,231,183,0.14);
            border-color: rgba(110,231,183,0.24);
        }
        .trigger-chip-row strong {
            display: block;
            color: var(--text);
            font-size: 12px;
        }
        .trigger-chip-row small {
            display: block;
            color: var(--text-muted);
            font-size: 10px;
            margin-top: 2px;
        }
        .trigger-chip-row b {
            width: 26px;
            height: 16px;
            border-radius: 999px;
            background: linear-gradient(90deg, rgba(88,166,255,0.22), rgba(162,201,255,0.70));
        }
        .trigger-chip-row.active b {
            background: linear-gradient(90deg, rgba(35,134,54,0.35), rgba(110,231,183,0.80));
        }
        .console-card p {
            margin: 10px 0 0;
            padding: 10px 12px;
            border-radius: 10px;
            color: var(--text);
            font-family: 'Consolas', 'JetBrains Mono', monospace;
            font-size: 11px;
            line-height: 1.5;
            background: rgba(255,255,255,0.035);
            border: 1px solid rgba(255,255,255,0.06);
        }
        .console-card mark {
            color: var(--brand-4);
            background: rgba(110,231,183,0.10);
            border-radius: 4px;
            padding: 1px 5px;
            margin-right: 6px;
        }
        /* P2-02: console rows en tiempo real */
        .console-empty {
            margin: 8px 0 0;
            color: var(--text-muted);
            font-size: 11px;
            font-style: italic;
        }
        .console-row {
            display: flex;
            align-items: baseline;
            gap: 6px;
            margin-top: 7px;
            font-size: 11px;
            line-height: 1.4;
            padding: 5px 8px;
            border-radius: 8px;
            background: rgba(255,255,255,0.03);
            border: 1px solid rgba(255,255,255,0.05);
        }
        .console-row--gesture { border-left: 2px solid rgba(88,166,255,0.50); }
        .console-row--event   { border-left: 2px solid rgba(110,231,183,0.50); }
        .console-ts {
            color: var(--text-muted);
            font-size: 10px;
            font-family: 'Consolas', monospace;
            white-space: nowrap;
            flex-shrink: 0;
        }
        .console-label {
            font-weight: 700;
            color: var(--text);
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            max-width: 110px;
        }
        .console-sub {
            color: var(--text-muted);
            font-size: 10px;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }
        .console-platform {
            font-size: 9px;
            font-weight: 800;
            text-transform: uppercase;
            letter-spacing: 0.06em;
            flex-shrink: 0;
        }
        .live-dot {
            display: inline-flex;
            align-items: center;
            gap: 4px;
            font-size: 9px;
            color: #4fc16a;
        }
        .live-dot::before {
            content: '';
            display: inline-block;
            width: 6px;
            height: 6px;
            border-radius: 50%;
            background: #4fc16a;
            animation: blink-live 1.4s ease-in-out infinite;
        }
        @keyframes blink-live {
            0%, 100% { opacity: 1; }
            50%       { opacity: 0.25; }
        }
        .engine-readout-grid {
            display: grid;
            grid-template-columns: repeat(2, minmax(0, 1fr));
            gap: 10px;
            margin: 4px 0 18px;
        }
        .engine-readout-grid div {
            min-height: 74px;
            padding: 12px;
            border-radius: 14px;
            background: rgba(5,7,11,0.54);
            border: 1px solid rgba(255,255,255,0.07);
        }
        .engine-readout-grid span {
            display: block;
            color: var(--text-muted);
            font-size: 10px;
            font-weight: 900;
            text-transform: uppercase;
            letter-spacing: 0.1em;
            margin-bottom: 8px;
        }
        .engine-readout-grid strong {
            color: var(--text);
            font-size: 26px;
            line-height: 1;
        }
        .engine-readout-grid strong.good {
            color: var(--brand-4);
        }
        .engine-readout-grid small {
            color: var(--text-muted);
            font-size: 11px;
        }
        .dashboard-side {
            display: grid;
            gap: 20px;
            align-content: start;
            min-width: 0;
        }
        .studio-section {
            margin-top: 24px;
            min-width: 0;
        }
        .section-panel {
            padding: 28px;
        }
        .section-heading {
            display: grid;
            grid-template-columns: minmax(0, 1fr) auto auto;
            align-items: center;
            gap: 12px;
            margin: 0 0 18px;
        }
        .compact-heading {
            margin-bottom: 24px;
            padding-bottom: 18px;
            border-bottom: 1px solid rgba(162,201,255,0.14);
        }
        .section-heading span {
            display: block;
            color: var(--brand-1);
            font-size: 10px;
            font-weight: 900;
            letter-spacing: 0.22em;
            text-transform: uppercase;
            margin-bottom: 8px;
        }
        .section-heading h2 {
            margin: 0;
            color: var(--text);
            font-size: 48px;
            line-height: 1;
            text-transform: uppercase;
        }
        .scene-layout-grid {
            display: grid;
            grid-template-columns: repeat(4, minmax(0, 1fr));
            gap: 20px;
        }
        .scene-card {
            position: relative;
            display: flex;
            flex-direction: column;
            min-height: 360px;
            padding: 18px;
            border-radius: 20px;
            background: rgba(17,24,34,0.65);
            border: 1px solid rgba(255,255,255,0.08);
            overflow: hidden;
            box-shadow: 0 4px 24px -1px rgba(0,0,0,0.20), inset 0 1px 0 rgba(255,255,255,0.05);
        }
        .scene-card.is-active {
            border-color: rgba(162,201,255,0.70);
            box-shadow: 0 0 0 1px rgba(162,201,255,0.20), 0 16px 38px rgba(88,166,255,0.12);
        }
        .scene-card img {
            width: 100%;
            aspect-ratio: 16 / 9;
            object-fit: cover;
            display: block;
            border-radius: 12px;
            margin-bottom: 16px;
            opacity: 0.9;
        }
        .scene-card span {
            position: absolute;
            top: 28px;
            left: 28px;
            padding: 5px 10px;
            border-radius: 999px;
            color: var(--text-muted);
            background: rgba(8,9,12,0.74);
            border: 1px solid rgba(255,255,255,0.10);
            font-size: 10px;
            font-weight: 900;
            letter-spacing: 0.08em;
            text-transform: uppercase;
        }
        .scene-card.is-active span {
            color: var(--brand-4);
            border-color: rgba(110,231,183,0.30);
            background: rgba(35,134,54,0.34);
        }
        .scene-card h3 {
            margin: 0 0 6px;
            color: var(--text);
            font-size: 21px;
        }
        .scene-card p {
            margin: 0 0 18px;
            color: var(--text-muted);
            line-height: 1.45;
        }
        .scene-card-link {
            display: block;
            margin-top: 10px;
            color: var(--brand-1);
            font-size: 11px;
            font-weight: 800;
            letter-spacing: 0.02em;
        }
        .scene-card-actions {
            display: flex;
            gap: 8px;
            align-items: center;
            margin-top: auto;
        }
        .scene-card-actions button {
            position: static;
        }
        .scene-card-actions button:disabled {
            opacity: 0.45;
            cursor: default;
        }
        .scene-actions-bar {
            display: flex;
            gap: 12px;
            justify-content: flex-end;
            margin-top: 20px;
            padding-top: 16px;
            border-top: 1px solid rgba(255,255,255,0.06);
        }
        .scene-config-form {
            display: grid;
            gap: 10px;
        }
        .scene-config-form label {
            color: var(--text-muted);
            font-size: 11px;
            font-weight: 900;
            letter-spacing: 0.08em;
            text-transform: uppercase;
        }
        .scene-config-form input,
        .scene-config-form select,
        .scene-config-form textarea {
            width: 100%;
        }
        .scene-active-toggle {
            display: flex !important;
            align-items: center;
            gap: 10px;
            margin-top: 4px;
            color: var(--text) !important;
            letter-spacing: 0 !important;
            text-transform: none !important;
            font-size: 13px !important;
        }
        .scene-active-toggle input {
            width: auto;
        }
        .settings-section {
            display: grid;
            grid-template-columns: minmax(0, 1fr) minmax(360px, 0.45fr);
            gap: 20px;
        }
        .settings-section .section-heading {
            grid-column: 1 / -1;
        }
        .settings-account-panel {
            grid-column: 1;
            grid-row: 2;
            min-height: 228px;
        }
        .sensitivity-panel {
            grid-column: 2;
            grid-row: 2;
        }
        .settings-section > #advanced-panel {
            grid-column: 1;
            grid-row: 3;
        }
        .settings-section > .history-panel {
            grid-column: 2;
            grid-row: 3;
        }
        .account-grid {
            display: grid;
            grid-template-columns: repeat(3, minmax(0, 1fr));
            gap: 14px;
            margin-top: 18px;
        }
        .account-card {
            min-height: 154px;
            padding: 16px;
            border-radius: 16px;
            background:
                linear-gradient(145deg, rgba(255,255,255,0.075), rgba(255,255,255,0.025)),
                rgba(5,7,11,0.58);
            border: 1px solid rgba(162,201,255,0.14);
            display: grid;
            grid-template-columns: auto 1fr;
            align-content: start;
            align-items: center;
            column-gap: 12px;
            row-gap: 6px;
            position: relative;
            box-shadow: inset 0 1px 0 rgba(255,255,255,0.05);
        }
        .account-card::after {
            content: '';
            position: absolute;
            right: 14px;
            top: 14px;
            width: 7px;
            height: 7px;
            border-radius: 999px;
            background: rgba(160,173,184,0.54);
        }
        .account-logo {
            width: 38px;
            height: 38px;
            padding: 8px;
            border-radius: 12px;
            object-fit: contain;
            background: rgba(5,7,11,0.76);
            border: 1px solid rgba(255,255,255,0.10);
            box-shadow: 0 10px 22px rgba(0,0,0,0.32);
        }
        .account-card-twitch .account-logo {
            background: linear-gradient(145deg, rgba(145,70,255,0.46), rgba(5,7,11,0.72));
            border-color: rgba(145,70,255,0.38);
            box-shadow: 0 0 26px rgba(145,70,255,0.18), 0 10px 22px rgba(0,0,0,0.32);
        }
        .account-card-youtube .account-logo {
            background: linear-gradient(145deg, rgba(255,0,0,0.42), rgba(5,7,11,0.72));
            border-color: rgba(255,0,0,0.32);
            box-shadow: 0 0 26px rgba(255,0,0,0.14), 0 10px 22px rgba(0,0,0,0.32);
        }
        .account-card-kick .account-logo {
            background: linear-gradient(145deg, rgba(83,252,24,0.34), rgba(5,7,11,0.72));
            border-color: rgba(83,252,24,0.28);
            box-shadow: 0 0 26px rgba(83,252,24,0.12), 0 10px 22px rgba(0,0,0,0.32);
        }
        .account-card-tiktok .account-logo {
            background: linear-gradient(145deg, rgba(254,44,85,0.38), rgba(5,7,11,0.72));
            border-color: rgba(254,44,85,0.30);
            box-shadow: 0 0 26px rgba(254,44,85,0.14), 0 10px 22px rgba(0,0,0,0.32);
        }
        .account-grid strong {
            color: var(--text);
            font-size: 15px;
            margin-top: 0;
        }
        .account-grid small {
            grid-column: 2;
            color: var(--text-muted);
            font-size: 11px;
        }
        /* MAINT-04: account-status badge dinámico */
        .account-status { transition: color 0.2s, background 0.2s; }
        .account-status--connected {
            color: #4fc16a !important;
            background: rgba(40,167,69,0.12) !important;
            border-color: rgba(40,167,69,0.30) !important;
        }
        .account-status--linking {
            color: var(--brand-1) !important;
            background: rgba(88,166,255,0.10) !important;
        }
        .account-card--connected::after {
            background: #4fc16a !important;
            box-shadow: 0 0 6px #4fc16a;
        }
        .account-grid b {
            grid-column: 1 / -1;
            width: max-content;
            margin-top: 8px;
            padding: 4px 7px;
            border-radius: 5px;
            color: var(--text-muted);
            background: rgba(255,255,255,0.06);
            font-size: 9px;
            text-transform: uppercase;
            letter-spacing: 0.08em;
        }
        .account-action {
            grid-column: 1 / -1;
            width: 100%;
            min-height: 34px;
            margin-top: 4px;
            text-align: center;
            text-decoration: none;
            display: inline-flex;
            align-items: center;
            justify-content: center;
        }
        .metric-label {
            color: var(--text-muted);
            text-transform: uppercase;
            font-size: 9px;
            letter-spacing: 0.5px;
        }
        .metric-value {
            color: var(--brand-1);
            font-family: 'Consolas', monospace;
            font-weight: 700;
            font-size: 14px;
        }
        .metric-value.metric-note {
            color: var(--text-muted);
            font-family: 'Inter', sans-serif;
            font-size: 10px;
            line-height: 1.25;
            white-space: normal;
        }

        /* Form controls */
        label {
            display: block;
            margin-top: 12px;
            font-size: 12px;
            color: var(--text-muted);
            font-weight: 500;
        }
        input[type="text"], input[type="password"], select {
            width: 100%; padding: 12px 14px;
            margin-top: 4px;
            border-radius: 8px;
            border: 1px solid rgba(139,145,157,0.30);
            background: rgba(5,7,11,0.82);
            color: var(--text);
            font-size: 13px;
            outline: none;
            transition: border-color 0.15s;
        }
        input:focus, select:focus { border-color: var(--brand-1); }

        button,
        a.secondary {
            padding: 11px 18px;
            border-radius: 9px;
            border: none;
            font-weight: 900;
            cursor: pointer;
            font-size: 13px;
            transition: all 0.15s;
            box-shadow: inset 0 1px 0 rgba(255,255,255,0.08);
        }
        button.primary {
            background: var(--brand-gradient);
            color: #071019;
        }
        button.primary:hover { opacity: 0.9; transform: translateY(-1px); }
        button.secondary,
        a.secondary {
            background: rgba(255,255,255,0.10);
            color: var(--text);
            border: 1px solid rgba(255,255,255,0.08);
        }
        button.danger {
            background: rgba(218,54,51,0.14);
            color: #ffb4ab;
            border: 1px solid rgba(218,54,51,0.30);
        }

        .row { display: flex; gap: 8px; margin-top: 12px; }
        .row > * { flex: 1; }

        details {
            margin-top: 12px;
            background: rgba(23,32,43,0.70);
            border: 1px solid var(--border-soft);
            border-radius: 8px;
            padding: 12px 14px;
        }
        details > summary {
            cursor: pointer;
            font-weight: 600;
            color: var(--text);
            display: flex; align-items: center; gap: 6px;
            user-select: none;
        }
        details > summary::-webkit-details-marker { display: none; }
        details > summary::before { content: '▶'; font-size: 0.7em; transition: transform 0.2s; }
        details[open] > summary::before { transform: rotate(90deg); }

        /* Acordeón de ayuda dentro de los paneles de plataformas */
        .platform-help-accordion {
            margin: 8px 0 4px;
            border: 1px solid rgba(88,166,255,0.2);
            border-radius: 6px;
            background: rgba(88,166,255,0.05);
        }
        .platform-help-accordion > summary::before { display: none; }
        .platform-help-toggle {
            font-size: 11px;
            color: var(--brand-1);
            cursor: pointer;
            padding: 6px 10px;
            list-style: none;
            user-select: none;
        }
        .platform-help-toggle:hover { color: #79c0ff; }
        .platform-help-steps {
            margin: 0;
            padding: 6px 10px 10px 28px;
            font-size: 11px;
            color: var(--text-muted);
            line-height: 1.7;
        }
        .platform-help-steps a { color: var(--brand-1); }
        .platform-help-steps code {
            background: rgba(255,255,255,0.08);
            padding: 1px 5px; border-radius: 3px;
            font-size: 10px; word-break: break-all;
        }

        .hint {
            margin-top: 8px;
            padding: 8px 12px;
            background: rgba(88, 166, 255, 0.08);
            border-left: 3px solid var(--brand-1);
            border-radius: 4px;
            font-size: 11px;
            color: var(--text-muted);
            font-style: italic;
        }

        /* Avisos de plataforma (token por caducar / sesión expirada) — auditoría jun 2026 */
        .app-notices {
            position: fixed;
            top: 12px;
            left: 50%;
            transform: translateX(-50%);
            z-index: 9999;
            display: flex;
            flex-direction: column;
            gap: 8px;
            width: min(680px, calc(100vw - 24px));
            pointer-events: none;
        }
        .app-notice {
            pointer-events: auto;
            display: flex;
            align-items: center;
            gap: 12px;
            padding: 12px 14px;
            border-radius: 10px;
            font-size: 13px;
            line-height: 1.45;
            color: #f8fbff;
            background: #1a2336;
            border: 1px solid #2d3e5e;
            box-shadow: 0 8px 24px rgba(0, 0, 0, .4);
            animation: app-notice-in .2s ease;
        }
        .app-notice.warn { background: #2a2410; border-color: #6b5e1e; }
        .app-notice.error { background: #2a1418; border-color: #7a2a36; }
        .app-notice-msg { flex: 1; }
        .app-notice-action {
            flex-shrink: 0;
            background: var(--brand-1, #58a6ff);
            color: #06121f;
            border: 0;
            border-radius: 8px;
            padding: 7px 12px;
            font-weight: 700;
            cursor: pointer;
        }
        .app-notice-action:hover { filter: brightness(1.08); }
        .app-notice-close {
            flex-shrink: 0;
            background: transparent;
            color: inherit;
            border: 0;
            font-size: 20px;
            line-height: 1;
            cursor: pointer;
            opacity: .7;
        }
        .app-notice-close:hover { opacity: 1; }
        @keyframes app-notice-in {
            from { opacity: 0; transform: translateY(-8px); }
            to { opacity: 1; transform: none; }
        }

        .footer {
            margin-top: 24px;
            margin-left: 240px;
            color: var(--text-muted);
            font-size: 11px;
            text-align: center;
        }
        .footer a {
            color: var(--brand-1);
            text-decoration: none;
        }
        .kbd {
            display: inline-block;
            padding: 1px 6px;
            background: var(--border);
            border-radius: 4px;
            font-family: 'Consolas', monospace;
            font-size: 10px;
            border-bottom: 2px solid #444c56;
        }

        /* Trigger UI Builder */
        .tb-universal-marker { color: #56d364; font-weight: 700; }
        .tb-cultural-marker { color: #d29922; font-weight: 700; }
        .tb-small { font-size: 11px; }
        .tb-warning {
            background: rgba(210, 153, 34, 0.10);
            border: 1px solid rgba(210, 153, 34, 0.28);
            border-left: 3px solid var(--warning);
            border-radius: 6px;
            padding: 10px 12px;
            margin-bottom: 12px;
            font-size: 12px;
        }
        .tb-warning-hint { margin: 4px 0 0; color: var(--text-muted); }
        .tb-builder {
            border: 1px solid rgba(255,255,255,0.08);
            border-radius: 20px;
            padding: 20px;
            background:
                radial-gradient(circle at 58% 20%, rgba(210,153,34,0.10), transparent 28%),
                radial-gradient(circle at 12% 0%, rgba(88,166,255,0.13), transparent 34%),
                linear-gradient(145deg, rgba(17,24,34,0.74), rgba(7,10,16,0.78));
            box-shadow: inset 0 1px 0 rgba(255,255,255,0.05);
            backdrop-filter: blur(16px);
        }
        .tb-steps {
            display: grid;
            grid-template-columns: 24px 1fr 24px 1fr 24px;
            align-items: center;
            gap: 8px;
            margin-bottom: 16px;
        }
        .tb-step {
            width: 24px; height: 24px; border-radius: 50%;
            display: grid; place-items: center;
            border: 1px solid var(--border-soft);
            color: var(--text-muted);
            font-size: 11px; font-weight: 800;
        }
        .tb-step.is-active {
            color: #071019;
            background: linear-gradient(135deg, var(--brand-1), var(--brand-2));
            border-color: rgba(255,255,255,0.22);
            box-shadow: 0 0 22px rgba(88,166,255,0.28);
        }
        .tb-step-line { height: 1px; background: var(--border); }
        .tb-flow-grid {
            display: grid;
            grid-template-columns: repeat(3, minmax(0, 1fr));
            gap: 20px;
        }
        .tb-flow-card {
            min-width: 0;
            position: relative;
            padding: 20px;
            border-radius: 16px;
            border: 1px solid rgba(255,255,255,0.08);
            background: rgba(13,17,23,0.56);
            box-shadow: inset 0 1px 0 rgba(255,255,255,0.04);
            transition: transform 0.24s cubic-bezier(0.2, 0.8, 0.2, 1), border-color 0.24s ease;
        }
        .tb-flow-card:hover {
            border-color: rgba(162,201,255,0.36);
            transform: translateY(-2px);
        }
        .tb-flow-card:not(:last-child)::after {
            content: '';
            position: absolute;
            top: 50%;
            right: -20px;
            width: 20px;
            height: 2px;
            background: linear-gradient(90deg, rgba(162,201,255,0.26), rgba(210,153,34,0.46));
            transform: translateY(-50%);
        }
        .tb-flow-card:not(:last-child)::before {
            content: '›';
            position: absolute;
            top: 50%;
            right: -25px;
            z-index: 2;
            color: rgba(210,153,34,0.82);
            font-size: 26px;
            font-weight: 700;
            line-height: 1;
            transform: translateY(-54%);
        }
        .tb-flow-card-hot {
            border-color: rgba(210,153,34,0.38);
            background:
                radial-gradient(circle at 78% 0%, rgba(210,153,34,0.13), transparent 34%),
                rgba(5,7,11,0.42);
        }
        .tb-flow-step {
            display: inline-flex;
            align-items: center;
            min-height: 22px;
            padding: 0 8px;
            border-radius: 999px;
            color: var(--brand-4);
            background: rgba(110,231,183,0.08);
            border: 1px solid rgba(110,231,183,0.16);
            font-size: 10px;
            font-weight: 900;
            letter-spacing: 0.18em;
            text-transform: uppercase;
            margin-bottom: 18px;
        }
        .tb-flow-card-hot .tb-flow-step {
            color: var(--warning);
            background: rgba(210,153,34,0.08);
            border-color: rgba(210,153,34,0.18);
        }
        .tb-flow-card h3 {
            margin: 0;
            color: var(--text);
            font-size: 26px;
            line-height: 1;
            font-weight: 800;
            text-transform: uppercase;
            letter-spacing: 0;
        }
        .tb-flow-card p {
            min-height: 44px;
            margin: 12px 0 16px;
            color: var(--text-muted);
            font-size: 12px;
            line-height: 1.45;
        }
        .tb-builder-grid, .tb-assignment-grid {
            display: grid;
            grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
            gap: 12px;
        }
        .tb-field {
            display: flex;
            flex-direction: column;
            gap: 5px;
            min-width: 0;
        }
        .tb-field label {
            color: var(--text-muted);
            font-size: 10px;
            font-weight: 900;
            letter-spacing: 0.12em;
            text-transform: uppercase;
        }
        .tb-select, .tb-scene-select {
            width: 100%;
            padding: 12px 12px;
            background: rgba(8,9,12,0.92);
            color: var(--text);
            border: 1px solid #344252;
            border-radius: 9px;
            font-size: 13px;
            font-family: 'Consolas', 'JetBrains Mono', monospace;
        }
        .tb-select:disabled, .tb-scene-select:disabled {
            opacity: 0.55;
            cursor: not-allowed;
        }
        .tb-category-enable {
            display: inline-flex;
            align-items: center;
            gap: 8px;
            margin-top: 10px;
            color: var(--text-muted);
            font-size: 12px;
        }
        .tb-category-enable input { accent-color: var(--brand-1); }
        .tb-assignment { margin-top: 12px; }
        .tb-assignment-card {
            border: 1px solid rgba(88,166,255,0.24);
            border-radius: 16px;
            padding: 16px;
            background:
                linear-gradient(90deg, rgba(88,166,255,0.08), transparent 50%),
                rgba(5,7,11,0.46);
            box-shadow: inset 0 1px 0 rgba(255,255,255,0.04);
        }
        .tb-assignment-head {
            display: flex;
            align-items: center;
            gap: 10px;
            margin-bottom: 10px;
        }
        .tb-trigger-icon {
            width: 34px; height: 34px;
            border-radius: 8px;
            display: grid; place-items: center;
            background: rgba(5,7,11,0.9);
            border: 1px solid var(--border-soft);
            font-size: 18px;
        }
        .tb-trigger-name { font-size: 14px; font-weight: 800; }
        .tb-trigger-kind { font-size: 11px; color: var(--text-muted); }
        .tb-cultural-note {
            color: #f0d088;
            background: rgba(210, 153, 34, 0.08);
            border: 1px solid rgba(210, 153, 34, 0.22);
            border-radius: 6px;
            padding: 8px 10px;
            margin-bottom: 10px;
            font-size: 11px;
            line-height: 1.45;
        }
        .tb-actions-cell {
            display: flex;
            align-items: end;
            gap: 8px;
            justify-content: flex-end;
            min-width: 0;
        }
        .tb-action-count {
            font-size: 11px;
            color: var(--brand-1);
            padding: 6px 8px;
            border: 1px solid rgba(88,166,255,0.28);
            border-radius: 999px;
            white-space: nowrap;
        }
        .tb-action-count-empty { color: var(--text-muted); border-color: var(--border); }
        .tb-action-config-btn {
            padding: 10px 12px;
            border-radius: 9px;
            border: 1px solid var(--border-soft);
            background: rgba(17,24,34,0.86);
            cursor: pointer;
            font-size: 12px;
            font-weight: 800;
            color: var(--text);
            transition: border-color 0.15s, background 0.15s;
            white-space: nowrap;
        }
        .tb-action-config-btn:hover { border-color: var(--brand-1); background: var(--panel-2); }
        .tb-configured-empty {
            color: var(--text-muted);
            font-size: 12px;
            text-align: center;
            padding: 12px 8px 0;
        }
        .tb-configured-section { margin-top: 12px; }
        .tb-configured-section h4 {
            margin: 0 0 8px;
            color: var(--text-muted);
            font-size: 11px;
            text-transform: uppercase;
            display: flex;
            align-items: center;
            gap: 8px;
        }
        .tb-trigger-count {
            display: inline-flex;
            align-items: center;
            padding: 1px 7px;
            border-radius: 20px;
            font-size: 10px;
            font-weight: 700;
            letter-spacing: 0.04em;
            background: rgba(88,166,255,0.12);
            color: var(--brand-1);
            border: 1px solid rgba(88,166,255,0.25);
            text-transform: none;
        }
        .tb-trigger-count--full {
            background: rgba(220, 53, 69, 0.15);
            color: #ff6b7a;
            border-color: rgba(220, 53, 69, 0.40);
        }
        .tb-trigger-count--unlimited {
            background: rgba(40, 167, 69, 0.12);
            color: #4fc16a;
            border-color: rgba(40, 167, 69, 0.30);
        }
        .tb-configured-row-wrap {
            width: 100%;
            display: grid;
            grid-template-columns: minmax(0, 1fr) auto;
            align-items: center;
            gap: 8px;
            margin-top: 6px;
        }
        .tb-configured-row {
            width: 100%;
            display: grid;
            grid-template-columns: 28px minmax(0, 1fr) auto;
            align-items: center;
            gap: 8px;
            padding: 10px 10px;
            color: var(--text);
            background: rgba(5,7,11,0.34);
            border: 1px solid var(--border-soft);
            border-radius: 9px;
            text-align: left;
            cursor: pointer;
        }
        .tb-configured-row:hover { border-color: var(--brand-1); background: rgba(88,166,255,0.06); }
        .tb-configured-icon { font-size: 16px; }
        .tb-configured-main { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
        .tb-configured-summary { color: var(--text-muted); font-size: 11px; white-space: nowrap; }
        .tb-configured-delete {
            min-height: 36px;
            padding: 0 12px;
            border-radius: 9px;
            border: 1px solid rgba(255,126,139,0.32);
            background: rgba(218,54,51,0.12);
            color: #ffb4ab;
            font-size: 11px;
            font-weight: 900;
            cursor: pointer;
        }
        .tb-configured-delete:hover {
            border-color: rgba(255,126,139,0.72);
            background: rgba(218,54,51,0.20);
        }
        .tb-priority-note {
            margin-top: 10px;
            color: var(--brand-4);
            font-size: 11px;
            line-height: 1.45;
        }
        .panel-automation .tb-priority-note {
            padding: 8px 10px;
            border-radius: 7px;
            background: rgba(110,231,183,0.07);
            border: 1px solid rgba(110,231,183,0.18);
        }

        @media (max-width: 900px) {
            .app-shell {
                grid-template-columns: 1fr;
                width: 100%;
                max-width: 100vw;
                overflow: hidden;
            }
            .studio-rail {
                position: relative;
                left: auto;
                width: 100%;
                height: auto;
                min-height: auto;
                padding: 14px;
                border-right: 0;
                border-bottom: 1px solid rgba(88,166,255,0.22);
                width: 100%;
                max-width: 100vw;
                overflow: hidden;
            }
            .rail-logo {
                width: min(260px, 100%);
                margin: 0 auto 14px;
            }
            .rail-nav {
                grid-template-columns: repeat(2, minmax(0, 1fr));
            }
            .rail-link {
                justify-content: center;
                gap: 6px;
                min-height: 38px;
                padding: 8px;
                font-size: 12px;
                text-align: center;
                line-height: 1.2;
                white-space: normal;
                min-width: 0;
                overflow-wrap: anywhere;
            }
            .rail-link span { min-width: 0; overflow-wrap: anywhere; }
            .rail-icon { display: none; }
            .rail-footer { display: none; }
            .studio-main {
                margin-left: 0;
                padding: 16px 12px 24px;
                width: 100%;
                max-width: 100vw;
                overflow: hidden;
            }
            .footer {
                margin-left: 0;
            }
            .operation-hero {
                grid-template-columns: 1fr;
                width: 100%;
                min-width: 0;
            }
            .operation-hero > div,
            .control-strip,
            .brand-header,
            .panel {
                width: 100%;
                max-width: 100%;
            }
            .hero-copy {
                font-size: 46px;
                overflow-wrap: anywhere;
            }
            .hero-subcopy {
                font-size: 15px;
                overflow-wrap: anywhere;
            }
            .hero-stats {
                grid-template-columns: repeat(3, minmax(0, 1fr));
            }
            .hero-stats strong {
                font-size: 20px;
            }
            .hero-stats span {
                font-size: 9px;
                overflow-wrap: anywhere;
            }
            .brand-header,
            .brand-lockup,
            .control-strip,
            .profile-bar {
                grid-template-columns: 1fr;
                flex-direction: column;
                align-items: stretch;
            }
            h1.brand-name {
                font-size: 34px;
                overflow-wrap: anywhere;
            }
            .brand-copy {
                flex-wrap: wrap;
                gap: 6px;
            }
            .brand-claim {
                font-size: 11px;
            }
            .brand-logo { width: min(100%, 520px); }
            .brand-copy {
                border-left: 0;
                padding-left: 0;
            }
            .brand-controls,
            .status-bar { justify-content: stretch; }
            .brand-controls {
                flex-direction: column;
                align-items: stretch;
                min-width: 0;
            }
            .live-pill {
                justify-content: center;
            }
            .lang-selector { width: 100%; }
            .status-bar { align-items: stretch; }
            .badge {
                white-space: normal;
                width: 100%;
                justify-content: center;
                text-align: center;
                line-height: 1.35;
                border-radius: 8px;
            }
            .dashboard,
            .config-stack,
            .video-panel {
                min-width: 0;
                width: 100%;
            }
            .metrics-grid {
                grid-template-columns: repeat(2, minmax(0, 1fr));
            }
        }
        @media (max-width: 700px) {
            .footer {
                margin-left: 0;
            }
            .rail-nav {
                grid-template-columns: 1fr;
            }
            .hero-copy {
                font-size: 34px;
            }
            .hero-stats {
                grid-template-columns: 1fr;
            }
            .hero-stats div {
                padding: 14px 16px;
            }
            .tb-flow-grid { grid-template-columns: 1fr; }
            .tb-flow-card:not(:last-child)::before,
            .tb-flow-card:not(:last-child)::after {
                display: none;
            }
            .tb-builder-grid, .tb-assignment-grid { grid-template-columns: 1fr; }
            .tb-actions-cell { justify-content: flex-start; align-items: center; flex-wrap: wrap; }
        }

        /* Action config modal */
        .action-modal-overlay {
            position: fixed; inset: 0; background: rgba(0,0,0,0.7);
            z-index: 50000; display: flex; align-items: center; justify-content: center;
            backdrop-filter: blur(4px);
        }
        .action-modal {
            background: var(--panel); border: 1px solid var(--border);
            border-radius: 12px; padding: 20px; width: 90%; max-width: 560px;
            max-height: 80vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,0.5);
        }
        .action-modal h3 {
            margin: 0 0 16px 0; font-size: 1.1em; color: var(--brand-1);
            border-bottom: 1px solid var(--border); padding-bottom: 8px;
        }
        .action-item {
            background: var(--panel-2); border: 1px solid var(--border);
            border-radius: 8px; padding: 10px 12px; margin-bottom: 8px;
            display: flex; align-items: center; gap: 10px;
        }
        .action-item-type {
            font-size: 11px; font-weight: 600; color: var(--brand-2);
            background: rgba(188,140,255,0.1); padding: 2px 8px; border-radius: 4px;
        }
        .action-item-params {
            flex: 1; font-size: 11px; color: var(--text-muted); overflow: hidden;
            text-overflow: ellipsis; white-space: nowrap;
        }
        .action-item-delete {
            cursor: pointer; color: var(--danger); font-size: 14px;
            padding: 2px 6px; border: none; background: none;
        }
        .action-item-delete:hover { opacity: 0.7; }
        .action-modal-section { margin-bottom: 16px; }
        .action-modal-section h4 { margin: 0 0 10px 0; font-size: 0.95em; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
        .action-builder-grid, .action-param-grid {
            display: grid; grid-template-columns: 1fr 2fr; gap: 8px 12px; align-items: center;
            margin-bottom: 12px;
        }
        .action-builder-grid label, .action-param-grid label {
            font-size: 12px; color: var(--text-muted); font-weight: 500;
        }
        .action-builder-grid select, .action-param-grid select,
        .action-builder-grid input, .action-param-grid input {
            background: var(--panel-2); border: 1px solid var(--border);
            border-radius: 6px; padding: 6px 10px; color: var(--text);
            font-size: 13px; width: 100%; box-sizing: border-box;
        }
        .action-builder-grid select:focus, .action-param-grid select:focus,
        .action-builder-grid input:focus, .action-param-grid input:focus {
            border-color: var(--brand-1); outline: none;
        }
        .action-modal-footer {
            display: flex; justify-content: flex-end; gap: 10px;
            padding-top: 12px; border-top: 1px solid var(--border);
            margin-top: 8px; position: sticky; bottom: -20px;
            background: var(--panel); padding-bottom: 4px;
        }
        .action-modal-footer button {
            padding: 8px 18px; border-radius: 8px; font-size: 13px; font-weight: 600;
            cursor: pointer; border: 1px solid var(--border);
        }
        .action-modal-footer button.primary {
            background: var(--brand-gradient); color: #fff; border: none;
        }
        .action-modal-footer button.secondary {
            background: var(--panel-2); color: var(--text-muted);
        }
        .action-modal-footer button:hover { opacity: 0.88; }
        .action-quick-scene {
            background: rgba(88,166,255,0.06); border: 1px solid var(--border);
            border-radius: 8px; padding: 8px 12px; margin-bottom: 10px; font-size: 12px;
        }
        .action-empty-state {
            color: var(--text-muted); font-size: 12px; font-style: italic; padding: 8px 0;
        }

/* ============================================================================
 * Calibration Wizard (TASK-102)
 * Imported from ChatGPT bundle, kept as plain CSS for CSP compliance.
 * ========================================================================== */
body.modal-open { overflow: hidden; }
.modal-overlay[hidden] { display: none !important; }
.modal-overlay {
    position: fixed; inset: 0; z-index: 99999;
    display: grid; place-items: center; padding: 20px;
}
.cw-backdrop {
    position: absolute; inset: 0;
    background: rgba(6, 10, 18, 0.82);
    backdrop-filter: blur(10px);
}
.cw-modal {
    position: relative; z-index: 1; width: min(860px, 100%);
    background: linear-gradient(180deg, rgba(22,27,34,0.98), rgba(13,17,23,0.98));
    border: 1px solid var(--border); border-radius: 18px;
    box-shadow: 0 24px 80px rgba(0,0,0,0.45);
    padding: 24px;
}
.cw-header { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; }
.cw-kicker { color: var(--brand-1); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 6px; }
.cw-header h2 { margin: 0; font-size: 1.6em; }
.cw-header p { color: var(--text-muted); margin: 8px 0 0 0; }
.cw-close { background: transparent; color: var(--text-muted); border: 1px solid var(--border); border-radius: 10px; width: 40px; height: 40px; font-size: 24px; cursor: pointer; }
.cw-progress { margin: 18px 0 22px; width: 100%; height: 8px; appearance: none; background: #0d1117; border-radius: 999px; overflow: hidden; border: 1px solid var(--border); }
.cw-progress::-webkit-progress-bar,
.cw-inline-progress::-webkit-progress-bar { background: #0d1117; border-radius: 999px; }
.cw-progress::-webkit-progress-value,
.cw-inline-progress::-webkit-progress-value { background: var(--brand-gradient); border-radius: 999px; }
.cw-progress::-moz-progress-bar,
.cw-inline-progress::-moz-progress-bar { background: var(--brand-gradient); border-radius: 999px; }
.cw-step-body { min-height: 280px; }
.cw-intro-grid, .cw-summary-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.cw-card { background: rgba(28, 33, 40, 0.85); border: 1px solid var(--border); border-radius: 14px; padding: 18px; }
.cw-card.tone { background: rgba(88, 166, 255, 0.08); }
.cw-card h3 { margin-top: 0; }
.cw-card ul { margin: 10px 0 0 18px; color: var(--text-muted); line-height: 1.6; }
.cw-card p { color: var(--text-muted); line-height: 1.6; }
.cw-actions-row { display: flex; align-items: center; gap: 12px; margin-top: 14px; flex-wrap: wrap; }
.cw-capture-pill { display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 999px; background: #0d1117; border: 1px solid var(--border); color: var(--brand-1); font-size: 12px; font-weight: 700; }
.cw-inline-progress { width: 100%; height: 8px; appearance: none; background: #0d1117; border-radius: 999px; overflow: hidden; border: 1px solid var(--border); margin-top: 12px; }
.cw-status { margin-top: 14px; padding: 12px 14px; border-radius: 12px; border: 1px dashed var(--border); color: var(--text-muted); }
.cw-status.ok { color: #d2f7dc; border-style: solid; border-color: rgba(35, 134, 54, 0.65); background: rgba(35, 134, 54, 0.12); }
.cw-footer { display: flex; justify-content: space-between; gap: 12px; align-items: center; margin-top: 22px; }
.cw-footer-right { display: flex; gap: 10px; align-items: center; }
.cw-metric-list { list-style: none; padding: 0; margin: 12px 0 0 0; }
.cw-metric-list li { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid rgba(48, 54, 61, 0.6); }
.cw-metric-list li:last-child { border-bottom: none; }
@media (max-width: 760px) {
    .cw-intro-grid, .cw-summary-grid { grid-template-columns: 1fr; }
    .cw-footer { flex-direction: column-reverse; align-items: stretch; }
    .cw-footer-right { width: 100%; justify-content: stretch; }
    .cw-footer-right > * { flex: 1; }
}

/* Premium calibration shell inspired by Stitch Studio Calibration. */
.cw-modal {
    width: min(1180px, calc(100vw - 48px));
    max-height: min(860px, calc(100vh - 48px));
    display: grid;
    grid-template-columns: 320px minmax(0, 1fr);
    padding: 0;
    overflow: hidden;
    background:
        radial-gradient(circle at 78% 18%, rgba(188,140,255,0.16), transparent 34%),
        radial-gradient(circle at 24% 0%, rgba(88,166,255,0.18), transparent 35%),
        rgba(12,15,21,0.94);
    border: 1px solid rgba(162,201,255,0.20);
    border-radius: 24px;
    box-shadow: 0 34px 90px rgba(0,0,0,0.62), inset 0 1px 0 rgba(255,255,255,0.06);
}
.cw-side {
    display: flex;
    flex-direction: column;
    min-width: 0;
    padding: 26px;
    border-right: 1px solid rgba(255,255,255,0.08);
    background: rgba(8,9,12,0.52);
}
.cw-side-logo {
    width: 104px;
    height: 46px;
    background: url('../assets/branding/logo-wordmark.png') center / contain no-repeat;
    filter: drop-shadow(0 0 18px rgba(88,166,255,0.25));
    margin-bottom: 28px;
}
.cw-side-copy span,
.cw-kicker {
    color: var(--brand-1);
    font-size: 10px;
    font-weight: 900;
    letter-spacing: 0.20em;
    text-transform: uppercase;
}
.cw-side-copy h3 {
    margin: 8px 0 20px;
    color: var(--text);
    font-size: 26px;
    line-height: 1.05;
}
.cw-sequence {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    gap: 10px;
}
.cw-sequence li {
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr);
    gap: 10px;
    align-items: center;
    padding: 10px;
    border-radius: 12px;
    color: var(--text-muted);
    border: 1px solid transparent;
    background: rgba(255,255,255,0.025);
}
.cw-sequence li.is-current {
    color: var(--text);
    border-color: rgba(162,201,255,0.28);
    background: rgba(88,166,255,0.10);
}
.cw-sequence li.is-done { color: var(--brand-4); }
.cw-sequence span {
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: rgba(255,255,255,0.06);
    font-family: 'Consolas', 'JetBrains Mono', monospace;
    font-size: 11px;
    font-weight: 900;
}
.cw-sequence strong {
    min-width: 0;
    font-size: 12px;
    overflow-wrap: anywhere;
}
.cw-camera-art {
    margin-top: auto;
    border-radius: 18px;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,0.08);
    background: #08090c;
}
.cw-camera-art img {
    display: block;
    width: 100%;
    aspect-ratio: 16 / 10;
    object-fit: cover;
    opacity: 0.86;
}
.cw-stage {
    min-width: 0;
    padding: 30px;
    overflow-y: auto;
}
.cw-header h2 {
    margin: 6px 0 0;
    color: var(--text);
    font-size: 44px;
    line-height: 1;
    text-transform: uppercase;
}
.cw-header p {
    max-width: 680px;
    color: var(--text-muted);
}
.cw-close {
    background: rgba(255,255,255,0.04);
    border-color: rgba(162,201,255,0.24);
}
.cw-progress,
.cw-inline-progress {
    height: 10px;
    border-color: rgba(255,255,255,0.08);
    background: rgba(5,7,11,0.84);
}
.cw-card {
    background: rgba(17,24,34,0.68);
    backdrop-filter: blur(16px);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 18px;
    padding: 22px;
}
.cw-card.tone {
    background:
        radial-gradient(circle at 78% 0%, rgba(88,166,255,0.14), transparent 38%),
        rgba(17,24,34,0.72);
}
.cw-card h3 {
    color: var(--text);
    font-size: 22px;
}
.cw-status {
    border-color: rgba(162,201,255,0.18);
    background: rgba(8,9,12,0.48);
}
@media (max-width: 900px) {
    .cw-modal {
        grid-template-columns: 1fr;
        width: min(100vw - 24px, 720px);
    }
    .cw-side { display: none; }
    .cw-stage { padding: 22px; }
    .cw-header h2 { font-size: 32px; }
}

/* Stitch-grade section refinements for the product workspace. */
.trigger-builder-section .panel-automation {
    background:
        radial-gradient(circle at 78% 18%, rgba(255,123,114,0.13), transparent 30%),
        radial-gradient(circle at 24% 0%, rgba(88,166,255,0.16), transparent 34%),
        rgba(12,15,21,0.86);
}
.trigger-builder-section .tb-builder {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 18px;
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
}
.trigger-builder-section .tb-steps {
    width: min(340px, 100%);
    margin: 0;
}
.trigger-builder-section .tb-flow-grid {
    grid-template-columns: 0.94fr 1.05fr 0.94fr;
    align-items: stretch;
}
.trigger-builder-section .tb-flow-card {
    min-height: 300px;
    padding: 24px;
    border-radius: 18px;
    background:
        linear-gradient(180deg, rgba(255,255,255,0.045), rgba(255,255,255,0.015)),
        rgba(13,17,23,0.70);
}
.trigger-builder-section .tb-flow-card-hot {
    min-height: 340px;
    border-color: rgba(210,153,34,0.46);
    background:
        linear-gradient(180deg, rgba(5,7,11,0.52), rgba(5,7,11,0.76)),
        url('../assets/stitch/trigger-hand.png') 50% 86% / min(360px, 92%) auto no-repeat,
        radial-gradient(circle at 78% 0%, rgba(210,153,34,0.13), transparent 34%),
        rgba(5,7,11,0.42);
}
.trigger-builder-section .tb-flow-card-hot::after {
    display: none;
}
.trigger-builder-section .tb-flow-card-hot > * {
    position: relative;
    z-index: 1;
}
.trigger-builder-section .tb-flow-card-hot .tb-field {
    margin-bottom: 152px;
}
.trigger-builder-section .tb-flow-card h3 {
    font-size: clamp(24px, 2.5vw, 36px);
}
.trigger-builder-section .tb-priority-note {
    margin: 4px 0 0;
    border-radius: 12px;
}
.platform-section .panel-control,
.combo-section .panel-automation,
.settings-section .panel {
    background:
        radial-gradient(circle at 82% 0%, rgba(88,166,255,0.10), transparent 32%),
        rgba(17,24,34,0.70);
}
.platform-section details {
    border-radius: 14px;
    background: rgba(5,7,11,0.42);
}
.combo-section .combo-hint,
.combo-section .hint {
    border-radius: 12px;
    border: 1px solid rgba(162,201,255,0.14);
    border-left: 0;
    background: rgba(88,166,255,0.06);
    font-style: normal;
}
.combo-section .combo-locked,
.combo-section .combo-empty {
    border-radius: 18px;
    background:
        radial-gradient(circle at 50% 0%, rgba(188,140,255,0.12), transparent 34%),
        rgba(5,7,11,0.44);
}
.combo-row {
    border-radius: 14px;
    background:
        linear-gradient(90deg, rgba(88,166,255,0.06), transparent 48%),
        rgba(13,17,23,0.72);
    border-color: rgba(255,255,255,0.08);
}
.settings-section .panel h2 {
    font-size: 22px;
}
.settings-section details {
    border-radius: 14px;
    background: rgba(5,7,11,0.45);
}
@media (max-width: 1180px) {
    .scene-layout-grid,
    .account-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .settings-section {
        grid-template-columns: 1fr;
    }
    .settings-account-panel,
    .sensitivity-panel,
    .settings-section > #advanced-panel,
    .settings-section > .history-panel {
        grid-column: 1;
        grid-row: auto;
    }
}
@media (max-width: 900px) {
    .section-heading,
    .compact-heading {
        grid-template-columns: 1fr;
    }
    .section-heading h2 {
        font-size: 34px;
    }
    .trigger-builder-section .tb-flow-grid {
        grid-template-columns: 1fr;
    }
    .trigger-builder-section .tb-flow-card:not(:last-child)::before,
    .trigger-builder-section .tb-flow-card:not(:last-child)::after {
        display: none;
    }
    .trigger-builder-section .tb-flow-card-hot .tb-field {
        margin-bottom: 124px;
    }
}
@media (max-width: 620px) {
    .scene-layout-grid,
    .account-grid,
    .studio-console-grid,
    .engine-readout-grid {
        grid-template-columns: 1fr;
    }
}

/* ============================================================================
 * Combo Triggers UI (Pro+ feature)
 * Panel para configurar evento de plataforma + gesto físico → acciones.
 * ========================================================================== */
.combo-hint {
    color: var(--text-muted); font-size: 12px; margin-bottom: 12px;
    line-height: 1.5;
}
.combo-list {
    display: flex; flex-direction: column; gap: 8px;
    margin-bottom: 12px;
}
.combo-empty {
    color: var(--text-muted); font-size: 13px;
    padding: 16px; border: 1px dashed var(--border);
    border-radius: 8px; text-align: center;
}
.combo-row {
    display: grid;
    grid-template-columns: auto 1fr auto 1fr auto auto auto;
    gap: 8px; align-items: center;
    padding: 10px 12px;
    background: var(--panel-2);
    border: 1px solid var(--border);
    border-radius: 8px;
}
.combo-toggle {
    display: flex; align-items: center; gap: 6px;
    font-size: 12px; color: var(--text-muted);
    cursor: pointer; white-space: nowrap;
}
.combo-toggle input { cursor: pointer; }
.combo-event-select, .combo-gesture-select {
    width: 100%; min-width: 0;
}
.combo-arrow {
    color: var(--brand-1); font-weight: bold;
    user-select: none;
}
.combo-action-summary {
    font-size: 11px; color: var(--text-muted);
    white-space: nowrap; padding: 2px 8px;
    background: rgba(88,166,255,0.08);
    border-radius: 12px;
}
.combo-actions-btn {
    padding: 4px 10px; font-size: 12px;
}
.combo-remove-btn {
    padding: 2px 8px; font-size: 14px;
    background: none; border: 1px solid var(--danger);
    color: var(--danger);
}
.combo-remove-btn:hover {
    background: var(--danger); color: white;
}
.combo-toolbar {
    display: flex; justify-content: flex-end;
}
.combo-locked {
    text-align: center; padding: 24px 16px;
    background: rgba(88,166,255,0.05);
    border: 1px dashed var(--border);
    border-radius: 12px;
}
.combo-locked h3 { margin-top: 0; color: var(--brand-1); }
.combo-locked p { color: var(--text-muted); margin: 8px 0; }
@media (max-width: 760px) {
    .combo-row {
        grid-template-columns: 1fr;
        gap: 6px;
    }
    .combo-arrow { display: none; }
}

/* === MAINT-01: clases CSP-safe — reemplazan todos los style= e .style inline === */
.hidden-select  { display: none !important; }
.visible-flex   { display: flex !important; }
.event-trigger-row {
    display: grid;
    grid-template-columns: 18px 130px 1fr 1fr 18px;
    gap: 8px;
    align-items: center;
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
    font-size: 12px;
}
.event-info-icon {
    color: var(--text-muted);
    cursor: help;
}

/* === home-scene-row (extracted from inline styles for CSP compliance) === */
#home-scene-row { display: none; margin-top: 12px; }
#home-scene-row > label {
    font-size: 12px; opacity: 0.8; display: block; margin-bottom: 4px;
}
#home-scene-select {
    width: 100%; padding: 9px 12px; border-radius: 6px;
    border: 1px solid var(--border); background: var(--bg);
    color: var(--text); font-size: 13px;
}

/* ====== Home scene explanation (Z-i18n-01) ====== */
.home-scene-explain {
    display: block;
    font-size: 11px;
    color: rgba(148, 163, 184, 0.7);
    margin-top: 2px;
    line-height: 1.4;
}

/* ====== Trigger Builder: assignment footer (Z-UX-02) ====== */
.tb-assignment-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 12px 16px 0;
    margin-top: 8px;
    border-top: 1px solid rgba(99, 102, 241, 0.15);
}
.tb-save-status {
    font-size: 12px;
    color: rgba(110, 231, 183, 0.8);
    font-weight: 500;
    transition: opacity 0.2s;
}
.tb-save-status.tb-save-flash {
    animation: tbSaveFlash 0.6s ease;
}
@keyframes tbSaveFlash {
    0% { opacity: 0.3; transform: scale(0.95); }
    50% { opacity: 1; transform: scale(1.05); color: rgba(110, 231, 183, 1); }
    100% { opacity: 1; transform: scale(1); }
}
.tb-save-btn {
    font-size: 13px;
    padding: 8px 20px;
    min-width: 90px;
}

/* ====== Trigger Builder: action preview (new unified flow) ====== */
.tb-action-preview {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    margin-top: 10px;
    background: rgba(99, 102, 241, 0.08);
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: 8px;
    font-size: 13px;
}
.tb-action-preview-label {
    font-weight: 600;
    color: var(--text-color-light, #94a3b8);
    white-space: nowrap;
}
.tb-action-preview-value {
    color: var(--text-color, #e2e8f0);
    font-weight: 500;
}
.tb-save-btn:disabled {
    opacity: 0.6;
    cursor: default;
}

/* ====== Trigger Builder highlight pulse (Z-UX-01) ====== */
@keyframes tbHighlightPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(99, 102, 241, 0); }
    50% { box-shadow: 0 0 0 6px rgba(99, 102, 241, 0.3); }
}
.tb-highlight-pulse {
    animation: tbHighlightPulse 0.6s ease-in-out 3;
    border-radius: 12px;
}

/* Camera in-use warning banner (UX: prevent refund requests) */
.camera-warning {
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 8px;
    padding: 12px 16px;
    margin: 8px 0;
    animation: camera-warning-pulse 2s ease-in-out infinite;
}
.camera-warning-content {
    display: flex;
    align-items: center;
    gap: 10px;
}
.camera-warning-icon {
    font-size: 1.5em;
    flex-shrink: 0;
}
.camera-warning-text {
    font-size: 0.9em;
    color: #856404;
    line-height: 1.4;
}
@keyframes camera-warning-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(255, 193, 7, 0.4); }
    50% { box-shadow: 0 0 0 8px rgba(255, 193, 7, 0); }
}
