:root{
  --bg1:#0b0f1a;
  --bg2:#0e1528;
  --border:rgba(255,255,255,.16);
  --text:rgba(255,255,255,.92);
  --muted:rgba(255,255,255,.72);
  --focus:#ffe066;
  --radius:18px;
}

*{box-sizing:border-box}
body{margin:0;font-family:system-ui,Segoe UI,Arial;background:linear-gradient(180deg,var(--bg1),var(--bg2));color:var(--text)}
.wrap{padding:14px;max-width:900px;margin:0 auto}


/* =========================
   HEADER LAYOUT (desktop + mobile)
   - Titolo a sinistra
   - Logo in alto a destra
   - Lingua sotto il logo, a destra
   ========================= */

.header{
  display:grid;
  grid-template-columns: 1fr auto;   /* sinistra elastica, destra stretta */
  grid-template-rows: auto auto;     /* due righe */
  column-gap:16px;
  row-gap:10px;
  align-items:start;
  margin-bottom:10px;
}

/* Titolo: occupa entrambe le righe a sinistra */
.title{
  grid-column:1;
  grid-row:1 / span 2;
  font-size:24px;
  font-weight:900;
  line-height:1.15;
  margin:0;
  max-width: 28ch; /* aiuta a formare 2 righe "belle" */
}

/* Blocco destro: logo sopra, lingua sotto */
.headerRight{
  grid-column:2;
  grid-row:1 / span 2;
  display:flex;
  flex-direction:column;
  align-items:flex-end;
  gap:8px;
}

/* Logo: sempre in alto */
.logo img{
  max-width:170px;
  height:auto;
  display:block;
}

/* =========================
   MOBILE TUNING
   ========================= */
@media (max-width:640px){

  .header{
    column-gap:12px;
    row-gap:8px;
  }

  .title{
    font-size:22px;
    max-width: 22ch;   /* forza 2 righe su mobile */
  }

  .logo img{
    max-width:150px;
  }

  /* lingua più compatta sotto il logo */
  .lang{
    padding:4px;
    gap:6px;
  }
  .langBtn{
    width:40px;
    height:34px;
  }
  .flagImg{
    width:22px;
  }
}


.sub{color:var(--muted);font-weight:700;margin:0 0 12px}

/* Switch lingua (bandiere) come index */
.lang{
  display:flex;
  align-items:center;
  gap:8px;
  background:rgba(255,255,255,.06);
  border:1px solid var(--border);
  border-radius:999px;
  padding:6px;
}
.langBtn{
  display:flex;
  align-items:center;
  justify-content:center;
  width:48px;
  height:40px;
  border-radius:999px;
  border:1px solid transparent;
  text-decoration:none;
  user-select:none;
  -webkit-tap-highlight-color: transparent;
}
.langBtn.active{
  background:rgba(255,255,255,.18);
  border-color:rgba(255,255,255,.25);
}
.langBtn:focus{outline:3px solid var(--focus);outline-offset:2px}
.flagImg{width:28px;height:auto;display:block}

button{width:100%;border:0;border-radius:14px;padding:18px 14px;font-size:20px;font-weight:900;margin:8px 0;cursor:pointer}
.ok{background:#2ee59d;color:#000}
.sec{background:#1b243b;color:#fff;border:1px solid rgba(255,255,255,.15)}
.stop{background:#ff5c7a;color:#000}

.status{margin:8px 0;color:rgba(255,255,255,.8);font-weight:900}

.box{
  margin-top:12px;background:#111a2b;border:1px solid rgba(255,255,255,.15);
  border-radius:14px;padding:14px;min-height:180px;white-space:pre-wrap;
  word-break:break-word;font-size:18px;line-height:1.35
}

#preview{
  width:100%;
  border-radius:14px;
  border:1px solid rgba(255,255,255,.15);
  display:none;
  margin-top:10px
}

input{display:none}

.mini-btn{
  margin-top:8px;
  border-radius:12px;
  padding:10px 12px;
  font-size:16px;
  font-weight:800;
}

.home-btn{
  margin-top:10px;
  border-radius:12px;
  padding:10px 12px;
  font-size:16px;
  font-weight:800;
}

.footer{margin-top:16px;text-align:center;font-size:13px;color:rgba(255,255,255,.6)}


.overlay{
  position:fixed;
  inset:0;
  display:none;              /* fondamentale */
  align-items:center;
  justify-content:center;
  background:rgba(0,0,0,.55);
  backdrop-filter:blur(6px);
  z-index:9999;
}

