
    /* ==========================================
       SCOPED VARIABLES & RESET (PROFILE ONLY)
    ========================================== */
    #view-profile {
        --bg: #000000; --bg2: #121212; --bg3: #1c1c1c; --bg4: #262626;
        --line: rgba(255,255,255,0.1);
        --txt: #F5F5F5; --txt2: #8E8E8E; --txt3: #555555;
        --danger: #ED4956; --green: #17c964; --accent: #0095F6; --pending: #f5a623;
        
        --profile-theme: var(--bg);
        --profile-theme-dark: var(--bg);
        --profile-theme-ring: rgba(255,255,255,0.15);   /* สีขอบไฮไลต์ — ตั้งตามธีมตอนโหลดโปรไฟล์ */
        --popup-theme: #1a1a1a;
        
        background-color: var(--profile-theme); 
        background-image: none;
        
        color: var(--txt);
        font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
        /* 🐞 บั๊กที่แจ้ง: หน้าโปรไฟล์ตอนโหลด (#profile-full-loader/#profile-transition ข้างล่าง
           position:absolute;inset:0 อ้างอิงกล่องนี้) เลื่อนได้ + พื้นหลังไม่เต็มจอ — 100vh บน Safari
           คือความสูงจอเต็มรวมพื้นที่หลังแถบเครื่องมือด้วย (ใหญ่กว่าพื้นที่มองเห็นจริงตอนแถบเครื่องมือ
           โผล่อยู่) เดิมไม่มีผลเพราะ .app-view เคย position:absolute;inset:0 บังคับความสูงตายตัวทับอยู่
           แล้ว พอเปลี่ยนให้ body เลื่อนจริงแทน (ดู [[project_hqux_full_page_scroll]]) กล่องนี้เลยสูงเกิน
           พื้นที่มองเห็นจริงไปเท่าความสูงแถบเครื่องมือ Safari ทำให้เลื่อนได้ทั้งที่ไม่ควร — เติม 100dvh
           (ความสูงพื้นที่มองเห็นจริง) ทับท้ายสุด 🌟 */
        min-height: 100vh; min-height: 100dvh; overflow-x: hidden; overflow-x: clip; padding-bottom: 80px;   /* clip ไม่ใช่ hidden: hidden ทำให้แกน y เป็น auto → หน้านี้กลายเป็นกล่องเลื่อนซ้อนใต้หน้าต่างหลัก ลูกกลิ้งใน Chrome ค้าง (ดู index.html) */
    }

    ::-webkit-scrollbar { display: none; }
    #view-profile .owner-only, #view-profile .guest-only { display: none !important; }
    .hl-nav-btn { display: none !important; }   /* ปกติไม่แสดง — คอมแนวนอนเท่านั้น (ดู @media) */
    #view-profile.is-owner .owner-only { display: flex !important; }
    #view-profile.is-guest .guest-only { display: flex !important; }
    body.no-scroll { overflow: hidden !important; touch-action: none; position: fixed; width: 100%; }

    /* ── PROFILE TRANSITION LOADING (อวาตาร์กลางจอ + วงแหวนหมุน + สีธีมทันที) ── */
    /* 🐞 บั๊กที่แจ้ง: อวาตาร์หลุดไปกองอยู่ล่างสุดจอ พื้นหลังไม่เต็ม — เดิม position:absolute;inset:0
       อ้างอิงความสูงของ #view-profile ซึ่งตอนนี้เป็น flow ปกติแล้ว (ดู [[project_hqux_full_page_scroll]])
       ถ้าจังหวะที่ #profile-data-content (เนื้อหาโปรไฟล์จริง ยาวหลายจอ) เริ่มโผล่ขึ้นมาพร้อมๆ กับที่
       overlay นี้กำลังจะจางหายไป #view-profile จะพองสูงขึ้นตามเนื้อหาจริงทันที ทำให้กล่องนี้ (inset:0
       ตาม #view-profile) สูงตามไปด้วยหลายจอ แล้ว justify-content:center จะไปเซ็นเตอร์เนื้อหาไว้กลาง
       กล่องที่สูงเกินจอนั้น อวาตาร์เลยเลื่อนลงไปไกลเกินจอจริง — เปลี่ยนเป็น position:fixed แทน ยึดกับจอ
       จริงเสมอ ไม่ขึ้นกับความสูงของ #view-profile อีกต่อไป (เหมือนโมดัล/oveylay ตัวอื่นในเว็บนี้ที่ล้วน
       ใช้ fixed) 🌟 */
    #profile-transition {
        position: fixed; inset: 0; z-index: 1300; display: none;
        flex-direction: column; align-items: center; justify-content: center; gap: 22px;
        padding-bottom: 30vh;  /* ขยับเนื้อหา (รูป+วงแหวน+ชื่อ) ขึ้นด้านบน ~15% ของจอ */
        background: var(--pt-theme, #111111);
        transition: background 0.4s ease, opacity 0.35s ease;
    }
    #profile-transition.active { display: flex; }
    /* 🖼️ รูปพื้นหลังโปรไฟล์ในหน้าโหลด — ชั้นเดียวกับ #profile-bg-layer ของหน้าจริง (มินิเบลอ → รูปเต็ม + ทับสีธีม) สลับไปหน้าจริงแล้วไม่สะดุด */
    .pt-bg { position: absolute; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; display: none; }
    .pt-bg.on { display: block; }
    .pt-bg img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
    .pt-bg .pt-bg-mini { filter: blur(8px); transform: scale(1.06); }
    .pt-bg .pt-bg-full { opacity: 0; transition: opacity 0.6s ease; }
    .pt-bg .pt-bg-full.ld { opacity: 1; }
    .pt-bg .pt-bg-t1 { position: absolute; inset: 0; background: var(--pt-theme, #111); opacity: 0.5; }
    .pt-bg .pt-bg-t2 { position: absolute; inset: 0; background: linear-gradient(to bottom, var(--pt-theme, #111) 0%, color-mix(in srgb, var(--pt-theme, #111) 70%, transparent) 14%, transparent 38%, transparent 62%, color-mix(in srgb, var(--pt-theme, #111) 70%, transparent) 86%, var(--pt-theme, #111) 100%); }
    .pt-bg .pt-bg-t3 { position: absolute; inset: 0; background: linear-gradient(to right, color-mix(in srgb, var(--pt-theme, #111) 55%, transparent) 0%, transparent 22%, transparent 78%, color-mix(in srgb, var(--pt-theme, #111) 55%, transparent) 100%); }
    #profile-transition > .pt-avatar-wrap, #profile-transition > .pt-names { z-index: 1; }
    #profile-transition > .pt-names { position: relative; }
    /* ใหญ่ขึ้น 25% (150→188) */
    .pt-avatar-wrap { position: relative; width: 188px; height: 188px; display:flex; align-items:center; justify-content:center; }
    /* วงแหวนโหลดแบบเดียวกับสตอรี่ (chasing-light) — ดันวงแหวนออกนอก เว้นระยะจากรูปมากขึ้น */
    .pt-ring-svg { position: absolute; inset: -7px; width: calc(100% + 14px); height: calc(100% + 14px); pointer-events: none; transition: opacity 0.3s ease; }
    .pt-ring-circle {
        fill: none; stroke: #FFFFFF; stroke-width: 3.2; stroke-linecap: round;
        stroke-dasharray: 80, 200; transform-origin: center;
        animation: chasing-light 1.2s cubic-bezier(0.4, 0, 0.2, 1) infinite;
        filter: blur(0.5px);
    }
    #pt-avatar {
        width: 168px; height: 168px; border-radius: 50%; object-fit: cover;  /* เล็กกว่า wrap → เว้นระยะกับวงแหวน */
        background: rgba(255,255,255,0.08); display: block;
        will-change: transform;
    }
    /* ชื่อที่แสดง (ถ้าตั้งไว้) อยู่บน @ชื่อผู้ใช้ — มีชื่อที่แสดงแล้ว @ชื่อผู้ใช้ลดเป็นบรรทัดรอง */
    .pt-names { display: flex; flex-direction: column; align-items: center; gap: 4px; max-width: 86vw; text-align: center; transition: opacity 0.3s ease; }
    .pt-display-name { color: #fff; font-weight: 800; font-size: 21px; letter-spacing: -0.3px; line-height: 1.25; text-shadow: 0 1px 6px rgba(0,0,0,0.4); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .pt-display-name:empty { display: none; }
    .pt-username { color: #fff; font-weight: 700; font-size: 17px; letter-spacing: -0.2px; text-shadow: 0 1px 6px rgba(0,0,0,0.4); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .pt-display-name:not(:empty) + .pt-uline .pt-username { font-size: 14px; font-weight: 600; opacity: 0.78; }
    /* ยศอยู่ขวาของ @ชื่อผู้ใช้ แต่ไม่นับรวมตอนจัดกึ่งกลาง (ชื่อผู้ใช้อยู่ตรงกลางเป๊ะ) */
    .pt-uline { position: relative; display: inline-flex; max-width: 100%; }
    .pt-badges-row { display: flex; justify-content: center; gap: 6px; margin: 4px 0 0 !important; }
    .pt-badges-row:empty { display: none; }
    .pt-badges { position: absolute; left: 100%; top: 50%; transform: translateY(-50%); margin: 0 0 0 6px !important; white-space: nowrap; }

    /* ── LOADING UI ── */
    /* 🐞 เหตุผลเดียวกับ #profile-transition ข้างบน — เปลี่ยนเป็น fixed กันปัญหาเดียวกัน แม้ตอนนี้จะ
       display:none ค้างไว้ (เลิกใช้แล้ว) ไว้เผื่ออนาคตมีใครเปิดกลับมาใช้ 🌟 */
    #profile-full-loader { position: fixed; inset: 0; background: var(--profile-theme); z-index: 1000; display: flex; flex-direction: column; align-items: center; padding-top: 150px; }
    .skeleton-avatar { width: 115px; height: 115px; border-radius: 50%; background: rgba(255,255,255,0.1); animation: pulse 1.5s infinite ease-in-out; margin-bottom: 20px;}
    .skeleton-line { height: 20px; background: rgba(255,255,255,0.1); border-radius: 10px; animation: pulse 1.5s infinite ease-in-out; margin-bottom: 10px;}
    @keyframes pulse { 0% { opacity: 0.5; } 50% { opacity: 1; } 100% { opacity: 0.5; } }

    /* ── NAV ── */
    .prf-nav {
        position: absolute; top: 0; left: 0; width: 100%; z-index: 1000 !important;
        padding: 0 16px; height: auto;
        display: flex; align-items: flex-start; justify-content: space-between;
        background: transparent; border: none; pointer-events: none;
        margin-top: 0;
    }
    
    @media (max-width: 600px) {
        .prf-nav {
            margin-top: 0;
            padding-top: max(8px, env(safe-area-inset-top));
        }
    }
    
    .pf-chat-btn { height: 32px; padding: 0 14px; margin: 0 4px; border-radius: 16px; border: none; background: #fff; color: #000;
        font: 700 13px/1 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, system-ui, sans-serif; letter-spacing: -0.1px;
        display: inline-flex; align-items: center; justify-content: center; white-space: nowrap; cursor: pointer; flex: none;
        transition: transform 0.15s; -webkit-tap-highlight-color: transparent; }
    .pf-chat-btn:active { transform: scale(0.94); }
    .pf-chat-ic svg { width: 22px; height: 22px; fill: none; stroke: #fff; stroke-width: 1.7; display: block; }
        .nav-left, .nav-actions { display: flex; align-items: center; gap: 2.5px; pointer-events: auto; touch-action: manipulation; }

    .prf-nav-btn, .nav-follow-icon {
        width: 34px; height: 34px; display: flex; align-items: center; justify-content: center;
        background: transparent; color: #fff; border: none; cursor: pointer; font-size: 24px; font-weight: 300; transition: 0.2s;
        text-shadow: 0 1px 4px rgba(0,0,0,0.6);
    }
    .prf-nav-btn.small-msg {
        width: 26px; height: 26px; font-size: 19px; opacity: 0.9;
    }
    .prf-nav-btn:active, .nav-follow-icon:active { transform: scale(0.85); opacity: 0.7; }
    .nav-follow-icon.following { color: #fff; }
    .nav-follow-icon.pending { color: var(--pending); }

    /* ── COVER 2.63:1 ── */
    .cover-wrap {
        position: relative; width: 100%;
        height: 38vw; max-height: 228px;
        background: rgba(0,0,0,0.1); display: block; overflow: hidden;
        /* ห้ามใส่ z-index ตัวเลข! จะสร้าง stacking context ทำให้ .prf-nav (z-index 1000) ถูกขังอยู่ในนี้
           แล้ว .cover-info-overlay (z-index 10) ที่ margin-top ติดลบจะทับปุ่มมุมบนขวาจนกดไม่ได้ (โดยเฉพาะจอมือถือ) */
        z-index: auto;
    }

    /* 🌟 โหมดไม่มีปก: ไม่เว้นพื้นที่ปก แต่ปุ่มยังอยู่มุมบนขวาขนาดเดิม 🌟 */
    #view-profile.no-cover .cover-wrap {
        height: max(6px, env(safe-area-inset-top)); max-height: none;
        background: transparent; overflow: visible; /* visible = ปุ่มมุมบนขวาไม่โดนตัด */
    }
    #view-profile.no-cover .cover-gradient, #view-profile.no-cover .cover-fade-bridge { display: none; }
    #view-profile.no-cover .cover-info-overlay { margin-top: 6px; padding-top: 64px; }  /* แถบว่างเหนือชื่อ (แตะค้างอัปโหลดปก) กว้างขึ้น */
    #nav-actions-inline-slot { display: none; }  /* ไม่ใช้ช่องปุ่มหลังชื่อแล้ว */
    .prog-img { position: absolute; top: 0; left: 0; width: 100%; height: 100%; object-fit: cover; transition: opacity 0.4s ease; pointer-events: none;}
    .prog-img.mini { filter: blur(10px); transform: scale(1.05); z-index: 1; }
    .prog-img.full { opacity: 0; z-index: 2; }
    .prog-img.full.loaded { opacity: 1; }
    
    .cover-gradient {
        position: absolute; bottom: 0; left: 0; right: 0; height: 90%;
        background: linear-gradient(to top,
            var(--profile-theme) 0%,
            color-mix(in srgb, var(--profile-theme) 90%, transparent) 12%,
            color-mix(in srgb, var(--profile-theme) 70%, transparent) 28%,
            color-mix(in srgb, var(--profile-theme) 40%, transparent) 48%,
            color-mix(in srgb, var(--profile-theme) 15%, transparent) 72%,
            transparent 100%);
        pointer-events: none; z-index: 3;
    }
    .cover-fade-bridge {
        position: relative; z-index: 2;
        height: 40px; margin-top: 0;
        background: linear-gradient(to bottom, var(--profile-theme) 0%, transparent 100%);
        pointer-events: none; flex-shrink: 0;
    }
    
    /* 🌟 PROFILE INFO OVERLAY 🌟 */
    .cover-info-overlay {
        position: relative; z-index: 10; display: flex; flex-direction: row; align-items: flex-start; gap: 16px;
        padding: 0 16px 20px; width: 100%; max-width: 600px; margin: 0 auto;
        margin-top: -60px; min-height: 120px;
    }

    /* ── ULTRA-PREMIUM MINIMALIST STORY RING ── */
    .story-ring-wrapper { 
        position: relative; display: inline-block; z-index: 20; 
        cursor: pointer; flex-shrink: 0; margin-top: -10px;
        transform-origin: center;
        transition: transform 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
        -webkit-tap-highlight-color: transparent;
    }
    
    /* The Press: Soft Compression (High-Tension Spring) */
.story-ring-wrapper:has(.pf-presence:active):active { transform: none; }   /* แตะจุดสถานะ: รูปโปรไฟล์ไม่เด้งตาม */
    .story-ring-wrapper:not(:has(.pf-presence:active)):active { 
        transform: scale(0.92); 
        transition: transform 0.15s cubic-bezier(0.1, 0.9, 0.2, 1);
    }

    .story-ring { 
        border-radius: 50%; padding: 4px; display: inline-flex; 
        position: relative; align-items: center; justify-content: center;
        transition: all 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
    }

    /* ⚪ Sharp Pure White Ring ⚪ */
    .liquid-ring-svg {
        position: absolute; inset: -4px; width: calc(100% + 8px); height: calc(100% + 8px);
        pointer-events: none; z-index: 1;
        opacity: 0; transform: scale(0.95);
        transition: opacity 0.5s ease, transform 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
    }
    
    .story-ring.has-story .liquid-ring-svg { opacity: 1; transform: scale(1); }
    
    .liquid-circle {
        fill: none; stroke: #FFFFFF; stroke-width: 2.2;
        stroke-linecap: round; transform-origin: center;
        transition: stroke 0.6s ease, opacity 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
    }

    /* Seen State: 30% Opacity Translucent White */
    .story-ring.viewed .liquid-circle { opacity: 0.3; stroke-width: 2.0; }

    /* Loading State: Chasing Light (Motion Blur Trail) */
    .story-ring.is-loading .liquid-circle {
        animation: chasing-light 1.2s cubic-bezier(0.4, 0, 0.2, 1) infinite;
        stroke-dasharray: 80, 200;
        stroke-dashoffset: 0;
        stroke-width: 3.5;
        filter: blur(0.5px); /* Sharp but slightly blurred trail */
    }

    @keyframes chasing-light {
        0% { stroke-dashoffset: 0; transform: rotate(0deg); }
        100% { stroke-dashoffset: -280; transform: rotate(360deg); }
    }

    /* ── AVATAR ── */
    .avatar-wrap { 
        width: 115px; height: 115px; border-radius: 50%; border: none !important; 
        background: var(--bg4) !important; display: flex; align-items: center; justify-content: center; 
        overflow: hidden; position: relative; box-shadow: none; z-index: 2; pointer-events: none;
        transition: all 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
    }
    /* Gap: 2px dimension space */
    .story-ring.has-story .avatar-wrap { margin: 2px; }


    .avatar-wrap img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; border: none !important; }
    .avatar-placeholder { position: absolute; top: 0; left: 0; width: 100%; height: 100%; object-fit: cover; border-radius: 50%; z-index: 1; }
    
    /* ปุ่มสร้างสตอรี่ (+) มุมขวาล่างของรูปโปรไฟล์ — วงกลมรองเป็น "รูโปร่ง" เจาะทะลุรูปโปรไฟล์ เห็นพื้นหลังของหน้าจริง
       (ปก/รูปพื้นหลัง/สีพื้น) ไม่ใช่วงกลมสีธีมทับ · ตำแหน่ง/ขนาดรูอ้างอิง --av-size, --add-off (คอมแนวนอนปรับให้ตามรูปที่ใหญ่ขึ้น) */
    #view-profile { --av-size: 115px; --add-off: 5px; }
    #view-profile.is-owner.pres-ready .cover-info-overlay .avatar-wrap {
        --hole-x: calc(var(--av-size) - 10px - var(--add-off));
        -webkit-mask: radial-gradient(circle at var(--hole-x) var(--hole-x), transparent 16.5px, #000 17px);
                mask: radial-gradient(circle at var(--hole-x) var(--hole-x), transparent 16.5px, #000 17px);
    }
    #view-profile.is-owner.pres-ready .cover-info-overlay .story-ring.has-story .avatar-wrap { --hole-x: calc(var(--av-size) - 8px - var(--add-off)); }
    .avatar-add-story-btn {
        position: absolute; bottom: var(--add-off, 5px); right: var(--add-off, 5px);
        width: 28px; height: 28px; border-radius: 50%;
        background: transparent; 
        color: #fff; display: flex; align-items: center; justify-content: center;
        font-size: 18px; border: none; 
        cursor: pointer; z-index: 25; transition: 0.2s;
    }
    .avatar-add-story-btn:active { transform: scale(0.85); filter: brightness(1.2); }
    /* ปุ่ม + สร้างสตอรี่: ขึ้นเฉพาะตอนรูปโปรไฟล์อยู่กับที่แล้ว (เหมือนจุดสถานะ) — ระหว่างรูปลอยเข้าที่/ขยาย-หุบ ซ่อนทั้งปุ่มและรูเจาะ */
    #view-profile:not(.pres-ready) .avatar-add-story-btn { opacity: 0; visibility: hidden; }
    #view-profile .avatar-add-story-btn { transition: opacity 0.22s ease, transform 0.2s; }
    /* 🟢 สถานะการใช้งาน (โปรไฟล์คนอื่น) แบบเฟซบุ๊ก: จุดสีบนขอบรูปโปรไฟล์มุมขวาล่าง
       ขอบรอบจุดเป็น "รูโปร่ง" เจาะทะลุรูป (เห็นพื้นหลังของหน้า แบบปุ่ม + สร้างสตอรี่) · ย่อ/ขยายตาม --av-size
       จุด 13% ของรูป · ช่องว่างรอบจุด 3.5% · ศูนย์กลางที่ 85% ของรูป (บนเส้นขอบวงกลมพอดี) · กรอบนอกใหญ่กว่ารูป 4px/ด้าน */
    /* ขึ้นเฉพาะตอนรูปโปรไฟล์ "อยู่กับที่" แล้ว (pres-ready) — ระหว่างรูปลอยเข้าที่ตอนโหลดโปรไฟล์ / ขยาย-หุบรูป ไม่แสดงทั้งจุดและรูเจาะ */
    #view-profile.has-presence.pres-ready:not(.is-owner) .cover-info-overlay .avatar-wrap {
        --pc: calc(var(--av-size) * 0.85);
        -webkit-mask: radial-gradient(circle at var(--pc) var(--pc), transparent calc(var(--av-size) * 0.1), #000 calc(var(--av-size) * 0.1 + 0.5px));
                mask: radial-gradient(circle at var(--pc) var(--pc), transparent calc(var(--av-size) * 0.1), #000 calc(var(--av-size) * 0.1 + 0.5px));
    }
    /* รูเจาะเดียวกันทะลุวงแหวนสตอรี่ด้วย (เดิมเจาะแค่รูป เส้นวงแหวนเลยลากผ่านรอบจุดสถานะ/ปุ่ม +)
       วงแหวน (svg) ใหญ่กว่ารูป: ระยะจากขอบ svg ถึงขอบรูป = 4 (inset) + 4 (padding) + 2 (margin ตอนมีสตอรี่) = 10px */
    #view-profile.has-presence.pres-ready:not(.is-owner) .cover-info-overlay .story-ring.has-story .liquid-ring-svg {
        --pc: calc(10px + var(--av-size) * 0.85);
        -webkit-mask: radial-gradient(circle at var(--pc) var(--pc), transparent calc(var(--av-size) * 0.1), #000 calc(var(--av-size) * 0.1 + 0.5px));
                mask: radial-gradient(circle at var(--pc) var(--pc), transparent calc(var(--av-size) * 0.1), #000 calc(var(--av-size) * 0.1 + 0.5px));
    }
    #view-profile.is-owner.pres-ready .cover-info-overlay .story-ring.has-story .liquid-ring-svg {
        --hx: calc(10px + var(--av-size) - 8px - var(--add-off));
        -webkit-mask: radial-gradient(circle at var(--hx) var(--hx), transparent 16.5px, #000 17px);
                mask: radial-gradient(circle at var(--hx) var(--hx), transparent 16.5px, #000 17px);
    }
    /* 👤 กรอบรูปโปรไฟล์ก็เจาะรูเดียวกัน (กรอบแหว่งรอบปุ่ม +/จุดสถานะ แบบรูปโปรไฟล์) — ภาพกรอบกว้าง 1.5 เท่าของรูป วางกึ่งกลาง
       → จุดเดียวกันในพิกัดกรอบ = ในพิกัดรูป + 0.25 × ขนาดรูป */
    #view-profile.is-owner.pres-ready .cover-info-overlay .story-ring > .hqaf {
        --fh: calc(var(--av-size) * 1.25 - 10px - var(--add-off));
        -webkit-mask: radial-gradient(circle at var(--fh) var(--fh), transparent 16.5px, #000 17px);
                mask: radial-gradient(circle at var(--fh) var(--fh), transparent 16.5px, #000 17px);
    }
    #view-profile.is-owner.pres-ready .cover-info-overlay .story-ring.has-story > .hqaf { --fh: calc(var(--av-size) * 1.25 - 8px - var(--add-off)); }
    #view-profile.has-presence.pres-ready:not(.is-owner) .cover-info-overlay .story-ring > .hqaf {
        --fh: calc(var(--av-size) * 1.1);
        -webkit-mask: radial-gradient(circle at var(--fh) var(--fh), transparent calc(var(--av-size) * 0.1), #000 calc(var(--av-size) * 0.1 + 0.5px));
                mask: radial-gradient(circle at var(--fh) var(--fh), transparent calc(var(--av-size) * 0.1), #000 calc(var(--av-size) * 0.1 + 0.5px));
    }
    .pf-presence { position: absolute; z-index: 25; cursor: pointer; -webkit-tap-highlight-color: transparent;
        width: calc(var(--av-size, 115px) * 0.13); height: calc(var(--av-size, 115px) * 0.13);
        right: calc(4px + var(--av-size, 115px) * 0.085); bottom: calc(4px + var(--av-size, 115px) * 0.085); }
    .pf-presence[hidden] { display: none; }
    #view-profile:not(.pres-ready) .pf-presence { visibility: hidden; opacity: 0; }
    .pf-presence { transition: opacity 0.22s ease; }
    #view-profile.is-owner .pf-presence { display: none; }
    .pf-presence .hq-pdot { display: block; width: 100%; height: 100%; border: none !important; box-sizing: border-box; pointer-events: none; transition: transform 0.15s; }
    .pf-presence:active .hq-pdot { transform: scale(0.85); }
    .pf-pdot[hidden] { display: none; }
    #view-profile.is-owner .pf-pdot { display: none; }

    /* ── INFO TEXT & INLINE EDITING ── */
    .info-text-wrap { 
        flex: 1; text-align: left; display: flex; flex-direction: column; justify-content: center; padding-bottom: 5px;
    }
    
    [contenteditable="plaintext-only"] { outline: none; cursor: text; transition: 0.2s; }
    
    /* 🌟 ช่องใส่ชื่อแบบล่องหน 🌟 */
    .handle-display { 
        font-size: 18px; font-weight: 800; color: #fff; margin-bottom: 2px; text-shadow: none; 
        display: none; word-break: break-word; box-sizing: border-box; min-height: 24px;
    }
    .handle-display:empty::before { content: 'เพิ่มชื่อที่แสดง...'; color: rgba(255,255,255,0.3); pointer-events: none; }
    
    /* ✦ แท็กข้าง @username — โทนขาวทั้งหมด: verified (ตราเช็ค) / owner / admin / AI */
    .hq-badges { display: inline-flex; align-items: center; gap: 5px; margin: 0 0 8px 6px; vertical-align: middle; flex: none; }
    .hq-badges:empty { display: none; }
    .pf-badges-row { display: none; }   /* แถวยศใต้ @ชื่อผู้ใช้ — ใช้เฉพาะโปรไฟล์แบบจัดกึ่งกลาง */
    .hq-badge {
        display: inline-flex; align-items: center; gap: 3px; height: 18px; padding: 0 7px 0 5px; border-radius: 100px;
        font-size: 10px; font-weight: 800; letter-spacing: .05em; color: #000; background: #fff; cursor: pointer;
        -webkit-user-select: none; user-select: none; line-height: 1; transition: transform .15s;
    }
    .hq-badge:active { transform: scale(.92); }
    .hq-badge svg { width: 10px; height: 10px; fill: currentColor; flex: none; }
    .hq-badge.ghost { background: transparent; color: #fff; box-shadow: inset 0 0 0 1px rgba(255,255,255,.55); }
    .hq-badge.seal { padding: 0; width: 17px; height: 17px; background: none; color: #fff; }
    .hq-badge.seal svg { width: 17px; height: 17px; }
    .handle-row-inline.has-ai .handle { display: inline-block; vertical-align: middle; }
    .handle { font-size: 13px; font-weight: 500; color: rgba(255,255,255,0.8); text-shadow: none; margin-bottom: 8px; cursor: default; }
    #view-profile.is-owner .handle { cursor: pointer; }
    
    /* 🌟 ช่องใส่ไบโอแบบล่องหน 🌟 */
    .bio-text { 
        font-size: 13px; line-height: 1.4; color: rgba(255,255,255,0.9); margin-bottom: 12px; white-space: pre-wrap; 
        width: 100%; text-shadow: none; display: none; word-break: break-word; box-sizing: border-box; min-height: 20px;
    }
    .bio-text:empty::before { content: 'เพิ่มคำอธิบายตัวเอง...'; color: rgba(255,255,255,0.3); pointer-events: none; }

    /* ลำดับข้อมูลโปรไฟล์ (ทุกหน้าจอ): ชื่อ → @ → สถิติ → คำอธิบาย (ไบโอ) → ลิงก์ */
    .info-text-wrap > .handle-display { order: 1; }
    .info-text-wrap > .handle-row-inline { order: 2; }
    .info-text-wrap > .inline-stats { order: 3; }
    .info-text-wrap > .bio-text { order: 4; margin-top: 8px; margin-bottom: 10px; }
    .info-text-wrap > .profile-links-container { order: 5; }
    .inline-stats { font-size: 14px; font-weight: 500; color: rgba(255,255,255,0.9); display: flex; gap: 16px; flex-wrap: wrap; text-shadow: none; }
    .stat-btn { display: flex; align-items: center; gap: 4px; transition: 0.2s; cursor: pointer;}
    .stat-btn:active { transform: scale(0.95); opacity: 0.8;}
    .inline-stats .stat-val { font-weight: 700; color: #fff; }

    .ui-level-pure { display: none !important; }

    /* ── MINIMAL LEVEL BAR ── */
    .ui-level-bar-wrapper {
        margin-top: 14px; width: 100%; max-width: 220px; cursor: pointer;
        transition: 0.2s; position: relative;
    }
    .ui-level-bar-wrapper:active { transform: scale(0.98); opacity: 0.8; }
    
    .level-bar-info {
        display: flex; align-items: center; gap: 8px;
        margin-bottom: 4px; padding: 0 2px;
    }
    .level-label { font-size: 12px; font-weight: 800; color: #fff; letter-spacing: -0.2px; opacity: 0.9; }
    
    .level-progress-bg {
        width: 100%; height: 14px; background: rgba(255,255,255,0.1);
        border-radius: 20px; overflow: hidden; position: relative;
        border: 1px solid rgba(255,255,255,0.05);
    }
    .level-progress-fill {
        position: absolute; left: 0; top: 0; height: 100%;
        background: #fff; border-radius: 20px; width: 0%;
        transition: width 0.8s cubic-bezier(0.16, 1, 0.3, 1);
        display: flex; align-items: center; justify-content: center;
    }
    .xp-inside-text {
        font-size: 9px; font-weight: 800; color: #000;
        white-space: nowrap; pointer-events: none;
    }
    .xp-outside-text {
        position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
        font-size: 9px; font-weight: 800; color: rgba(255,255,255,0.4);
        white-space: nowrap; pointer-events: none; z-index: 0;
    }

    /* ── POSTS SECTION ── */
    .profile-posts-wrapper { width: 100%; max-width: 600px; margin: 0 auto; padding: 10px 0 120px; position: relative; clear: both; }
    /* 🐞 ระหว่างโหลดโพสต์ การ์ดโหลดอยู่ใต้กล่องนี้ (posts.html) → ระยะเผื่อท้าย 120px กลายเป็นช่องว่างเหนือการ์ดโหลด */
    #view-profile:has(#profile-grid-skeleton.active) .profile-posts-wrapper { padding-bottom: 0; }
    #view-profile:has(#profile-grid-skeleton.active) #profile-sub-components .portfolio { padding-bottom: 120px; }
    /* 🖥️ คอม (≥768px): เต็มหน้าต่างเหมือนหน้าแจ้งเตือน ไม่จำกัด 600px (กริดโพสต์ดู posts.html) */
    @media (min-width: 768px) {
        .cover-info-overlay { max-width: none; padding-left: 32px; padding-right: 32px; }
        .profile-posts-wrapper { max-width: none; }
    }
    /* 🖥️ คอม + หน้าต่างแนวนอน (แบบ Instagram เวอร์ชันคอม): ส่วนบนของโปรไฟล์อยู่กึ่งกลางในกรอบกว้าง 935px
       รูปโปรไฟล์ใหญ่ขึ้น (150px) วางคู่กับข้อมูล · มือถือ/แท็บเล็ต/หน้าต่างแนวตั้ง = แบบเดิม */
    @media (hover: hover) and (pointer: fine) and (min-width: 900px) {   /* คอม (เมาส์) จอแนวนอนหรือตั้งแนวตั้งก็ได้ */
        /* 🌟 หน้าต่างแนวนอนกว้าง ๆ: ข้อมูลกระจายเต็มขึ้น ไม่กองกลางจอ — กรอบกว้างขึ้นตามจอ (สูงสุด 1180px)
           รูปโปรไฟล์/ตัวอักษร/ระยะห่างโตตามความกว้างหน้าต่าง (clamp) จอ ~1000px ยังเท่าเดิม 🌟 */
        .cover-info-overlay {
            max-width: min(1180px, 86vw); padding-left: 24px; padding-right: 24px;
            justify-content: center; align-items: center; gap: clamp(20px, 3.4vw, 56px);
        }
        #view-profile { --av-size: clamp(150px, 13.5vw, 196px); --add-off: calc(var(--av-size) * 0.073); }
        .cover-info-overlay .avatar-wrap { width: var(--av-size); height: var(--av-size); }
        .cover-info-overlay .info-text-wrap { flex: 0 1 auto; min-width: 0; max-width: 720px; }
        /* ขนาดตัวอักษรโตตามจอ: ชื่อ 20→26 · @ 15→17 · ไบโอ 14→16 · สถิติ 16→19 */
        .cover-info-overlay .handle-display { font-size: clamp(20px, 1.85vw, 26px); min-height: 26px; margin-bottom: 4px; }
        .cover-info-overlay .handle { font-size: clamp(15px, 1.2vw, 17px); margin-bottom: 12px; }
        .cover-info-overlay .bio-text { font-size: clamp(14px, 1.12vw, 16px); line-height: 1.5; }
        .cover-info-overlay .inline-stats { font-size: clamp(16px, 1.35vw, 19px); gap: clamp(22px, 3vw, 44px); margin-top: 6px; }
        /* คำอธิบาย (ไบโอ) อยู่ใต้สถิติ แบบ Instagram: ชื่อ → @ → สถิติ → ไบโอ → ลิงก์ */
        .cover-info-overlay .info-text-wrap > .handle-display { order: 1; }
        .cover-info-overlay .info-text-wrap > .handle-row-inline { order: 2; }
        .cover-info-overlay .info-text-wrap > .inline-stats { order: 3; margin-top: 0; }
        .cover-info-overlay .info-text-wrap > .bio-text { order: 4; margin-top: 12px; margin-bottom: 0; }
        .cover-info-overlay .info-text-wrap > .profile-links-container { order: 5; }
        .cover-info-overlay .inline-stats .stat-val { font-size: inherit; }
        /* 🌟 จัดกึ่งกลางทั้งหมด (ซ้อนลงมาเป็นแนวตั้ง): รูปโปรไฟล์ → ชื่อ → @ → สถิติ → ไบโอ → ลิงก์ */
        .cover-info-overlay {
            max-width: 1040px; padding-left: 32px; padding-right: 32px;
            flex-direction: column; justify-content: flex-start; align-items: center; gap: 18px;
        }
        #view-profile { --av-size: clamp(140px, 11vw, 168px); }
        .cover-info-overlay .story-ring-wrapper { margin-top: 0; }
        .cover-info-overlay .info-text-wrap {
            flex: 0 0 auto; width: 100%; max-width: 720px;
            display: flex; flex-direction: column; align-items: center; text-align: center; padding-bottom: 0;
        }
        .cover-info-overlay .info-text-wrap > .handle-row-inline { display: flex; align-items: center; justify-content: center; position: relative; align-self: center; width: max-content; max-width: 100%; }
        /* ยึด @ชื่อผู้ใช้ไว้กึ่งกลาง — ยศลอยอยู่ด้านขวา ไม่ดันชื่อให้เยื้อง */
        .cover-info-overlay .info-text-wrap > .handle-row-inline > .hq-badges { position: absolute; left: 100%; top: 0; bottom: 12px; margin: 0 0 0 6px; display: inline-flex; align-items: center; white-space: nowrap; }
        .cover-info-overlay .info-text-wrap > .handle-row-inline > .hq-badges:empty { display: none; }
        /* โปรไฟล์จัดกึ่งกลาง: ตราเช็คยืนยันตัวตนอยู่หลัง @ชื่อผู้ใช้ · ยศอื่น (OWNER/DEV/…) ลงมาอีกบรรทัด */
        .cover-info-overlay .info-text-wrap > .handle-row-inline > .hq-badges .hq-badge:not(.seal) { display: none; }
        .cover-info-overlay .info-text-wrap > .pf-badges-row:not(:empty) { display: flex; order: 2; justify-content: center; flex-wrap: wrap; gap: 6px; margin: -4px 0 12px; }
        .cover-info-overlay .info-text-wrap > .bio-text { max-width: 560px; text-align: center; }
        .cover-info-overlay .info-text-wrap > .profile-links-container { justify-content: center; }
        .cover-info-overlay .info-text-wrap > .inline-stats {
            justify-content: center; flex-wrap: nowrap; gap: clamp(36px, 4vw, 64px); margin-top: 8px;
        }
        .cover-info-overlay .inline-stats .stat-btn { flex-direction: column; align-items: center; gap: 2px; }
        .cover-info-overlay .inline-stats .stat-val { font-size: clamp(22px, 2.1vw, 30px); font-weight: 800; line-height: 1.15; }
        .cover-info-overlay .inline-stats .stat-btn > span:not(.stat-val) { font-size: clamp(12.5px, 0.95vw, 14px); color: rgba(255,255,255,0.6); font-weight: 500; }
        .cover-info-overlay .hq-badge:not(.seal) { height: 20px; font-size: 11px; }
        /* ปุ่มสร้างไฮไลต์ย้ายไปมุมขวาบน (ซ้ายของปุ่มสร้างโพสต์) — เฉพาะเจ้าของโปรไฟล์ */
        #view-profile.is-owner .hl-nav-btn { display: flex !important; }
        /* หน้าตาเดียวกับปุ่มสร้างไฮไลต์เดิม (กรอบมนเส้นจุด) แต่เล็กลง จุดน้อยลง (12 จุด) */
        /* ทั้งปุ่มรวมกรอบ = ขนาดเท่าไอคอนปุ่มสร้างโพสต์ (กรอบ 22px ในพื้นที่กด 34px เท่าปุ่มข้างๆ) */
        #view-profile .hl-nav-btn {
            border: none !important;
            background: transparent url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22'%3E%3Crect x='1' y='1' width='20' height='20' rx='6.5' ry='6.5' pathLength='100' fill='none' stroke='white' stroke-opacity='0.85' stroke-width='1.6' stroke-dasharray='0.1 8.233' stroke-linecap='round'/%3E%3C/svg%3E") center / 22px 22px no-repeat !important;
            align-items: center; justify-content: center;
        }
        #view-profile .hl-nav-btn i { font-size: 13px; }
    }
    .profile-empty-state { display: none; flex-direction: column; align-items: center; justify-content: center; padding: 40px 20px; text-align: center; color: var(--txt2); position: relative; z-index: 1; }
    .profile-empty-state i { font-size: 48px; margin-bottom: 12px; color: rgba(255,255,255,0.3); }
    .profile-empty-state .msg { font-size: 14px; font-weight: 600; line-height: 1.5; color: #fff; }

    /* 📈 แดชบอร์ดสถิติของเจ้าของ (หน้าต่างผู้เข้าชมโปรไฟล์) — ขาวดำมินิมอล */
    #views-modal .ep-content { max-width: 440px; }
    #views-modal .ep-body { overflow-y: auto; }
    .pst-h { font-size: 12px; font-weight: 700; letter-spacing: .04em; color: rgba(255,255,255,.45); margin: 18px 6px 8px; }
    .pst-tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
    .pst-tile { background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.06); border-radius: 18px; padding: 12px 14px; cursor: pointer; text-align: left; color: #fff; font: inherit; transition: background .2s, border-color .2s; }
    .pst-tile.on { background: rgba(255,255,255,.12); border-color: rgba(255,255,255,.22); }
    .pst-tile .v { font-size: 22px; font-weight: 800; letter-spacing: -.02em; line-height: 1.15; font-variant-numeric: tabular-nums; }
    .pst-tile .l { font-size: 12px; color: rgba(255,255,255,.55); margin-top: 2px; }
    .pst-tile .d { font-size: 11px; font-weight: 700; margin-top: 4px; color: rgba(255,255,255,.4); }
    .pst-tile .d.up { color: #5ee6a0; } .pst-tile .d.down { color: #ff7f8d; }
    .pst-chart { display: flex; align-items: flex-end; gap: 4px; height: 120px; padding: 14px 4px 0; }
    .pst-bar { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 5px; min-width: 0; }
    .pst-bar i { display: block; width: 100%; max-width: 18px; border-radius: 6px 6px 3px 3px; background: rgba(255,255,255,.85); min-height: 2px; transition: height .5s cubic-bezier(.2,.8,.2,1); }
    .pst-bar.zero i { background: rgba(255,255,255,.12); }
    .pst-bar b { font-size: 9.5px; font-weight: 600; color: rgba(255,255,255,.35); }
    .pst-bar.today b { color: #fff; }
    .pst-note { font-size: 11.5px; color: rgba(255,255,255,.4); margin: 8px 6px 0; line-height: 1.45; }
    .pst-row { display: flex; align-items: center; gap: 10px; padding: 7px 6px; font-size: 13px; }
    .pst-row .n { flex: 0 0 38%; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #fff; font-weight: 600; }
    .pst-row .track { flex: 1; height: 6px; border-radius: 3px; background: rgba(255,255,255,.08); overflow: hidden; }
    .pst-row .track i { display: block; height: 100%; background: #fff; border-radius: 3px; }
    .pst-row .c { flex: 0 0 auto; font-size: 12px; color: rgba(255,255,255,.55); font-variant-numeric: tabular-nums; }
    .pst-split { display: flex; height: 8px; border-radius: 4px; overflow: hidden; margin: 4px 6px 6px; background: rgba(255,255,255,.08); }
    .pst-split i { display: block; height: 100%; }
    .pst-legend { display: flex; justify-content: space-between; font-size: 12px; color: rgba(255,255,255,.55); margin: 0 6px; }
    .pst-posts { display: flex; gap: 8px; overflow-x: auto; padding: 2px 4px 6px; scrollbar-width: none; }
    .pst-post { flex: 0 0 104px; cursor: pointer; }
    .pst-post .im { width: 104px; aspect-ratio: 4 / 5; border-radius: 14px; background: rgba(255,255,255,.06) center / cover no-repeat; }
    .pst-post .m { display: flex; gap: 8px; font-size: 11px; color: rgba(255,255,255,.65); margin-top: 6px; font-variant-numeric: tabular-nums; }
    .pst-post .m span { display: inline-flex; align-items: center; gap: 2px; }
    .pst-skel { height: 220px; border-radius: 18px; background: rgba(255,255,255,.05); animation: pulse 1.5s infinite ease-in-out; }

    /* ── UNIFIED PREMIUM MODALS ── */
    .ep-modal, .level-modal, .views-modal { 
        display: none; position: fixed !important; inset: 0 !important; z-index: 1000000 !important; 
        background: rgba(0,0,0,0.85); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
        justify-content: center; align-items: center; padding: 20px; box-sizing: border-box; 
    }
    .ep-content {
        width: 100%; max-width: 400px; background: rgba(18,18,18,0.8); backdrop-filter: blur(30px); -webkit-backdrop-filter: blur(30px);
        border-radius: 32px; border: 1px solid rgba(255,255,255,0.08); overflow: hidden;
        animation: sysPopIn 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
        display: flex; flex-direction: column; box-shadow: 0 40px 100px rgba(0,0,0,0.8);
    }
    /* ℹ️ หน้าต่างเกี่ยวกับโปรไฟล์ — ขาวดำมินิมอล: เลเวล (วงแหวน) · ตัวเลขหลัก 2 ช่อง · รายการข้อมูลมีไอคอน */
    #about-profile-modal .ep-content.ap-card {
        max-width: 380px; border-radius: 40px; padding: 10px 18px 20px; box-sizing: border-box; gap: 0;
        background: rgba(14,14,14,0.86); border: 0.5px solid rgba(255,255,255,0.12);
        font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, system-ui, sans-serif;
    }
    .ap-grab { width: 36px; height: 4px; border-radius: 2px; background: rgba(255,255,255,0.18); margin: 4px auto 14px; }
    .ap-title { text-align: center; font-size: 13px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: rgba(255,255,255,0.45); margin-bottom: 16px; }
    .ap-level { display: flex; align-items: center; gap: 16px; padding: 16px; border-radius: 26px; background: rgba(255,255,255,0.05); margin-bottom: 10px; }
    .ap-ring { position: relative; width: 64px; height: 64px; flex: none; }
    .ap-ring svg { width: 64px; height: 64px; transform: rotate(-90deg); }
    .ap-ring circle { fill: none; stroke-width: 5; }
    .ap-ring-bg { stroke: rgba(255,255,255,0.1); }
    .ap-ring-fg { stroke: #fff; stroke-linecap: round; stroke-dasharray: 169.6; stroke-dashoffset: 169.6; transition: stroke-dashoffset 1s cubic-bezier(0.16, 1, 0.3, 1); }
    .ap-ring-num { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1; color: #fff; }
    .ap-ring-num small { font-size: 9px; font-weight: 700; letter-spacing: 0.08em; color: rgba(255,255,255,0.5); text-transform: uppercase; }
    .ap-ring-num span { font-size: 20px; font-weight: 800; margin-top: 2px; }
    .ap-level-info { flex: 1; min-width: 0; }
    .ap-level-head { font-size: 15px; font-weight: 700; color: #fff; margin-bottom: 8px; }
    .ap-level-bar { height: 6px; border-radius: 3px; background: rgba(255,255,255,0.1); overflow: hidden; }
    .ap-level-bar .ap-fill { height: 100%; width: 0%; background: #fff; border-radius: 3px; transition: width 1s cubic-bezier(0.16, 1, 0.3, 1); }
    .ap-level-xp { margin-top: 7px; font-size: 12px; font-weight: 600; color: rgba(255,255,255,0.45); font-variant-numeric: tabular-nums; }
    .ap-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 10px; }
    .ap-stat { padding: 16px 16px 14px; border-radius: 26px; background: rgba(255,255,255,0.05); color: #fff; }
    .ap-stat i { font-size: 19px; color: rgba(255,255,255,0.55); }
    .ap-stat-val { font-size: 26px; font-weight: 800; letter-spacing: -0.5px; margin-top: 10px; line-height: 1.1; font-variant-numeric: tabular-nums; }
    .ap-stat-lbl { font-size: 12.5px; color: rgba(255,255,255,0.45); margin-top: 3px; }
    .ap-stat.ap-tap { cursor: pointer; transition: transform 0.15s, background 0.15s; }
    .ap-stat.ap-tap:active { transform: scale(0.96); background: rgba(255,255,255,0.09); }
    .ap-list { border-radius: 26px; background: rgba(255,255,255,0.05); padding: 4px 0; }
    .ap-row { display: flex; align-items: center; gap: 12px; padding: 11px 16px; }
    .ap-row + .ap-row { border-top: 0.5px solid rgba(255,255,255,0.06); }
    .ap-ic { width: 32px; height: 32px; border-radius: 11px; background: #fff; color: #000; display: flex; align-items: center; justify-content: center; font-size: 17px; flex: none; }
    .ap-k { flex: 1; font-size: 14.5px; color: rgba(255,255,255,0.6); }
    .ap-v { font-size: 14.5px; font-weight: 600; color: #fff; text-align: right; }
    .ep-header { 
        padding: 24px 20px 20px; border-bottom: 1px solid rgba(255,255,255,0.05); 
        text-align: center; font-weight: 850; font-size: 16px; position: relative; flex-shrink: 0; color: #fff;
        letter-spacing: -0.2px; text-transform: uppercase;
    }
    .ep-close { 
        position: absolute; right: 16px; top: 16px; 
        background: rgba(255,255,255,0.05); border: none; color: #fff; 
        width: 36px; height: 36px; border-radius: 50%; cursor: pointer; 
        display: flex; align-items: center; justify-content: center; font-size: 24px;
        transition: 0.2s;
    }
    .ep-close:active { transform: scale(0.9); background: rgba(255,255,255,0.1); }
    .ep-body { flex: 1; overflow-y: auto; padding: 8px 0; max-height: 75vh; display: flex; flex-direction: column; }
    
    .ep-row { 
        display: flex; align-items: center; gap: 14px; padding: 14px 20px; 
        cursor: pointer; transition: 0.2s; position: relative; 
        border-bottom: 1px solid rgba(255,255,255,0.03);
    }
    .ep-row:last-child { border-bottom: none; }
    .ep-row:active { background: rgba(255,255,255,0.04); transform: scale(0.98); }
    
    .ep-avatar { width: 50px; height: 50px; border-radius: 50%; object-fit: cover; background: #222; flex-shrink: 0; border: none; }
    .ep-info { flex: 1; display: flex; flex-direction: column; gap: 1px; overflow: hidden; }
    .ep-name { font-weight: 700; color: #fff; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .ep-uname { color: rgba(255,255,255,0.4); font-size: 12px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

    @keyframes sysPopIn { from { transform: scale(0.92) translateY(10px); opacity: 0; } to { transform: scale(1) translateY(0); opacity: 1; } }
    
    /* ── PAPER PLANE MODAL ── */
    .paper-modal {
        position: fixed; inset: 0; z-index: 10000; background: rgba(0,0,0,0.9); backdrop-filter: blur(15px);
        display: none; align-items: center; justify-content: center; padding: 20px;
    }
    .paper-container { width: 100%; max-width: 380px; position: relative; perspective: 2500px; }
    .paper-sheet {
        background: #fff; padding: 45px 35px; border-radius: 2px; position: relative;
        box-shadow: 0 15px 45px rgba(0,0,0,0.4); transform-style: preserve-3d;
        transition: transform 1s cubic-bezier(0.23, 1, 0.32, 1), opacity 0.5s;
    }
    .paper-sheet::before {
        content: ''; position: absolute; top: 0; right: 0; width: 40px; height: 40px;
        background: linear-gradient(225deg, rgba(0,0,0,0.05) 50%, #fff 50%);
    }
    .paper-title { color: #000; font-size: 20px; font-weight: 950; letter-spacing: -1px; border-bottom: 2.5px solid #000; padding-bottom: 10px; margin-bottom: 25px; text-transform: uppercase; }
    
    .paper-input {
        width: 100%; border: none; background: transparent; color: #000; font-family: inherit;
        font-size: 16px; font-weight: 700; padding: 12px 0; border-bottom: 1.5px solid rgba(0,0,0,0.1);
        outline: none; margin-bottom: 15px;
    }
    .paper-textarea {
        width: 100%; border: none; background: transparent; color: #000; font-family: inherit;
        font-size: 16px; font-weight: 600; line-height: 1.6; padding: 12px 0; outline: none; min-height: 140px; resize: none;
    }
    .paper-footer { display: flex; justify-content: space-between; align-items: center; margin-top: 25px; }
    .paper-btn-send {
        background: #000; color: #fff; border: none; border-radius: 40px;
        padding: 12px 30px; font-weight: 900; font-size: 12px; cursor: pointer; transition: 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    }
    .paper-btn-send:active { transform: scale(0.85); }
    .paper-btn-close { color: #000; font-size: 26px; cursor: pointer; opacity: 0.3; transition: 0.2s; }
    .paper-btn-close:hover { opacity: 1; }

    /* 📍 ปุ่มแนบตำแหน่งในจดหมาย */
    /* หมุด GPS แบบไอคอนเติมสี (Phosphor ชุดเดียวกับเมนูบาร์) ไม่มีวงกลมรอบ — แนบแล้ว = เข้มเต็ม */
    .paper-btn-loc {
        width: 38px; height: 38px; border: none; padding: 0;
        background: transparent; color: #000; opacity: 0.35; cursor: pointer;
        display: flex; align-items: center; justify-content: center; font-size: 24px;
        transition: 0.2s; touch-action: manipulation; flex-shrink: 0;
    }
    .paper-btn-loc:active { transform: scale(0.85); }
    .paper-btn-loc.active { opacity: 1; }
    .paper-btn-loc.loading { opacity: 0.8; animation: pulse 1s infinite ease-in-out; }

    @keyframes fold-and-fly {
        0% { transform: translate3d(0,0,0) rotateX(0deg) scale(1); clip-path: inset(0% 0% 0% 0%); opacity: 1; }
        
        /* Phase 1: Fold into a sleek plane */
        25% { transform: translate3d(0, 10px, 0) rotateX(25deg) scale(0.95); clip-path: polygon(50% 0%, 100% 100%, 50% 85%, 0% 100%); opacity: 1; }
        
        /* Phase 2: Dip down slightly to catch wind */
        40% { transform: translate3d(0, 40px, -100px) rotateX(45deg) scale(0.8); clip-path: polygon(50% 0%, 100% 100%, 50% 85%, 0% 100%); }
        
        /* Final Phase: Launch deep into the distance (Z-axis) and upwards (Y-axis) */
        100% { transform: translate3d(0, -1200px, -4000px) rotateX(90deg) scale(0); clip-path: polygon(50% 0%, 100% 100%, 50% 85%, 0% 100%); opacity: 0; }
    }
    .paper-sending { animation: fold-and-fly 2s cubic-bezier(0.55, 0.055, 0.675, 0.19) forwards; }

    .ep-content { width: 100%; max-width: 400px; background: var(--popup-theme); border-radius: 20px; border: 1px solid rgba(255,255,255,0.1); overflow: hidden; animation: popIn 0.3s ease; display: flex; flex-direction: column; box-shadow: none;}
    .ep-header { padding: 16px; border-bottom: 1px solid rgba(255,255,255,0.1); text-align: center; font-weight: 700; font-size: 16px; position: relative; flex-shrink: 0; color: #fff;}
    .ep-close { position: absolute; right: 16px; top: 50%; transform: translateY(-50%); background: rgba(255,255,255,0.1); border-radius: 50%; width: 30px; height: 30px; border: none; color: #fff; font-size: 20px; cursor: pointer; display: flex; align-items: center; justify-content: center; }
    .ep-body { padding: 20px; display: flex; flex-direction: column; gap: 15px; max-height: 70vh; overflow-y: auto; }
    
    .color-picker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); gap: 10px; padding: 10px 5px; max-height: 400px; overflow-y: auto; }
    .color-picker-grid::-webkit-scrollbar { display: none; }
    .color-circle { width: 40px; height: 40px; border-radius: 50%; cursor: pointer; border: 2px solid transparent; transition: 0.2s; }
    .color-circle.active { border-color: #fff; transform: scale(1.15); }

    /* ── PROFILE LINKS ── */
    .profile-links-container {
        display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px;
        width: 100%;
    }
    .profile-link-capsule {
        padding: 3px 12px; border-radius: 20px; font-size: 10px; font-weight: 800;
        background: var(--profile-link-bg, rgba(255,255,255,0.08));
        color: #fff; border: none; transition: 0.2s; cursor: pointer;
        display: flex; align-items: center; gap: 4px;
    }
    .profile-link-capsule:active { transform: scale(0.95); opacity: 0.8; }
    .profile-link-capsule .pl-ic { font-size: 13px; line-height: 1; color: #fff; margin-left: -3px; display: inline-flex; }
    .profile-link-capsule .pl-svg svg { width: 13px; height: 13px; display: block; }
    .profile-link-capsule.add-btn {
        background: rgba(255,255,255,0.05); color: rgba(255,255,255,0.3);
    }
    
    @keyframes popIn { from { transform: scale(0.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }

    /* ── AVATAR FULLSCREEN VIEWER (IG-style) ── */
    /* 🌟 แบบไอจี: แตะรูปโปรไฟล์ → วงกลมขยายออกจากตำแหน่งรูปจริงไปเป็นวงกลมใหญ่กลางจอ พื้นหลังเบลอค่อย ๆ เข้ม
       ปุ่มด้านล่าง (ติดตาม/แชร์/คัดลอกลิงก์) ค่อย ๆ โผล่ · ปิด = หดกลับเข้าที่เดิม */
    /* ปุ่ม "ติดตามกลับ" บนแถบโปรไฟล์ (บัญชีนั้นติดตามเราอยู่) */
    #view-profile .nav-follow-icon.follow-back {
        width: auto !important; padding: 0 14px 0 10px; gap: 5px; border-radius: 18px !important;
        background: #fff !important; color: #000 !important; font-size: 13.5px; font-weight: 700; white-space: nowrap;
    }
    #view-profile .nav-follow-icon.follow-back i { font-size: 18px; }
    #avatar-viewer-overlay {
        position: fixed; inset: 0; z-index: 999999;
        display: none; align-items: center; justify-content: center; cursor: zoom-out;
        -webkit-tap-highlight-color: transparent;
    }
    #avatar-viewer-overlay .avv-bg {
        position: absolute; inset: 0; background: rgba(0,0,0,0.45);
        backdrop-filter: blur(36px) saturate(1.2); -webkit-backdrop-filter: blur(36px) saturate(1.2);
        opacity: 0; transition: opacity 0.3s ease;
    }
    #avatar-viewer-overlay.shown .avv-bg { opacity: 1; }
    #avatar-viewer-img {
        position: relative; z-index: 1;
        width: min(78vw, 64vh, 420px); height: min(78vw, 64vh, 420px);
        border-radius: 50%; object-fit: cover; transform-origin: 0 0;
        pointer-events: none; user-select: none; -webkit-user-drag: none;
        box-shadow: 0 30px 80px rgba(0,0,0,0.55);
        margin-bottom: 12vh;   /* ยกขึ้นเหนือกึ่งกลางเล็กน้อย */
    }
    #avatar-viewer-overlay .avv-actions { display: none !important; }   /* ขยายรูปโปรไฟล์: ไม่มีปุ่มใต้รูป */
    #avatar-viewer-overlay .avv-actions {
        position: absolute; z-index: 2; left: 0; right: 0; bottom: calc(env(safe-area-inset-bottom) + 34px);
        display: flex; justify-content: center; gap: 34px;
        opacity: 0; transform: translateY(14px); transition: opacity 0.28s ease 0.12s, transform 0.32s cubic-bezier(0.2, 0.85, 0.25, 1) 0.12s;
    }
    #avatar-viewer-overlay.shown .avv-actions { opacity: 1; transform: none; }
    #avatar-viewer-overlay.closing .avv-actions { transition-delay: 0s; }
    .avv-act { display: flex; flex-direction: column; align-items: center; gap: 7px; background: none; border: none; color: #fff; cursor: pointer; font-size: 12px; font-family: inherit; }
    .avv-act .ic { width: 48px; height: 48px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 22px;
        background: rgba(255,255,255,0.14); border: 0.5px solid rgba(255,255,255,0.18); transition: transform 0.15s, background 0.15s; }
    .avv-act:active .ic { transform: scale(0.9); background: rgba(255,255,255,0.24); }

    /* 🌟 ดึงจอลงมาบนสุด = รีเฟรชข้อมูลโปรไฟล์ (ไม่ใช่โหลดหน้าเว็บใหม่) — ดู window.setupPullToRefresh
       ใน feed.html (โหลดก่อนไฟล์นี้เสมอ จึงเรียกใช้ร่วมกันได้) แบบเดียวกับเฟซบุ๊ค/ทวิตเตอร์
       เนื้อหา (#profile-data-content) เลื่อนลงตามระยะที่ดึง เผยพื้นที่ว่างด้านบนออกมา ตัวชี้วัดโผล่มาโชว์
       "ในพื้นที่ว่างนั้นเป๊ะ"
       🌟 ควบคุมการโชว์/ซ่อนด้วย opacity ตรงๆ จาก JS เท่านั้น (ของเดิมใช้ top ติดลบ + overflow ของ
       .app-view บังไว้แทน ซึ่งบางเบราว์เซอร์/โหมด PWA เอาไม่อยู่ ทำให้บางทีโผล่ให้เห็นทั้งที่ยังไม่ได้
       ดึงจอเลย) การันตีว่าโผล่มาเฉพาะตอนกำลังดึงจอลงจริงๆ เท่านั้น 100%
       🌟 เปลี่ยนจากวงแหวนหมุนเป็นจุดไข่ปลา 3 จุด — ตอนแรกเป็นวงกลมกลวง (แค่เส้นขอบ) ยิ่งดึงจอลงจุด
       จะค่อยๆ ทึบขึ้นทีละจุดจนครบ 3 จุด (ดู setPct ใน setupPullToRefresh ที่หาร progress เป็น 3 ช่วง) 🌟 */
    .ptr-indicator {
        position: absolute; top: max(8px, env(safe-area-inset-top)); left: 50%; z-index: 5;
        width: 34px; height: 34px;
        transform: translate(-50%, 0);
        display: flex; align-items: center; justify-content: center; gap: 6px;
        opacity: 0; visibility: hidden; pointer-events: none;
    }
    .ptr-indicator .ptr-dot {
        width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
        border: 1.5px solid rgba(255,255,255,0.5);
        box-sizing: border-box; position: relative;
    }
    .ptr-indicator .ptr-dot-fill {
        position: absolute; inset: 0; border-radius: 50%; background: #fff;
        transform: scale(0); transition: transform 0.08s linear;
    }
    .ptr-indicator.ptr-spinning .ptr-dot-fill { animation: ptrDotPulse 1s ease-in-out infinite; }
    .ptr-indicator.ptr-spinning .ptr-dot:nth-child(2) .ptr-dot-fill { animation-delay: 0.15s; }
    .ptr-indicator.ptr-spinning .ptr-dot:nth-child(3) .ptr-dot-fill { animation-delay: 0.3s; }
    @keyframes ptrDotPulse { 0%, 100% { transform: scale(0.3); opacity: 0.4; } 50% { transform: scale(1); opacity: 1; } }
