
// ===== OK ITHAKI V249345 DIAGNOSED FIX: FEED HEIGHT + LEXICON + WALL =====
(function(){
  if(window.__ITHAKI_V249345_DIAGNOSED_FIX__) return;
  window.__ITHAKI_V249345_DIAGNOSED_FIX__ = 1;
  const BUILD = 'V249345';
  const GOLD = '#d8aa45', GOLD2 = '#ffd978';
  const $ = id => document.getElementById(id);
  const room = () => { try { return (window.state && state.room) || localStorage.getItem('ith_room') || 'ithaki-phone-test'; } catch { return 'ithaki-phone-test'; } };
  const dev = () => { try { return (window.state && state.device) || localStorage.getItem('ith_device') || 'dev_web'; } catch { return 'dev_web'; } };
  const apiBase = () => { try { return (window.state && state.api) || location.origin; } catch { return location.origin; } };
  const esc = s => String(s ?? '').replace(/[&<>"']/g, m => ({'&':'&amp;','<':'&lt;','>':'&gt;','"':'&quot;',"'":'&#39;'}[m]));
  async function api(path,opt={}){
    const r = await fetch(apiBase()+path, Object.assign({cache:'no-store', headers:{'Content-Type':'application/json'}}, opt));
    let d=null; try{ d=await r.json(); }catch{ d={ok:false,status:r.status}; }
    if(!r.ok) throw new Error((d && (d.detail||d.message)) || ('HTTP '+r.status));
    return d;
  }
  function toast(msg){ try{ window.toast ? window.toast(msg) : console.log(msg); }catch{} }
  function vh(){ return Math.max(560, Math.round((window.visualViewport && visualViewport.height) || window.innerHeight || document.documentElement.clientHeight || 720)); }
  function setVars(){ try{ document.documentElement.style.setProperty('--ith-vh345', vh()+'px'); }catch{} }

  function css(){
    if($('ithV249345Css')) return;
    const st = document.createElement('style');
    st.id = 'ithV249345Css';
    st.textContent = `
      :root{--ith-vh345:100dvh;--ith-gold345:${GOLD};--ith-bottom345:calc(env(safe-area-inset-bottom,0px) + 74px)}
      #ithBuild345{position:fixed;right:8px;top:calc(env(safe-area-inset-top,0px) + 2px);z-index:2147483640;font:900 10px/1 system-ui;color:#ffd978;background:rgba(0,0,0,.55);border:1px solid rgba(255,217,120,.35);border-radius:999px;padding:4px 7px;pointer-events:none}
      #ithDiag345{position:fixed;right:8px;top:calc(env(safe-area-inset-top,0px) + 24px);z-index:2147483640;font:800 9px/1.2 system-ui;color:#fff;background:rgba(0,0,0,.42);border:1px solid rgba(255,255,255,.16);border-radius:10px;padding:4px 6px;pointer-events:none;max-width:150px;text-align:right}
      #ithBook345{position:fixed;top:calc(env(safe-area-inset-top,0px) + 9px);left:50%;transform:translateX(-50%);z-index:2147482600;height:44px;min-width:122px;border-radius:999px;border:1px solid rgba(255,217,120,.62);background:rgba(4,10,18,.82);color:#fff2c8;font:950 15px/1 system-ui;display:flex;align-items:center;justify-content:center;gap:8px;box-shadow:0 12px 34px rgba(0,0,0,.38),inset 0 0 0 1px rgba(255,255,255,.06);backdrop-filter:blur(12px);-webkit-backdrop-filter:blur(12px)}
      #ithBook345:active{transform:translateX(-50%) scale(.96)}
      #ithFeature345{position:fixed;left:10px;top:calc(env(safe-area-inset-top,0px) + 62px);z-index:2147482400;display:flex;gap:7px;pointer-events:auto}
      #ithFeature345 button{border-radius:999px;border:1px solid rgba(255,217,120,.45);background:rgba(3,8,16,.72);color:#ffe6a6;font:900 12px/1 system-ui;padding:9px 11px;box-shadow:0 8px 22px rgba(0,0,0,.32);backdrop-filter:blur(10px);-webkit-backdrop-filter:blur(10px)}
      body[data-page="feed"] #feedPage{position:fixed!important;inset:0!important;width:100vw!important;height:var(--ith-vh345)!important;max-height:var(--ith-vh345)!important;background:#000!important;padding:0!important;margin:0!important;overflow:hidden!important}
      body[data-page="feed"] #feedPage .feedList{height:var(--ith-vh345)!important;max-height:var(--ith-vh345)!important;width:100vw!important;overflow-y:auto!important;overflow-x:hidden!important;scroll-snap-type:y mandatory!important;scroll-padding:0!important;overscroll-behavior-y:contain!important;-webkit-overflow-scrolling:touch!important;background:#000!important;padding:0!important;margin:0!important}
      body[data-page="feed"] #feedPage .post.mediaPost,body[data-page="feed"] #feedPage article.card.post.mediaPost,body[data-page="feed"] #feedPage .ithFeedCard345{position:relative!important;width:100vw!important;height:var(--ith-vh345)!important;min-height:var(--ith-vh345)!important;max-height:var(--ith-vh345)!important;margin:0 0 46px 0!important;padding:0!important;border:0!important;border-radius:0!important;background:transparent!important;overflow:hidden!important;box-shadow:none!important;scroll-snap-align:start!important;scroll-snap-stop:always!important}
      body[data-page="feed"] #feedPage .postMediaWrap.tiktokScreen,body[data-page="feed"] #feedPage .postMediaWrap,body[data-page="feed"] #feedPage .mediaInline{position:absolute!important;inset:0!important;width:100%!important;height:100%!important;min-height:100%!important;max-height:100%!important;background:transparent!important;border:0!important;border-radius:0!important;margin:0!important;padding:0!important;overflow:hidden!important}
      body[data-page="feed"] #feedPage video.feedVideo,body[data-page="feed"] #feedPage .postMediaWrap video,body[data-page="feed"] #feedPage .mediaInline video{width:100%!important;height:100%!important;min-height:100%!important;max-height:none!important;object-fit:cover!important;object-position:center center!important;background:#000!important;border:0!important;border-radius:0!important;margin:0!important;padding:0!important}
      body[data-page="feed"] #feedPage video.ithOrigVideo345{opacity:.02!important;pointer-events:none!important}
      #ithFeedBackplate345{position:fixed!important;inset:0!important;width:100vw!important;height:var(--ith-vh345)!important;object-fit:cover!important;object-position:center center!important;background:#000!important;z-index:2!important;pointer-events:none!important;display:none}
      body[data-page="feed"] #ithFeedBackplate345{display:block!important}
      body[data-page="feed"] #feedPage .leftActions,body[data-page="feed"] #feedPage .feedAvatarOverlay,body[data-page="feed"] #feedPage .feedPreviewCommentOverlayV249296,body[data-page="feed"] #feedPage .textClamp,body[data-page="feed"] #feedPage .postActions,body[data-page="feed"] #feedPage .translateTools{position:relative!important;z-index:25!important}
      body[data-page="feed"] #feedPage .mediaOpenBtn,body[data-page="feed"] #feedPage .fileTools,body[data-page="feed"] #feedPage [class*="fullscreen" i],body[data-page="feed"] #feedPage [id*="fullscreen" i],body[data-page="feed"] #feedPage [class*="zoom" i],body[data-page="feed"] #feedPage [id*="zoom" i],body[data-page="feed"] #feedPage button[title*="full" i],body[data-page="feed"] #feedPage button[title*="zoom" i],body[data-page="feed"] #feedPage button[title*="μεγ" i],body[data-page="feed"] #feedPage button[aria-label*="full" i],body[data-page="feed"] #feedPage button[aria-label*="zoom" i]{display:none!important;visibility:hidden!important;opacity:0!important;pointer-events:none!important;width:0!important;height:0!important;overflow:hidden!important}
      body[data-page="feed"] #feedPage video::-webkit-media-controls-fullscreen-button{display:none!important}
      #previewModal.show,.previewModal.show{overflow-y:auto!important;-webkit-overflow-scrolling:touch!important;align-items:unset!important;justify-content:unset!important;padding-bottom:calc(env(safe-area-inset-bottom,0px) + 34px)!important}
      #previewModal.show .row:last-child,.previewModal.show .row:last-child{position:sticky!important;bottom:0!important;z-index:2147483600!important;background:rgba(7,17,30,.98)!important;border-radius:16px!important;padding:10px!important;display:flex!important;gap:8px!important;flex-wrap:wrap!important}
      #ithPreviewCancel345{position:fixed!important;top:calc(env(safe-area-inset-top,0px) + 8px)!important;left:10px!important;z-index:2147483647!important;border:0!important;border-radius:16px!important;background:#d83b3b!important;color:#fff!important;font-weight:1000!important;padding:11px 15px!important;box-shadow:0 12px 30px rgba(0,0,0,.45)!important}
      .ithModal345{position:fixed;inset:0;z-index:2147483300;background:#02070e;color:#fff;overflow-y:auto;-webkit-overflow-scrolling:touch;font-family:system-ui,-apple-system,Segoe UI,sans-serif}.ithModal345 *{box-sizing:border-box}.ithClose345{position:fixed;right:12px;top:calc(env(safe-area-inset-top,0px) + 12px);z-index:10;width:42px;height:42px;border-radius:50%;border:1px solid rgba(255,217,120,.45);background:rgba(0,0,0,.55);color:#fff;font-size:25px}
      .lex345{min-height:var(--ith-vh345);padding:calc(env(safe-area-inset-top,0px) + 62px) 14px calc(env(safe-area-inset-bottom,0px) + 60px);background:radial-gradient(circle at 50% 0,rgba(216,170,69,.18),transparent 30%),linear-gradient(160deg,#07111d,#04070b 70%,#010204)}.lexCard345{max-width:760px;margin:0 auto;border:1px solid rgba(255,217,120,.28);background:rgba(4,10,18,.78);border-radius:24px;padding:16px;box-shadow:0 20px 60px rgba(0,0,0,.38)}.lexCard345 h1{margin:0 0 8px;color:#ffd978}.lexCard345 textarea{width:100%;min-height:92px;border-radius:16px;border:1px solid rgba(255,255,255,.16);background:rgba(0,0,0,.22);color:#fff;padding:12px;font-size:16px}.lexCard345 button{height:46px;border-radius:14px;border:1px solid rgba(255,217,120,.45);background:#bd862b;color:#fff;font-weight:1000;padding:0 14px}.lexOut345{margin-top:12px;border-radius:16px;background:rgba(0,0,0,.24);border:1px solid rgba(255,255,255,.12);padding:12px;min-height:70px;color:#fff}
      .wall345{min-height:var(--ith-vh345);padding:calc(env(safe-area-inset-top,0px) + 28px) 12px calc(env(safe-area-inset-bottom,0px) + 106px);background:radial-gradient(circle at 50% 0,rgba(45,109,160,.24),transparent 32%),radial-gradient(circle at 0 44%,rgba(216,170,69,.14),transparent 26%),linear-gradient(160deg,#07111d,#04070b 64%,#010204)}.wallHead345{text-align:center;padding:10px 44px 14px}.wallLogo345{display:flex;align-items:center;justify-content:center;gap:9px;margin-bottom:8px}.wallLogo345 img{width:42px;height:42px;object-fit:cover;border-radius:14px;border:1px solid rgba(255,217,120,.38)}.wallLogo345 b{font-size:26px}.wallLogo345 span{color:#d8aa45;font-weight:900}.wallHead345 h1{font-size:clamp(31px,8vw,44px);margin:6px 0 4px}.wallHead345 p{margin:0;color:#d8dce5}.wallShield345{color:#d8aa45;font-size:13px;margin-top:8px}.wallLive345{display:flex;justify-content:space-between;align-items:center;margin:6px auto 14px;max-width:760px;color:#cfd9e8;font-size:13px}.wallLive345 b{color:#87d98b}.wallList345{display:grid;gap:12px;max-width:760px;margin:0 auto}.wallCard345{border:1px solid rgba(255,217,120,.20);background:linear-gradient(145deg,rgba(16,30,45,.82),rgba(6,11,18,.78));border-radius:22px;padding:14px;box-shadow:0 14px 38px rgba(0,0,0,.32),inset 0 1px 0 rgba(255,255,255,.06)}.wallMeta345{display:flex;align-items:center;gap:10px}.wallMask345{width:42px;height:42px;border-radius:50%;display:grid;place-items:center;border:1px solid rgba(255,217,120,.48);background:rgba(216,170,69,.14);font-size:22px}.wallMeta345 b{font-size:17px}.wallMeta345 small{display:block;color:#aeb7c4}.wallDots345{margin-left:auto;background:none;border:0;color:#bec6d0;font-size:24px}.wallText345{font-size:17px;line-height:1.38;margin:13px 0;color:#fff}.wallActions345{display:grid;grid-template-columns:repeat(3,1fr);gap:8px}.wallActions345 button{border-radius:13px;border:1px solid rgba(255,255,255,.16);background:rgba(0,0,0,.20);color:#f5f0e5;padding:9px 6px;font-weight:900}.wallActions345 b{color:#ffd978;margin-left:5px}.wallReport345{display:block;margin:8px auto 0;border:0;background:none;color:#aeb7c4}.wallNew345{display:block;margin:15px auto 10px;width:min(560px,84vw);height:54px;border-radius:999px;border:0;background:linear-gradient(135deg,#c99536,#f0c56f);color:#fff;font-size:18px;font-weight:1000;box-shadow:0 14px 34px rgba(0,0,0,.34)}.wallComposer345{position:sticky;bottom:calc(env(safe-area-inset-bottom,0px) + 6px);max-width:820px;margin:0 auto;border-radius:24px;border:1px solid rgba(255,217,120,.28);background:rgba(8,18,30,.96);padding:12px;box-shadow:0 -12px 40px rgba(0,0,0,.45);backdrop-filter:blur(12px);-webkit-backdrop-filter:blur(12px)}.wallComposer345 .anon{display:flex;justify-content:flex-end;color:#d8aa45;font-size:13px;font-weight:900}.wallComposer345 textarea{width:100%;min-height:92px;max-height:160px;resize:vertical;border:1px solid rgba(255,255,255,.16);border-radius:16px;background:rgba(0,0,0,.20);color:#fff;font-size:16px;padding:12px;outline:0}.wallComposer345 .counter{text-align:right;color:#aeb7c4;font-size:12px}.wallComposerBtns345{display:grid;grid-template-columns:1fr 1fr;gap:10px;margin-top:10px}.wallComposerBtns345 button{height:50px;border-radius:15px;font-weight:1000;font-size:16px}.wallCancel345{background:#08111e;border:1px solid rgba(216,170,69,.5);color:#d8aa45}.wallSend345{border:0;background:linear-gradient(135deg,#c99536,#f0c56f);color:#fff}
    `;
    document.head.appendChild(st);
  }

  function ensureUI(){
    css(); setVars();
    ['ithBuild339','ithBuild340','ithBuild341','ithBuild342','ithBuild343','ithBuild344','ithTrueFeed341','ithTrueFeedList341','ithRestoreNote342','ithBook339','ithBook343','ithBook344','ithFeature343','ithFeature344'].forEach(id=>{try{$(id)?.remove()}catch{}});
    try{document.body.classList.remove('ithTrueFeedOn341')}catch{}
    if(!$('ithBuild345')){const b=document.createElement('div');b.id='ithBuild345';b.textContent=BUILD;document.body.appendChild(b)}
    if(!$('ithDiag345')){const d=document.createElement('div');d.id='ithDiag345';d.textContent='v:0 h:'+vh();document.body.appendChild(d)}
    if(!$('ithBook345')){const b=document.createElement('button');b.id='ithBook345';b.type='button';b.innerHTML='<span>📖</span><span>Λεξικό</span>';b.onclick=openLexicon;document.body.appendChild(b)}
    if(!$('ithFeature345')){const f=document.createElement('div');f.id='ithFeature345';f.innerHTML='<button type="button" data-open="wall">🧱 Τοίχος</button><button type="button" data-open="light">🕯️ Φάρος</button>';f.onclick=e=>{const b=e.target.closest('button');if(!b)return;b.dataset.open==='wall'?openWall():openLighthouse();};document.body.appendChild(f)}
  }

  function currentFeedVideo(videos){
    const center = vh()/2; let best=null, bd=1e9;
    videos.forEach(v=>{try{const r=v.getBoundingClientRect(); if(r.width<30||r.height<30) return; const d=Math.abs((r.top+r.bottom)/2-center); if(d<bd){bd=d;best=v;}}catch{}});
    return best || videos[0] || null;
  }

  function fixFeed(){
    ensureUI();
    const feed=$('feedPage'); const diag=$('ithDiag345');
    if(!feed){ if(diag) diag.textContent='no feed'; return; }
    if((document.body.dataset.page||'')!=='feed'){ const bp=$('ithFeedBackplate345'); if(bp) bp.style.display='none'; if(diag) diag.textContent='idle h:'+vh(); return; }
    const h=vh(); document.documentElement.style.setProperty('--ith-vh345',h+'px');
    feed.style.setProperty('position','fixed','important'); feed.style.setProperty('inset','0','important'); feed.style.setProperty('height',h+'px','important'); feed.style.setProperty('max-height',h+'px','important'); feed.style.setProperty('overflow','hidden','important'); feed.style.setProperty('background','#000','important');
    const list=feed.querySelector('.feedList') || feed;
    list.style.setProperty('height',h+'px','important'); list.style.setProperty('max-height',h+'px','important'); list.style.setProperty('overflow-y','auto','important'); list.style.setProperty('scroll-snap-type','y mandatory','important'); list.style.setProperty('padding','0','important'); list.style.setProperty('margin','0','important');
    const videos=[...feed.querySelectorAll('video')];
    let active=currentFeedVideo(videos);
    videos.forEach(v=>{
      try{
        v.classList.add('ithOrigVideo345');
        v.controls=false; v.removeAttribute('controls'); v.setAttribute('playsinline',''); v.setAttribute('webkit-playsinline',''); v.setAttribute('controlsList','nodownload nofullscreen noremoteplayback'); v.disablePictureInPicture=true; v.disableRemotePlayback=true;
        let card=v.closest('article.card.post.mediaPost,.post.mediaPost,article,.feedItem') || v.parentElement;
        if(card){card.classList.add('ithFeedCard345');card.style.setProperty('height',h+'px','important');card.style.setProperty('min-height',h+'px','important');card.style.setProperty('max-height',h+'px','important');card.style.setProperty('background','transparent','important');card.style.setProperty('overflow','hidden','important');}
        let p=v.parentElement, n=0; while(p && p!==card && p!==feed && n++<6){p.style.setProperty('height','100%','important');p.style.setProperty('min-height','100%','important');p.style.setProperty('max-height','100%','important');p.style.setProperty('background','transparent','important');p.style.setProperty('overflow','hidden','important');p=p.parentElement;}
      }catch{}
    });
    feed.querySelectorAll('.mediaOpenBtn,.fileTools,[class*="fullscreen" i],[id*="fullscreen" i],[class*="zoom" i],[id*="zoom" i],button[title*="full" i],button[title*="zoom" i],button[title*="μεγ" i],button[aria-label*="full" i],button[aria-label*="zoom" i]').forEach(el=>{try{el.remove()}catch{try{el.style.setProperty('display','none','important')}catch{}}});
    let bp=$('ithFeedBackplate345');
    if(!bp){bp=document.createElement('video');bp.id='ithFeedBackplate345';bp.muted=true;bp.loop=true;bp.autoplay=true;bp.playsInline=true;bp.setAttribute('playsinline','');bp.setAttribute('webkit-playsinline','');bp.setAttribute('controlsList','nodownload nofullscreen noremoteplayback');feed.prepend(bp)}
    if(active){
      const src=active.currentSrc||active.src||active.getAttribute('src')||'';
      if(src && bp.src!==src){bp.src=src; try{bp.load()}catch{}}
      try{bp.currentTime = active.currentTime || bp.currentTime || 0}catch{}
      try{bp.play&&bp.play().catch(()=>{})}catch{}
      bp.style.display='block';
      if(diag) diag.textContent='v:'+videos.length+' h:'+Math.round(active.getBoundingClientRect().height)+'→'+h;
    }else{
      bp.style.display='none';
      if(diag) diag.textContent='v:0 h:'+h;
    }
  }

  function preview(){
    const pm=$('previewModal'); if(!pm) return;
    const show=pm.classList.contains('show')||String(pm.innerHTML||'').trim().length>20;
    if(!show){$('ithPreviewCancel345')?.remove(); return;}
    pm.classList.add('show');
    if(!$('ithPreviewCancel345')){const c=document.createElement('button');c.id='ithPreviewCancel345';c.textContent='Άκυρο';c.type='button';c.onclick=()=>{try{if(window.ITH&&ITH.closePreview)ITH.closePreview();else{pm.classList.remove('show');pm.innerHTML='';}}catch{pm.classList.remove('show');pm.innerHTML='';}c.remove();};document.body.appendChild(c)}
  }

  function openLexicon(){
    const candidates=[
      'openTranslationBookV249345','openTranslationBookV249342','openTranslationBookV249338','openTranslationBookV249336','openTranslationBookV249335','openTranslationBookV249324'
    ];
    for(const name of candidates){
      try{ if(window.ITH && typeof ITH[name]==='function'){ITH[name](); return;} }catch{}
      try{ if(typeof window[name]==='function'){window[name](); return;} }catch{}
    }
    let root=$('ithLex345'); if(!root){root=document.createElement('div');root.id='ithLex345';root.className='ithModal345';document.body.appendChild(root)}
    root.innerHTML=`<button class="ithClose345">×</button><section class="lex345"><div class="lexCard345"><h1>📖 Λεξικό ΙΘΑΚΗΣ</h1><p>Γράψε λέξη ή φράση. Αν δεν υπάρχει μετάφραση, μένει εδώ για συμπλήρωση.</p><textarea id="lexIn345" placeholder="Λέξη / φράση..."></textarea><div style="display:flex;gap:8px;margin-top:10px;flex-wrap:wrap"><button id="lexSave345">Αποθήκευση</button><button id="lexExport345">Εξαγωγή</button></div><div class="lexOut345" id="lexOut345">Το προσωπικό λεξικό είναι έτοιμο.</div></div></section>`;
    root.querySelector('.ithClose345').onclick=()=>root.remove();
    $('lexSave345').onclick=()=>{const t=($('lexIn345').value||'').trim(); if(!t)return; const a=JSON.parse(localStorage.getItem('ith_lexicon_345')||'[]'); a.unshift({text:t,ts:Date.now()}); localStorage.setItem('ith_lexicon_345',JSON.stringify(a.slice(0,400))); $('lexOut345').textContent='Αποθηκεύτηκε: '+t;};
    $('lexExport345').onclick=()=>{$('lexOut345').textContent=localStorage.getItem('ith_lexicon_345')||'[]';};
  }

  let ws345=null;
  function live(onmsg){
    if(ws345 && ws345.readyState<=1) return ws345;
    try{
      ws345=new WebSocket(apiBase().replace(/^http/,'ws')+'/ws/live_v249345');
      ws345.onmessage=e=>{try{const m=JSON.parse(e.data); if(m.type && !['ready','pong'].includes(m.type)) onmsg&&onmsg(m)}catch{}};
      ws345.onclose=()=>{ws345=null};
    }catch{}
    return ws345;
  }

  async function openWall(){
    ensureUI(); let root=$('ithWall345'); if(!root){root=document.createElement('div');root.id='ithWall345';root.className='ithModal345';document.body.appendChild(root)}
    root.innerHTML=`<button class="ithClose345">×</button><section class="wall345"><header class="wallHead345"><div class="wallLogo345"><img src="/ok_ithaki_ship_logo.png" onerror="this.style.display='none'"><div><b>OK</b><span> ITHAKI</span></div></div><h1>Ανώνυμος Τοίχος 🛡️</h1><p>Μοιράσου σκέψεις ανώνυμα με ασφάλεια</p><div class="wallShield345">⚓ 100% Ανώνυμο · χωρίς όνομα στο μήνυμα</div></header><div class="wallLive345"><span>🟢 Ζωντανά τώρα: <b id="wallLive345">0</b></span><span>Ανανεώνεται ζωντανά</span></div><div class="wallList345" id="wallList345"><div class="wallCard345">Φόρτωση...</div></div><button class="wallNew345" id="wallNew345">+ Νέα ανώνυμη ανάρτηση</button><div class="wallComposer345" id="wallComposer345"><div class="anon">🛡️ 100% Ανώνυμο</div><textarea id="wallText345" maxlength="500" placeholder="Γράψε ανώνυμα..."></textarea><div class="counter"><span id="wallCount345">0</span> / 500</div><div class="wallComposerBtns345"><button class="wallCancel345" id="wallCancel345">Ακύρωση</button><button class="wallSend345" id="wallSend345">Δημοσίευση ➤</button></div></div></section>`;
    root.querySelector('.ithClose345').onclick=()=>root.remove();
    $('wallNew345').onclick=()=>$('wallText345')?.focus();
    $('wallCancel345').onclick=()=>{const t=$('wallText345'); if(t){t.value='';$('wallCount345').textContent='0'}};
    $('wallText345').oninput=()=>{$('wallCount345').textContent=String(($('wallText345').value||'').length)};
    $('wallSend345').onclick=async()=>{const t=($('wallText345')?.value||'').trim(); if(!t)return toast('Γράψε πρώτα κάτι.'); try{await api('/api/wall/post_v249345',{method:'POST',body:JSON.stringify({room_id:room(),owner_token:dev(),text:t})});$('wallText345').value='';$('wallCount345').textContent='0';await loadWall();}catch(e){toast('Δεν στάλθηκε: '+e.message)}};
    window.__wallReact345=async(post_id,kind,btn)=>{try{const r=await api('/api/wall/react_v249345',{method:'POST',body:JSON.stringify({room_id:room(),owner_token:dev(),post_id,kind})}); if(btn){btn.querySelector('b').textContent=String(kind==='understand'?r.understand:(kind==='reply'?r.replies:r.support));}}catch(e){toast('Δεν μετρήθηκε.')}};
    window.__wallReport345=async(post_id)=>{try{await api('/api/wall/report_v249345',{method:'POST',body:JSON.stringify({room_id:room(),owner_token:dev(),post_id,reason:'user_report'})});toast('Έγινε αναφορά.')}catch(e){}};
    async function loadWall(){
      try{
        const d=await api('/api/wall/list_v249345?room_id='+encodeURIComponent(room())+'&limit=80');
        $('wallLive345').textContent=d.live_now||0;
        const sample=[
          {text:'Μερικές μέρες νιώθω ότι κανείς δεν με καταλαβαίνει. Απλώς ήθελα να το γράψω κάπου.',support:28,replies:12,understand:41,created_at:Date.now()/1000-7200,post_id:'sample1'},
          {text:'Προσπαθώ να αλλάξω, αλλά με φοβίζει το αύριο. Έχει κάποιος περάσει κάτι παρόμοιο;',support:19,replies:8,understand:27,created_at:Date.now()/1000-18000,post_id:'sample2'},
          {text:'Ευγνώμων για τη μικρή χαρά της ημέρας. Ένα ηλιοβασίλεμα αρκεί καμιά φορά.',support:35,replies:6,understand:53,created_at:Date.now()/1000-86400,post_id:'sample3'}
        ];
        const posts=(d.posts&&d.posts.length?d.posts:sample);
        $('wallList345').innerHTML=posts.map(p=>{const dt=new Date((p.created_at||0)*1000); const when=dt.toLocaleString('el-GR',{day:'2-digit',month:'2-digit',hour:'2-digit',minute:'2-digit'}); return `<article class="wallCard345" data-post="${esc(p.post_id)}"><div class="wallMeta345"><div class="wallMask345">🎭</div><div><b>Ανώνυμος</b><small>${esc(when)}</small></div><button class="wallDots345">•••</button></div><p class="wallText345">${esc(p.text)}</p><div class="wallActions345"><button onclick="__wallReact345('${esc(p.post_id)}','support',this)">❤️ Στήριξη <b>${p.support||0}</b></button><button onclick="__wallReact345('${esc(p.post_id)}','reply',this)">💬 Απάντηση <b>${p.replies||0}</b></button><button onclick="__wallReact345('${esc(p.post_id)}','understand',this)">🕯️ Κατανόηση <b>${p.understand||0}</b></button></div><button class="wallReport345" onclick="__wallReport345('${esc(p.post_id)}')">⚐ Αναφορά</button></article>`}).join('');
      }catch(e){$('wallList345').innerHTML='<div class="wallCard345">Δεν φορτώθηκε ο Τοίχος: '+esc(e.message)+'</div>';}
    }
    await loadWall();
    live(m=>{if(!$('ithWall345'))return; if(m.type&&m.type.startsWith('wall_')) loadWall();});
  }

  function openLighthouse(){
    alert('Ο Φάρος παραμένει ενεργός από το server. Θα τον κάνουμε μετά τη Ροή/Τοίχο για να μη μπερδευτούν ξανά.');
  }

  function loop(){ ensureUI(); fixFeed(); preview(); }
  if(document.readyState==='loading') document.addEventListener('DOMContentLoaded',loop,{once:true}); else loop();
  [80,180,420,900,1600,2600,4200,6500].forEach(t=>setTimeout(loop,t));
  setInterval(loop,650);
  try{new MutationObserver(loop).observe(document.documentElement,{childList:true,subtree:true,attributes:true})}catch{}
  addEventListener('resize',()=>{setVars();fixFeed()});
  if(window.visualViewport) visualViewport.addEventListener('resize',()=>{setVars();fixFeed()});
  window.ITH=window.ITH||{};
  Object.assign(window.ITH,{openWallV249345:openWall,openAnonymousWallV249345:openWall,openLighthouseV249345:openLighthouse,forceFeedHeightV249345:fixFeed,openLexiconV249345:openLexicon});
})();
// ===== END OK ITHAKI V249345 DIAGNOSED FIX =====
