(()=>{
  const BUILD='V249335-special-clean-ui-final';
  const TOKEN='OKITHAKI_PUBLIC_BETA_TOKEN_SERVER_ONLY_2026';
  const $=id=>document.getElementById(id);
  const esc=s=>String(s??'').replace(/[&<>"']/g,m=>({'&':'&amp;','<':'&lt;','>':'&gt;','"':'&quot;',"'":'&#39;'}[m]));
  const apiBase=()=>{try{if(location.protocol.startsWith('http'))return location.origin;}catch{} return 'https://ok-ithaki.gr';};
  const api=p=>apiBase()+p;
  function setVh(){try{const h=Math.max(320, Math.floor((window.visualViewport&&window.visualViewport.height)||window.innerHeight||document.documentElement.clientHeight||720));document.documentElement.style.setProperty('--ith-vh335',h+'px');}catch{}}
  function injectCss(){
    if($('ithClean335Css')) return;
    const st=document.createElement('style'); st.id='ithClean335Css'; st.textContent=`
      :root{--ith-vh335:100dvh;--ith-bar335:68px;--ith-gap335:18dvh}
      #localDoveBtn,.localDoveBtn,.doveIcon,.doveMark,.pigeonBtn,.pigeonButton,#pigeonBtn,.pigeonFloating{display:none!important;visibility:hidden!important;pointer-events:none!important;width:0!important;height:0!important;overflow:hidden!important}
      .bookBtn335{position:fixed!important;top:max(10px,env(safe-area-inset-top))!important;right:10px!important;z-index:2147483647!important;width:52px!important;height:52px!important;border-radius:18px!important;border:1px solid rgba(255,217,110,.62)!important;background:radial-gradient(circle at 25% 15%,rgba(255,246,178,.55),rgba(255,217,110,.22) 42%,rgba(15,23,42,.86))!important;color:#fff7dc!important;font-size:25px!important;display:grid!important;place-items:center!important;box-shadow:0 18px 44px rgba(0,0,0,.35)!important;pointer-events:auto!important}
      .bookModal335{position:fixed!important;inset:0!important;z-index:2147483647!important;display:none!important;place-items:center!important;background:rgba(0,0,0,.70)!important;backdrop-filter:blur(12px)!important;padding:12px!important;box-sizing:border-box!important}
      .bookModal335.show{display:grid!important}.bookPanel335{width:min(820px,100%)!important;max-height:92dvh!important;display:flex!important;flex-direction:column!important;gap:10px!important;border-radius:28px!important;background:linear-gradient(155deg,#06111f,#10243a 62%,#070b12)!important;border:1px solid rgba(255,217,110,.26)!important;box-shadow:0 28px 100px rgba(0,0,0,.72)!important;color:#edf7ff!important;padding:14px!important;box-sizing:border-box!important}.bookPanel335 input{width:100%!important;box-sizing:border-box!important;border-radius:14px!important;border:1px solid rgba(255,255,255,.14)!important;background:rgba(255,255,255,.07)!important;color:#fff!important;padding:11px!important}.bookTop335{display:flex!important;align-items:center!important;gap:8px!important}.bookTop335 b{color:#ffd76f!important;font-size:18px!important}.bookGrid335{display:grid!important;grid-template-columns:1fr 1fr 110px!important;gap:8px!important}.bookList335{flex:1 1 auto!important;min-height:0!important;max-height:58dvh!important;overflow-y:auto!important;overflow-x:hidden!important;-webkit-overflow-scrolling:touch!important;display:grid!important;gap:8px!important;padding-right:4px!important}.bookRow335{display:grid!important;grid-template-columns:1fr 1fr auto!important;gap:8px!important;align-items:center!important;border-radius:16px!important;background:rgba(255,255,255,.055)!important;border:1px solid rgba(255,255,255,.08)!important;padding:8px!important}.bookBtnSmall335,.bookPanel335 .btn{border:0!important;border-radius:14px!important;padding:10px 12px!important;background:rgba(255,255,255,.10)!important;color:#fff!important;font-weight:900!important}.bookGold335{background:linear-gradient(180deg,#ffd76f,#b7791f)!important;color:#1a1204!important}.bookDanger335{background:rgba(255,77,77,.22)!important;color:#ffd1d1!important}
      body[data-page="feed"] #feedPage{position:fixed!important;inset:0!important;width:100vw!important;height:var(--ith-vh335,100dvh)!important;min-height:var(--ith-vh335,100dvh)!important;max-height:var(--ith-vh335,100dvh)!important;padding:0!important;margin:0!important;overflow:hidden!important;background:#000!important;z-index:1!important}
      body[data-page="feed"] #feedPage #previewModal,body[data-page="feed"] #feedPage .previewModal{display:none!important;pointer-events:none!important}
      body[data-page="feed"] #feedPage .feedToolbar332,body[data-page="feed"] #feedPage .feedSearchBar,body[data-page="feed"] #feedPage [id^="feedSearchBarV"],body[data-page="feed"] #feedPage [id^="feedTopBar"],body[data-page="feed"] #feedPage .oldFeedBar{display:none!important;visibility:hidden!important;pointer-events:none!important}
      body[data-page="feed"] #feedPage>.feedList,body[data-page="feed"] #feedPage .feedList,body[data-page="feed"] #feedPage #ithCleanFeed332,body[data-page="feed"] #feedPage [id^="ithakiTikTokFeedList"]{position:absolute!important;inset:0!important;width:100vw!important;height:var(--ith-vh335,100dvh)!important;min-height:var(--ith-vh335,100dvh)!important;max-height:var(--ith-vh335,100dvh)!important;overflow-y:auto!important;overflow-x:hidden!important;scroll-snap-type:y mandatory!important;scroll-padding:0!important;scroll-behavior:smooth!important;-webkit-overflow-scrolling:touch!important;overscroll-behavior-y:contain!important;background:#000!important;margin:0!important;padding:0!important;box-sizing:border-box!important;z-index:2!important;display:block!important}
      body[data-page="feed"] #feedPage .feedList>.post,body[data-page="feed"] #feedPage .feedList>article,body[data-page="feed"] #feedPage .feedList>.feedGoldWisdomCard,body[data-page="feed"] #feedPage .feedList>.feedGoldPollCard,body[data-page="feed"] #feedPage .feedList>.feedProCard{position:relative!important;width:100vw!important;height:var(--ith-vh335,100dvh)!important;min-height:var(--ith-vh335,100dvh)!important;max-height:var(--ith-vh335,100dvh)!important;margin:0 0 var(--ith-gap335,18dvh) 0!important;padding:0!important;border:0!important;border-radius:0!important;background:#000!important;box-shadow:none!important;overflow:hidden!important;scroll-snap-align:start!important;scroll-snap-stop:always!important;display:block!important;box-sizing:border-box!important}
      body[data-page="feed"] #feedPage .postMediaWrap,body[data-page="feed"] #feedPage .mediaInline,body[data-page="feed"] #feedPage .tiktokScreen,body[data-page="feed"] #feedPage .mediaFrame{position:absolute!important;inset:0!important;width:100%!important;height:100%!important;min-height:100%!important;max-height:100%!important;margin:0!important;padding:0!important;border:0!important;border-radius:0!important;overflow:hidden!important;background:#000!important;display:block!important}
      body[data-page="feed"] #feedPage video,body[data-page="feed"] #feedPage img.feedImage,body[data-page="feed"] #feedPage .postMediaWrap img,body[data-page="feed"] #feedPage .mediaInline img,body[data-page="feed"] #feedPage .postMediaWrap video,body[data-page="feed"] #feedPage .mediaInline video,body[data-page="feed"] #feedPage video.feedVideo{position:absolute!important;inset:0!important;width:100%!important;height:100%!important;min-height:100%!important;max-height:100%!important;object-fit:cover!important;object-position:center center!important;background:#000!important;border-radius:0!important;margin:0!important;padding:0!important;border:0!important;display:block!important;filter:none!important;opacity:1!important;transform:none!important}
      body[data-page="feed"] #feedPage .postHead{position:absolute!important;left:10px!important;right:70px!important;top:10px!important;z-index:20!important;background:rgba(0,0,0,.34)!important;border-radius:18px!important;padding:8px 10px!important;border:1px solid rgba(255,255,255,.08)!important;backdrop-filter:blur(8px)!important}
      body[data-page="feed"] #feedPage .leftActions,body[data-page="feed"] #feedPage .feedGoldCardActions,body[data-page="feed"] #feedPage .pollPostActions{position:absolute!important;right:8px!important;top:50%!important;left:auto!important;bottom:auto!important;transform:translateY(-50%)!important;z-index:25!important;display:flex!important;flex-direction:column!important;gap:10px!important;background:rgba(0,0,0,.24)!important;padding:6px 4px!important;border-radius:18px!important;border:1px solid rgba(255,255,255,.08)!important}
      body[data-page="feed"] #feedPage .actionIcon,body[data-page="feed"] #feedPage .feedGoldCardActions .btn{width:46px!important;height:46px!important;min-width:46px!important;min-height:46px!important;border-radius:16px!important;display:grid!important;place-items:center!important;background:rgba(0,0,0,.34)!important;color:#fff!important}
      body[data-page="feed"] #feedPage .feedOverlayLineV249298,body[data-page="feed"] #feedPage .feedOverlayLineV249299,body[data-page="feed"] #feedPage .feedOverlayLineV249301,body[data-page="feed"] #feedPage .feedOverlayLineV249302{display:none!important;visibility:hidden!important;pointer-events:none!important}
      body[data-page="feed"] #feedPage .textClamp,body[data-page="feed"] #feedPage .pollAsText,body[data-page="feed"] #feedPage .postTextOverlayV249332{position:absolute!important;left:12px!important;right:72px!important;bottom:76px!important;z-index:24!important;max-height:22dvh!important;overflow-y:auto!important;padding:10px 12px!important;border-radius:18px!important;background:linear-gradient(180deg,rgba(0,0,0,.04),rgba(0,0,0,.50))!important;color:#fff!important;line-height:1.42!important;white-space:pre-wrap!important;border:1px solid rgba(255,255,255,.08)!important;backdrop-filter:blur(6px)!important}.textClamp:empty,.pollAsText:empty{display:none!important}
      body[data-page="feed"] #feedPage .feedGoldCardInner,body[data-page="feed"] #feedPage .pollFeedCard,body[data-page="feed"] #feedPage .professionalPollCard{position:relative!important;z-index:10!important;width:min(84vw,620px)!important;max-height:72dvh!important;overflow-y:auto!important;border-radius:24px!important;background:radial-gradient(circle at 20% 0%,rgba(255,217,110,.18),transparent 34%),linear-gradient(145deg,#171108,#2d1806 55%,#070504)!important;border:1px solid rgba(255,217,110,.30)!important;box-shadow:0 18px 60px rgba(0,0,0,.45)!important;padding:14px!important;color:#fff7dc!important;margin:auto!important}
      body[data-page="feed"] #feedPage .feedGoldWisdomCard,body[data-page="feed"] #feedPage .feedGoldPollCard{display:grid!important;place-items:center!important;background:#000!important}
      #previewModal.show,.previewModal.show{position:fixed!important;inset:0!important;z-index:2147483646!important;display:flex!important;align-items:flex-start!important;justify-content:center!important;overflow-y:auto!important;overflow-x:hidden!important;-webkit-overflow-scrolling:touch!important;padding:max(14px,env(safe-area-inset-top)) 10px max(18px,env(safe-area-inset-bottom))!important;background:rgba(0,0,0,.72)!important;box-sizing:border-box!important}
      #previewModal.show>.previewBox,#previewModal.show .previewBox,#previewModal.show>.callBox,#previewModal.show .callBox,.previewModal.show>.previewBox,.previewModal.show .previewBox{position:relative!important;width:min(760px,100%)!important;max-height:none!important;min-height:auto!important;overflow:visible!important;margin:0 auto!important;border-radius:22px!important;box-sizing:border-box!important}
      #ithPreviewCancel335{position:fixed!important;top:max(10px,env(safe-area-inset-top))!important;left:10px!important;z-index:2147483647!important;border:0!important;border-radius:16px!important;background:rgba(255,80,80,.88)!important;color:#fff!important;font-weight:1000!important;padding:10px 14px!important;box-shadow:0 12px 30px rgba(0,0,0,.34)!important}
      #previewModal button,#previewModal .btn{pointer-events:auto!important}
      #previewModal button.zoom,#previewModal .zoomBtn,#previewModal .magnify,#previewModal [data-action="zoom"],#previewModal [title*="μεγ"],#previewModal [title*="zoom" i]{display:none!important;visibility:hidden!important;pointer-events:none!important}
      body[data-page="dm"] #dmPage{height:var(--ith-vh335,100dvh)!important;overflow:hidden!important}body[data-page="dm"] #dmPage .peopleList,body[data-page="dm"] #dmPage .dmFriendListV249235,body[data-page="dm"] #dmPage .dmPanelV249314,body[data-page="dm"] #dmPage .dmPanelV249316{overflow-y:auto!important;overflow-x:hidden!important;-webkit-overflow-scrolling:touch!important;touch-action:pan-y!important;max-height:calc(var(--ith-vh335,100dvh) - 120px)!important;min-height:180px!important}
    `; document.head.appendChild(st);
  }
  function ensureBook(){
    if(!$('ithBookBtn335')){ const b=document.createElement('button'); b.id='ithBookBtn335'; b.className='bookBtn335'; b.type='button'; b.textContent='📚'; b.title='Βιβλίο Μετάφρασης'; ['click','pointerup','touchend'].forEach(ev=>b.addEventListener(ev,e=>{try{e.preventDefault();e.stopPropagation()}catch{} openBook();}, {passive:false})); document.body.appendChild(b); }
    if(!$('ithBookModal335')){ const m=document.createElement('div'); m.id='ithBookModal335'; m.className='bookModal335'; m.innerHTML=`<div class="bookPanel335"><div class="bookTop335"><b>📚 Βιβλίο Μετάφρασης</b><button class="bookBtnSmall335" id="bookExport335" type="button" style="margin-left:auto">Export</button><button class="bookBtnSmall335 bookDanger335" id="bookClose335" type="button">Κλείσιμο</button></div><div class="bookGrid335"><input id="bookSrc335" placeholder="Λέξη / φράση"><input id="bookDst335" placeholder="Μετάφραση"><button class="bookBtnSmall335 bookGold335" id="bookSave335" type="button">Save</button></div><div style="display:flex;gap:8px;align-items:center"><input id="bookPair335" value="el->en" placeholder="el->en" style="max-width:130px"><button class="bookBtnSmall335" id="bookImport335" type="button">Import</button><input id="bookFile335" type="file" accept="application/json" style="display:none"></div><div id="bookStatus335" style="opacity:.85;font-size:13px">Τοπικό λεξικό πρώτα · μετά server fallback.</div><div id="bookList335" class="bookList335"></div></div>`; m.addEventListener('click',e=>{ if(e.target===m) closeBook(); }); document.body.appendChild(m); $('bookClose335').onclick=closeBook; $('bookSave335').onclick=saveRow; $('bookExport335').onclick=exportRows; $('bookImport335').onclick=()=>$('bookFile335').click(); $('bookFile335').onchange=importRows; }
  }
  function rows(){ try{return JSON.parse(localStorage.getItem('ith_translation_book_v249335')||'[]')}catch{return[]} }
  function setRows(r){ localStorage.setItem('ith_translation_book_v249335', JSON.stringify(r.slice(-2000))); }
  function renderRows(){ ensureBook(); const box=$('bookList335'); const r=rows().slice().reverse(); box.innerHTML = r.length ? r.map((x,i)=>`<div class="bookRow335"><div><b>${esc(x.source)}</b><br><small>${esc(x.pair||'el->en')}</small></div><div>${esc(x.target)}</div><button class="bookBtnSmall335 bookDanger335" data-del="${i}">×</button></div>`).join('') : '<div style="opacity:.8;padding:10px">Δεν υπάρχουν αποθηκευμένες λέξεις ακόμη.</div>'; box.querySelectorAll('[data-del]').forEach(btn=>btn.onclick=()=>{ const all=rows(); all.splice(all.length-1-Number(btn.dataset.del),1); setRows(all); renderRows(); }); }
  async function saveRow(){ const source=$('bookSrc335').value.trim(), target=$('bookDst335').value.trim(), pair=$('bookPair335').value.trim()||'el->en'; if(!source||!target) return; const all=rows(); all.push({source,target,pair,ts:Date.now()}); setRows(all); $('bookSrc335').value=''; $('bookDst335').value=''; renderRows(); try{const [src_lang,dst_lang]=pair.split('->'); await fetch(api('/api/bridge/dictionary/add'),{method:'POST',headers:{'Content-Type':'application/json','X-ITHAKI-TOKEN':TOKEN},body:JSON.stringify({source,target,src_lang:src_lang||'el',dst_lang:dst_lang||'en',kind:'word'})}); $('bookStatus335').textContent='Αποθηκεύτηκε τοπικά και στάλθηκε στον server.';}catch{ $('bookStatus335').textContent='Αποθηκεύτηκε τοπικά. Ο server δεν απάντησε τώρα.'; }}
  function exportRows(){ const blob=new Blob([JSON.stringify(rows(),null,2)],{type:'application/json'}); const a=document.createElement('a'); a.href=URL.createObjectURL(blob); a.download='ithaki_translation_book_v249335.json'; a.click(); setTimeout(()=>URL.revokeObjectURL(a.href),500); }
  function importRows(){ const f=$('bookFile335').files&&$('bookFile335').files[0]; if(!f)return; const rd=new FileReader(); rd.onload=()=>{ try{ const arr=JSON.parse(rd.result); if(Array.isArray(arr)){ setRows(rows().concat(arr)); renderRows(); }}catch(e){alert('Δεν διαβάστηκε JSON');} }; rd.readAsText(f); }
  function openBook(){ ensureBook(); renderRows(); $('ithBookModal335').classList.add('show'); return false; }
  function closeBook(){ $('ithBookModal335')?.classList.remove('show'); return false; }
  function closePreview(){ const pm=$('previewModal'); if(pm){ pm.classList.remove('show','callCompactV249218','voiceCallV249218','videoCallV249218'); pm.innerHTML=''; } const b=$('ithPreviewCancel335'); if(b) b.remove(); return false; }
  function cleanPreview(){ const pm=$('previewModal'); if(!pm) return; if(pm.classList.contains('show')){ if(!$('ithPreviewCancel335')){ const b=document.createElement('button'); b.id='ithPreviewCancel335'; b.type='button'; b.textContent='Άκυρο'; b.onclick=closePreview; document.body.appendChild(b); } pm.querySelectorAll('button,.btn').forEach(btn=>{ const t=(btn.textContent||btn.title||'').toLowerCase(); if(t.includes('🔍')||t.includes('zoom')||t.includes('μεγ')) btn.style.display='none'; }); } else { $('ithPreviewCancel335')?.remove(); } }
  function cleanFeed(){ setVh(); injectCss(); ensureBook(); const feed=$('feedPage'); if(!feed) return; const list=feed.querySelector('.feedList')||feed.querySelector('#ithCleanFeed332')||feed.querySelector('[id^="ithakiTikTokFeedList"]'); if(list){ list.id='ithCleanFeed335'; [...list.children].forEach(card=>{ if(card.nodeType!==1) return; card.classList.add('ithFullCard335'); card.querySelectorAll('video').forEach(v=>{ try{v.setAttribute('playsinline','');v.setAttribute('webkit-playsinline','');v.preload='metadata';v.style.objectFit='cover';}catch{} }); card.querySelectorAll('img').forEach(im=>{ try{im.style.objectFit='cover';}catch{} }); const txt=card.querySelector('.textClamp,.pollAsText'); if(txt && !(txt.textContent||'').trim()) txt.style.display='none'; }); }
  }
  function wrap(){ if(window.__ith335Wrapped) return; window.__ith335Wrapped=1; const aliases=['openTranslationBookV249313','openTranslationBookV249315','openTranslationBookV249316','openTranslationBookV249318','openTranslationBookV249319','openTranslationBookV249324','openTranslationBookV249332','openTranslationBookV249335']; window.ITH=window.ITH||{}; aliases.forEach(k=>{window.ITH[k]=openBook; window[k]=openBook;});
    const oldPage=(window.ITH&&window.ITH.page)?window.ITH.page.bind(window.ITH):(window.page?window.page.bind(window):null); if(oldPage){ const p=function(id){ const r=oldPage(id); setTimeout(()=>{ if(id==='feed') cleanFeed(); if(id==='dm') cleanDm(); cleanPreview();},60); setTimeout(()=>{ if(id==='feed') cleanFeed(); cleanPreview();},300); return r; }; window.page=p; window.ITH.page=p; }
    const oldLoad=(window.ITH&&window.ITH.loadFeed)?window.ITH.loadFeed.bind(window.ITH):(window.loadFeed?window.loadFeed.bind(window):null); if(oldLoad){ const l=function(){ const r=oldLoad(); setTimeout(cleanFeed,60); setTimeout(cleanFeed,300); setTimeout(cleanFeed,900); return r; }; window.loadFeed=l; window.ITH.loadFeed=l; }
    window.ITH.cleanFeedV249335=cleanFeed; window.ITH.closePreviewV249335=closePreview;
  }
  function cleanDm(){ injectCss(); }
  function install(){ setVh(); injectCss(); ensureBook(); wrap(); cleanPreview(); if(document.body?.dataset?.page==='feed') cleanFeed(); if(document.body?.dataset?.page==='dm') cleanDm(); const mo=new MutationObserver(()=>{ if(document.body?.dataset?.page==='feed') cleanFeed(); cleanPreview(); }); mo.observe(document.documentElement,{childList:true,subtree:true,attributes:true,attributeFilter:['class','style','data-page']}); setInterval(()=>{setVh(); if(document.body?.dataset?.page==='feed') cleanFeed(); cleanPreview();},1800); }
  window.addEventListener('resize',setVh); window.visualViewport&&window.visualViewport.addEventListener('resize',setVh); window.addEventListener('orientationchange',()=>setTimeout(setVh,300));
  if(document.readyState==='loading') document.addEventListener('DOMContentLoaded',install,{once:true}); else install();
})();
