:root{
  --core:#5FE0D3;
  --claude:#A79CF0;
  --premium:#F0B860;
  --good:#6EDBA0;
  --warn:#F0B860;
  --danger:#E38080;
  --text:#F5F8F9;
  --text-muted:rgba(245,248,249,0.62);
  --text-faint:rgba(245,248,249,0.4);
  --glass-fill: linear-gradient(135deg, rgba(255,255,255,0.14), rgba(255,255,255,0.03));
  --glass-border: rgba(255,255,255,0.22);
  --glass-shadow: 0 10px 40px -8px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.3), inset 0 0 0 1px rgba(255,255,255,0.04);
}
*{ box-sizing:border-box; margin:0; padding:0; }
html,body{ height:100%; }
body{ font-family:'Inter',sans-serif; color:var(--text); background:#0A0E14; overflow-x:hidden; -webkit-font-smoothing:antialiased; }

.backdrop{ position:fixed; inset:0; z-index:0; overflow:hidden; }
.blob{ position:absolute; border-radius:50%; filter:blur(90px); opacity:0.5; }
.blob-1{ width:520px; height:520px; background:radial-gradient(circle, var(--claude), transparent 70%); top:-160px; left:-120px; animation: drift1 22s ease-in-out infinite alternate; }
.blob-2{ width:460px; height:460px; background:radial-gradient(circle, var(--core), transparent 70%); top:120px; right:-160px; animation: drift2 26s ease-in-out infinite alternate; }
.blob-3{ width:400px; height:400px; background:radial-gradient(circle, var(--premium), transparent 70%); bottom:-200px; left:25%; animation: drift3 30s ease-in-out infinite alternate; }
@keyframes drift1{ from{ transform:translate(0,0);} to{ transform:translate(60px,40px);} }
@keyframes drift2{ from{ transform:translate(0,0);} to{ transform:translate(-50px,50px);} }
@keyframes drift3{ from{ transform:translate(0,0);} to{ transform:translate(40px,-30px);} }

.page{ position:relative; z-index:2; max-width:760px; margin:0 auto; padding:26px 20px 90px; }

.glass{
  background:var(--glass-fill);
  backdrop-filter: blur(22px) saturate(160%);
  -webkit-backdrop-filter: blur(22px) saturate(160%);
  border:1px solid var(--glass-border);
  box-shadow:var(--glass-shadow);
  border-radius:22px;
}

.auth-card{ max-width:360px; margin:80px auto; padding:30px; }
.brand{ display:flex; align-items:center; gap:9px; }
.brand-mark{ width:22px; height:22px; border-radius:7px; background:conic-gradient(from 220deg, var(--claude), var(--core), var(--premium), var(--claude)); }
.brand-name{ font-family:'Space Grotesk',sans-serif; font-weight:600; font-size:15px; }

.field{ margin-bottom:14px; }
.field label{ display:block; font-size:12px; color:var(--text-muted); margin-bottom:6px; }
.field .hint{ color:var(--text-faint); font-weight:400; }
.field input, select{
  width:100%; padding:10px 12px; border-radius:10px;
  background:rgba(255,255,255,0.06); border:1px solid rgba(255,255,255,0.16);
  color:var(--text); font-size:13.5px; font-family:'Inter',sans-serif;
}
.field input::placeholder{ color:var(--text-faint); }
.error{ color:var(--danger); font-size:12px; min-height:16px; margin-bottom:6px; }
.switch-auth{ text-align:center; font-size:12.5px; color:var(--text-muted); margin-top:14px; }
.switch-auth a{ color:var(--core); cursor:pointer; font-weight:500; }

.run-btn{ padding:10px 18px; border-radius:12px; background:linear-gradient(135deg, var(--core), var(--claude)); color:#0A0E14; font-size:13px; font-weight:700; border:none; cursor:pointer; }
.run-btn.full{ width:100%; margin-top:6px; }
.run-btn:disabled{ opacity:0.5; cursor:default; }

.topbar{ display:flex; align-items:center; justify-content:space-between; padding:11px 18px; margin-bottom:26px; border-radius:18px; }
.top-actions{ display:flex; align-items:center; gap:12px; }
.pill-btn{ font-size:12.5px; font-weight:500; padding:8px 15px; border-radius:30px; background:rgba(255,255,255,0.06); border:1px solid rgba(255,255,255,0.14); color:var(--text-muted); cursor:pointer; }
.hint{ font-size:12px; color:var(--text-faint); }

.section-label{ font-size:13px; font-weight:600; margin-bottom:12px; padding:0 4px; }

.connectors-strip{ padding:18px 20px; margin-bottom:26px; }
.cs-head{ margin-bottom:12px; }
.cs-title{ font-size:13px; font-weight:600; }
.cs-row{ display:flex; gap:10px; flex-wrap:wrap; margin-bottom:14px; }
.cs-chip{ display:flex; align-items:center; gap:8px; padding:8px 13px; border-radius:12px; background:rgba(255,255,255,0.05); border:1px solid rgba(255,255,255,0.13); font-size:12px; }
.cs-dot{ width:6px; height:6px; border-radius:50%; }
.chip-remove{
  background:none; border:none; color:var(--text-faint); cursor:pointer;
  font-size:14px; line-height:1; padding:0 0 0 4px; margin-left:2px;
}
.chip-remove:hover{ color:var(--danger); }
.add-connection{ display:flex; gap:8px; flex-wrap:wrap; border-top:1px solid rgba(255,255,255,0.1); padding-top:14px; }
.add-connection select, .add-connection input{ flex:1; min-width:120px; }
.try-btn{ font-size:12px; font-weight:600; padding:9px 14px; border-radius:9px; background:rgba(255,255,255,0.08); border:1px solid rgba(255,255,255,0.18); color:var(--text); cursor:pointer; }

.team-card{ padding:18px 20px; margin-bottom:14px; }
.team-head{ display:flex; align-items:center; justify-content:space-between; margin-bottom:10px; }
.team-name{ font-family:'Space Grotesk',sans-serif; font-size:15px; font-weight:600; }
.team-steps{ font-size:12px; color:var(--text-muted); margin-bottom:12px; }
.team-actions{ display:flex; gap:8px; align-items:center; flex-wrap:wrap; }
.team-input{ flex:1; min-width:160px; padding:9px 12px; border-radius:9px; background:rgba(255,255,255,0.06); border:1px solid rgba(255,255,255,0.16); color:var(--text); font-size:13px; }
.team-output{ margin-top:12px; padding:12px 14px; border-radius:12px; background:rgba(0,0,0,0.28); border:1px solid rgba(255,255,255,0.08); font-size:13px; line-height:1.6; color:var(--text-muted); white-space:pre-wrap; }
.status-chip{ font-size:10.5px; font-weight:600; padding:3px 9px; border-radius:20px; }
.chip-ok{ background:rgba(110,219,160,0.15); color:var(--good); }
.chip-warn{ background:rgba(240,184,96,0.15); color:var(--warn); }

.gallery{ display:grid; grid-template-columns:repeat(3,1fr); gap:12px; margin-bottom:26px; }
.tpl-card{ padding:16px; cursor:pointer; transition:transform 0.15s ease; }
.tpl-card:hover{ transform:translateY(-2px); }
.tpl-icon{ width:32px; height:32px; border-radius:10px; display:flex; align-items:center; justify-content:center; margin-bottom:12px; background:rgba(95,224,211,0.14); border:1px solid rgba(95,224,211,0.3); color:var(--core); }
.tpl-icon svg{ width:16px; height:16px; }
.tpl-icon.claude{ background:rgba(167,156,240,0.14); border-color:rgba(167,156,240,0.3); color:var(--claude); }
.tpl-icon.premium{ background:rgba(240,184,96,0.14); border-color:rgba(240,184,96,0.3); color:var(--premium); }
.tpl-title{ font-size:13.5px; font-weight:600; margin-bottom:4px; }
.tpl-desc{ font-size:11.5px; color:var(--text-muted); line-height:1.4; }

.team-header-row{ display:flex; gap:8px; }
.team-edit-btn{ font-size:11.5px; padding:6px 11px; }

.builder-step-card{ padding:16px 18px; margin-bottom:12px; }
.builder-step-row{ display:flex; gap:8px; margin-bottom:8px; flex-wrap:wrap; }
.builder-step-row input, .builder-step-row select{ flex:1; min-width:130px; }
.builder-step-row textarea{
  width:100%; min-height:60px; padding:9px 12px; border-radius:9px;
  background:rgba(255,255,255,0.06); border:1px solid rgba(255,255,255,0.16);
  color:var(--text); font-size:13px; font-family:'Inter',sans-serif; resize:vertical;
}
.builder-step-actions{ display:flex; gap:8px; align-items:center; margin-top:8px; flex-wrap:wrap; }
.builder-step-output{ margin-top:8px; padding:10px 12px; border-radius:9px; background:rgba(0,0,0,0.25); font-size:12.5px; color:var(--text-muted); white-space:pre-wrap; display:none; }
.remove-step{ font-size:11.5px; color:var(--danger); background:none; border:none; cursor:pointer; margin-left:auto; }

.field textarea{
  width:100%; min-height:70px; padding:10px 12px; border-radius:10px;
  background:rgba(255,255,255,0.06); border:1px solid rgba(255,255,255,0.16);
  color:var(--text); font-size:13.5px; font-family:'Inter',sans-serif; resize:vertical;
}
.feedback-row, .feedback-nota-row{ display:flex; align-items:center; gap:8px; margin-top:10px; flex-wrap:wrap; }
.condividi-label{ display:flex; align-items:center; gap:6px; font-size:12px; color:var(--text-muted); }
.condividi-label input{ width:auto; }

.nota-appresa-row{ display:flex; align-items:center; justify-content:space-between; gap:10px; padding:8px 0; border-bottom:1px solid rgba(255,255,255,0.06); }
.nota-appresa-row:last-child{ border-bottom:none; }
.nota-appresa-testo{ font-size:12.5px; color:var(--text-muted); flex:1; }

.storico-box{ margin-top:12px; padding-top:12px; border-top:1px solid rgba(255,255,255,0.1); }
.storico-item{ padding:12px 0; border-bottom:1px solid rgba(255,255,255,0.06); }
.storico-item:last-child{ border-bottom:none; }
.storico-item-head{ display:flex; align-items:center; justify-content:space-between; margin-bottom:6px; }
.storico-item-testo{ font-size:12.5px; color:var(--text-muted); line-height:1.5; white-space:pre-wrap; }

.audit-row{ display:flex; align-items:center; gap:10px; padding:8px 0; border-bottom:1px solid rgba(255,255,255,0.06); flex-wrap:wrap; font-size:12.5px; }
.audit-row:last-child{ border-bottom:none; }
.audit-azione{ font-weight:500; }
.audit-data{ margin-left:auto; }

/* ============================================================
   RESPONSIVE — smartphone, tablet, schermi grandi.
   Approccio mobile-first sopra, qui sotto solo le eccezioni che
   servono davvero, non un ridimensionamento generico a caso.
   ============================================================ */

/* Tablet: la galleria template passa da 3 a 2 colonne — 3 diventano
   troppo strette per leggere bene titolo+descrizione */
@media (max-width: 980px) and (min-width: 681px){
  .gallery{ grid-template-columns:repeat(2,1fr); }
}

/* Smartphone e tablet piccoli */
@media (max-width: 680px){
  .page{ padding:16px 14px 80px; }

  .gallery{ grid-template-columns:1fr; }

  .auth-card{ margin:36px auto; padding:24px 20px; max-width:100%; }

  .topbar{ flex-wrap:wrap; gap:10px; padding:10px 14px; }
  .top-actions{ flex-wrap:wrap; gap:8px; }

  /* Su iOS, un campo con testo sotto i 16px fa scattare lo zoom automatico
     al tocco — fastidioso e disorientante. Forziamo 16px solo sul tocco. */
  .field input, .field textarea, select, .team-input, .add-connection input,
  .builder-step-row input, .builder-step-row textarea{
    font-size:16px;
  }

  /* Bersagli più larghi per il dito, non per il mouse */
  .run-btn, .try-btn, .pill-btn, .chip-remove, .remove-step{
    padding-top:11px; padding-bottom:11px;
  }
  .chip-remove{ padding:6px 4px 6px 8px; }

  .team-header-row{ width:100%; }
  .team-actions{ flex-direction:column; align-items:stretch; }
  .team-actions .run-btn{ width:100%; }

  .builder-step-row{ flex-direction:column; }
  .builder-step-row input, .builder-step-row select{ min-width:0; width:100%; }

  .add-connection{ flex-direction:column; align-items:stretch; }
  .add-connection select, .add-connection input, .add-connection .try-btn{ min-width:0; width:100%; }

  .storico-item-head{ flex-direction:column; align-items:flex-start; gap:4px; }

  .audit-row{ flex-direction:column; align-items:flex-start; gap:2px; }
  .audit-data{ margin-left:0; }
}

/* Telefoni molto piccoli (iPhone SE e simili) */
@media (max-width: 360px){
  .page{ padding:12px 10px 80px; }
  .team-name, .brand-name{ font-size:14px; }
}

/* Schermi grandi: la pagina può respirare un po' di più senza diventare
   una riga di testo lunghissima da leggere */
@media (min-width: 1400px){
  .page{ max-width:900px; }
}

/* Rispetto per chi ha disattivato le animazioni nel sistema operativo */
@media (prefers-reduced-motion: reduce){
  .blob{ animation:none; }
  .tpl-card:hover{ transform:none; }
}
