/* MediaFM World — stile (dark cyberpunk) */
.mfw{
  --mfw-h:640px;
  --bg:#0b0f1d; --bg2:#121833; --line:rgba(123,92,255,.22);
  --violet:#7b5cff; --cyan:#35b7ff; --green:#19d3a2; --pink:#ff5d8f; --gold:#ffb020;
  --ink:#e8ecff; --muted:#93a0c8;
  position:relative; width:100%; border-radius:18px; overflow:hidden;
  background:radial-gradient(1200px 500px at 70% -10%, #1a2040 0%, var(--bg) 60%);
  border:1px solid var(--line); color:var(--ink);
  font-family:system-ui,-apple-system,"Segoe UI",Roboto,sans-serif;
  box-shadow:0 30px 80px -40px rgba(0,0,0,.8);
}
.mfw *{ box-sizing:border-box; }

/* HUD */
.mfw__hud{ display:flex; align-items:center; justify-content:space-between; gap:12px;
  padding:12px 16px; background:linear-gradient(180deg,rgba(10,14,28,.9),rgba(10,14,28,.35)); position:relative; z-index:4; }
.mfw__brand{ display:flex; align-items:center; gap:10px; min-width:0; }
.mfw__logo{ width:30px; height:30px; display:grid; place-items:center; border-radius:9px;
  background:linear-gradient(135deg,var(--violet),var(--cyan)); color:#fff; font-size:17px; box-shadow:0 6px 18px -6px var(--violet); }
.mfw__ttl{ font-weight:800; letter-spacing:.2px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.mfw__live{ display:inline-flex; align-items:center; gap:6px; font-size:11px; font-weight:800; letter-spacing:1px;
  color:#ff6b6b; border:1px solid rgba(255,107,107,.4); border-radius:999px; padding:3px 9px; }
.mfw__live i{ width:7px; height:7px; border-radius:50%; background:#ff5252; animation:mfwPulse 1.4s infinite; }
@keyframes mfwPulse{ 0%,100%{ opacity:1; box-shadow:0 0 0 0 rgba(255,82,82,.6); } 50%{ opacity:.5; box-shadow:0 0 0 6px rgba(255,82,82,0); } }
.mfw__meta{ display:flex; align-items:center; gap:8px; }
.mfw__stat,.mfw__clock{ font-size:13px; font-weight:700; color:var(--muted); background:rgba(255,255,255,.05); padding:5px 10px; border-radius:9px; }
.mfw__stat b{ color:var(--ink); }
.mfw__icon{ width:32px; height:32px; border-radius:9px; border:1px solid var(--line); background:rgba(255,255,255,.04);
  color:var(--ink); cursor:pointer; font-size:14px; line-height:1; transition:background .15s, transform .15s; }
.mfw__icon:hover{ background:rgba(123,92,255,.2); transform:translateY(-1px); }
.mfw__icon.off{ opacity:.5; }

/* STAGE */
.mfw__stage{ position:relative; height:var(--mfw-h); }
.mfw__canvas{ position:absolute; inset:0; width:100%; height:100%; display:block; cursor:grab; touch-action:none; }
.mfw__canvas:active{ cursor:grabbing; }

/* BOARD */
.mfw__board{ position:absolute; top:14px; right:14px; width:230px; max-height:calc(100% - 28px); overflow:auto; z-index:3;
  background:rgba(12,17,34,.82); backdrop-filter:blur(10px); border:1px solid var(--line); border-radius:14px; padding:12px; }
.mfw__board h4{ margin:0 0 10px; font-size:12px; letter-spacing:1px; text-transform:uppercase; color:var(--muted); }
.mfw__empty{ color:var(--muted); font-size:13px; margin:4px 0; }
.mfw__p{ background:rgba(255,255,255,.04); border:1px solid rgba(255,255,255,.07); border-radius:10px; padding:9px 10px; margin-bottom:8px; }
.mfw__p-top{ display:flex; justify-content:space-between; gap:8px; align-items:baseline; }
.mfw__p-ttl{ font-weight:700; font-size:13px; line-height:1.2; }
.mfw__p-st{ font-size:11px; font-weight:800; color:var(--cyan); white-space:nowrap; }
.mfw__p.done .mfw__p-st{ color:var(--green); } .mfw__p.queue .mfw__p-st{ color:var(--gold); }
.mfw__p-who{ font-size:11px; color:var(--muted); margin:2px 0 6px; }
.mfw__p-bar{ height:5px; border-radius:999px; background:rgba(255,255,255,.1); overflow:hidden; }
.mfw__p-bar i{ display:block; height:100%; background:linear-gradient(90deg,var(--violet),var(--cyan)); transition:width .5s; }
.mfw__p.done .mfw__p-bar i{ background:var(--green); }

/* INSPECTOR */
.mfw__inspector{ position:absolute; top:14px; left:14px; width:230px; z-index:3;
  background:rgba(12,17,34,.9); backdrop-filter:blur(10px); border:1px solid var(--line); border-radius:14px; padding:14px; }
.mfw__inspector-x{ position:absolute; top:8px; right:10px; border:0; background:transparent; color:var(--muted); font-size:20px; cursor:pointer; }
.mfw__ins-head{ display:flex; gap:10px; align-items:center; margin-bottom:12px; }
.mfw__ins-dot{ width:16px; height:16px; border-radius:50%; flex:0 0 auto; box-shadow:0 0 12px currentColor; }
.mfw__ins-head strong{ display:block; font-size:15px; } .mfw__ins-head span{ font-size:12px; color:var(--muted); }
.mfw__ins-row{ display:flex; justify-content:space-between; gap:10px; font-size:13px; padding:5px 0; border-top:1px solid rgba(255,255,255,.06); }
.mfw__ins-row span{ color:var(--muted); } .mfw__ins-row b{ text-align:right; }
.mfw__ins-bar{ height:6px; border-radius:999px; background:rgba(255,255,255,.1); overflow:hidden; margin-top:8px; }
.mfw__ins-bar i{ display:block; height:100%; background:var(--green); }

/* CHAT */
.mfw__chat{ position:absolute; left:14px; bottom:14px; width:300px; max-width:calc(100% - 28px); z-index:3;
  background:rgba(12,17,34,.82); backdrop-filter:blur(12px); border:1px solid var(--line); border-radius:16px; display:flex; flex-direction:column;
  max-height:min(50%,340px); box-shadow:0 20px 50px -20px rgba(0,0,0,.7); transition:transform .25s, opacity .25s; }
.mfw__chat.hid{ transform:translateY(calc(100% - 46px)); }
.mfw__chat-head{ display:flex; align-items:center; gap:8px; padding:11px 14px; border-bottom:1px solid var(--line); }
.mfw__chat-dot{ width:9px; height:9px; border-radius:50%; background:var(--green); box-shadow:0 0 10px var(--green); }
.mfw__chat-head strong{ font-size:14px; } .mfw__chat-sub{ font-size:11px; color:var(--muted); }
.mfw__chat-log{ flex:1; overflow:auto; padding:12px 14px; display:flex; flex-direction:column; gap:9px; min-height:120px; }
.mfw__sys{ align-self:center; font-size:11px; color:var(--muted); background:rgba(255,255,255,.05); padding:3px 10px; border-radius:999px; }
.mfw__msg{ display:flex; flex-direction:column; max-width:85%; }
.mfw__msg.me{ align-self:flex-end; align-items:flex-end; }
.mfw__who{ font-size:11px; color:var(--cyan); font-weight:700; margin:0 0 2px 6px; }
.mfw__bub{ font-size:13.5px; line-height:1.4; padding:8px 12px; border-radius:14px; background:rgba(255,255,255,.07); }
.mfw__msg.me .mfw__bub{ background:linear-gradient(135deg,var(--violet),#6a4bd6); color:#fff; border-bottom-right-radius:4px; }
.mfw__msg.them .mfw__bub{ border-bottom-left-radius:4px; }
.mfw__msg.typing .mfw__bub{ display:inline-flex; gap:4px; }
.mfw__msg.typing i{ width:6px; height:6px; border-radius:50%; background:var(--muted); animation:mfwDot 1s infinite; }
.mfw__msg.typing i:nth-child(2){ animation-delay:.15s; } .mfw__msg.typing i:nth-child(3){ animation-delay:.3s; }
@keyframes mfwDot{ 0%,100%{ opacity:.3; transform:translateY(0); } 50%{ opacity:1; transform:translateY(-3px); } }
.mfw__chips{ display:flex; gap:6px; padding:0 12px 8px; flex-wrap:wrap; }
.mfw__chips button{ font-size:12px; font-weight:600; color:var(--ink); background:rgba(123,92,255,.14); border:1px solid var(--line);
  border-radius:999px; padding:5px 11px; cursor:pointer; transition:background .15s; }
.mfw__chips button:hover{ background:rgba(123,92,255,.3); }
.mfw__chat-form{ display:flex; gap:8px; padding:10px 12px; border-top:1px solid var(--line); }
.mfw__chat-form input{ flex:1; background:rgba(255,255,255,.06); border:1px solid var(--line); border-radius:10px;
  padding:10px 12px; color:var(--ink); font-size:13.5px; outline:none; }
.mfw__chat-form input:focus{ border-color:var(--violet); }
.mfw__chat-form button{ width:42px; border:0; border-radius:10px; background:linear-gradient(135deg,var(--violet),var(--cyan));
  color:#fff; font-size:15px; cursor:pointer; }
.mfw__spectator{ padding:12px 14px; font-size:12.5px; color:var(--muted); border-top:1px solid var(--line); line-height:1.5; }

/* responsive */
@media (max-width:820px){
  .mfw__board{ width:170px; top:10px; right:10px; padding:10px; }
  .mfw__inspector{ width:180px; }
  .mfw__chat{ width:calc(100% - 20px); left:10px; bottom:10px; max-height:52%; }
  .mfw__ttl{ max-width:40vw; }
}
/* --- mobile: pannelli compatti, chat come scheda richiudibile col tap --- */
@media (max-width:620px){
  .mfw__hud{ padding:8px 10px; gap:8px; }
  .mfw__ttl{ max-width:34vw; font-size:13px; }
  .mfw__live{ display:none; }
  .mfw__meta{ gap:5px; }
  .mfw__icon{ width:30px; height:30px; }
  .mfw__board{ width:auto; max-width:45vw; top:8px; right:8px; padding:8px 10px; max-height:30%; font-size:11px; }
  .mfw__board h4{ font-size:10px; margin-bottom:6px; }
  .mfw__inspector{ width:calc(100% - 16px); left:8px; top:auto; bottom:calc(46px + 2%); }
  .mfw__chat{ width:calc(100% - 16px); left:8px; bottom:8px; max-height:44vh; }
  /* intestazione chat = maniglia per aprire/chiudere */
  .mfw__chat-head{ cursor:pointer; position:relative; }
  .mfw__chat-head::after{ content:"⌄"; position:absolute; right:14px; top:50%; transform:translateY(-50%); color:var(--muted); font-size:16px; transition:transform .2s; }
  .mfw__chat.hid{ transform:translateY(calc(100% - 46px)); }
  .mfw__chat.hid .mfw__chat-head::after{ transform:translateY(-50%) rotate(180deg); }
  /* etichette più piccole e meno affollate */
  .mfw3-name{ font-size:10px; padding:1px 6px; }
  .mfw3-bub{ font-size:11px; max-width:150px; padding:4px 8px; }
  .mfw3-room{ font-size:9px; padding:2px 7px; }
}
@media (max-width:400px){
  .mfw__board{ display:none; }
  .mfw3-bub{ display:none !important; }
}
@media (prefers-reduced-motion:reduce){ .mfw__live i{ animation:none; } }

/* ===================== 3D (Three.js) overlay & loading ===================== */
.mfw3-overlay{ position:absolute; inset:0; pointer-events:none; overflow:hidden; z-index:2; }
.mfw3-label{ position:absolute; top:0; left:0; display:flex; flex-direction:column; align-items:center; gap:4px; pointer-events:none; will-change:transform; }
.mfw3-name{ background:rgba(10,14,24,.82); color:#ffe9cf; font-size:12px; font-weight:700; padding:2px 9px; border-radius:7px; white-space:nowrap; box-shadow:0 4px 12px -6px rgba(0,0,0,.8); }
.mfw3-bub{ display:none; max-width:200px; background:rgba(252,248,240,.97); color:#2a2230; font-size:12.5px; line-height:1.3; padding:6px 10px; border-radius:10px; box-shadow:0 8px 20px -8px rgba(0,0,0,.6); }
.mfw3-bub.on{ display:block; }
.mfw3-room{ position:absolute; top:0; left:0; pointer-events:none; will-change:transform; font-size:11px; font-weight:800; letter-spacing:.08em; text-transform:uppercase; color:#fff; background:rgba(10,14,24,.55); padding:3px 10px; border-radius:20px; white-space:nowrap; box-shadow:0 4px 14px -8px rgba(0,0,0,.9); backdrop-filter:blur(3px); }
.mfw__canvas{ cursor:grab; } .mfw__canvas:active{ cursor:grabbing; }
.mfw__loading{ position:absolute; inset:0; z-index:5; display:flex; align-items:center; justify-content:center; gap:12px;
  background:radial-gradient(600px 300px at 50% 40%, #1a2040, #0a0e1d 70%); color:var(--muted); font-weight:600; font-size:15px; }
.mfw:not(.mfw--loading) .mfw__loading{ display:none; }
.mfw__spin{ width:22px; height:22px; border-radius:50%; border:3px solid rgba(123,92,255,.25); border-top-color:var(--violet); animation:mfwSpin .8s linear infinite; }
@keyframes mfwSpin{ to{ transform:rotate(360deg); } }

/* ===================== modalità a tutto schermo (rotta /mondo) ===================== */
.mfw--fs{ position:fixed; inset:0; width:100vw; height:100vh; border-radius:0; border:0; z-index:99999; box-shadow:none; }
.mfw--fs .mfw__stage{ height:calc(100vh - 56px); }
.mfw--fs .mfw__hud{ position:relative; z-index:6; }
.mfw__exit{ text-decoration:none; }
body.mfw-fullscreen-page{ margin:0; }
@media (max-width:560px){ .mfw--fs .mfw__stage{ height:calc(100vh - 52px); } }

/* ===================== menu a tendina sull'agente ===================== */
.mfw__menu{ position:fixed; z-index:100000; min-width:210px; max-width:260px;
  background:rgba(12,17,34,.97); backdrop-filter:blur(10px); border:1px solid var(--line);
  border-radius:12px; padding:7px; box-shadow:0 18px 44px -14px rgba(0,0,0,.8); color:var(--ink);
  font-family:system-ui,-apple-system,"Segoe UI",Roboto,sans-serif; animation:mfwPop .12s ease; }
@keyframes mfwPop{ from{ opacity:0; transform:translateY(-4px) scale(.98); } to{ opacity:1; transform:none; } }
.mfw__menu-head{ display:flex; gap:9px; align-items:center; padding:6px 8px 8px; }
.mfw__menu-dot{ width:14px; height:14px; border-radius:50%; flex:0 0 auto; box-shadow:0 0 10px currentColor; }
.mfw__menu-head strong{ display:block; font-size:14px; } .mfw__menu-head span{ font-size:11.5px; color:var(--muted); }
.mfw__menu-state{ font-size:12px; color:var(--cyan); padding:0 8px 8px; }
.mfw__menu-sep{ height:1px; background:var(--line); margin:2px 4px 6px; }
.mfw__menu button{ display:block; width:100%; text-align:left; background:transparent; border:0; color:var(--ink);
  font-size:13.5px; padding:9px 10px; border-radius:8px; cursor:pointer; }
.mfw__menu button:hover{ background:rgba(123,92,255,.2); }
.mfw__target{ display:flex; align-items:center; gap:8px; margin:0 12px 6px; font-size:12.5px; font-weight:700;
  color:#fff; background:linear-gradient(135deg,var(--violet),var(--cyan)); border-radius:999px; padding:5px 12px; align-self:flex-start; }
.mfw__target button{ border:0; background:rgba(255,255,255,.25); color:#fff; border-radius:50%; width:18px; height:18px; cursor:pointer; line-height:1; }
.mfw--targeting .mfw__chat-form input{ border-color:var(--violet); box-shadow:0 0 0 2px rgba(123,92,255,.25); }

/* --- camera follow --- */
.mfw__follow{ position:absolute; top:14px; left:50%; transform:translateX(-50%); z-index:5; display:flex; align-items:center; gap:8px;
  background:rgba(10,14,24,.78); border:1px solid var(--line); border-radius:20px; padding:6px 10px 6px 14px; font-size:13px; backdrop-filter:blur(4px); }
.mfw__follow b{ color:#fff; }
.mfw__follow button{ width:22px; height:22px; border:0; border-radius:50%; background:rgba(255,255,255,.1); color:#fff; cursor:pointer; }
/* --- controllo tempo --- */
.mfw__time{ display:flex; align-items:center; gap:6px; }
.mfw__time input[type=range]{ width:92px; accent-color:var(--violet); cursor:pointer; }
.mfw__icon.off{ opacity:.45; }
/* --- banner riunione --- */
.mfw__banner{ position:absolute; top:14px; left:50%; transform:translateX(-50%); z-index:5; background:linear-gradient(135deg,var(--violet),var(--cyan));
  color:#fff; font-weight:700; font-size:13px; padding:7px 16px; border-radius:20px; box-shadow:0 8px 24px -10px rgba(0,0,0,.8); animation:mfwPulse 2s ease-in-out infinite; }
@keyframes mfwPulse{ 0%,100%{ transform:translateX(-50%) scale(1);} 50%{ transform:translateX(-50%) scale(1.04);} }
/* --- stato da revisionare + approva --- */
.mfw__p.review{ border-color:rgba(255,176,32,.5); }
.mfw__p.review .mfw__p-st{ color:#ffb020; }
.mfw__approve{ margin-top:8px; width:100%; border:0; border-radius:8px; padding:6px; cursor:pointer; font-weight:700; font-size:12px;
  background:rgba(33,160,106,.9); color:#fff; }
.mfw__approve:hover{ background:#21a06a; }
/* --- scheda: pensiero + memoria --- */
.mfw__ins-think{ margin-top:10px; padding:8px 10px; border-radius:8px; background:rgba(123,92,255,.12); font-size:12px; font-style:italic; color:#cbb8ff; }
.mfw__ins-mem{ margin-top:10px; }
.mfw__ins-mem>span{ font-size:11px; text-transform:uppercase; letter-spacing:.06em; color:var(--muted); }
.mfw__ins-mem ul{ margin:6px 0 0; padding-left:16px; font-size:12px; color:var(--txt); display:flex; flex-direction:column; gap:3px; }
@media (max-width:620px){ .mfw__time input[type=range]{ width:64px; } .mfw__follow{ top:8px; font-size:12px; } }

/* --- selettore piano --- */
.mfw__floors{ position:absolute; right:14px; bottom:14px; z-index:4; display:flex; flex-direction:column; gap:6px; }
.mfw__floors button{ width:52px; padding:8px 6px; border:1px solid var(--line); border-radius:10px; cursor:pointer; font-weight:700; font-size:12px;
  background:rgba(10,14,24,.72); color:var(--txt); backdrop-filter:blur(4px); }
.mfw__floors button.on{ background:linear-gradient(135deg,var(--violet),var(--cyan)); color:#fff; border-color:transparent; }
@media (max-width:620px){ .mfw__floors{ right:8px; bottom:70px; } .mfw__floors button{ width:44px; } }
