

  :root{
    --blue:#1877F2;
    --bg:#F0F2F5; --card:#FFFFFF; --text:#050505; --sec:#65676B;
    --bubble:#F0F2F5; --divider:#CED0D4; --icon:#65676B; --chipbg:#E4E6EB;
    --pillbg:#FFFFFF; --pillshadow:0 1px 2px rgba(0,0,0,.2);
  }
  body.dark{
    --bg:#18191A; --card:#242526; --text:#E4E6EB; --sec:#B0B3B8;
    --bubble:#3A3B3C; --divider:#3E4042; --icon:#B0B3B8; --chipbg:#3A3B3C;
    --pillbg:#3A3B3C; --pillshadow:0 1px 2px rgba(0,0,0,.5);
  }
  *{box-sizing:border-box; -webkit-tap-highlight-color:transparent;}
  html,body{margin:0;padding:0;}
  body{
    background:var(--bg); color:var(--text);
    font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif;
    padding-top:env(safe-area-inset-top);
    padding-bottom:env(safe-area-inset-bottom);
  }
  [contenteditable]{outline:none;}
  body.edit [contenteditable="true"]:focus{outline:1.5px dashed var(--blue); outline-offset:2px; border-radius:4px;}
  img{display:block;}
  svg{display:block;}

  /* ---------- top bar ---------- */
  .topbar{
    background:var(--card);
    display:flex; align-items:center; justify-content:space-between;
    padding:8px 14px 4px 14px;
  }
  .fblogo{
    color:var(--blue); font-size:28px; font-weight:800; letter-spacing:-0.7px;
    font-family:Helvetica,Arial,sans-serif; user-select:none;
  }
  .topicons{display:flex; gap:10px;}
  .chip{
    width:38px;height:38px;border-radius:50%;
    background:var(--chipbg); display:flex;align-items:center;justify-content:center;
  }
  .chip svg{width:20px;height:20px;fill:var(--text);}

  /* ---------- tabs ---------- */
  .tabs{
    background:var(--card); display:flex;
    border-bottom:1px solid var(--divider);
  }
  .tab{
    flex:1; display:flex; align-items:center; justify-content:center;
    padding:10px 0 9px 0; position:relative;
  }
  .tab svg{width:26px;height:26px;fill:var(--icon);}
  .tab.active svg{fill:var(--blue);}
  .tab.active::after{
    content:""; position:absolute; left:12%; right:12%; bottom:0;
    height:3px; background:var(--blue); border-radius:2px 2px 0 0;
  }

  /* ---------- post card ---------- */
  .card{background:var(--card); margin-top:8px;}
  .posthead{display:flex; align-items:flex-start; padding:12px 16px 0 16px;}
  .avatar{border-radius:50%; object-fit:cover; background:#ccc; flex:none;}
  .posthead .avatar{width:40px;height:40px;}
  .phinfo{flex:1; margin-left:10px; min-width:0;}
  .pname{font-size:16.5px; font-weight:600; line-height:1.25;}
  .psub{font-size:13px; color:var(--sec); display:flex; align-items:center; gap:4px; margin-top:1px;}
  .psub svg{width:12px;height:12px;fill:var(--sec);}
  .editedmark{display:none;}
  .editedmark b{font-weight:700; color:var(--text);}
  body.show-edited .editedmark{display:inline;}
  .phactions{display:flex; align-items:center; gap:14px; color:var(--sec); padding-top:4px;}
  .phactions svg{width:20px;height:20px;fill:var(--sec);}
  .ptext{padding:8px 16px 10px 16px; font-size:17px; line-height:1.4; white-space:pre-wrap; word-wrap:break-word;}
  .pimgwrap{position:relative;}
  .pimg{width:100%; max-height:70vh; object-fit:cover;}

  /* stats */
  .stats{
    display:flex; align-items:center; justify-content:space-between;
    padding:10px 16px; font-size:14px; color:var(--sec);
  }
  .reactions{display:flex; align-items:center; gap:6px;}
  .ricons{display:flex;}
  .ricon{
    width:18px;height:18px;border-radius:50%;
    display:flex;align-items:center;justify-content:center;
    border:1.5px solid var(--card);
  }
  .ricon+.ricon{margin-left:-4px;}
  .ricon.like{background:var(--blue);}
  .ricon.love{background:linear-gradient(#FF6680,#E41E3F);}
  .ricon svg{width:10px;height:10px;fill:#fff;}
  .rstats span[contenteditable]{min-width:8px; display:inline-block;}

  /* action buttons */
  .actions{
    display:flex; border-top:1px solid var(--divider);
    margin:0 12px; padding:2px 0;
  }
  .abtn{
    flex:1; display:flex; align-items:center; justify-content:center; gap:6px;
    padding:9px 0; color:var(--sec); font-size:14px; font-weight:600;
    border-radius:6px; user-select:none;
  }
  .abtn svg{width:19px;height:19px;fill:var(--sec);}

  /* ---------- comments ---------- */
  .comments{padding:4px 16px 10px 16px;}
  .csort{
    display:flex; align-items:center; gap:4px; padding:8px 0 10px 0;
    font-size:14px; font-weight:600; color:var(--sec);
  }
  .csort svg{width:14px;height:14px;fill:var(--sec);}
  .comment{display:flex; margin-bottom:12px; position:relative;}
  .comment .avatar{width:32px;height:32px; margin-top:2px;}
  .comment.reply{margin-left:42px;}
  .comment.reply .avatar{width:26px;height:26px;}
  .cbody{margin-left:8px; min-width:0; max-width:calc(100% - 60px);}
  .bubble{
    background:var(--bubble); border-radius:18px; padding:8px 12px;
    position:relative; display:inline-block; min-width:60px;
  }
  .cname{font-size:14.5px; font-weight:600; line-height:1.3;}
  .ctext{font-size:17px; line-height:1.38; word-wrap:break-word; white-space:pre-wrap;}
  .likepill{
    position:absolute; right:-8px; bottom:-10px;
    background:var(--pillbg); border-radius:11px; box-shadow:var(--pillshadow);
    display:flex; align-items:center; gap:3px; padding:2px 6px 2px 3px;
    font-size:12px; color:var(--sec);
  }
  .likepill .rc{
    width:16px;height:16px;border-radius:50%;
    display:flex;align-items:center;justify-content:center; flex:none;
  }
  .likepill .rc+.rc{margin-left:-4px;}
  .likepill .rc.like{background:var(--blue);}
  .likepill .rc.love{background:linear-gradient(#FF6680,#E41E3F);}
  .likepill .rc svg{width:9px;height:9px;fill:#fff;}
  .likepill .rc.emo{font-size:13px;background:none;}
  .rstack{display:flex;align-items:center;}
  .likepill.hidden{display:none;}
  /* author badge (like FB's "Author" tag on creator comments) */
  .cnamerow{display:flex;align-items:center;gap:5px;}
  .abadge{
    display:inline-flex;align-items:center;gap:3px; flex:none;
    background:var(--chipbg); color:var(--sec);
    font-size:10.5px;font-weight:600;border-radius:9px;padding:1.5px 6px;
  }
  .abadge svg{width:9px;height:9px;fill:var(--sec);}
  /* comment images */
  .cimg{max-width:62%;max-height:220px;width:auto;object-fit:cover;border-radius:14px;margin-top:6px;display:block;}
  /* profile post images */
  .pvimg{width:100%;border-radius:10px;margin:2px 0 8px 0;display:block;}
  .cmeta{
    display:flex; gap:16px; font-size:13px; color:var(--sec);
    margin:5px 0 0 12px;
  }
  .cmeta b{font-weight:600; cursor:default;}
  /* comment edit controls */
  .editbar{
    position:absolute; right:0; top:-6px; display:none; gap:6px;
  }
  body.edit .editbar{display:flex;}
  .mini{
    width:26px;height:26px;border-radius:50%; border:none;
    background:var(--chipbg); color:var(--sec); font-size:13px; line-height:1;
    display:flex;align-items:center;justify-content:center; opacity:.85;
  }
  .addcomment{display:none; margin:2px 0 10px 0;}
  body.edit .addcomment{display:block;}
  .addcomment button, .addbtn{
    border:1.5px dashed var(--sec); background:none; color:var(--sec);
    border-radius:18px; padding:7px 14px; font-size:13px; font-weight:600;
  }

  /* comment input bar */
  .cinput{
    position:sticky; bottom:0; background:var(--card);
    border-top:1px solid var(--divider);
    display:flex; align-items:center; gap:8px; padding:8px 12px calc(8px + env(safe-area-inset-bottom)) 12px;
  }
  .cinput .avatar{width:32px;height:32px;}
  .cfield{
    flex:1; display:flex; align-items:center;
    background:var(--bubble); border-radius:18px; padding:0 4px 0 14px;
  }
  .cfield input{
    flex:1; border:none; background:none; outline:none;
    font-size:15px; color:var(--text); padding:9px 0;
    font-family:inherit; min-width:0;
  }
  .cfield input::placeholder{color:var(--sec);}
  #cSend, #cPhotoBtn{
    border:none; background:none; padding:6px 6px; flex:none;
    display:flex; align-items:center;
  }
  #cSend svg{width:20px;height:20px;fill:var(--blue);}
  #cPhotoBtn svg{width:20px;height:20px;fill:var(--sec);}
  #cPhotoPreview{
    width:26px;height:26px;border-radius:6px;object-fit:cover;
    flex:none;display:none;margin-right:2px;
  }

  /* interactive likes */
  .abtn.liked{color:var(--blue);}
  .abtn.liked svg{fill:var(--blue);}
  .j-clike.liked{color:var(--blue);}
  body.film .abtn, body.film .j-clike, body.film .j-creply{cursor:pointer;}

  /* ---------- profile view ---------- */
  #profileView{display:none;}
  body.view-profile #profileView{display:block;}
  body.view-profile .topbar, body.view-profile .tabs,
  body.view-profile #feedView, body.view-profile .cinput{display:none;}

  .pv-top{
    position:sticky; top:0; z-index:40; background:var(--card);
    display:flex; align-items:center; gap:12px; padding:10px 14px;
    border-bottom:1px solid var(--divider);
  }
  .pv-top .navbtn{border:none;background:none;padding:4px;margin:-4px;}
  .pv-top svg{width:24px;height:24px;fill:var(--text);}
  .pv-topname{flex:1; font-size:17px; font-weight:700; white-space:nowrap; overflow:hidden; text-overflow:ellipsis;}
  .pv-cover{height:150px; background:#8aa; background-size:cover; background-position:center;}
  .pv-head{background:var(--card); padding:0 16px 14px 16px;}
  .pv-avatar{
    width:110px;height:110px;border-radius:50%;
    border:4px solid var(--card); margin-top:-55px;
    object-fit:cover; background:#ccc;
  }
  .pv-name{font-size:24px; font-weight:800; margin-top:8px; line-height:1.2;}
  .pv-bio{font-size:15px; margin-top:3px;}
  .pv-friends{font-size:15px; color:var(--sec); margin-top:4px;}
  .pv-friends b{color:var(--text);}
  .pv-btns{display:flex; gap:8px; margin-top:12px;}
  .pbtn2{
    flex:1; border:none; border-radius:8px; padding:9px 0;
    font-size:15px; font-weight:600; background:var(--chipbg); color:var(--text);
  }
  .pbtn2.primary{background:var(--blue); color:#fff;}
  .pv-sec{background:var(--card); margin-top:8px; padding:12px 16px;}
  .pv-sect{font-size:17px; font-weight:700; margin-bottom:10px;}
  .inforow{display:flex; align-items:flex-start; gap:10px; margin-bottom:11px; font-size:15px; position:relative;}
  .inforow svg{width:20px;height:20px;fill:var(--sec);flex:none; margin-top:1px;}
  .inforow .itext{flex:1;}
  .inforow .mini{position:absolute; right:0; top:0; display:none;}
  body.edit .inforow .mini{display:flex;}
  .fgrid{display:grid; grid-template-columns:repeat(3,1fr); gap:8px;}
  .fcell img{width:100%; aspect-ratio:1; border-radius:8px; object-fit:cover; background:#ccc;}
  .fcell div{font-size:12.5px; font-weight:600; margin-top:4px; line-height:1.2;}
  .seeall{
    margin-top:12px; width:100%; border:none; background:var(--chipbg);
    color:var(--text); border-radius:8px; padding:8px 0; font-weight:600; font-size:14px;
  }
  .pv-post{border-top:1px solid var(--divider); padding-top:12px; margin-top:12px; position:relative;}
  .pv-post .posthead{padding:0;}
  .pv-post .ptext{padding:8px 0 10px 0;}
  .pv-post .stats{padding:10px 0;}
  .pv-post .actions{margin:0;}
  .pv-post .editbar{top:0;}
  .pv-editonly{display:none; margin-top:12px;}
  body.edit .pv-editonly{display:block;}

  /* ---------- edit UI ---------- */
  #gear{
    position:fixed; right:14px; bottom:76px; z-index:60;
    width:48px;height:48px;border-radius:50%; border:none;
    background:var(--blue); color:#fff; box-shadow:0 3px 10px rgba(0,0,0,.3);
    font-size:22px; display:flex;align-items:center;justify-content:center;
  }
  body.film #gear, body.locked #gear{display:none;}
  .install-float{
    position:fixed; left:14px; bottom:76px; z-index:60;
    border:none; background:var(--blue); color:#fff;
    font-weight:700; font-size:14px; font-family:inherit;
    padding:10px 16px; border-radius:22px;
    box-shadow:0 3px 10px rgba(0,0,0,.3);
    display:flex; align-items:center; gap:7px;
  }
  .install-float svg{width:17px;height:17px;fill:#fff;}
  .install-float.hidden{display:none;}
  /* native in-post CTA (like FB app-ad attachment) */
  .postcta{
    display:flex; align-items:center; justify-content:space-between; gap:10px;
    background:var(--bubble); border-radius:8px;
    margin:4px 16px 10px 16px; padding:10px 12px;
  }
  .postcta.hidden{display:none;}
  .ctanote{
    display:inline-flex; align-items:center; gap:5px;
    font-size:12.5px; color:var(--sec); font-weight:600; min-width:0;
  }
  .ctanote svg{width:14px;height:14px;flex:none;}
  .ctabtn{
    border:none; background:var(--blue); color:#fff; flex:none;
    font-weight:700; font-size:14px; font-family:inherit;
    padding:8px 14px; border-radius:6px;
  }
  /* install CTA inside a comment */
  .ccta{margin:8px 0 2px 0; padding:10px 12px; justify-content:flex-start; gap:12px;}
  .ccta .ctanote{font-size:12px;}
  .ccta .ctabtn{font-size:15.5px; padding:11px 22px; order:-1;}
  #panel{
    position:fixed; left:0; right:0; bottom:0; z-index:70;
    background:var(--card); border-radius:16px 16px 0 0;
    box-shadow:0 -4px 24px rgba(0,0,0,.35);
    padding:14px 16px calc(18px + env(safe-area-inset-bottom)) 16px;
    transform:translateY(110%); transition:transform .25s ease;
    max-height:78vh; overflow-y:auto;
  }
  #panel.open{transform:translateY(0);}
  .prow{display:flex; align-items:center; justify-content:space-between; margin-bottom:12px; gap:10px; flex-wrap:wrap;}
  .plabel{font-size:14px; font-weight:600;}
  .seg{display:flex; background:var(--bubble); border-radius:8px; padding:3px;}
  .seg button{
    border:none; background:none; color:var(--sec); font-size:13px; font-weight:600;
    padding:6px 12px; border-radius:6px;
  }
  .seg button.on{background:var(--blue); color:#fff;}
  .pbtn{
    border:none; background:var(--bubble); color:var(--text);
    font-size:13px; font-weight:600; padding:9px 14px; border-radius:8px;
  }
  .pbtn.primary{background:var(--blue); color:#fff;}
  .pbtn.danger{color:#E41E3F;}
  .profbtns{display:flex; flex-wrap:wrap; gap:8px; width:100%;}
  .phint{font-size:12.5px; color:var(--sec); line-height:1.45; margin-top:6px;}
  #panelClose{
    position:absolute; right:12px; top:10px; border:none; background:var(--bubble);
    width:30px;height:30px;border-radius:50%; color:var(--sec); font-size:15px;
  }
  .ptitle{font-size:16px; font-weight:700; margin:0 0 14px 0;}
  #editHint{
    position:fixed; left:50%; transform:translateX(-50%);
    bottom:calc(20px + env(safe-area-inset-bottom));
    background:rgba(0,0,0,.75); color:#fff; font-size:12.5px;
    padding:8px 14px; border-radius:20px; z-index:50; white-space:nowrap;
    opacity:0; pointer-events:none; transition:opacity .3s;
  }
  #editHint.show{opacity:1;}
  #fileInput{display:none;}

