/**
 * NECIO PRO v5.7 - INDUSTRIAL MASTERCLASS
 * Engineered for iPhone 11 (A13 Bionic) | 4K 180Mbps Mastery.
 */

:root {
    --bg-os: #020202;
    --acc-red: #f31a1a;
    --acc-blue: #2a6df1;
    --acc-green: #00ff73;
    --acc-purple: #9b51e0;
    --acc-yellow: #ffee00;
    --text-main: #ffffff;
    --text-dim: #9ea0a5;
    --border-color: rgba(255, 255, 255, 0.1);
    --glass-panel: linear-gradient(135deg, rgba(255, 255, 255, 0.05) 0%, rgba(255, 255, 255, 0.01) 100%);
    --nav-height: 65px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    font-family: 'Inter', sans-serif;
}

body {
    background: var(--bg-os);
    color: var(--text-main);
    overflow: hidden;
    height: 100vh;
    width: 100vw;
    user-select: none;
}

.glass-panel {
    background: var(--glass-panel);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border: 1px solid var(--border-color);
    border-radius: 12px;
}

/* 1. OVERLAYS */
.startup-overlay,
.welcome-overlay,
.dial-container {
    position: fixed;
    inset: 0;
    z-index: 5000;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.hidden {
    display: none !important;
}

.logo-text {
    font-family: 'Outfit';
    font-size: 2.2rem;
    letter-spacing: 5px;
}

.logo-text span {
    color: var(--acc-red);
}

#btn-start,
.action-btn-main {
    background: var(--acc-red);
    border: none;
    padding: 18px;
    width: 100%;
    border-radius: 12px;
    color: #fff;
    font-weight: 700;
    cursor: pointer;
}

/* 2. WRAPPERS FOR IPHONE 11 ADAPTATION */
.content-wrapper {
    position: relative;
    height: calc(100vh - var(--nav-height) - env(safe-area-inset-bottom));
    width: 100vw;
    overflow: hidden;
}

.view {
    position: absolute;
    inset: 0;
    display: none;
    flex-direction: column;
    background: #000;
}

.view.active {
    display: flex;
}

.view-header {
    height: 60px;
    padding: 0 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    z-index: 10;
    border-bottom: 1px solid var(--border-color);
    margin-top: env(safe-area-inset-top);
}

.view-header h2 {
    font-size: 0.9rem;
    letter-spacing: 2px;
    font-weight: 800;
    text-transform: uppercase;
}

/* 3. CAMERA HUD ADAPTATION */
.viewfinder-wrapper {
    position: relative;
    flex: 1;
    overflow: hidden;
    background: #000;
}

#hardware-stream {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: filter 0.25s ease-out, transform 0.4s ease;
}

.iso-grain {
    filter: url(#sensor-noise) !important;
}

#peaking-canvas,
#zebra-rect,
#grid-layer {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 5;
}

#zebra-rect {
    background-image: repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.3) 0, rgba(255, 255, 255, 0.3) 2px, transparent 2px, transparent 10px);
    mix-blend-mode: overlay;
    opacity: 0.6;
}

/* Grid Layer */
.v-line,
.h-line {
    position: absolute;
    background: rgba(255, 255, 255, 0.25);
}

.v-line {
    top: 0;
    bottom: 0;
    width: 1px;
}

.h-line {
    left: 0;
    right: 0;
    height: 1px;
}

.v1 {
    left: 33.33%;
}

.v2 {
    left: 66.66%;
}

.h1 {
    top: 33.33%;
}

.h2 {
    top: 66.66%;
}

/* HUD Header Positioned for Notch */
.hud-header {
    position: absolute;
    top: calc(55px + env(safe-area-inset-top));
    left: 10px;
    right: 10px;
    height: 40px;
    border-radius: 12px;
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 100;
}

.hud-unit {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
}

.hud-unit span {
    font-weight: 700;
    font-size: 0.85rem;
    font-family: 'Outfit';
}

.hud-unit small {
    font-size: 0.4rem;
    color: var(--acc-red);
    font-weight: 900;
    letter-spacing: 1px;
    line-height: 1;
}

.sidebar {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.sidebar-l {
    left: 10px;
}

.sidebar-r {
    right: 10px;
    align-items: flex-end;
}

.icon-tool {
    width: 34px;
    height: 34px;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    color: #fff;
    font-size: 0.85rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-tool.hw-power {
    border-color: var(--acc-green);
    color: var(--acc-green);
}

.icon-tool.hw-power.off {
    border-color: var(--acc-red);
    color: var(--acc-red);
    background: rgba(255, 0, 0, 0.2);
}

.icon-tool.active {
    background: var(--acc-red);
    border-color: var(--acc-red);
    box-shadow: 0 0 15px rgba(243, 26, 26, 0.5);
}

.icon-tool.stabilizer-on,
.icon-tool.active {
    background: var(--acc-green);
    border-color: var(--acc-green);
    box-shadow: 0 0 15px rgba(0, 200, 100, 0.5);
}

.icon-tool#btn-doodle.active {
    background: var(--acc-yellow);
    border-color: var(--acc-yellow);
    box-shadow: 0 0 15px rgba(255, 200, 0, 0.5);
    color: #000;
}

/* Stabilizer: CSS Electronic Image Stabilization */
.viewfinder-wrapper.stabilized {
    overflow: hidden;
}

.viewfinder-wrapper.stabilized #hardware-stream {
    transform: scale(1.06);
    transform-origin: center center;
    transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
    will-change: transform;
}

/* 5. PRO MONITORING MODULES (Anchored to Screen Limits) */
.pro-monitor-right {
    position: absolute;
    bottom: 5px;
    right: 5px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 2px;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 4px;
    padding: 2px 6px;
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    pointer-events: none;
    transform: scale(0.6);
    transform-origin: bottom right;
}

.pro-monitor-left {
    position: absolute;
    bottom: 5px;
    left: 5px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 4px;
    padding: 6px;
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    pointer-events: none;
    transform: scale(0.6);
    transform-origin: bottom left;
}

.hist-container {
    display: flex;
    flex-direction: column;
    align-items: center;
}

#rgb-histogram {
    width: 100px;
    height: 20px;
    background: rgba(0, 0, 0, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 2px;
}

.hist-labels {
    width: 100%;
    display: flex;
    justify-content: space-between;
    font-size: 0.6rem;
    font-family: 'JetBrains Mono', monospace;
    opacity: 0.8;
    margin-top: 4px;
    color: var(--text-dim);
}

.ballistic-meters {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.meter-channel {
    display: flex;
    align-items: center;
    gap: 1vw;
}

.ch-label {
    font-size: 0.65rem;
    font-family: 'JetBrains Mono', monospace;
    opacity: 0.9;
    width: 10px;
    font-weight: 700;
}

.meter-track {
    width: 100px;
    height: 3px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 2px;
    overflow: hidden;
    position: relative;
}

.level-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--acc-green) 60%, var(--acc-yellow) 85%, var(--acc-red) 100%);
    transition: width 0.05s ease-out;
}

.peak-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
}

.peak-dot.clip {
    background: var(--acc-red);
    box-shadow: 0 0 5px var(--acc-red);
}

.audio-db-scale {
    display: none;
}

/* 4. CAMERA RECORD HUB (ABOVE PERSISTENT NAV) */
.camera-record-hub {
    position: absolute;
    bottom: 0px;
    left: 0;
    right: 0;
    height: 85px;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.95), transparent);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
}

.record-bar-content {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 40px;
    padding: 0 30px;
}

.master-tc {
    position: absolute;
    top: calc(5px + env(safe-area-inset-top));
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    font-family: 'JetBrains Mono', monospace;
    font-size: 2.2rem;
    font-weight: 800;
    color: var(--acc-red);
    text-shadow: 0 0 10px rgba(0, 0, 0, 0.8);
    pointer-events: none;
    letter-spacing: 2px;
}

.rec-ring {
    width: 72px;
    height: 72px;
    border: 4px solid #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    padding: 0;
    margin: 0;
}

#btn-record {
    width: 64px;
    /* Perfect fit: 72px - (4px border * 2) = 64px */
    height: 64px;
    background: var(--acc-red);
    border-radius: 50%;
    border: none;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    margin: 0;
    padding: 0;
    outline: none;
    box-sizing: border-box;
    display: block;
}

#btn-record.recording {
    border-radius: 12px;
    transform: scale(0.6);
}

.lens-switcher {
    display: flex;
    gap: 10px;
}

.lens-btn {
    font-size: 0.75rem !important;
    font-weight: 900;
    font-family: 'JetBrains Mono', monospace;
    color: #fff;
    border-radius: 50% !important;
    /* Totally round as requested */
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.2s;
}

.lens-btn.active {
    background: var(--acc-red) !important;
    color: #fff !important;
    border-color: #fff !important;
    box-shadow: 0 0 10px var(--acc-red);
}

/* --- 4.5 ZOOM CONTROL --- */
.zoom-control {
    position: absolute;
    bottom: 95px;
    left: 50%;
    transform: translateX(-50%);
    width: 150px;
    background: rgba(0, 0, 0, 0.7);
    padding: 5px 10px;
    border-radius: 15px;
    backdrop-filter: blur(10px);
    z-index: 210;
    display: flex;
    flex-direction: column;
    gap: 2px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.zoom-control.visible {
    opacity: 1;
    pointer-events: auto;
}

.zoom-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    font-weight: 800;
    font-family: 'JetBrains Mono';
    color: #fff;
}

#zoom-slider {
    width: 100%;
    height: 6px;
    accent-color: var(--acc-red);
    cursor: pointer;
}

/* 5. PERSISTENT FOOTER FOR IPHONE 11 */
.persistent-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(var(--nav-height) + env(safe-area-inset-bottom));
    background: #000;
    border-top: 1px solid #111;
    z-index: 1000;
    padding-bottom: env(safe-area-inset-bottom);
    display: flex;
}

.view-nav {
    flex: 1;
    display: flex;
}

.btn-v-nav {
    flex: 1;
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 0.65rem;
    font-weight: 900;
    letter-spacing: 1px;
    cursor: pointer;
    opacity: 0.6;
    transition: 0.2s;
    border-top: 3px solid transparent;
}

.btn-v-nav.active {
    color: var(--acc-red);
    border-top-color: var(--acc-red);
    opacity: 1;
}

/* 6. SCREENS CONTENT */
.menu-scroll-area {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    padding-bottom: 40px;
}

.menu-section {
    margin-bottom: 25px;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 14px;
    padding: 18px;
    border: 1px solid var(--border-color);
}

.menu-section h4 {
    font-size: 0.7rem;
    color: var(--acc-red);
    margin-bottom: 15px;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.menu-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.menu-row label {
    font-size: 0.7rem;
    color: var(--text-dim);
}

.menu-row select {
    background: #111;
    border: 1px solid #333;
    color: #fff;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 0.65rem;
}

.media-grid {
    padding: 15px;
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    overflow-y: auto;
}

.media-card {
    background: #0b0b0d;
    border-radius: 12px;
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid var(--border-color);
}

.studio-workspace {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 10px;
}

/* TOAST ADAPTATION */
.toast {
    position: fixed;
    top: calc(75px + env(safe-area-inset-top));
    left: 50%;
    transform: translateX(-50%);
    background: #000;
    border: 1px solid var(--acc-blue);
    border-left: 5px solid var(--acc-blue);
    padding: 12px 25px;
    border-radius: 8px;
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    z-index: 6000;
    box-shadow: 0 5px 25px rgba(0, 0, 0, 0.6);
}

input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    background: #333;
    height: 2px;
    border-radius: 1px;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    background: #fff;
    border-radius: 50%;
    cursor: pointer;
}

/* 7. STUDIO EDITOR ENGINE (DaVinci/Blackmagic Masterclass) */
.studio-workspace {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: #000;
    overflow: hidden;
}

.studio-monitoring-bar {
    display: flex;
    height: 45%;
    gap: 10px;
    padding: 10px;
}

.view-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.viewer-main {
    flex: 2;
    background: #020202;
    border-radius: 8px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #111;
    overflow: hidden;
}

.viewer-main video {
    max-width: 100%;
    max-height: 100%;
    border-radius: 4px;
}

.viewer-controls {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    padding: 6px 15px;
    border-radius: 20px;
    display: flex;
    gap: 15px;
    z-index: 10;
}

.viewer-controls button {
    background: none;
    border: none;
    color: #fff;
    font-size: 1.2rem;
    cursor: pointer;
}

.studio-scopes {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 10px;
}

.scope-unit {
    flex: 1;
    background: rgba(10, 10, 10, 0.8);
    border: 1px solid #222;
    border-radius: 6px;
    padding: 5px;
    display: flex;
    flex-direction: column;
}

.scope-unit small {
    font-size: 0.5rem;
    color: var(--acc-yellow);
    margin-bottom: 2px;
    letter-spacing: 1px;
}

#studio-histogram {
    flex: 1;
    width: 100%;
    background: #000;
}

.studio-audio-meters {
    flex: 1;
    display: flex;
    gap: 4px;
    padding: 5px 0;
}

.meter-v {
    flex: 1;
    background: #050505;
    position: relative;
    border-radius: 2px;
    overflow: hidden;
}

.meter-v .lvl {
    position: absolute;
    bottom: 0;
    width: 100%;
    height: 0%;
    background: linear-gradient(to top, var(--acc-green), var(--acc-yellow) 80%, var(--acc-red));
    transition: height 0.1s ease;
}

/* Timeline */
.studio-timeline-area {
    height: 25%;
    background: #050505;
    border-top: 1px solid #222;
    display: flex;
    flex-direction: column;
}

.tl-tools {
    height: 30px;
    display: flex;
    align-items: center;
    padding: 0 10px;
    gap: 10px;
    background: #080808;
}

.tl-tools button {
    background: none;
    border: none;
    color: #888;
    font-size: 1rem;
}

#tl-timecode {
    margin-left: auto;
    font-family: 'JetBrains Mono';
    font-size: 0.6rem;
    color: var(--acc-red);
}

.tl-scroll {
    flex: 1;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 10px 0;
    position: relative;
}

.tl-track,
.tl-track-audio {
    height: 35px;
    background: rgba(255, 255, 255, 0.02);
    margin-bottom: 4px;
    width: 2000px;
    position: relative;
}

.tl-clip {
    height: 100%;
    width: 300px;
    background: #1a3a5a;
    border: 1px solid #3a5a7a;
    border-radius: 4px;
    color: #fff;
    font-size: 0.5rem;
    display: flex;
    align-items: center;
    padding: 0 10px;
    font-weight: 700;
}

.tl-clip-audio {
    background: #2a4a3a;
    border-color: #3a5a4a;
    width: 300px;
    height: 100%;
    border-radius: 4px;
}

.tl-playhead {
    position: absolute;
    top: 0;
    left: 100px;
    width: 2px;
    height: 100%;
    background: var(--acc-red);
    box-shadow: 0 0 10px var(--acc-red);
    z-index: 5;
}

/* Panels */
.studio-panels-stack {
    flex: 1;
    background: #0a0a0a;
    border-top: 1px solid #1a1a1a;
    display: flex;
    flex-direction: column;
}

.panel-tabs {
    display: flex;
    border-bottom: 1px solid #222;
}

.tab-btn {
    flex: 1;
    background: none;
    border: none;
    padding: 10px;
    color: #555;
    font-size: 0.7rem;
    font-weight: 900;
    cursor: pointer;
}

.tab-btn.active {
    color: var(--acc-red);
    background: rgba(255, 0, 0, 0.05);
}

.studio-tab-content {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
}

.color-wheels-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.ctrl-group label {
    display: block;
    font-size: 0.5rem;
    color: var(--text-dim);
    margin-bottom: 5px;
}

.studio-tab-content.hidden {
    display: none;
}

.btn-auto-color {
    margin-top: 15px;
    background: linear-gradient(45deg, #111, #222);
    border: 1px solid var(--acc-yellow);
    color: var(--acc-yellow);
}

.form-row {
    margin-bottom: 15px;
}

.form-row label {
    display: block;
    font-size: 0.6rem;
    color: #888;
    margin-bottom: 4px;
}

.form-row select,
.form-row input {
    width: 100%;
    background: #111;
    border: 1px solid #333;
    color: #fff;
    padding: 8px;
    border-radius: 6px;
}

/* Transitions */
.view {
    transition: opacity 0.3s ease;
}

/* 8. PREMIUM A13 MASTERING TOUCHES */
.a13-badge {
    background: linear-gradient(90deg, #f31a1a, #ff7e5f);
    color: #fff;
    font-size: 0.5rem;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 900;
    margin-left: 8px;
    vertical-align: middle;
}

@keyframes pulse-ai {
    0% {
        box-shadow: 0 0 0 0 rgba(243, 26, 26, 0.4);
    }
}

.ai-active {
    animation: pulse-ai 2s infinite;
}

#active-tl-clip {
    background: linear-gradient(to right, #1a3a5a, #2a4a7a);
    box-shadow: inset 0 0 15px rgba(255, 255, 255, 0.05);
}

.viewer-controls button:active {
    transform: scale(0.9);
    color: var(--acc-red);
}

::-webkit-scrollbar {
    width: 4px;
    height: 4px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #333;
    border-radius: 10px;
}

.studio-Scopes.hidden {
    display: none !important;
}

/* --- DOODLE ENGINE FILTERS --- */
.doodle-anime-classic {
    filter: brightness(1.1) contrast(1.2) saturate(1.8) sepia(0.1);
}

.doodle-caricature-doodle {
    filter: contrast(1.4) saturate(2.0) hue-rotate(-10deg) brightness(1.05);
}

.doodle-manga-ink {
    filter: grayscale(1) contrast(2.5) brightness(0.9);
}

.doodle-lens {
    filter: contrast(1.5) saturate(1.5);
    animation: doodle-jitter 0.15s infinite alternate;
}

@keyframes doodle-jitter {
    0% {
        transform: scale(1.005) translate(0.5px, 0.5px);
    }

    100% {
        transform: scale(1) translate(-0.5px, -0.5px);
    }
}

/* --- ESTABILIZADOR PROFESIONAL --- */
.stabilized video {
    transform: scale(1.1);
    transition: transform 0.4s cubic-bezier(0.1, 0.7, 0.1, 1);
}

.viewfinder-wrapper.stabilized {
    overflow: hidden;
}

.icon-tool.stabilizer-on {
    color: var(--acc-yellow) !important;
    border-color: var(--acc-yellow) !important;
}

/* FC REMOVED */

.color-wheels-grid input[type="range"] {
    height: 4px;
    accent-color: var(--acc-red);
}

/* --- 9. PIP MODULE (Picture-in-Picture) --- */
.pip-overlay {
    position: absolute;
    top: 80px;
    right: 20px;
    width: 120px;
    height: 160px;
    z-index: 5000;
    background: #000;
    border: 2px solid var(--acc-red);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8);
    display: flex;
    overflow: hidden;
    transition: border-radius 0.3s ease;
}

.pip-overlay.hidden {
    display: none !important;
}

.pip-overlay.shape-square {
    border-radius: 0;
}

.pip-overlay.shape-round {
    border-radius: 12px;
}

.pip-overlay.shape-circle {
    border-radius: 50%;
    width: 140px;
    height: 140px;
    /* Force 1:1 for perfect circle */
}

.pip-header {
    position: absolute;
    top: 5px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 8px;
    z-index: 5010;
    opacity: 0;
    transition: opacity 0.2s;
    background: rgba(0, 0, 0, 0.6);
    padding: 6px;
    border-radius: 20px;
    backdrop-filter: blur(5px);
    cursor: grab;
}

.pip-header:active {
    cursor: grabbing;
}

.pip-overlay:hover .pip-header,
.pip-overlay:active .pip-header,
.pip-overlay:hover .pip-resize-handle,
.pip-overlay:active .pip-resize-handle {
    opacity: 1;
}

.pip-header button {
    background: none;
    border: none;
    color: white;
    font-size: 1.1rem;
    cursor: pointer;
    padding: 0;
}

#pip-stream {
    width: 100%;
    height: 100%;
    object-fit: cover;
    pointer-events: none;
    /* Let drag events pass through */
    transform: scaleX(-1);
    /* Mirror selfie camera for natural movement */
}

.pip-resize-handle {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 30px;
    height: 30px;
    background: linear-gradient(135deg, transparent 50%, rgba(255, 255, 255, 0.4) 100%);
    z-index: 5010;
    cursor: nwse-resize;
    display: flex;
    align-items: flex-end;
    justify-content: flex-end;
    padding: 2px;
    color: white;
    font-size: 0.8rem;
    opacity: 0;
    transition: opacity 0.2s;
}