

#ai-panel {
  position: fixed;
  bottom: 10px;
  right: 14px;
  width: min(320px, 85vw);
  max-height: 55vh;
  overflow: auto;
  background: var(--panel);
  color: var(--text);
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 12px 28px rgba(0,0,0,.35);
  z-index: 10002;
}

#ai-panel.hidden {
  display: none;
}

#ai-close {
    pointer-events: auto; /* forza il click sempre sulla X */
}

#ai-hide {
    pointer-events: auto; /* forza il click sempre sulla X */
}

#ai-panel {
    position: absolute;
}

#ai-panel.dragging {
  user-select: none;
  cursor: grabbing;
}

#ai-title {
  cursor: grab;
}

#ai-close {
      position: absolute;
      top: 6px;
      right: 8px;

      font-size: 20px;
      line-height: 20px;

      padding: 4px 8px;
      border-radius: 6px;

      border: 1px solid rgba(244, 67, 54, 0.5);
      background: transparent;
      color: rgba(244, 67, 54, 0.8);

      cursor: pointer;
    }

    #ai-close:hover {
      background: rgba(244, 67, 54, 0.15);
      color: #f44336;
    }


    #ai-hide {
      position: absolute;
      top: 6px;
      left: 8px;

      font-size: 14px;
      line-height: 1;

      padding: 6px 10px;
      border-radius: 6px;

      border: 1px solid rgba(33, 150, 243, 0.6);
      background: rgba(33, 150, 243, 0.12);
      color: #2196f3;

      cursor: pointer;
    }

    #ai-hide:hover {
      background: rgba(33, 150, 243, 0.25);
    }

.ai-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ai-run-btn {
  margin-left: auto;
  padding: 4px 10px;
  font-size: 13px;
  cursor: pointer;
}

.ai-run-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

#ai-fab {
    position: fixed;
    right: 126px;          /* a sinistra del help */
    bottom: 14px;
    width: 48px;
    height: 48px;
    border-radius: 999px;
    background: var(--panel);
    color: var(--text);
    border: 1px solid var(--border);
    box-shadow: 0 8px 24px rgba(0,0,0,.30);
    display: grid;
    place-items: center;
    z-index: 10001;
    cursor: pointer;
  }

  #ai-fab.active {
    background: #4caf50;
    color: #fff;
  }
